19 echo "Unknown argument $1"
25 if [ -z "$BASEURL" ]; then
26 echo "$0: missing BASEURL"
27 echo "Usage: $0 -b BASEURL"
34 if [ $SERVICE_USER -eq 1 -o $APPLICATION_USER -eq 1 ];then
35 su - $AGLDRIVER -c "afm-util $*"
42 if [ ! -f index.html ] ; then
43 wget -q $BASEURL -O index.html
45 echo "ERROR: Cannot wget $BASEURL"
50 grep -o '[a-z-]*.wgt' index.html | sort | uniq |
53 # remove extension and the debug state
54 WGTNAME=$(echo $wgtfile | sed 's,.wgt$,,' | sed 's,-debug$,,')
58 echo "DEBUG: fetch $wgtfile"
60 if [ ! -f $wgtfile ] ; then
61 wget -q $BASEURL/$wgtfile
63 echo "ERROR: wget from $BASEURL/$wgtfile"
68 echo "DEBUG: analyse wgt file"
71 # TODO Do not fail yet, busybox unzip seems to "fail with success" when checking CRC
72 echo "ERROR: cannot unzip $wgtfile"
74 if [ -f config.xml ];then
75 grep hidden config.xml
77 echo "DEBUG: hidden package"
79 echo "DEBUG: not hidden package"
81 # a service sets urn:AGL:widget:provided-api
82 grep "urn:AGL:widget:provided-api" config.xml
83 if [ $? -eq 0 ] ; then
84 # we are a service, now determine the scope ...
85 grep "urn:AGL:permission::partner:scope-platform" config.xml
92 # we are an application
94 # no other type known (yet)
97 echo "DEBUG: fail to unzip"
100 echo "DEBUG: list current pkgs"
103 afm-util list --all > $LIST
105 echo "ERROR: afm-util list exit with error"
108 if [ ! -s "$LIST" ];then
109 echo "ERROR: afm-util list is empty"
113 echo "DEBUG: check presence of $WGTNAME"
114 NAMEID=$(grep id\\\":\\\"${WGTNAME}\" $LIST | cut -d\" -f4 | cut -d\\ -f1)
115 if [ ! -z "$NAMEID" ];then
116 echo "DEBUG: $WGTNAME already installed as $NAMEID"
117 # need to kill then deinstall
118 do_afm_util ps --all | grep -q $WGTNAME
120 echo "DEBUG: kill $WGTNAME"
121 do_afm_util kill $WGTNAME
123 echo "ERROR: afm-util kill"
124 #lava-test-case afm-util-pre-kill-$WGTNAME --result fail
127 # lava-test-case afm-util-pre-kill-$WGTNAME --result pass
130 echo "DEBUG: no need to kill $WGTNAME"
133 echo "DEBUG: deinstall $WGTNAME"
134 afm-util remove $NAMEID
136 echo "ERROR: afm-util remove"
137 #lava-test-case afm-util-remove-$WGTNAME --result fail
138 journalctl -b | tail -40
141 lava-test-case afm-util-remove-$WGTNAME --result pass
144 echo "DEBUG: $WGTNAME not installed"
148 echo "DEBUG: install $wgtfile"
150 afm-util install $wgtfile > $OUT
152 echo "ERROR: afm-util install"
153 lava-test-case afm-util-install-$WGTNAME --result fail
156 lava-test-case afm-util-install-$WGTNAME --result pass
158 # message is like \"added\":\"mediaplayer@0.1\"
159 NAMEID=$(grep d\\\":\\\"${WGTNAME}\" $OUT | cut -d\" -f4 | cut -d\\ -f1)
160 if [ -z "$NAMEID" ];then
161 echo "ERROR: Cannot get nameid"
162 echo "DEBUG: ========== DUMPING output =========="
164 echo "DEBUG: ========== END DUMP =========="
167 echo "DEBUG: $WGTNAME is installed as $NAMEID"
169 afm-util list --all > $LIST
171 echo "ERROR: afm-util list exit with error"
174 if [ ! -s "$LIST" ];then
175 echo "ERROR: afm-util list is empty"
178 echo "DEBUG: Verify that $WGTNAME is installed"
179 grep -q $NAMEID $LIST
181 echo "ERROR: $WGTNAME is not installed"
182 # for debugging, give full output
183 echo "DEBUG: start of list"
185 echo "DEBUG: end of list"
188 do_afm_util info $NAMEID
190 echo "ERROR: afm-util info"
191 lava-test-case afm-util-info-$WGTNAME --result fail
193 lava-test-case afm-util-info-$WGTNAME --result pass
196 echo "DEBUG: check if we see the package with systemctl list-units (before start)"
197 systemctl list-units --full | grep "afm.*$WGTNAME--"
198 echo "DEBUG: check if we see the package with systemctl -a (before start)"
199 systemctl -a |grep "afm.*$WGTNAME--"
201 echo "DEBUG: start $NAMEID"
202 do_afm_util start $NAMEID > "rid"
204 echo "ERROR: afm-util start"
205 lava-test-case afm-util-start-$WGTNAME --result fail
208 lava-test-case afm-util-start-$WGTNAME --result pass
211 echo "DEBUG: check if we see the package with systemctl list-units (after start)"
212 systemctl list-units --full | grep "afm.*$WGTNAME--"
213 echo "DEBUG: check if we see the package with systemctl -a (after start)"
214 systemctl -a |grep "afm.*$WGTNAME--"
216 echo "DEBUG: Get RID for $NAMEID"
218 afm-util ps --all > $PSLIST
220 echo "ERROR: afm-util ps"
221 lava-test-case afm-util-ps-$WGTNAME --result fail
225 lava-test-case afm-util-ps-$WGTNAME --result pass
227 # TODO, compare RID with the list in $PSLIST"
229 if [ "$RID" == 'null' ];then
231 echo "DEBUG: retry start $NAMEID"
232 do_afm_util start $NAMEID > "rid"
234 echo "ERROR: afm-util start"
235 lava-test-case afm-util-start-$WGTNAME --result fail
241 if [ "$RID" == 'null' ];then
242 echo "ERROR: RID is null, service fail to start"
243 lava-test-case afm-util-status-$WGTNAME --result fail
247 echo "DEBUG: status $NAMEID ($RID)"
248 do_afm_util status $RID
250 echo "ERROR: afm-util status"
251 lava-test-case afm-util-status-$WGTNAME --result fail
254 lava-test-case afm-util-status-$WGTNAME --result pass
257 echo "DEBUG: kill $NAMEID ($RID)"
258 do_afm_util kill $NAMEID
260 echo "ERROR: afm-util kill"
261 lava-test-case afm-util-kill-$WGTNAME --result fail
264 lava-test-case afm-util-kill-$WGTNAME --result pass
267 echo "DEBUG: start2 $NAMEID"
268 do_afm_util start $NAMEID > rid
270 echo "ERROR: afm-util start2"
271 lava-test-case afm-util-start2-$WGTNAME --result fail
274 lava-test-case afm-util-start2-$WGTNAME --result pass
277 if [ "$RID" == 'null' ];then
278 echo "ERROR: RID is null"
282 echo "DEBUG: status2 $NAMEID ($RID)"
283 do_afm_util status $RID
285 echo "ERROR: afm-util status2"
286 lava-test-case afm-util-status2-$WGTNAME --result fail
289 lava-test-case afm-util-status2-$WGTNAME --result pass