18 echo "Unknown argument $1"
24 if [ -z "$BASEURL" ]; then
25 echo "$0: missing BASEURL"
26 echo "Usage: $0 -b BASEURL"
32 if [ $SERVICE_USER -eq 1 -o $APPLICATION_USER -eq 1 ];then
33 su - $AGLDRIVER -c "afm-util $*"
40 wget -q $BASEURL -O index.html
42 echo "ERROR: Cannot wget $BASEURL"
46 grep -o '[a-z-]*.wgt' index.html | sort | uniq |
49 WGTNAME=$(echo $wgtfile | sed 's,.wgt$,,')
53 echo "DEBUG: fetch $wgtfile"
54 wget -q $BASEURL/$wgtfile
56 echo "ERROR: wget from $BASEURL/$wgtfile"
60 echo "DEBUG: analyse wgt file"
63 # TODO Do not fail yet, busybox unzip seems to "fail with success" when checking CRC
64 echo "ERROR: cannot unzip $wgtfile"
66 if [ -f config.xml ];then
67 grep hidden config.xml
69 echo "DEBUG: hidden package"
71 echo "DEBUG: not hidden package"
73 # a service sets urn:AGL:widget:provided-api
74 grep "urn:AGL:widget:provided-api" config.xml
75 if [ $? -eq 0 ] ; then
76 # we are a service, now determine the scope ...
77 grep "urn:AGL:permission::partner:scope-platform" config.xml
84 # we are an application
86 # no other type known (yet)
89 echo "DEBUG: fail to unzip"
92 echo "DEBUG: list current pkgs"
95 afm-util list --all > $LIST
97 echo "ERROR: afm-util list exit with error"
100 if [ ! -s "$LIST" ];then
101 echo "ERROR: afm-util list is empty"
105 echo "DEBUG: check presence of $WGTNAME"
106 NAMEID=$(grep id\\\":\\\"${WGTNAME}@ $LIST | cut -d\" -f4 | cut -d\\ -f1)
107 if [ ! -z "$NAMEID" ];then
108 echo "DEBUG: $WGTNAME already installed as $NAMEID"
109 # need to kill then deinstall
110 afm-util ps | grep -q $WGTNAME
112 echo "DEBUG: kill $WGTNAME"
113 afm-util kill $WGTNAME
115 echo "ERROR: afm-util kill"
116 lava-test-case afm-util-pre-kill-$WGTNAME --result fail
119 lava-test-case afm-util-pre-kill-$WGTNAME --result pass
122 echo "DEBUG: no need to kill $WGTNAME"
125 echo "DEBUG: deinstall $WGTNAME"
126 afm-util remove $NAMEID
128 echo "ERROR: afm-util remove"
129 lava-test-case afm-util-remove-$WGTNAME --result fail
132 lava-test-case afm-util-remove-$WGTNAME --result pass
135 echo "DEBUG: $WGTNAME not installed"
139 echo "DEBUG: install $wgtfile"
141 afm-util install $wgtfile > $OUT
143 echo "ERROR: afm-util install"
144 lava-test-case afm-util-install-$WGTNAME --result fail
147 lava-test-case afm-util-install-$WGTNAME --result pass
149 # message is like \"added\":\"mediaplayer@0.1\"
150 NAMEID=$(grep d\\\":\\\"${WGTNAME}@ $OUT | cut -d\" -f4 | cut -d\\ -f1)
151 if [ -z "$NAMEID" ];then
152 echo "ERROR: Cannot get nameid"
155 echo "DEBUG: $WGTNAME is installed as $NAMEID"
157 afm-util list --all > $LIST
159 echo "ERROR: afm-util list exit with error"
162 if [ ! -s "$LIST" ];then
163 echo "ERROR: afm-util list is empty"
166 echo "DEBUG: Verify that $WGTNAME is installed"
167 grep -q $NAMEID $LIST
169 echo "ERROR: $WGTNAME is not installed"
170 # for debugging, give full output
171 echo "DEBUG: start of list"
173 echo "DEBUG: end of list"
176 afm-util info $NAMEID
178 echo "ERROR: afm-util info"
179 lava-test-case afm-util-info-$WGTNAME --result fail
181 lava-test-case afm-util-info-$WGTNAME --result pass
184 echo "DEBUG: check if we see the package with systemctl list-units (before start)"
185 systemctl list-units --full | grep "afm.*$WGTNAME"
186 echo "DEBUG: check if we see the package with systemctl -a (before start)"
187 systemctl -a |grep "afm.*$WGTNAME"
189 echo "DEBUG: start $NAMEID"
190 do_afm_util start $NAMEID > "rid"
192 echo "ERROR: afm-util start"
193 lava-test-case afm-util-start-$WGTNAME --result fail
196 lava-test-case afm-util-start-$WGTNAME --result pass
199 echo "DEBUG: check if we see the package with systemctl list-units (after start)"
200 systemctl list-units --full | grep "afm.*$WGTNAME"
201 echo "DEBUG: check if we see the package with systemctl -a (after start)"
202 systemctl -a |grep "afm.*$WGTNAME"
204 echo "DEBUG: Get RID for $NAMEID"
206 afm-util ps > $PSLIST
208 echo "ERROR: afm-util ps"
209 lava-test-case afm-util-ps-$WGTNAME --result fail
213 lava-test-case afm-util-ps-$WGTNAME --result pass
215 # TODO, compare RID with the list in $PSLIST"
218 echo "DEBUG: status $NAMEID ($RID)"
221 echo "ERROR: afm-util status"
222 lava-test-case afm-util-status-$WGTNAME --result fail
225 lava-test-case afm-util-status-$WGTNAME --result pass
228 echo "DEBUG: kill $NAMEID ($RID)"
229 afm-util kill $NAMEID
231 echo "ERROR: afm-util kill"
232 lava-test-case afm-util-kill-$WGTNAME --result fail
235 lava-test-case afm-util-kill-$WGTNAME --result pass
238 echo "DEBUG: start2 $NAMEID"
239 do_afm_util start $NAMEID
241 echo "ERROR: afm-util start2"
242 lava-test-case afm-util-start2-$WGTNAME --result fail
245 lava-test-case afm-util-start2-$WGTNAME --result pass