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 if $(grep "urn:AGL:widget:provided-api" config.xml) ; then
75 # we are a service, now determine the scope ...
76 if $(grep "urn:AGL:permission::partner:scope-platform" config.xml) ; then
82 # we are an application
84 # no other type known (yet)
87 echo "DEBUG: fail to unzip"
90 echo "DEBUG: list current pkgs"
93 afm-util list --all > $LIST
95 echo "ERROR: afm-util list exit with error"
98 if [ ! -s "$LIST" ];then
99 echo "ERROR: afm-util list is empty"
103 echo "DEBUG: check presence of $WGTNAME"
104 NAMEID=$(grep id\\\":\\\"${WGTNAME}@ $LIST | cut -d\" -f4 | cut -d\\ -f1)
105 if [ ! -z "$NAMEID" ];then
106 echo "DEBUG: $WGTNAME already installed as $NAMEID"
107 # need to kill then deinstall
108 afm-util ps | grep -q $WGTNAME
110 echo "DEBUG: kill $WGTNAME"
111 afm-util kill $WGTNAME
113 echo "ERROR: afm-util kill"
114 lava-test-case afm-util-pre-kill-$WGTNAME --result fail
117 lava-test-case afm-util-pre-kill-$WGTNAME --result pass
120 echo "DEBUG: no need to kill $WGTNAME"
123 echo "DEBUG: deinstall $WGTNAME"
124 afm-util remove $NAMEID
126 echo "ERROR: afm-util remove"
127 lava-test-case afm-util-remove-$WGTNAME --result fail
130 lava-test-case afm-util-remove-$WGTNAME --result pass
133 echo "DEBUG: $WGTNAME not installed"
137 echo "DEBUG: install $wgtfile"
139 afm-util install $wgtfile > $OUT
141 echo "ERROR: afm-util install"
142 lava-test-case afm-util-install-$WGTNAME --result fail
145 lava-test-case afm-util-install-$WGTNAME --result pass
147 # message is like \"added\":\"mediaplayer@0.1\"
148 NAMEID=$(grep d\\\":\\\"${WGTNAME}@ $OUT | cut -d\" -f4 | cut -d\\ -f1)
149 if [ -z "$NAMEID" ];then
150 echo "ERROR: Cannot get nameid"
153 echo "DEBUG: $WGTNAME is installed as $NAMEID"
155 afm-util list --all > $LIST
157 echo "ERROR: afm-util list exit with error"
160 if [ ! -s "$LIST" ];then
161 echo "ERROR: afm-util list is empty"
164 echo "DEBUG: Verify that $WGTNAME is installed"
165 grep -q $NAMEID $LIST
167 echo "ERROR: $WGTNAME is not installed"
168 # for debugging, give full output
169 echo "DEBUG: start of list"
171 echo "DEBUG: end of list"
174 afm-util info $NAMEID
176 echo "ERROR: afm-util info"
177 lava-test-case afm-util-info-$WGTNAME --result fail
179 lava-test-case afm-util-info-$WGTNAME --result pass
182 echo "DEBUG: check if we see the package with systemctl list-units (before start)"
183 systemctl list-units --full | grep "afm.*$WGTNAME"
184 echo "DEBUG: check if we see the package with systemctl -a (before start)"
185 systemctl -a |grep "afm.*$WGTNAME"
187 echo "DEBUG: start $NAMEID"
188 do_afm_util start $NAMEID > "rid"
190 echo "ERROR: afm-util start"
191 lava-test-case afm-util-start-$WGTNAME --result fail
194 lava-test-case afm-util-start-$WGTNAME --result pass
197 echo "DEBUG: check if we see the package with systemctl list-units (after start)"
198 systemctl list-units --full | grep "afm.*$WGTNAME"
199 echo "DEBUG: check if we see the package with systemctl -a (after start)"
200 systemctl -a |grep "afm.*$WGTNAME"
202 echo "DEBUG: Get RID for $NAMEID"
204 afm-util ps > $PSLIST
206 echo "ERROR: afm-util ps"
207 lava-test-case afm-util-ps-$WGTNAME --result fail
211 lava-test-case afm-util-ps-$WGTNAME --result pass
213 # TODO, compare RID with the list in $PSLIST"
216 echo "DEBUG: status $NAMEID ($RID)"
219 echo "ERROR: afm-util status"
220 lava-test-case afm-util-status-$WGTNAME --result fail
223 lava-test-case afm-util-status-$WGTNAME --result pass
226 echo "DEBUG: kill $NAMEID ($RID)"
227 afm-util kill $NAMEID
229 echo "ERROR: afm-util kill"
230 lava-test-case afm-util-kill-$WGTNAME --result fail
233 lava-test-case afm-util-kill-$WGTNAME --result pass
236 echo "DEBUG: start2 $NAMEID"
237 do_afm_util start $NAMEID
239 echo "ERROR: afm-util start2"
240 lava-test-case afm-util-start2-$WGTNAME --result fail
243 lava-test-case afm-util-start2-$WGTNAME --result pass