19 echo "Unknown argument $1"
25 if [ -z "$BASEURL" ]; then
26 echo "$0: missing BASEURL"
27 echo "Usage: $0 -b BASEURL"
33 if [ $SERVICE_USER -eq 1 -o $APPLICATION_USER -eq 1 ];then
34 su - $AGLDRIVER -c "afm-util $*"
41 wget -q $BASEURL -O index.html
43 echo "ERROR: Cannot wget $BASEURL"
47 grep -o '[a-z-]*.wgt' index.html | sort | uniq |
50 WGTNAME=$(echo $wgtfile | sed 's,.wgt$,,')
54 echo "DEBUG: fetch $wgtfile"
55 wget -q $BASEURL/$wgtfile
57 echo "ERROR: wget from $BASEURL/$wgtfile"
61 echo "DEBUG: analyse wgt file"
64 # TODO Do not fail yet, busybox unzip seems to "fail with success" when checking CRC
65 echo "ERROR: cannot unzip $wgtfile"
67 if [ -f config.xml ];then
68 grep hidden config.xml
70 echo "DEBUG: hidden package"
72 echo "DEBUG: not hidden package"
74 # a service sets urn:AGL:widget:provided-api
75 grep "urn:AGL:widget:provided-api" config.xml
76 if [ $? -eq 0 ] ; then
77 # we are a service, now determine the scope ...
78 grep "urn:AGL:permission::partner:scope-platform" config.xml
85 # we are an application
87 # no other type known (yet)
90 echo "DEBUG: fail to unzip"
93 echo "DEBUG: list current pkgs"
96 afm-util list --all > $LIST
98 echo "ERROR: afm-util list exit with error"
101 if [ ! -s "$LIST" ];then
102 echo "ERROR: afm-util list is empty"
106 echo "DEBUG: check presence of $WGTNAME"
107 NAMEID=$(grep id\\\":\\\"${WGTNAME}@ $LIST | cut -d\" -f4 | cut -d\\ -f1)
108 if [ ! -z "$NAMEID" ];then
109 echo "DEBUG: $WGTNAME already installed as $NAMEID"
110 # need to kill then deinstall
111 afm-util ps --all | grep -q $WGTNAME
113 echo "DEBUG: kill $WGTNAME"
114 afm-util kill $WGTNAME
116 echo "ERROR: afm-util kill"
117 lava-test-case afm-util-pre-kill-$WGTNAME --result fail
120 lava-test-case afm-util-pre-kill-$WGTNAME --result pass
123 echo "DEBUG: no need to kill $WGTNAME"
126 echo "DEBUG: deinstall $WGTNAME"
127 afm-util remove $NAMEID
129 echo "ERROR: afm-util remove"
130 lava-test-case afm-util-remove-$WGTNAME --result fail
133 lava-test-case afm-util-remove-$WGTNAME --result pass
136 echo "DEBUG: $WGTNAME not installed"
140 echo "DEBUG: install $wgtfile"
142 afm-util install $wgtfile > $OUT
144 echo "ERROR: afm-util install"
145 lava-test-case afm-util-install-$WGTNAME --result fail
148 lava-test-case afm-util-install-$WGTNAME --result pass
150 # message is like \"added\":\"mediaplayer@0.1\"
151 NAMEID=$(grep d\\\":\\\"${WGTNAME}@ $OUT | cut -d\" -f4 | cut -d\\ -f1)
152 if [ -z "$NAMEID" ];then
153 echo "ERROR: Cannot get nameid"
156 echo "DEBUG: $WGTNAME is installed as $NAMEID"
158 afm-util list --all > $LIST
160 echo "ERROR: afm-util list exit with error"
163 if [ ! -s "$LIST" ];then
164 echo "ERROR: afm-util list is empty"
167 echo "DEBUG: Verify that $WGTNAME is installed"
168 grep -q $NAMEID $LIST
170 echo "ERROR: $WGTNAME is not installed"
171 # for debugging, give full output
172 echo "DEBUG: start of list"
174 echo "DEBUG: end of list"
177 do_afm_util info $NAMEID
179 echo "ERROR: afm-util info"
180 lava-test-case afm-util-info-$WGTNAME --result fail
182 lava-test-case afm-util-info-$WGTNAME --result pass
185 echo "DEBUG: check if we see the package with systemctl list-units (before start)"
186 systemctl list-units --full | grep "afm.*$WGTNAME"
187 echo "DEBUG: check if we see the package with systemctl -a (before start)"
188 systemctl -a |grep "afm.*$WGTNAME"
190 echo "DEBUG: start $NAMEID"
191 do_afm_util start $NAMEID > "rid"
193 echo "ERROR: afm-util start"
194 lava-test-case afm-util-start-$WGTNAME --result fail
197 lava-test-case afm-util-start-$WGTNAME --result pass
200 echo "DEBUG: check if we see the package with systemctl list-units (after start)"
201 systemctl list-units --full | grep "afm.*$WGTNAME"
202 echo "DEBUG: check if we see the package with systemctl -a (after start)"
203 systemctl -a |grep "afm.*$WGTNAME"
205 echo "DEBUG: Get RID for $NAMEID"
207 afm-util ps --all > $PSLIST
209 echo "ERROR: afm-util ps"
210 lava-test-case afm-util-ps-$WGTNAME --result fail
214 lava-test-case afm-util-ps-$WGTNAME --result pass
216 # TODO, compare RID with the list in $PSLIST"
219 echo "DEBUG: status $NAMEID ($RID)"
220 do_afm_util status $RID
222 echo "ERROR: afm-util status"
223 lava-test-case afm-util-status-$WGTNAME --result fail
226 lava-test-case afm-util-status-$WGTNAME --result pass
229 echo "DEBUG: kill $NAMEID ($RID)"
230 do_afm_util kill $NAMEID
232 echo "ERROR: afm-util kill"
233 lava-test-case afm-util-kill-$WGTNAME --result fail
236 lava-test-case afm-util-kill-$WGTNAME --result pass
239 echo "DEBUG: start2 $NAMEID"
240 do_afm_util start $NAMEID
242 echo "ERROR: afm-util start2"
243 lava-test-case afm-util-start2-$WGTNAME --result fail
246 lava-test-case afm-util-start2-$WGTNAME --result pass