chiark / gitweb /
tests: prefer GNU sed on BSD/OSX, BSD's sed has lame syntax
[fdroidserver.git] / tests / run-tests
1 #!/bin/bash
2
3 set -e # quit script on error
4
5 echo_header() {
6     { echo -e "==============================================================================\n$1"; } 2>/dev/null
7 }
8
9 copy_apks_into_repo() {
10     set +x
11     find $APKDIR -type f -name '*.apk' -print0 | while IFS= read -r -d '' f; do
12         echo $f | grep -F -v -e unaligned -e unsigned -e badsig -e badcert -e bad-unicode || continue
13         apk=`$aapt dump badging "$f" | sed -n "s,^package: name='\(.*\)' versionCode='\([0-9][0-9]*\)' .*,\1_\2.apk,p"`
14         test "$f" -nt repo/$apk && rm -f repo/$apk  # delete existing if $f is newer
15         if [ ! -e repo/$apk ] && [ ! -e archive/$apk ]; then
16             echo "$f --> repo/$apk"
17             ln "$f" $1/repo/$apk || \
18                 rsync -axv "$f" $1/repo/$apk # rsync if hard link is not possible
19         fi
20     done
21     set -x
22 }
23
24 # keep this as an old version to test the automatic parsing of build-tools
25 # verion numbers in `fdroid init`
26 create_fake_android_home() {
27     mkdir $1/tools
28     mkdir $1/platform-tools
29     mkdir $1/build-tools
30     mkdir $1/build-tools/19.0.2
31     touch $1/build-tools/19.0.2/aapt
32 }
33
34 create_test_dir() {
35     test -e $WORKSPACE/.testfiles || mkdir $WORKSPACE/.testfiles
36     mktemp -d $WORKSPACE/.testfiles/run-tests.XXXX
37 }
38
39 create_test_file() {
40     test -e $WORKSPACE/.testfiles || mkdir $WORKSPACE/.testfiles
41     TMPDIR=$WORKSPACE/.testfiles  mktemp
42 }
43
44 # the < is reverse since 0 means success in exit codes
45 have_git_2_3() {
46     python3 -c "import sys; from distutils.version import LooseVersion as V; sys.exit(V(sys.argv[3]) < V('2.3'))" `git --version`
47 }
48
49 #------------------------------------------------------------------------------#
50 # "main"
51
52 if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
53     set +x
54     echo "Usage: $0 '/path/to/folder/with/apks'"
55     exit 1
56 fi
57
58 if [ -z "$ANDROID_HOME" ]; then
59     echo "ANDROID_HOME must be set with the path to the Android SDK, i.e.: "
60     echo "  export ANDROID_HOME=/opt/android-sdk"
61     exit 1
62 fi
63
64 if [ -d tests ]; then
65     cd tests
66 fi
67
68 if [ -z "$1" ]; then
69     APKDIR=`pwd`
70 else
71     APKDIR=$1
72 fi
73
74 if [ -z $WORKSPACE ]; then
75     WORKSPACE=`dirname $(pwd)`
76     echo "Setting Workspace to $WORKSPACE"
77 fi
78
79 # allow the location of the script to be overridden
80 if [ -z $fdroid ]; then
81     fdroid="$WORKSPACE/fdroid"
82 fi
83
84 # allow the location of aapt to be overridden
85 if [ -z $aapt ]; then
86     aapt=`ls -1 $ANDROID_HOME/build-tools/*/aapt | sort | tail -1`
87 fi
88
89 # allow the location of python to be overridden
90 if [ -z $python ]; then
91     python=python3
92 fi
93
94 # try to use GNU sed on OSX/BSD cuz BSD sed sucks
95 if which gsed; then
96     sed=gsed
97 else
98     sed=sed
99 fi
100
101 set -x # show each command as it is executed
102
103 #------------------------------------------------------------------------------#
104 echo_header "run commit hooks"
105
106 cd $WORKSPACE
107 ./hooks/pre-commit
108
109
110 #------------------------------------------------------------------------------#
111 echo_header "test python getsig replacement"
112
113 cd $WORKSPACE/tests/getsig
114 ./make.sh
115
116 cd $WORKSPACE/tests
117 for testcase in $WORKSPACE/tests/*.TestCase; do
118     $testcase
119 done
120
121
122 #------------------------------------------------------------------------------#
123 echo_header "print fdroid version"
124
125 $fdroid --version
126
127
128 #------------------------------------------------------------------------------#
129 echo_header 'run process when building and signing are on separate machines'
130
131 REPOROOT=`create_test_dir`
132 cd $REPOROOT
133 cp $WORKSPACE/tests/keystore.jks $REPOROOT/
134 $fdroid init --keystore keystore.jks --repo-keyalias=sova
135 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
136 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
137 echo "accepted_formats = ['txt', 'yml']" >> config.py
138 echo 'keydname = "CN=Birdman, OU=Cell, O=Alcatraz, L=Alcatraz, S=California, C=US"' >> config.py
139 test -d archive || mkdir archive
140 test -d metadata || mkdir metadata
141 cp $WORKSPACE/tests/metadata/info.guardianproject.urzip.yml metadata/
142 test -d repo || mkdir repo
143 test -d unsigned || mkdir unsigned
144 cp $WORKSPACE/tests/urzip-release-unsigned.apk unsigned/info.guardianproject.urzip_100.apk
145 $fdroid publish --verbose
146 $fdroid update --verbose --nosign
147 $fdroid signindex --verbose
148 test -e repo/index.xml
149 test -e repo/index.jar
150 test -e repo/index-v1.jar
151 test -e tmp/apkcache
152 ! test -z tmp/apkcache
153 test -L urzip.apk
154 grep -F '<application id=' repo/index.xml > /dev/null
155
156
157 #------------------------------------------------------------------------------#
158 echo_header "test UTF-8 metadata"
159
160 REPOROOT=`create_test_dir`
161 cd $REPOROOT
162
163 $fdroid init
164 $sed -i.tmp 's,^ *repo_description.*,repo_description = """获取已安装在您的设备上的应用的,' config.py
165 echo "mirrors = ('https://foo.bar/fdroid', 'http://secret.onion/fdroid')" >> config.py
166 mkdir metadata
167 cp $WORKSPACE/tests/urzip.apk $WORKSPACE/tests/bad-unicode*.apk repo/
168 cp $WORKSPACE/tests/metadata/info.guardianproject.urzip.yml metadata/
169
170 $fdroid readmeta
171 $fdroid update
172
173
174 #------------------------------------------------------------------------------#
175 echo_header 'run `fdroid build` in fresh git checkout from import.TestCase'
176
177 cd $WORKSPACE/tests/tmp/importer
178 git remote update -p
179 git clean -fdx
180 # stick with known working commit, in case future commits break things for this code
181 git reset --hard cecf00c08aec56ae7a5eba444150c4d1ae868814
182 if [ -d $ANDROID_HOME/platforms/android-23 ]; then
183     echo "build_tools = '`ls -1 $ANDROID_HOME/build-tools/ | sort -n | tail -1`'" > config.py
184     echo "force_build_tools = True" >> config.py
185     $fdroid build --verbose org.fdroid.ci.test.app:300
186 else
187     echo 'WARNING: Skipping `fdroid build` test since android-23 is missing!'
188 fi
189
190 #------------------------------------------------------------------------------#
191 echo_header 'copy git import and run `fdroid scanner` on it'
192
193 REPOROOT=`create_test_dir`
194 cd $REPOROOT
195 cp $WORKSPACE/examples/fdroid-icon.png $REPOROOT/
196 mkdir metadata
197 echo "Auto Name:Just A Test" > metadata/org.fdroid.ci.test.app.txt
198 echo "Web Site:" >> metadata/org.fdroid.ci.test.app.txt
199 echo "Build:0.3,300" >> metadata/org.fdroid.ci.test.app.txt
200 echo "    commit=0.3" >> metadata/org.fdroid.ci.test.app.txt
201 echo "    subdir=app" >> metadata/org.fdroid.ci.test.app.txt
202 echo "    gradle=yes" >> metadata/org.fdroid.ci.test.app.txt
203 echo "" >> metadata/org.fdroid.ci.test.app.txt
204 echo "Repo:https://gitlab.com/fdroid/ci-test-app.git" >> metadata/org.fdroid.ci.test.app.txt
205 echo "Repo Type:git" >> metadata/org.fdroid.ci.test.app.txt
206 mkdir build
207 cp -a $WORKSPACE/tests/tmp/importer build/org.fdroid.ci.test.app
208 ls -l build/org.fdroid.ci.test.app
209 $fdroid scanner org.fdroid.ci.test.app --verbose
210
211
212 #------------------------------------------------------------------------------#
213 echo_header "copy tests/repo, generate java/gpg keys, update, and gpgsign"
214
215 REPOROOT=`create_test_dir`
216 GNUPGHOME=$REPOROOT/gnupghome
217 KEYSTORE=$WORKSPACE/tests/keystore.jks
218 cd $REPOROOT
219 $fdroid init --keystore $KEYSTORE --repo-keyalias=sova
220 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
221 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
222 cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $WORKSPACE/tests/stats $REPOROOT/
223 cp -a $WORKSPACE/tests/gnupghome $GNUPGHOME
224 chmod 0700 $GNUPGHOME
225 echo "accepted_formats = ['json', 'txt', 'yml']" >> config.py
226 echo "install_list = 'org.adaway'" >> config.py
227 echo "uninstall_list = ('com.android.vending', 'com.facebook.orca',)" >> config.py
228 echo "gpghome = '$GNUPGHOME'" >> config.py
229 echo "gpgkey = 'CE71F7FB'" >> config.py
230 echo "mirrors = ('http://foobarfoobarfoobar.onion/fdroid','https://foo.bar/fdroid',)" >> config.py
231 $fdroid update --verbose --pretty
232 test -e repo/index.xml
233 test -e repo/index.jar
234 test -e repo/index-v1.jar
235 grep -F '<application id=' repo/index.xml > /dev/null
236 grep -F '<install packageName=' repo/index.xml > /dev/null
237 grep -F '<uninstall packageName=' repo/index.xml > /dev/null
238 $fdroid gpgsign --verbose
239 $fdroid gpgsign --verbose
240 test -e repo/obb.mainpatch.current_1619.apk.asc
241 test -e repo/obb.main.twoversions_1101617_src.tar.gz.asc
242 ! test -e repo/obb.mainpatch.current_1619.apk.asc.asc
243 ! test -e repo/obb.main.twoversions_1101617_src.tar.gz.asc.asc
244 ! test -e repo/index.xml.asc
245
246 # we can't easily reproduce the timestamps for things, so just hardcode them
247 $sed -i.tmp -e 's,timestamp="[0-9]*",timestamp="1480431575",' repo/index.xml
248 diff -uw $WORKSPACE/tests/repo/index.xml repo/index.xml
249
250
251 #------------------------------------------------------------------------------#
252 echo_header 'test moving lots of APKs to the archive'
253
254 REPOROOT=`create_test_dir`
255 cd $REPOROOT
256 cp $WORKSPACE/tests/keystore.jks $REPOROOT/
257 $fdroid init --keystore keystore.jks --repo-keyalias=sova
258 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
259 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
260 echo "accepted_formats = ['txt']" >> config.py
261 $sed -i.tmp '/allow_disabled_algorithms/d' config.py
262 test -d metadata || mkdir metadata
263 cp $WORKSPACE/tests/metadata/*.txt metadata/
264 echo 'Summary:good test version of urzip' > metadata/info.guardianproject.urzip.txt
265 echo 'Summary:good MD5 sig, which is disabled algorithm' > metadata/org.bitbucket.tickytacky.mirrormirror.txt
266 $sed -i.tmp '/Archive Policy:/d' metadata/*.txt
267 test -d repo || mkdir repo
268 cp $WORKSPACE/tests/urzip.apk \
269    $WORKSPACE/tests/org.bitbucket.tickytacky.mirrormirror_[0-9].apk \
270    $WORKSPACE/tests/repo/com.politedroid_[0-9].apk \
271    $WORKSPACE/tests/repo/obb.main.twoversions_110161[357].apk \
272    repo/
273 $sed -i.tmp 's,archive_older = [0-9],archive_older = 3,' config.py
274
275 $fdroid update --pretty --nosign
276 echo "This will fail when jarsigner allows MD5 for APK signatures"
277 test `grep '<package>' archive/index.xml | wc -l` -eq 5
278 test `grep '<package>' repo/index.xml | wc -l` -eq 7
279
280
281 #------------------------------------------------------------------------------#
282 echo_header 'test per-app "Archive Policy"'
283
284 REPOROOT=`create_test_dir`
285 cd $REPOROOT
286 cp $WORKSPACE/tests/keystore.jks $REPOROOT/
287 $fdroid init --keystore keystore.jks --repo-keyalias=sova
288 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
289 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
290 echo "accepted_formats = ['txt']" >> config.py
291 test -d metadata || mkdir metadata
292 cp $WORKSPACE/tests/metadata/com.politedroid.txt metadata/
293 test -d repo || mkdir repo
294 cp $WORKSPACE/tests/repo/com.politedroid_[0-9].apk repo/
295 $sed -i.tmp 's,archive_older = [0-9],archive_older = 3,' config.py
296
297 $fdroid update --pretty --nosign
298 test `grep '<package>' archive/index.xml | wc -l` -eq 0
299 test `grep '<package>' repo/index.xml | wc -l` -eq 4
300 grep -F com.politedroid_3.apk repo/index.xml
301 grep -F com.politedroid_4.apk repo/index.xml
302 grep -F com.politedroid_5.apk repo/index.xml
303 grep -F com.politedroid_6.apk repo/index.xml
304 test -e repo/com.politedroid_3.apk
305 test -e repo/com.politedroid_4.apk
306 test -e repo/com.politedroid_5.apk
307 test -e repo/com.politedroid_6.apk
308
309 echo "enable one app in the repo"
310 $sed -i.tmp 's,^Archive Policy:4,Archive Policy:1,' metadata/com.politedroid.txt
311 $fdroid update --pretty --nosign
312 test `grep '<package>' archive/index.xml | wc -l` -eq 3
313 test `grep '<package>' repo/index.xml | wc -l` -eq 1
314 grep -F com.politedroid_3.apk archive/index.xml
315 grep -F com.politedroid_4.apk archive/index.xml
316 grep -F com.politedroid_5.apk archive/index.xml
317 grep -F com.politedroid_6.apk repo/index.xml
318 test -e archive/com.politedroid_3.apk
319 test -e archive/com.politedroid_4.apk
320 test -e archive/com.politedroid_5.apk
321 test -e repo/com.politedroid_6.apk
322
323 echo "remove all apps from the repo"
324 $sed -i.tmp 's,^Archive Policy:1,Archive Policy:0,' metadata/com.politedroid.txt
325 $fdroid update --pretty --nosign
326 test `grep '<package>' archive/index.xml | wc -l` -eq 4
327 test `grep '<package>' repo/index.xml | wc -l` -eq 0
328 grep -F com.politedroid_3.apk archive/index.xml
329 grep -F com.politedroid_4.apk archive/index.xml
330 grep -F com.politedroid_5.apk archive/index.xml
331 grep -F com.politedroid_6.apk archive/index.xml
332 test -e archive/com.politedroid_3.apk
333 test -e archive/com.politedroid_4.apk
334 test -e archive/com.politedroid_5.apk
335 test -e archive/com.politedroid_6.apk
336 ! test -e repo/com.politedroid_6.apk
337
338 echo "move back one from archive to the repo"
339 $sed -i.tmp 's,^Archive Policy:0,Archive Policy:1,' metadata/com.politedroid.txt
340 $fdroid update --pretty --nosign
341 test `grep '<package>' archive/index.xml | wc -l` -eq 3
342 test `grep '<package>' repo/index.xml | wc -l` -eq 1
343 grep -F com.politedroid_3.apk archive/index.xml
344 grep -F com.politedroid_4.apk archive/index.xml
345 grep -F com.politedroid_5.apk archive/index.xml
346 grep -F com.politedroid_6.apk repo/index.xml
347 test -e archive/com.politedroid_3.apk
348 test -e archive/com.politedroid_4.apk
349 test -e archive/com.politedroid_5.apk
350 ! test -e archive/com.politedroid_6.apk
351 test -e repo/com.politedroid_6.apk
352
353
354
355 #------------------------------------------------------------------------------#
356 echo_header 'test moving old APKs to and from the archive'
357
358 REPOROOT=`create_test_dir`
359 cd $REPOROOT
360 cp $WORKSPACE/tests/keystore.jks $REPOROOT/
361 $fdroid init --keystore keystore.jks --repo-keyalias=sova
362 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
363 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
364 echo "accepted_formats = ['txt']" >> config.py
365 test -d metadata || mkdir metadata
366 cp $WORKSPACE/tests/metadata/com.politedroid.txt metadata/
367 $sed -i.tmp '/Archive Policy:/d' metadata/com.politedroid.txt
368 test -d repo || mkdir repo
369 cp $WORKSPACE/tests/repo/com.politedroid_[0-9].apk repo/
370 $sed -i.tmp 's,archive_older = [0-9],archive_older = 3,' config.py
371
372 $fdroid update --pretty --nosign
373 test `grep '<package>' archive/index.xml | wc -l` -eq 1
374 test `grep '<package>' repo/index.xml | wc -l` -eq 3
375 grep -F com.politedroid_3.apk archive/index.xml
376 grep -F com.politedroid_4.apk repo/index.xml
377 grep -F com.politedroid_5.apk repo/index.xml
378 grep -F com.politedroid_6.apk repo/index.xml
379 test -e archive/com.politedroid_3.apk
380 test -e repo/com.politedroid_4.apk
381 test -e repo/com.politedroid_5.apk
382 test -e repo/com.politedroid_6.apk
383
384 $sed -i.tmp 's,archive_older = 3,archive_older = 1,' config.py
385 $fdroid update --pretty --nosign
386 test `grep '<package>' archive/index.xml | wc -l` -eq 3
387 test `grep '<package>' repo/index.xml | wc -l` -eq 1
388 grep -F com.politedroid_3.apk archive/index.xml
389 grep -F com.politedroid_4.apk archive/index.xml
390 grep -F com.politedroid_5.apk archive/index.xml
391 grep -F com.politedroid_6.apk repo/index.xml
392 test -e archive/com.politedroid_3.apk
393 test -e archive/com.politedroid_4.apk
394 test -e archive/com.politedroid_5.apk
395 test -e repo/com.politedroid_6.apk
396
397 # disabling deletes from the archive
398 $sed -i.tmp 's/Build:1.3,4/Build:1.3,4\n    disable=testing deletion/' metadata/com.politedroid.txt
399 $fdroid update --pretty --nosign
400 test `grep '<package>' archive/index.xml | wc -l` -eq 2
401 test `grep '<package>' repo/index.xml | wc -l` -eq 1
402 grep -F com.politedroid_3.apk archive/index.xml
403 ! grep -F com.politedroid_4.apk archive/index.xml
404 grep -F com.politedroid_5.apk archive/index.xml
405 grep -F com.politedroid_6.apk repo/index.xml
406 test -e archive/com.politedroid_3.apk
407 ! test -e archive/com.politedroid_4.apk
408 test -e archive/com.politedroid_5.apk
409 test -e repo/com.politedroid_6.apk
410
411 # disabling deletes from the repo, and promotes one from the archive
412 $sed -i.tmp 's/Build:1.5,6/Build:1.5,6\n    disable=testing deletion/' metadata/com.politedroid.txt
413 $fdroid update --pretty --nosign
414 test `grep '<package>' archive/index.xml | wc -l` -eq 1
415 test `grep '<package>' repo/index.xml | wc -l` -eq 1
416 grep -F com.politedroid_3.apk archive/index.xml
417 grep -F com.politedroid_5.apk repo/index.xml
418 ! grep -F com.politedroid_6.apk repo/index.xml
419 test -e archive/com.politedroid_3.apk
420 test -e repo/com.politedroid_5.apk
421 ! test -e repo/com.politedroid_6.apk
422
423
424 #------------------------------------------------------------------------------#
425 echo_header 'test allowing disabled signatures in repo and archive'
426
427 REPOROOT=`create_test_dir`
428 cd $REPOROOT
429 cp $WORKSPACE/tests/keystore.jks $REPOROOT/
430 $fdroid init --keystore keystore.jks --repo-keyalias=sova
431 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
432 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
433 echo "accepted_formats = ['txt']" >> config.py
434 echo 'allow_disabled_algorithms = True' >> config.py
435 $sed -i.tmp 's,archive_older = [0-9],archive_older = 3,' config.py
436 test -d metadata || mkdir metadata
437 cp $WORKSPACE/tests/metadata/com.politedroid.txt metadata/
438 echo 'Summary:good test version of urzip' > metadata/info.guardianproject.urzip.txt
439 echo 'Summary:good MD5 sig, disabled algorithm' > metadata/org.bitbucket.tickytacky.mirrormirror.txt
440 $sed -i.tmp '/Archive Policy:/d' metadata/*.txt
441 test -d repo || mkdir repo
442 cp $WORKSPACE/tests/repo/com.politedroid_[0-9].apk \
443    $WORKSPACE/tests/org.bitbucket.tickytacky.mirrormirror_[0-9].apk \
444    $WORKSPACE/tests/urzip-badsig.apk \
445    repo/
446
447 $fdroid update --pretty --nosign
448 test `grep '<package>' archive/index.xml | wc -l` -eq 2
449 test `grep '<package>' repo/index.xml | wc -l` -eq 6
450 grep -F com.politedroid_3.apk archive/index.xml
451 grep -F com.politedroid_4.apk repo/index.xml
452 grep -F com.politedroid_5.apk repo/index.xml
453 grep -F com.politedroid_6.apk repo/index.xml
454 grep -F org.bitbucket.tickytacky.mirrormirror_1.apk archive/index.xml
455 grep -F org.bitbucket.tickytacky.mirrormirror_2.apk repo/index.xml
456 grep -F org.bitbucket.tickytacky.mirrormirror_3.apk repo/index.xml
457 grep -F org.bitbucket.tickytacky.mirrormirror_4.apk repo/index.xml
458 ! grep -F urzip-badsig.apk repo/index.xml
459 ! grep -F urzip-badsig.apk archive/index.xml
460 test -e archive/com.politedroid_3.apk
461 test -e repo/com.politedroid_4.apk
462 test -e repo/com.politedroid_5.apk
463 test -e repo/com.politedroid_6.apk
464 test -e archive/org.bitbucket.tickytacky.mirrormirror_1.apk
465 test -e repo/org.bitbucket.tickytacky.mirrormirror_2.apk
466 test -e repo/org.bitbucket.tickytacky.mirrormirror_3.apk
467 test -e repo/org.bitbucket.tickytacky.mirrormirror_4.apk
468 test -e archive/urzip-badsig.apk
469
470 $sed -i.tmp '/allow_disabled_algorithms/d' config.py
471 $fdroid update --pretty --nosign
472 test `grep '<package>' archive/index.xml | wc -l` -eq 5
473 test `grep '<package>' repo/index.xml | wc -l` -eq 3
474 grep -F org.bitbucket.tickytacky.mirrormirror_1.apk archive/index.xml
475 grep -F org.bitbucket.tickytacky.mirrormirror_2.apk archive/index.xml
476 grep -F org.bitbucket.tickytacky.mirrormirror_3.apk archive/index.xml
477 grep -F org.bitbucket.tickytacky.mirrormirror_4.apk archive/index.xml
478 grep -F com.politedroid_3.apk archive/index.xml
479 grep -F com.politedroid_4.apk repo/index.xml
480 grep -F com.politedroid_5.apk repo/index.xml
481 grep -F com.politedroid_6.apk repo/index.xml
482 ! grep -F urzip-badsig.apk repo/index.xml
483 ! grep -F urzip-badsig.apk archive/index.xml
484 test -e archive/org.bitbucket.tickytacky.mirrormirror_1.apk
485 test -e archive/org.bitbucket.tickytacky.mirrormirror_2.apk
486 test -e archive/org.bitbucket.tickytacky.mirrormirror_3.apk
487 test -e archive/org.bitbucket.tickytacky.mirrormirror_4.apk
488 test -e archive/com.politedroid_3.apk
489 test -e archive/urzip-badsig.apk
490 test -e repo/com.politedroid_4.apk
491 test -e repo/com.politedroid_5.apk
492 test -e repo/com.politedroid_6.apk
493
494
495 #------------------------------------------------------------------------------#
496 echo_header 'rename apks with `fdroid update --rename-apks`, --nosign for speed'
497
498 REPOROOT=`create_test_dir`
499 cd $REPOROOT
500 cp $WORKSPACE/tests/keystore.jks $REPOROOT/
501 $fdroid init --keystore keystore.jks --repo-keyalias=sova
502 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
503 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
504 echo "accepted_formats = ['txt', 'yml']" >> config.py
505 echo 'keydname = "CN=Birdman, OU=Cell, O=Alcatraz, L=Alcatraz, S=California, C=US"' >> config.py
506 test -d metadata || mkdir metadata
507 cp $WORKSPACE/tests/metadata/info.guardianproject.urzip.yml metadata/
508 test -d repo || mkdir repo
509 cp $WORKSPACE/tests/urzip.apk "repo/asdfiuhk urzip-πÇÇπÇÇ现代汉语通用字-български-عربي1234 ö.apk"
510 $fdroid update --rename-apks --pretty --nosign
511 test -e repo/info.guardianproject.urzip_100.apk
512 grep -F 'info.guardianproject.urzip_100.apk' repo/index-v1.json repo/index.xml
513 cp $WORKSPACE/tests/urzip-release.apk repo/
514 $fdroid update --rename-apks --pretty --nosign
515 test -e repo/info.guardianproject.urzip_100.apk
516 test -e repo/info.guardianproject.urzip_100_b4964fd.apk
517 grep -F 'info.guardianproject.urzip_100.apk' repo/index-v1.json repo/index.xml
518 grep -F 'info.guardianproject.urzip_100_b4964fd.apk' repo/index-v1.json
519 ! grep -F 'info.guardianproject.urzip_100_b4964fd.apk' repo/index.xml
520 cp $WORKSPACE/tests/urzip-release.apk repo/
521 $fdroid update --rename-apks --pretty --nosign
522 test -e repo/info.guardianproject.urzip_100.apk
523 test -e repo/info.guardianproject.urzip_100_b4964fd.apk
524 test -e duplicates/repo/info.guardianproject.urzip_100_b4964fd.apk
525 grep -F 'info.guardianproject.urzip_100.apk' repo/index-v1.json repo/index.xml
526 grep -F 'info.guardianproject.urzip_100_b4964fd.apk' repo/index-v1.json
527 ! grep -F 'info.guardianproject.urzip_100_b4964fd.apk' repo/index.xml
528
529
530 #------------------------------------------------------------------------------#
531 echo_header "test metadata checks"
532
533 REPOROOT=`create_test_dir`
534 cd $REPOROOT
535
536 mkdir repo
537 cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
538
539 set +e
540 $fdroid build
541 if [ $? -eq 0 ]; then
542     echo "This should have failed because there is no metadata!"
543     exit 1
544 else
545     echo "testing metadata checks passed"
546 fi
547 set -e
548
549 mkdir $REPOROOT/metadata/
550 cp $WORKSPACE/tests/metadata/org.smssecure.smssecure.txt $REPOROOT/metadata/
551 $fdroid readmeta
552
553 # now make a fake duplicate
554 touch $REPOROOT/metadata/org.smssecure.smssecure.yml
555
556 set +e
557 $fdroid readmeta
558 if [ $? -eq 0 ]; then
559     echo "This should have failed because there is a duplicate metadata file!"
560     exit 1
561 else
562     echo "testing duplicate metadata checks passed"
563 fi
564 set -e
565
566
567 #------------------------------------------------------------------------------#
568 echo_header "ensure commands that don't need the JDK work without a JDK configed"
569
570 REPOROOT=`create_test_dir`
571 cd $REPOROOT
572 mkdir repo
573 mkdir metadata
574 echo "License:GPL-2.0" >> metadata/fake.txt
575 echo "Summary:Yup still fake" >> metadata/fake.txt
576 echo "Categories:Internet" >> metadata/fake.txt
577 echo "Description:" >> metadata/fake.txt
578 echo "this is fake" >> metadata/fake.txt
579 echo "." >> metadata/fake.txt
580
581 # fake that no JDKs are available
582 echo 'java_paths = {}' > config.py
583
584 LOCAL_COPY_DIR=`create_test_dir`/fdroid
585 mkdir -p $LOCAL_COPY_DIR/repo
586 echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
587
588 $fdroid checkupdates
589 $fdroid gpgsign
590 $fdroid lint
591 $fdroid readmeta
592 $fdroid rewritemeta fake
593 $fdroid server update
594 $fdroid scanner
595
596 # run these to get their output, but the are not setup, so don't fail
597 $fdroid build || true
598 $fdroid import || true
599 $fdroid install || true
600
601
602 #------------------------------------------------------------------------------#
603 echo_header "create a source tarball and use that to build a repo"
604
605 cd $WORKSPACE
606 $python setup.py sdist
607
608 REPOROOT=`create_test_dir`
609 cd $REPOROOT
610 tar xzf `ls -1 $WORKSPACE/dist/fdroidserver-*.tar.gz | sort -n | tail -1`
611 cd $REPOROOT
612 ./fdroidserver-*/fdroid init
613 copy_apks_into_repo $REPOROOT
614 ./fdroidserver-*/fdroid update --create-metadata --verbose
615
616
617 #------------------------------------------------------------------------------#
618 echo_header "test config checks of local_copy_dir"
619
620 REPOROOT=`create_test_dir`
621 cd $REPOROOT
622 $fdroid init
623 $fdroid update --create-metadata --verbose
624 $fdroid readmeta
625 $fdroid server update --local-copy-dir=/tmp/fdroid
626
627 # now test the errors work
628 set +e
629 $fdroid server update --local-copy-dir=thisisnotanabsolutepath
630 if [ $? -eq 0 ]; then
631     echo "This should have failed because thisisnotanabsolutepath is not an absolute path!"
632     exit 1
633 else
634     echo "testing absolute path checker passed"
635 fi
636 $fdroid server update --local-copy-dir=/tmp/IReallyDoubtThisPathExistsasdfasdf
637 if [ $? -eq 0 ]; then
638     echo "This should have failed because the path does not end with 'fdroid'!"
639     exit 1
640 else
641     echo "testing dirname exists checker passed"
642 fi
643 $fdroid server update --local-copy-dir=/tmp/IReallyDoubtThisPathExistsasdfasdf/fdroid
644 if [ $? -eq 0 ]; then
645     echo "This should have failed because the dirname path does not exist!"
646     exit 1
647 else
648     echo "testing dirname exists checker passed"
649 fi
650 set -e
651
652
653 #------------------------------------------------------------------------------#
654 echo_header "setup a new repo from scratch using ANDROID_HOME and do a local sync"
655
656 REPOROOT=`create_test_dir`
657 cd $REPOROOT
658 $fdroid init
659 copy_apks_into_repo $REPOROOT
660 $fdroid update --create-metadata --verbose
661 $fdroid readmeta
662 grep -F '<application id=' repo/index.xml > /dev/null
663
664 LOCALCOPYDIR=`create_test_dir`/fdroid
665 $fdroid server update --local-copy-dir=$LOCALCOPYDIR
666 NEWREPOROOT=`create_test_dir`
667 cd $NEWREPOROOT
668 $fdroid init
669 echo "sync_from_local_copy_dir = True" >> config.py
670 $fdroid server update --local-copy-dir=$LOCALCOPYDIR
671
672
673 #------------------------------------------------------------------------------#
674 # check that --android-home fails when dir does not exist or is not a dir
675
676 REPOROOT=`create_test_dir`
677 KEYSTORE=$REPOROOT/keystore.jks
678 cd $REPOROOT
679 set +e
680 $fdroid init --keystore $KEYSTORE --android-home /opt/fakeandroidhome
681 if [ $? -eq 0 ]; then
682     echo "This should have failed because /opt/fakeandroidhome does not exist!"
683     exit 1
684 else
685     echo "testing android-home path checker passed"
686 fi
687 TESTFILE=`create_test_file`
688 $fdroid init --keystore $KEYSTORE --android-home $TESTFILE
689 if [ $? -eq 0 ]; then
690     echo "This should have failed because $TESTFILE is a file not a dir!"
691     exit 1
692 else
693     echo "testing android-home not-dir checker passed"
694 fi
695 set -e
696
697
698 #------------------------------------------------------------------------------#
699 echo_header "check that fake android home passes 'fdroid init'"
700
701 REPOROOT=`create_test_dir`
702 FAKE_ANDROID_HOME=`create_test_dir`
703 create_fake_android_home $FAKE_ANDROID_HOME
704 KEYSTORE=$REPOROOT/keystore.jks
705 cd $REPOROOT
706 $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
707
708
709 #------------------------------------------------------------------------------#
710 echo_header "check that 'fdroid init' fails when build-tools cannot be found"
711
712 if [ -e /usr/bin/aapt ]; then
713     echo "/usr/bin/aapt exists, not running test"
714 else
715     REPOROOT=`create_test_dir`
716     FAKE_ANDROID_HOME=`create_test_dir`
717     create_fake_android_home $FAKE_ANDROID_HOME
718     rm -f $FAKE_ANDROID_HOME/build-tools/*/aapt
719     KEYSTORE=$REPOROOT/keystore.jks
720     cd $REPOROOT
721     set +e
722     $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
723     [ $? -eq 0 ] && exit 1
724     set -e
725 fi
726
727
728 #------------------------------------------------------------------------------#
729 echo_header "check that --android-home overrides ANDROID_HOME"
730
731 REPOROOT=`create_test_dir`
732 FAKE_ANDROID_HOME=`create_test_dir`
733 create_fake_android_home $FAKE_ANDROID_HOME
734 KEYSTORE=$REPOROOT/keystore.jks
735 cd $REPOROOT
736 $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
737 set +e
738 grep $FAKE_ANDROID_HOME $REPOROOT/config.py
739 if [ $? -ne 0 ]; then
740     echo "the value set in --android-home '$FAKE_ANDROID_HOME' should override ANDROID_HOME '$ANDROID_HOME'"
741     exit 1
742 fi
743 set -e
744
745
746 #------------------------------------------------------------------------------#
747 # In this case, ANDROID_HOME is set to a fake, non-working version that will
748 # be detected by fdroid as an Android SDK install.  It should use the path set
749 # by --android-home over the one in ANDROID_HOME, therefore if it uses the one
750 # in ANDROID_HOME, it won't work because it is a fake one.  Only
751 # --android-home provides a working one.
752 echo_header "setup a new repo from scratch with keystore and android-home set on cmd line"
753
754 REPOROOT=`create_test_dir`
755 KEYSTORE=$REPOROOT/keystore.jks
756 FAKE_ANDROID_HOME=`create_test_dir`
757 create_fake_android_home $FAKE_ANDROID_HOME
758 STORED_ANDROID_HOME=$ANDROID_HOME
759 unset ANDROID_HOME
760 echo "ANDROID_HOME: $ANDROID_HOME"
761 cd $REPOROOT
762 $fdroid init --keystore $KEYSTORE --android-home $STORED_ANDROID_HOME --no-prompt
763 test -e $KEYSTORE
764 copy_apks_into_repo $REPOROOT
765 $fdroid update --create-metadata --verbose
766 $fdroid readmeta
767 grep -F '<application id=' repo/index.xml > /dev/null
768 test -e repo/index.xml
769 test -e repo/index.jar
770 test -e repo/index-v1.jar
771 test -e tmp/apkcache
772 ! test -z tmp/apkcache
773 export ANDROID_HOME=$STORED_ANDROID_HOME
774
775
776 #------------------------------------------------------------------------------#
777 echo_header "check duplicate files are properly handled by fdroid update"
778
779 REPOROOT=`create_test_dir`
780 KEYSTORE=$WORKSPACE/tests/keystore.jks
781 cd $REPOROOT
782 $fdroid init --keystore $KEYSTORE --repo-keyalias=sova
783 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
784 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
785 mkdir $REPOROOT/metadata
786 cp -a $WORKSPACE/tests/metadata/obb.mainpatch.current.txt $REPOROOT/metadata
787 echo "accepted_formats = ['txt']" >> config.py
788 cp $WORKSPACE/tests/repo/obb.mainpatch.current_1619.apk $REPOROOT/repo/
789 cp $WORKSPACE/tests/repo/obb.mainpatch.current_1619_another-release-key.apk $REPOROOT/repo/
790 $fdroid update --pretty
791 grep -F 'obb.mainpatch.current_1619.apk' repo/index.xml repo/index-v1.json
792 grep -F 'obb.mainpatch.current_1619_another-release-key.apk' repo/index-v1.json
793 ! grep -F 'obb.mainpatch.current_1619_another-release-key.apk' repo/index.xml
794 # die if there are exact duplicates
795 cp $WORKSPACE/tests/repo/obb.mainpatch.current_1619.apk $REPOROOT/repo/duplicate.apk
796 ! $fdroid update
797
798
799 #------------------------------------------------------------------------------#
800 echo_header "setup new repo from scratch using ANDROID_HOME, putting APKs in repo first"
801
802 REPOROOT=`create_test_dir`
803 cd $REPOROOT
804 mkdir repo
805 copy_apks_into_repo $REPOROOT
806 $fdroid init
807 $fdroid update --create-metadata --verbose
808 $fdroid readmeta
809 grep -F '<application id=' repo/index.xml > /dev/null
810
811
812 #------------------------------------------------------------------------------#
813 echo_header "setup a new repo from scratch and generate a keystore"
814
815 REPOROOT=`create_test_dir`
816 KEYSTORE=$REPOROOT/keystore.jks
817 cd $REPOROOT
818 $fdroid init --keystore $KEYSTORE
819 test -e $KEYSTORE
820 copy_apks_into_repo $REPOROOT
821 $fdroid update --create-metadata --verbose
822 $fdroid readmeta
823 test -e repo/index.xml
824 test -e repo/index.jar
825 test -e repo/index-v1.jar
826 test -e tmp/apkcache
827 ! test -z tmp/apkcache
828 grep -F '<application id=' repo/index.xml > /dev/null
829
830
831 #------------------------------------------------------------------------------#
832 echo_header "setup a new repo manually and generate a keystore"
833
834 REPOROOT=`create_test_dir`
835 KEYSTORE=$REPOROOT/keystore.jks
836 cd $REPOROOT
837 cp $WORKSPACE/examples/fdroid-icon.png $REPOROOT/
838 ! test -e $KEYSTORE
839 set +e
840 $fdroid update
841 if [ $? -eq 0 ]; then
842     echo "This should have failed because this repo has no keystore!"
843     exit 1
844 else
845     echo '`fdroid update` prompted to add keystore'
846 fi
847 set -e
848 $fdroid update --create-key
849 test -e $KEYSTORE
850 copy_apks_into_repo $REPOROOT
851 $fdroid update --create-metadata --verbose
852 $fdroid readmeta
853 test -e repo/index.xml
854 test -e repo/index.jar
855 test -e repo/index-v1.jar
856 test -e tmp/apkcache
857 ! test -z tmp/apkcache
858 grep -F '<application id=' repo/index.xml > /dev/null
859
860
861 #------------------------------------------------------------------------------#
862 echo_header "setup a new repo from scratch, generate a keystore, then add APK and update"
863
864 REPOROOT=`create_test_dir`
865 KEYSTORE=$REPOROOT/keystore.jks
866 cd $REPOROOT
867 $fdroid init --keystore $KEYSTORE
868 test -e $KEYSTORE
869 copy_apks_into_repo $REPOROOT
870 $fdroid update --create-metadata --verbose
871 $fdroid readmeta
872 test -e repo/index.xml
873 test -e repo/index.jar
874 test -e repo/index-v1.jar
875 grep -F '<application id=' repo/index.xml > /dev/null
876 test -e $REPOROOT/repo/info.guardianproject.urzip_100.apk || \
877     cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
878 $fdroid update --create-metadata --verbose
879 $fdroid readmeta
880 test -e repo/index.xml
881 test -e repo/index.jar
882 test -e repo/index-v1.jar
883 test -e tmp/apkcache
884 ! test -z tmp/apkcache
885 grep -F '<application id=' repo/index.xml > /dev/null
886
887
888 #------------------------------------------------------------------------------#
889 echo_header "setup a new repo from scratch with a HSM/smartcard"
890 REPOROOT=`create_test_dir`
891 cd $REPOROOT
892 $fdroid init --keystore NONE
893 test -e opensc-fdroid.cfg
894 test ! -e NONE
895
896
897 #------------------------------------------------------------------------------#
898 echo_header "setup a new repo with no keystore, add APK, and update"
899
900 REPOROOT=`create_test_dir`
901 KEYSTORE=$REPOROOT/keystore.jks
902 cd $REPOROOT
903 touch fdroid-icon.png
904 mkdir repo
905 cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
906 set +e
907 $fdroid update --create-metadata --verbose
908 if [ $? -eq 0 ]; then
909     echo "This should have failed because this repo has no keystore!"
910     exit 1
911 else
912     echo '`fdroid update` prompted to add keystore'
913 fi
914 set -e
915
916 # now set up fake, non-working keystore setup
917 touch $KEYSTORE
918 echo "keystore = \"$KEYSTORE\"" >> config.py
919 echo 'repo_keyalias = "foo"' >> config.py
920 echo 'keystorepass = "foo"' >> config.py
921 echo 'keypass = "foo"' >> config.py
922 set +e
923 $fdroid update --create-metadata --verbose
924 if [ $? -eq 0 ]; then
925     echo "This should have failed because this repo has a bad/fake keystore!"
926     exit 1
927 else
928     echo '`fdroid update` prompted to add keystore'
929 fi
930 set -e
931
932
933 #------------------------------------------------------------------------------#
934 echo_header "copy tests/repo, update with binary transparency log"
935
936 REPOROOT=`create_test_dir`
937 GIT_REMOTE=`create_test_dir`
938 GNUPGHOME=$REPOROOT/gnupghome
939 KEYSTORE=$WORKSPACE/tests/keystore.jks
940 cd $REPOROOT
941 $fdroid init --keystore $KEYSTORE --repo-keyalias=sova
942 cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $WORKSPACE/tests/stats $REPOROOT/
943 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
944 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
945 echo "binary_transparency_remote = '$GIT_REMOTE'" >> config.py
946 echo "accepted_formats = ['json', 'txt', 'yml']" >> config.py
947 $fdroid update --verbose
948 if have_git_2_3; then
949     $fdroid server update --verbose
950     test -e repo/index.xml
951     test -e repo/index.jar
952     test -e repo/index-v1.jar
953     grep -F '<application id=' repo/index.xml > /dev/null
954     cd binary_transparency
955     [ `git rev-list --count HEAD` == "2" ]
956     cd $GIT_REMOTE
957     [ `git rev-list --count HEAD` == "2" ]
958 else
959     echo "Skipping test, `git --version` older than 2.3"
960 fi
961
962
963 #------------------------------------------------------------------------------#
964 echo_header "setup a new repo with keystore with APK, update, then without key"
965
966 REPOROOT=`create_test_dir`
967 KEYSTORE=$REPOROOT/keystore.jks
968 cd $REPOROOT
969 $fdroid init --keystore $KEYSTORE
970 test -e $KEYSTORE
971 cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
972 $fdroid update --create-metadata --verbose
973 $fdroid readmeta
974 test -e repo/index.xml
975 test -e repo/index.jar
976 test -e repo/index-v1.jar
977 test -e tmp/apkcache
978 ! test -z tmp/apkcache
979 grep -F '<application id=' repo/index.xml > /dev/null
980
981 # now set fake repo_keyalias
982 $sed -i.tmp 's,^ *repo_keyalias.*,repo_keyalias = "fake",' $REPOROOT/config.py
983 set +e
984 $fdroid update
985 if [ $? -eq 0 ]; then
986     echo "This should have failed because this repo has a bad repo_keyalias!"
987     exit 1
988 else
989     echo '`fdroid update` prompted to add keystore'
990 fi
991 set -e
992
993 # try creating a new keystore, but fail because the old one is there
994 test -e $KEYSTORE
995 set +e
996 $fdroid update --create-key
997 if [ $? -eq 0 ]; then
998     echo "This should have failed because a keystore is already there!"
999     exit 1
1000 else
1001     echo '`fdroid update` complained about existing keystore'
1002 fi
1003 set -e
1004
1005 # now actually create the key with the existing settings
1006 rm -f $KEYSTORE
1007 ! test -e $KEYSTORE
1008 $fdroid update --create-key
1009 test -e $KEYSTORE
1010
1011
1012 #------------------------------------------------------------------------------#
1013 echo_header "sign binary repo in offline box, then publishing from online box"
1014
1015 OFFLINE_ROOT=`create_test_dir`
1016 KEYSTORE=$WORKSPACE/tests/keystore.jks
1017 LOCAL_COPY_DIR=`create_test_dir`/fdroid
1018 mkdir $LOCAL_COPY_DIR
1019 ONLINE_ROOT=`create_test_dir`
1020 SERVERWEBROOT=`create_test_dir`
1021
1022 # create offline binary transparency log
1023 cd $OFFLINE_ROOT
1024 mkdir binary_transparency
1025 cd binary_transparency
1026 git init
1027
1028 # fake git remote server for binary transparency log
1029 BINARY_TRANSPARENCY_REMOTE=`create_test_dir`
1030
1031 # fake git remote server for repo mirror
1032 SERVER_GIT_MIRROR=`create_test_dir`
1033 cd $SERVER_GIT_MIRROR
1034 git init
1035 if have_git_2_3; then
1036     git config receive.denyCurrentBranch updateInstead
1037 fi
1038
1039 cd $OFFLINE_ROOT
1040 $fdroid init --keystore $KEYSTORE --repo-keyalias=sova
1041 cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $WORKSPACE/tests/stats $OFFLINE_ROOT/
1042
1043 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
1044 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
1045 echo "mirrors = ['http://foo.bar/fdroid', 'http://asdflkdsfjafdsdfhkjh.onion/fdroid']" >> config.py
1046 echo "servergitmirrors = '$SERVER_GIT_MIRROR'" >> config.py
1047 echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
1048 echo "accepted_formats = ['json', 'txt', 'yml']" >> config.py
1049 $fdroid update --pretty
1050 grep -F '<application id=' repo/index.xml > /dev/null
1051 grep -F '/fdroid/repo</mirror>' repo/index.xml
1052 grep -F '/fdroid/archive</mirror>' archive/index.xml
1053 test `grep '<mirror>' repo/index.xml | wc -l` -eq 2
1054 test `grep '<mirror>' archive/index.xml | wc -l` -eq 2
1055 cd binary_transparency
1056 [ `git rev-list --count HEAD` == "1" ]
1057 cd ..
1058 $fdroid server update --verbose
1059 grep -F '<application id=' $LOCAL_COPY_DIR/repo/index.xml > /dev/null
1060 cd $ONLINE_ROOT
1061 echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
1062 echo "sync_from_local_copy_dir = True" >> config.py
1063 echo "serverwebroots = '$SERVERWEBROOT'" >> config.py
1064 echo "servergitmirrors = '$SERVER_GIT_MIRROR'" >> config.py
1065 echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
1066 echo "binary_transparency_remote = '$BINARY_TRANSPARENCY_REMOTE'" >> config.py
1067 $fdroid server update --verbose
1068 cd $BINARY_TRANSPARENCY_REMOTE
1069 [ `git rev-list --count HEAD` == "1" ]
1070 cd $SERVER_GIT_MIRROR
1071 [ `git rev-list --count HEAD` == "1" ]
1072
1073
1074 #------------------------------------------------------------------------------#
1075
1076 # remove this to prevent git conflicts and complaining
1077 rm -rf $WORKSPACE/fdroidserver.egg-info/
1078
1079 echo SUCCESS