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 WGTNAME=$(echo $wgtfile | sed 's,.wgt$,,')
57 echo "DEBUG: fetch $wgtfile"
59 if [ ! -f $wgtfile ] ; then
60 wget -q $BASEURL/$wgtfile
62 echo "ERROR: wget from $BASEURL/$wgtfile"
67 echo "DEBUG: analyse wgt file"
70 # TODO Do not fail yet, busybox unzip seems to "fail with success" when checking CRC
71 echo "ERROR: cannot unzip $wgtfile"
73 if [ -f config.xml ];then
74 grep hidden config.xml
76 echo "DEBUG: hidden package"
78 echo "DEBUG: not hidden package"
80 # a service sets urn:AGL:widget:provided-api
81 grep "urn:AGL:widget:provided-api" config.xml
82 if [ $? -eq 0 ] ; then
83 # we are a service, now determine the scope ...
84 grep "urn:AGL:permission::partner:scope-platform" config.xml
91 # we are an application
93 # no other type known (yet)
96 echo "DEBUG: fail to unzip"
99 echo "DEBUG: list current pkgs"
102 afm-util list --all > $LIST
104 echo "ERROR: afm-util list exit with error"
107 if [ ! -s "$LIST" ];then
108 echo "ERROR: afm-util list is empty"
112 echo "DEBUG: check presence of $WGTNAME"
113 NAMEID=$(grep id\\\":\\\"${WGTNAME} $LIST | cut -d\" -f4 | cut -d\\ -f1)
114 if [ ! -z "$NAMEID" ];then
115 echo "DEBUG: $WGTNAME already installed as $NAMEID"
116 # need to kill then deinstall
117 do_afm_util ps --all | grep -q $WGTNAME
119 echo "DEBUG: kill $WGTNAME"
120 do_afm_util kill $WGTNAME
122 echo "ERROR: afm-util kill"
123 #lava-test-case afm-util-pre-kill-$WGTNAME --result fail
126 # lava-test-case afm-util-pre-kill-$WGTNAME --result pass
129 echo "DEBUG: no need to kill $WGTNAME"
132 echo "DEBUG: deinstall $WGTNAME"
133 afm-util remove $NAMEID
135 echo "ERROR: afm-util remove"
136 #lava-test-case afm-util-remove-$WGTNAME --result fail
137 journalctl -b | tail -40
140 lava-test-case afm-util-remove-$WGTNAME --result pass
143 echo "DEBUG: $WGTNAME not installed"
147 echo "DEBUG: install $wgtfile"
149 afm-util install $wgtfile > $OUT
151 echo "ERROR: afm-util install"
152 lava-test-case afm-util-install-$WGTNAME --result fail
155 lava-test-case afm-util-install-$WGTNAME --result pass
157 # message is like \"added\":\"mediaplayer@0.1\"
158 NAMEID=$(grep d\\\":\\\"${WGTNAME} $OUT | cut -d\" -f4 | cut -d\\ -f1)
159 if [ -z "$NAMEID" ];then
160 echo "ERROR: Cannot get nameid"
163 echo "DEBUG: $WGTNAME is installed as $NAMEID"
165 afm-util list --all > $LIST
167 echo "ERROR: afm-util list exit with error"
170 if [ ! -s "$LIST" ];then
171 echo "ERROR: afm-util list is empty"
174 echo "DEBUG: Verify that $WGTNAME is installed"
175 grep -q $NAMEID $LIST
177 echo "ERROR: $WGTNAME is not installed"
178 # for debugging, give full output
179 echo "DEBUG: start of list"
181 echo "DEBUG: end of list"
184 do_afm_util info $NAMEID
186 echo "ERROR: afm-util info"
187 lava-test-case afm-util-info-$WGTNAME --result fail
189 lava-test-case afm-util-info-$WGTNAME --result pass
192 echo "DEBUG: check if we see the package with systemctl list-units (before start)"
193 systemctl list-units --full | grep "afm.*$WGTNAME"
194 echo "DEBUG: check if we see the package with systemctl -a (before start)"
195 systemctl -a |grep "afm.*$WGTNAME"
197 echo "DEBUG: start $NAMEID"
198 do_afm_util start $NAMEID > "rid"
200 echo "ERROR: afm-util start"
201 lava-test-case afm-util-start-$WGTNAME --result fail
204 lava-test-case afm-util-start-$WGTNAME --result pass
207 echo "DEBUG: check if we see the package with systemctl list-units (after start)"
208 systemctl list-units --full | grep "afm.*$WGTNAME"
209 echo "DEBUG: check if we see the package with systemctl -a (after start)"
210 systemctl -a |grep "afm.*$WGTNAME"
212 echo "DEBUG: Get RID for $NAMEID"
214 afm-util ps --all > $PSLIST
216 echo "ERROR: afm-util ps"
217 lava-test-case afm-util-ps-$WGTNAME --result fail
221 lava-test-case afm-util-ps-$WGTNAME --result pass
223 # TODO, compare RID with the list in $PSLIST"
225 if [ "$RID" == 'null' ];then
227 echo "DEBUG: retry start $NAMEID"
228 do_afm_util start $NAMEID > "rid"
230 echo "ERROR: afm-util start"
231 lava-test-case afm-util-start-$WGTNAME --result fail
237 if [ "$RID" == 'null' ];then
238 echo "ERROR: RID is null, service fail to start"
239 lava-test-case afm-util-status-$WGTNAME --result fail
243 echo "DEBUG: status $NAMEID ($RID)"
244 do_afm_util status $RID
246 echo "ERROR: afm-util status"
247 lava-test-case afm-util-status-$WGTNAME --result fail
250 lava-test-case afm-util-status-$WGTNAME --result pass
253 echo "DEBUG: kill $NAMEID ($RID)"
254 do_afm_util kill $NAMEID
256 echo "ERROR: afm-util kill"
257 lava-test-case afm-util-kill-$WGTNAME --result fail
260 lava-test-case afm-util-kill-$WGTNAME --result pass
263 echo "DEBUG: start2 $NAMEID"
264 do_afm_util start $NAMEID > rid
266 echo "ERROR: afm-util start2"
267 lava-test-case afm-util-start2-$WGTNAME --result fail
270 lava-test-case afm-util-start2-$WGTNAME --result pass
273 if [ "$RID" == 'null' ];then
274 echo "ERROR: RID is null"
278 echo "DEBUG: status2 $NAMEID ($RID)"
279 do_afm_util status $RID
281 echo "ERROR: afm-util status2"
282 lava-test-case afm-util-status2-$WGTNAME --result fail
285 lava-test-case afm-util-status2-$WGTNAME --result pass