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 echo "DEBUG: do_afm_util as $AGLDRIVER"
34 su - $AGLDRIVER -c "afm-util $*"
36 echo "DEBUG: do_afm_util as $(whoami)"
42 wget -q $BASEURL -O index.html
44 echo "ERROR: Cannot wget $BASEURL"
48 grep -o '[a-z-]*.wgt' index.html | sort | uniq |
51 WGTNAME=$(echo $wgtfile | sed 's,.wgt$,,')
55 echo "DEBUG: fetch $wgtfile"
56 wget -q $BASEURL/$wgtfile
58 echo "ERROR: wget from $BASEURL/$wgtfile"
62 echo "DEBUG: analyse wgt file"
65 # TODO Do not fail yet, busybox unzip seems to "fail with success" when checking CRC
66 echo "ERROR: cannot unzip $wgtfile"
68 if [ -f config.xml ];then
69 grep hidden config.xml
71 echo "DEBUG: hidden package"
73 echo "DEBUG: not hidden package"
75 # a service sets urn:AGL:widget:provided-api
76 grep "urn:AGL:widget:provided-api" config.xml
77 if [ $? -eq 0 ] ; then
78 # we are a service, now determine the scope ...
79 grep "urn:AGL:permission::partner:scope-platform" config.xml
86 # we are an application
88 # no other type known (yet)
91 echo "DEBUG: fail to unzip"
94 echo "DEBUG: list current pkgs"
97 afm-util list --all > $LIST
99 echo "ERROR: afm-util list exit with error"
102 if [ ! -s "$LIST" ];then
103 echo "ERROR: afm-util list is empty"
107 echo "DEBUG: check presence of $WGTNAME"
108 NAMEID=$(grep id\\\":\\\"${WGTNAME}@ $LIST | cut -d\" -f4 | cut -d\\ -f1)
109 if [ ! -z "$NAMEID" ];then
110 echo "DEBUG: $WGTNAME already installed as $NAMEID"
111 # need to kill then deinstall
112 afm-util ps | grep -q $WGTNAME
114 echo "DEBUG: kill $WGTNAME"
115 afm-util kill $WGTNAME
117 echo "ERROR: afm-util kill"
118 lava-test-case afm-util-pre-kill-$WGTNAME --result fail
121 lava-test-case afm-util-pre-kill-$WGTNAME --result pass
124 echo "DEBUG: no need to kill $WGTNAME"
127 echo "DEBUG: deinstall $WGTNAME"
128 afm-util remove $NAMEID
130 echo "ERROR: afm-util remove"
131 lava-test-case afm-util-remove-$WGTNAME --result fail
134 lava-test-case afm-util-remove-$WGTNAME --result pass
137 echo "DEBUG: $WGTNAME not installed"
141 echo "DEBUG: install $wgtfile"
143 afm-util install $wgtfile > $OUT
145 echo "ERROR: afm-util install"
146 lava-test-case afm-util-install-$WGTNAME --result fail
149 lava-test-case afm-util-install-$WGTNAME --result pass
151 # message is like \"added\":\"mediaplayer@0.1\"
152 NAMEID=$(grep d\\\":\\\"${WGTNAME}@ $OUT | cut -d\" -f4 | cut -d\\ -f1)
153 if [ -z "$NAMEID" ];then
154 echo "ERROR: Cannot get nameid"
157 echo "DEBUG: $WGTNAME is installed as $NAMEID"
159 afm-util list --all > $LIST
161 echo "ERROR: afm-util list exit with error"
164 if [ ! -s "$LIST" ];then
165 echo "ERROR: afm-util list is empty"
168 echo "DEBUG: Verify that $WGTNAME is installed"
169 grep -q $NAMEID $LIST
171 echo "ERROR: $WGTNAME is not installed"
172 # for debugging, give full output
173 echo "DEBUG: start of list"
175 echo "DEBUG: end of list"
178 afm-util info $NAMEID
180 echo "ERROR: afm-util info"
181 lava-test-case afm-util-info-$WGTNAME --result fail
183 lava-test-case afm-util-info-$WGTNAME --result pass
186 echo "DEBUG: check if we see the package with systemctl list-units (before start)"
187 systemctl list-units --full | grep "afm.*$WGTNAME"
188 echo "DEBUG: check if we see the package with systemctl -a (before start)"
189 systemctl -a |grep "afm.*$WGTNAME"
191 echo "DEBUG: start $NAMEID"
192 do_afm_util start $NAMEID > "rid"
194 echo "ERROR: afm-util start"
195 lava-test-case afm-util-start-$WGTNAME --result fail
198 lava-test-case afm-util-start-$WGTNAME --result pass
201 echo "DEBUG: check if we see the package with systemctl list-units (after start)"
202 systemctl list-units --full | grep "afm.*$WGTNAME"
203 echo "DEBUG: check if we see the package with systemctl -a (after start)"
204 systemctl -a |grep "afm.*$WGTNAME"
206 echo "DEBUG: Get RID for $NAMEID"
208 afm-util ps > $PSLIST
210 echo "ERROR: afm-util ps"
211 lava-test-case afm-util-ps-$WGTNAME --result fail
215 lava-test-case afm-util-ps-$WGTNAME --result pass
217 # TODO, compare RID with the list in $PSLIST"
220 echo "DEBUG: status $NAMEID ($RID)"
223 echo "ERROR: afm-util status"
224 lava-test-case afm-util-status-$WGTNAME --result fail
227 lava-test-case afm-util-status-$WGTNAME --result pass
230 echo "DEBUG: kill $NAMEID ($RID)"
231 afm-util kill $NAMEID
233 echo "ERROR: afm-util kill"
234 lava-test-case afm-util-kill-$WGTNAME --result fail
237 lava-test-case afm-util-kill-$WGTNAME --result pass
240 echo "DEBUG: start2 $NAMEID"
241 do_afm_util start $NAMEID
243 echo "ERROR: afm-util start2"
244 lava-test-case afm-util-start2-$WGTNAME --result fail
247 lava-test-case afm-util-start2-$WGTNAME --result pass