chiark / gitweb /
tests: don't run gpgsign tests on Travis CI's OSX, gpg always fails
[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 # OSX tests are run on Travis-CI, and gpg fails to launch gpg-agent there
239 if [ "$TRAVIS_OS_NAME" != "osx" ]; then
240     $fdroid gpgsign --verbose
241     $fdroid gpgsign --verbose
242     test -e repo/obb.mainpatch.current_1619.apk.asc
243     test -e repo/obb.main.twoversions_1101617_src.tar.gz.asc
244     ! test -e repo/obb.mainpatch.current_1619.apk.asc.asc
245     ! test -e repo/obb.main.twoversions_1101617_src.tar.gz.asc.asc
246     ! test -e repo/index.xml.asc
247 fi
248
249 # we can't easily reproduce the timestamps for things, so just hardcode them
250 $sed -i.tmp -e 's,timestamp="[0-9]*",timestamp="1480431575",' repo/index.xml
251 diff -uw $WORKSPACE/tests/repo/index.xml repo/index.xml
252
253
254 #------------------------------------------------------------------------------#
255 echo_header 'test moving lots of APKs to the archive'
256
257 REPOROOT=`create_test_dir`
258 cd $REPOROOT
259 cp $WORKSPACE/tests/keystore.jks $REPOROOT/
260 $fdroid init --keystore keystore.jks --repo-keyalias=sova
261 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
262 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
263 echo "accepted_formats = ['txt']" >> config.py
264 $sed -i.tmp '/allow_disabled_algorithms/d' config.py
265 test -d metadata || mkdir metadata
266 cp $WORKSPACE/tests/metadata/*.txt metadata/
267 echo 'Summary:good test version of urzip' > metadata/info.guardianproject.urzip.txt
268 echo 'Summary:good MD5 sig, which is disabled algorithm' > metadata/org.bitbucket.tickytacky.mirrormirror.txt
269 $sed -i.tmp '/Archive Policy:/d' metadata/*.txt
270 test -d repo || mkdir repo
271 cp $WORKSPACE/tests/urzip.apk \
272    $WORKSPACE/tests/org.bitbucket.tickytacky.mirrormirror_[0-9].apk \
273    $WORKSPACE/tests/repo/com.politedroid_[0-9].apk \
274    $WORKSPACE/tests/repo/obb.main.twoversions_110161[357].apk \
275    repo/
276 $sed -i.tmp 's,archive_older = [0-9],archive_older = 3,' config.py
277
278 $fdroid update --pretty --nosign
279 echo "This will fail when jarsigner allows MD5 for APK signatures"
280 test `grep '<package>' archive/index.xml | wc -l` -eq 5
281 test `grep '<package>' repo/index.xml | wc -l` -eq 7
282
283
284 #------------------------------------------------------------------------------#
285 echo_header 'test per-app "Archive Policy"'
286
287 REPOROOT=`create_test_dir`
288 cd $REPOROOT
289 cp $WORKSPACE/tests/keystore.jks $REPOROOT/
290 $fdroid init --keystore keystore.jks --repo-keyalias=sova
291 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
292 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
293 echo "accepted_formats = ['txt']" >> config.py
294 test -d metadata || mkdir metadata
295 cp $WORKSPACE/tests/metadata/com.politedroid.txt metadata/
296 test -d repo || mkdir repo
297 cp $WORKSPACE/tests/repo/com.politedroid_[0-9].apk repo/
298 $sed -i.tmp 's,archive_older = [0-9],archive_older = 3,' config.py
299
300 $fdroid update --pretty --nosign
301 test `grep '<package>' archive/index.xml | wc -l` -eq 0
302 test `grep '<package>' repo/index.xml | wc -l` -eq 4
303 grep -F com.politedroid_3.apk repo/index.xml
304 grep -F com.politedroid_4.apk repo/index.xml
305 grep -F com.politedroid_5.apk repo/index.xml
306 grep -F com.politedroid_6.apk repo/index.xml
307 test -e repo/com.politedroid_3.apk
308 test -e repo/com.politedroid_4.apk
309 test -e repo/com.politedroid_5.apk
310 test -e repo/com.politedroid_6.apk
311
312 echo "enable one app in the repo"
313 $sed -i.tmp 's,^Archive Policy:4,Archive Policy:1,' metadata/com.politedroid.txt
314 $fdroid update --pretty --nosign
315 test `grep '<package>' archive/index.xml | wc -l` -eq 3
316 test `grep '<package>' repo/index.xml | wc -l` -eq 1
317 grep -F com.politedroid_3.apk archive/index.xml
318 grep -F com.politedroid_4.apk archive/index.xml
319 grep -F com.politedroid_5.apk archive/index.xml
320 grep -F com.politedroid_6.apk repo/index.xml
321 test -e archive/com.politedroid_3.apk
322 test -e archive/com.politedroid_4.apk
323 test -e archive/com.politedroid_5.apk
324 test -e repo/com.politedroid_6.apk
325
326 echo "remove all apps from the repo"
327 $sed -i.tmp 's,^Archive Policy:1,Archive Policy:0,' metadata/com.politedroid.txt
328 $fdroid update --pretty --nosign
329 test `grep '<package>' archive/index.xml | wc -l` -eq 4
330 test `grep '<package>' repo/index.xml | wc -l` -eq 0
331 grep -F com.politedroid_3.apk archive/index.xml
332 grep -F com.politedroid_4.apk archive/index.xml
333 grep -F com.politedroid_5.apk archive/index.xml
334 grep -F com.politedroid_6.apk archive/index.xml
335 test -e archive/com.politedroid_3.apk
336 test -e archive/com.politedroid_4.apk
337 test -e archive/com.politedroid_5.apk
338 test -e archive/com.politedroid_6.apk
339 ! test -e repo/com.politedroid_6.apk
340
341 echo "move back one from archive to the repo"
342 $sed -i.tmp 's,^Archive Policy:0,Archive Policy:1,' metadata/com.politedroid.txt
343 $fdroid update --pretty --nosign
344 test `grep '<package>' archive/index.xml | wc -l` -eq 3
345 test `grep '<package>' repo/index.xml | wc -l` -eq 1
346 grep -F com.politedroid_3.apk archive/index.xml
347 grep -F com.politedroid_4.apk archive/index.xml
348 grep -F com.politedroid_5.apk archive/index.xml
349 grep -F com.politedroid_6.apk repo/index.xml
350 test -e archive/com.politedroid_3.apk
351 test -e archive/com.politedroid_4.apk
352 test -e archive/com.politedroid_5.apk
353 ! test -e archive/com.politedroid_6.apk
354 test -e repo/com.politedroid_6.apk
355
356
357
358 #------------------------------------------------------------------------------#
359 echo_header 'test moving old APKs to and from the archive'
360
361 REPOROOT=`create_test_dir`
362 cd $REPOROOT
363 cp $WORKSPACE/tests/keystore.jks $REPOROOT/
364 $fdroid init --keystore keystore.jks --repo-keyalias=sova
365 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
366 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
367 echo "accepted_formats = ['txt']" >> config.py
368 test -d metadata || mkdir metadata
369 cp $WORKSPACE/tests/metadata/com.politedroid.txt metadata/
370 $sed -i.tmp '/Archive Policy:/d' metadata/com.politedroid.txt
371 test -d repo || mkdir repo
372 cp $WORKSPACE/tests/repo/com.politedroid_[0-9].apk repo/
373 $sed -i.tmp 's,archive_older = [0-9],archive_older = 3,' config.py
374
375 $fdroid update --pretty --nosign
376 test `grep '<package>' archive/index.xml | wc -l` -eq 1
377 test `grep '<package>' repo/index.xml | wc -l` -eq 3
378 grep -F com.politedroid_3.apk archive/index.xml
379 grep -F com.politedroid_4.apk repo/index.xml
380 grep -F com.politedroid_5.apk repo/index.xml
381 grep -F com.politedroid_6.apk repo/index.xml
382 test -e archive/com.politedroid_3.apk
383 test -e repo/com.politedroid_4.apk
384 test -e repo/com.politedroid_5.apk
385 test -e repo/com.politedroid_6.apk
386
387 $sed -i.tmp 's,archive_older = 3,archive_older = 1,' config.py
388 $fdroid update --pretty --nosign
389 test `grep '<package>' archive/index.xml | wc -l` -eq 3
390 test `grep '<package>' repo/index.xml | wc -l` -eq 1
391 grep -F com.politedroid_3.apk archive/index.xml
392 grep -F com.politedroid_4.apk archive/index.xml
393 grep -F com.politedroid_5.apk archive/index.xml
394 grep -F com.politedroid_6.apk repo/index.xml
395 test -e archive/com.politedroid_3.apk
396 test -e archive/com.politedroid_4.apk
397 test -e archive/com.politedroid_5.apk
398 test -e repo/com.politedroid_6.apk
399
400 # disabling deletes from the archive
401 $sed -i.tmp 's/Build:1.3,4/Build:1.3,4\n    disable=testing deletion/' metadata/com.politedroid.txt
402 $fdroid update --pretty --nosign
403 test `grep '<package>' archive/index.xml | wc -l` -eq 2
404 test `grep '<package>' repo/index.xml | wc -l` -eq 1
405 grep -F com.politedroid_3.apk archive/index.xml
406 ! grep -F com.politedroid_4.apk archive/index.xml
407 grep -F com.politedroid_5.apk archive/index.xml
408 grep -F com.politedroid_6.apk repo/index.xml
409 test -e archive/com.politedroid_3.apk
410 ! test -e archive/com.politedroid_4.apk
411 test -e archive/com.politedroid_5.apk
412 test -e repo/com.politedroid_6.apk
413
414 # disabling deletes from the repo, and promotes one from the archive
415 $sed -i.tmp 's/Build:1.5,6/Build:1.5,6\n    disable=testing deletion/' metadata/com.politedroid.txt
416 $fdroid update --pretty --nosign
417 test `grep '<package>' archive/index.xml | wc -l` -eq 1
418 test `grep '<package>' repo/index.xml | wc -l` -eq 1
419 grep -F com.politedroid_3.apk archive/index.xml
420 grep -F com.politedroid_5.apk repo/index.xml
421 ! grep -F com.politedroid_6.apk repo/index.xml
422 test -e archive/com.politedroid_3.apk
423 test -e repo/com.politedroid_5.apk
424 ! test -e repo/com.politedroid_6.apk
425
426
427 #------------------------------------------------------------------------------#
428 echo_header 'test allowing disabled signatures in repo and archive'
429
430 REPOROOT=`create_test_dir`
431 cd $REPOROOT
432 cp $WORKSPACE/tests/keystore.jks $REPOROOT/
433 $fdroid init --keystore keystore.jks --repo-keyalias=sova
434 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
435 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
436 echo "accepted_formats = ['txt']" >> config.py
437 echo 'allow_disabled_algorithms = True' >> config.py
438 $sed -i.tmp 's,archive_older = [0-9],archive_older = 3,' config.py
439 test -d metadata || mkdir metadata
440 cp $WORKSPACE/tests/metadata/com.politedroid.txt metadata/
441 echo 'Summary:good test version of urzip' > metadata/info.guardianproject.urzip.txt
442 echo 'Summary:good MD5 sig, disabled algorithm' > metadata/org.bitbucket.tickytacky.mirrormirror.txt
443 $sed -i.tmp '/Archive Policy:/d' metadata/*.txt
444 test -d repo || mkdir repo
445 cp $WORKSPACE/tests/repo/com.politedroid_[0-9].apk \
446    $WORKSPACE/tests/org.bitbucket.tickytacky.mirrormirror_[0-9].apk \
447    $WORKSPACE/tests/urzip-badsig.apk \
448    repo/
449
450 $fdroid update --pretty --nosign
451 test `grep '<package>' archive/index.xml | wc -l` -eq 2
452 test `grep '<package>' repo/index.xml | wc -l` -eq 6
453 grep -F com.politedroid_3.apk archive/index.xml
454 grep -F com.politedroid_4.apk repo/index.xml
455 grep -F com.politedroid_5.apk repo/index.xml
456 grep -F com.politedroid_6.apk repo/index.xml
457 grep -F org.bitbucket.tickytacky.mirrormirror_1.apk archive/index.xml
458 grep -F org.bitbucket.tickytacky.mirrormirror_2.apk repo/index.xml
459 grep -F org.bitbucket.tickytacky.mirrormirror_3.apk repo/index.xml
460 grep -F org.bitbucket.tickytacky.mirrormirror_4.apk repo/index.xml
461 ! grep -F urzip-badsig.apk repo/index.xml
462 ! grep -F urzip-badsig.apk archive/index.xml
463 test -e archive/com.politedroid_3.apk
464 test -e repo/com.politedroid_4.apk
465 test -e repo/com.politedroid_5.apk
466 test -e repo/com.politedroid_6.apk
467 test -e archive/org.bitbucket.tickytacky.mirrormirror_1.apk
468 test -e repo/org.bitbucket.tickytacky.mirrormirror_2.apk
469 test -e repo/org.bitbucket.tickytacky.mirrormirror_3.apk
470 test -e repo/org.bitbucket.tickytacky.mirrormirror_4.apk
471 test -e archive/urzip-badsig.apk
472
473 $sed -i.tmp '/allow_disabled_algorithms/d' config.py
474 $fdroid update --pretty --nosign
475 test `grep '<package>' archive/index.xml | wc -l` -eq 5
476 test `grep '<package>' repo/index.xml | wc -l` -eq 3
477 grep -F org.bitbucket.tickytacky.mirrormirror_1.apk archive/index.xml
478 grep -F org.bitbucket.tickytacky.mirrormirror_2.apk archive/index.xml
479 grep -F org.bitbucket.tickytacky.mirrormirror_3.apk archive/index.xml
480 grep -F org.bitbucket.tickytacky.mirrormirror_4.apk archive/index.xml
481 grep -F com.politedroid_3.apk archive/index.xml
482 grep -F com.politedroid_4.apk repo/index.xml
483 grep -F com.politedroid_5.apk repo/index.xml
484 grep -F com.politedroid_6.apk repo/index.xml
485 ! grep -F urzip-badsig.apk repo/index.xml
486 ! grep -F urzip-badsig.apk archive/index.xml
487 test -e archive/org.bitbucket.tickytacky.mirrormirror_1.apk
488 test -e archive/org.bitbucket.tickytacky.mirrormirror_2.apk
489 test -e archive/org.bitbucket.tickytacky.mirrormirror_3.apk
490 test -e archive/org.bitbucket.tickytacky.mirrormirror_4.apk
491 test -e archive/com.politedroid_3.apk
492 test -e archive/urzip-badsig.apk
493 test -e repo/com.politedroid_4.apk
494 test -e repo/com.politedroid_5.apk
495 test -e repo/com.politedroid_6.apk
496
497
498 #------------------------------------------------------------------------------#
499 echo_header 'rename apks with `fdroid update --rename-apks`, --nosign for speed'
500
501 REPOROOT=`create_test_dir`
502 cd $REPOROOT
503 cp $WORKSPACE/tests/keystore.jks $REPOROOT/
504 $fdroid init --keystore keystore.jks --repo-keyalias=sova
505 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
506 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
507 echo "accepted_formats = ['txt', 'yml']" >> config.py
508 echo 'keydname = "CN=Birdman, OU=Cell, O=Alcatraz, L=Alcatraz, S=California, C=US"' >> config.py
509 test -d metadata || mkdir metadata
510 cp $WORKSPACE/tests/metadata/info.guardianproject.urzip.yml metadata/
511 test -d repo || mkdir repo
512 cp $WORKSPACE/tests/urzip.apk "repo/asdfiuhk urzip-πÇÇπÇÇ现代汉语通用字-български-عربي1234 ö.apk"
513 $fdroid update --rename-apks --pretty --nosign
514 test -e repo/info.guardianproject.urzip_100.apk
515 grep -F 'info.guardianproject.urzip_100.apk' repo/index-v1.json repo/index.xml
516 cp $WORKSPACE/tests/urzip-release.apk repo/
517 $fdroid update --rename-apks --pretty --nosign
518 test -e repo/info.guardianproject.urzip_100.apk
519 test -e repo/info.guardianproject.urzip_100_b4964fd.apk
520 grep -F 'info.guardianproject.urzip_100.apk' repo/index-v1.json repo/index.xml
521 grep -F 'info.guardianproject.urzip_100_b4964fd.apk' repo/index-v1.json
522 ! grep -F 'info.guardianproject.urzip_100_b4964fd.apk' repo/index.xml
523 cp $WORKSPACE/tests/urzip-release.apk repo/
524 $fdroid update --rename-apks --pretty --nosign
525 test -e repo/info.guardianproject.urzip_100.apk
526 test -e repo/info.guardianproject.urzip_100_b4964fd.apk
527 test -e duplicates/repo/info.guardianproject.urzip_100_b4964fd.apk
528 grep -F 'info.guardianproject.urzip_100.apk' repo/index-v1.json repo/index.xml
529 grep -F 'info.guardianproject.urzip_100_b4964fd.apk' repo/index-v1.json
530 ! grep -F 'info.guardianproject.urzip_100_b4964fd.apk' repo/index.xml
531
532
533 #------------------------------------------------------------------------------#
534 echo_header "test metadata checks"
535
536 REPOROOT=`create_test_dir`
537 cd $REPOROOT
538
539 mkdir repo
540 cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
541
542 set +e
543 $fdroid build
544 if [ $? -eq 0 ]; then
545     echo "This should have failed because there is no metadata!"
546     exit 1
547 else
548     echo "testing metadata checks passed"
549 fi
550 set -e
551
552 mkdir $REPOROOT/metadata/
553 cp $WORKSPACE/tests/metadata/org.smssecure.smssecure.txt $REPOROOT/metadata/
554 $fdroid readmeta
555
556 # now make a fake duplicate
557 touch $REPOROOT/metadata/org.smssecure.smssecure.yml
558
559 set +e
560 $fdroid readmeta
561 if [ $? -eq 0 ]; then
562     echo "This should have failed because there is a duplicate metadata file!"
563     exit 1
564 else
565     echo "testing duplicate metadata checks passed"
566 fi
567 set -e
568
569
570 #------------------------------------------------------------------------------#
571 echo_header "ensure commands that don't need the JDK work without a JDK configed"
572
573 REPOROOT=`create_test_dir`
574 cd $REPOROOT
575 mkdir repo
576 mkdir metadata
577 echo "License:GPL-2.0" >> metadata/fake.txt
578 echo "Summary:Yup still fake" >> metadata/fake.txt
579 echo "Categories:Internet" >> metadata/fake.txt
580 echo "Description:" >> metadata/fake.txt
581 echo "this is fake" >> metadata/fake.txt
582 echo "." >> metadata/fake.txt
583
584 # fake that no JDKs are available
585 echo 'java_paths = {}' > config.py
586
587 LOCAL_COPY_DIR=`create_test_dir`/fdroid
588 mkdir -p $LOCAL_COPY_DIR/repo
589 echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
590
591 $fdroid checkupdates
592 $fdroid gpgsign
593 $fdroid lint
594 $fdroid readmeta
595 $fdroid rewritemeta fake
596 $fdroid server update
597 $fdroid scanner
598
599 # run these to get their output, but the are not setup, so don't fail
600 $fdroid build || true
601 $fdroid import || true
602 $fdroid install || true
603
604
605 #------------------------------------------------------------------------------#
606 echo_header "create a source tarball and use that to build a repo"
607
608 cd $WORKSPACE
609 $python setup.py sdist
610
611 REPOROOT=`create_test_dir`
612 cd $REPOROOT
613 tar xzf `ls -1 $WORKSPACE/dist/fdroidserver-*.tar.gz | sort -n | tail -1`
614 cd $REPOROOT
615 ./fdroidserver-*/fdroid init
616 copy_apks_into_repo $REPOROOT
617 ./fdroidserver-*/fdroid update --create-metadata --verbose
618
619
620 #------------------------------------------------------------------------------#
621 echo_header "test config checks of local_copy_dir"
622
623 REPOROOT=`create_test_dir`
624 cd $REPOROOT
625 $fdroid init
626 $fdroid update --create-metadata --verbose
627 $fdroid readmeta
628 $fdroid server update --local-copy-dir=/tmp/fdroid
629
630 # now test the errors work
631 set +e
632 $fdroid server update --local-copy-dir=thisisnotanabsolutepath
633 if [ $? -eq 0 ]; then
634     echo "This should have failed because thisisnotanabsolutepath is not an absolute path!"
635     exit 1
636 else
637     echo "testing absolute path checker passed"
638 fi
639 $fdroid server update --local-copy-dir=/tmp/IReallyDoubtThisPathExistsasdfasdf
640 if [ $? -eq 0 ]; then
641     echo "This should have failed because the path does not end with 'fdroid'!"
642     exit 1
643 else
644     echo "testing dirname exists checker passed"
645 fi
646 $fdroid server update --local-copy-dir=/tmp/IReallyDoubtThisPathExistsasdfasdf/fdroid
647 if [ $? -eq 0 ]; then
648     echo "This should have failed because the dirname path does not exist!"
649     exit 1
650 else
651     echo "testing dirname exists checker passed"
652 fi
653 set -e
654
655
656 #------------------------------------------------------------------------------#
657 echo_header "setup a new repo from scratch using ANDROID_HOME and do a local sync"
658
659 REPOROOT=`create_test_dir`
660 cd $REPOROOT
661 $fdroid init
662 copy_apks_into_repo $REPOROOT
663 $fdroid update --create-metadata --verbose
664 $fdroid readmeta
665 grep -F '<application id=' repo/index.xml > /dev/null
666
667 LOCALCOPYDIR=`create_test_dir`/fdroid
668 $fdroid server update --local-copy-dir=$LOCALCOPYDIR
669 NEWREPOROOT=`create_test_dir`
670 cd $NEWREPOROOT
671 $fdroid init
672 echo "sync_from_local_copy_dir = True" >> config.py
673 $fdroid server update --local-copy-dir=$LOCALCOPYDIR
674
675
676 #------------------------------------------------------------------------------#
677 # check that --android-home fails when dir does not exist or is not a dir
678
679 REPOROOT=`create_test_dir`
680 KEYSTORE=$REPOROOT/keystore.jks
681 cd $REPOROOT
682 set +e
683 $fdroid init --keystore $KEYSTORE --android-home /opt/fakeandroidhome
684 if [ $? -eq 0 ]; then
685     echo "This should have failed because /opt/fakeandroidhome does not exist!"
686     exit 1
687 else
688     echo "testing android-home path checker passed"
689 fi
690 TESTFILE=`create_test_file`
691 $fdroid init --keystore $KEYSTORE --android-home $TESTFILE
692 if [ $? -eq 0 ]; then
693     echo "This should have failed because $TESTFILE is a file not a dir!"
694     exit 1
695 else
696     echo "testing android-home not-dir checker passed"
697 fi
698 set -e
699
700
701 #------------------------------------------------------------------------------#
702 echo_header "check that fake android home passes 'fdroid init'"
703
704 REPOROOT=`create_test_dir`
705 FAKE_ANDROID_HOME=`create_test_dir`
706 create_fake_android_home $FAKE_ANDROID_HOME
707 KEYSTORE=$REPOROOT/keystore.jks
708 cd $REPOROOT
709 $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
710
711
712 #------------------------------------------------------------------------------#
713 echo_header "check that 'fdroid init' fails when build-tools cannot be found"
714
715 if [ -e /usr/bin/aapt ]; then
716     echo "/usr/bin/aapt exists, not running test"
717 else
718     REPOROOT=`create_test_dir`
719     FAKE_ANDROID_HOME=`create_test_dir`
720     create_fake_android_home $FAKE_ANDROID_HOME
721     rm -f $FAKE_ANDROID_HOME/build-tools/*/aapt
722     KEYSTORE=$REPOROOT/keystore.jks
723     cd $REPOROOT
724     set +e
725     $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
726     [ $? -eq 0 ] && exit 1
727     set -e
728 fi
729
730
731 #------------------------------------------------------------------------------#
732 echo_header "check that --android-home overrides ANDROID_HOME"
733
734 REPOROOT=`create_test_dir`
735 FAKE_ANDROID_HOME=`create_test_dir`
736 create_fake_android_home $FAKE_ANDROID_HOME
737 KEYSTORE=$REPOROOT/keystore.jks
738 cd $REPOROOT
739 $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
740 set +e
741 grep $FAKE_ANDROID_HOME $REPOROOT/config.py
742 if [ $? -ne 0 ]; then
743     echo "the value set in --android-home '$FAKE_ANDROID_HOME' should override ANDROID_HOME '$ANDROID_HOME'"
744     exit 1
745 fi
746 set -e
747
748
749 #------------------------------------------------------------------------------#
750 # In this case, ANDROID_HOME is set to a fake, non-working version that will
751 # be detected by fdroid as an Android SDK install.  It should use the path set
752 # by --android-home over the one in ANDROID_HOME, therefore if it uses the one
753 # in ANDROID_HOME, it won't work because it is a fake one.  Only
754 # --android-home provides a working one.
755 echo_header "setup a new repo from scratch with keystore and android-home set on cmd line"
756
757 REPOROOT=`create_test_dir`
758 KEYSTORE=$REPOROOT/keystore.jks
759 FAKE_ANDROID_HOME=`create_test_dir`
760 create_fake_android_home $FAKE_ANDROID_HOME
761 STORED_ANDROID_HOME=$ANDROID_HOME
762 unset ANDROID_HOME
763 echo "ANDROID_HOME: $ANDROID_HOME"
764 cd $REPOROOT
765 $fdroid init --keystore $KEYSTORE --android-home $STORED_ANDROID_HOME --no-prompt
766 test -e $KEYSTORE
767 copy_apks_into_repo $REPOROOT
768 $fdroid update --create-metadata --verbose
769 $fdroid readmeta
770 grep -F '<application id=' repo/index.xml > /dev/null
771 test -e repo/index.xml
772 test -e repo/index.jar
773 test -e repo/index-v1.jar
774 test -e tmp/apkcache
775 ! test -z tmp/apkcache
776 export ANDROID_HOME=$STORED_ANDROID_HOME
777
778
779 #------------------------------------------------------------------------------#
780 echo_header "check duplicate files are properly handled by fdroid update"
781
782 REPOROOT=`create_test_dir`
783 KEYSTORE=$WORKSPACE/tests/keystore.jks
784 cd $REPOROOT
785 $fdroid init --keystore $KEYSTORE --repo-keyalias=sova
786 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
787 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
788 mkdir $REPOROOT/metadata
789 cp -a $WORKSPACE/tests/metadata/obb.mainpatch.current.txt $REPOROOT/metadata
790 echo "accepted_formats = ['txt']" >> config.py
791 cp $WORKSPACE/tests/repo/obb.mainpatch.current_1619.apk $REPOROOT/repo/
792 cp $WORKSPACE/tests/repo/obb.mainpatch.current_1619_another-release-key.apk $REPOROOT/repo/
793 $fdroid update --pretty
794 grep -F 'obb.mainpatch.current_1619.apk' repo/index.xml repo/index-v1.json
795 grep -F 'obb.mainpatch.current_1619_another-release-key.apk' repo/index-v1.json
796 ! grep -F 'obb.mainpatch.current_1619_another-release-key.apk' repo/index.xml
797 # die if there are exact duplicates
798 cp $WORKSPACE/tests/repo/obb.mainpatch.current_1619.apk $REPOROOT/repo/duplicate.apk
799 ! $fdroid update
800
801
802 #------------------------------------------------------------------------------#
803 echo_header "setup new repo from scratch using ANDROID_HOME, putting APKs in repo first"
804
805 REPOROOT=`create_test_dir`
806 cd $REPOROOT
807 mkdir repo
808 copy_apks_into_repo $REPOROOT
809 $fdroid init
810 $fdroid update --create-metadata --verbose
811 $fdroid readmeta
812 grep -F '<application id=' repo/index.xml > /dev/null
813
814
815 #------------------------------------------------------------------------------#
816 echo_header "setup a new repo from scratch and generate a keystore"
817
818 REPOROOT=`create_test_dir`
819 KEYSTORE=$REPOROOT/keystore.jks
820 cd $REPOROOT
821 $fdroid init --keystore $KEYSTORE
822 test -e $KEYSTORE
823 copy_apks_into_repo $REPOROOT
824 $fdroid update --create-metadata --verbose
825 $fdroid readmeta
826 test -e repo/index.xml
827 test -e repo/index.jar
828 test -e repo/index-v1.jar
829 test -e tmp/apkcache
830 ! test -z tmp/apkcache
831 grep -F '<application id=' repo/index.xml > /dev/null
832
833
834 #------------------------------------------------------------------------------#
835 echo_header "setup a new repo manually and generate a keystore"
836
837 REPOROOT=`create_test_dir`
838 KEYSTORE=$REPOROOT/keystore.jks
839 cd $REPOROOT
840 cp $WORKSPACE/examples/fdroid-icon.png $REPOROOT/
841 ! test -e $KEYSTORE
842 set +e
843 $fdroid update
844 if [ $? -eq 0 ]; then
845     echo "This should have failed because this repo has no keystore!"
846     exit 1
847 else
848     echo '`fdroid update` prompted to add keystore'
849 fi
850 set -e
851 $fdroid update --create-key
852 test -e $KEYSTORE
853 copy_apks_into_repo $REPOROOT
854 $fdroid update --create-metadata --verbose
855 $fdroid readmeta
856 test -e repo/index.xml
857 test -e repo/index.jar
858 test -e repo/index-v1.jar
859 test -e tmp/apkcache
860 ! test -z tmp/apkcache
861 grep -F '<application id=' repo/index.xml > /dev/null
862
863
864 #------------------------------------------------------------------------------#
865 echo_header "setup a new repo from scratch, generate a keystore, then add APK and update"
866
867 REPOROOT=`create_test_dir`
868 KEYSTORE=$REPOROOT/keystore.jks
869 cd $REPOROOT
870 $fdroid init --keystore $KEYSTORE
871 test -e $KEYSTORE
872 copy_apks_into_repo $REPOROOT
873 $fdroid update --create-metadata --verbose
874 $fdroid readmeta
875 test -e repo/index.xml
876 test -e repo/index.jar
877 test -e repo/index-v1.jar
878 grep -F '<application id=' repo/index.xml > /dev/null
879 test -e $REPOROOT/repo/info.guardianproject.urzip_100.apk || \
880     cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
881 $fdroid update --create-metadata --verbose
882 $fdroid readmeta
883 test -e repo/index.xml
884 test -e repo/index.jar
885 test -e repo/index-v1.jar
886 test -e tmp/apkcache
887 ! test -z tmp/apkcache
888 grep -F '<application id=' repo/index.xml > /dev/null
889
890
891 #------------------------------------------------------------------------------#
892 echo_header "setup a new repo from scratch with a HSM/smartcard"
893 REPOROOT=`create_test_dir`
894 cd $REPOROOT
895 $fdroid init --keystore NONE
896 test -e opensc-fdroid.cfg
897 test ! -e NONE
898
899
900 #------------------------------------------------------------------------------#
901 echo_header "setup a new repo with no keystore, add APK, and update"
902
903 REPOROOT=`create_test_dir`
904 KEYSTORE=$REPOROOT/keystore.jks
905 cd $REPOROOT
906 touch fdroid-icon.png
907 mkdir repo
908 cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
909 set +e
910 $fdroid update --create-metadata --verbose
911 if [ $? -eq 0 ]; then
912     echo "This should have failed because this repo has no keystore!"
913     exit 1
914 else
915     echo '`fdroid update` prompted to add keystore'
916 fi
917 set -e
918
919 # now set up fake, non-working keystore setup
920 touch $KEYSTORE
921 echo "keystore = \"$KEYSTORE\"" >> config.py
922 echo 'repo_keyalias = "foo"' >> config.py
923 echo 'keystorepass = "foo"' >> config.py
924 echo 'keypass = "foo"' >> config.py
925 set +e
926 $fdroid update --create-metadata --verbose
927 if [ $? -eq 0 ]; then
928     echo "This should have failed because this repo has a bad/fake keystore!"
929     exit 1
930 else
931     echo '`fdroid update` prompted to add keystore'
932 fi
933 set -e
934
935
936 #------------------------------------------------------------------------------#
937 echo_header "copy tests/repo, update with binary transparency log"
938
939 REPOROOT=`create_test_dir`
940 GIT_REMOTE=`create_test_dir`
941 GNUPGHOME=$REPOROOT/gnupghome
942 KEYSTORE=$WORKSPACE/tests/keystore.jks
943 cd $REPOROOT
944 $fdroid init --keystore $KEYSTORE --repo-keyalias=sova
945 cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $WORKSPACE/tests/stats $REPOROOT/
946 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
947 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
948 echo "binary_transparency_remote = '$GIT_REMOTE'" >> config.py
949 echo "accepted_formats = ['json', 'txt', 'yml']" >> config.py
950 $fdroid update --verbose
951 if have_git_2_3; then
952     $fdroid server update --verbose
953     test -e repo/index.xml
954     test -e repo/index.jar
955     test -e repo/index-v1.jar
956     grep -F '<application id=' repo/index.xml > /dev/null
957     cd binary_transparency
958     [ `git rev-list --count HEAD` == "2" ]
959     cd $GIT_REMOTE
960     [ `git rev-list --count HEAD` == "2" ]
961 else
962     echo "Skipping test, `git --version` older than 2.3"
963 fi
964
965
966 #------------------------------------------------------------------------------#
967 echo_header "setup a new repo with keystore with APK, update, then without key"
968
969 REPOROOT=`create_test_dir`
970 KEYSTORE=$REPOROOT/keystore.jks
971 cd $REPOROOT
972 $fdroid init --keystore $KEYSTORE
973 test -e $KEYSTORE
974 cp $WORKSPACE/tests/urzip.apk $REPOROOT/repo/
975 $fdroid update --create-metadata --verbose
976 $fdroid readmeta
977 test -e repo/index.xml
978 test -e repo/index.jar
979 test -e repo/index-v1.jar
980 test -e tmp/apkcache
981 ! test -z tmp/apkcache
982 grep -F '<application id=' repo/index.xml > /dev/null
983
984 # now set fake repo_keyalias
985 $sed -i.tmp 's,^ *repo_keyalias.*,repo_keyalias = "fake",' $REPOROOT/config.py
986 set +e
987 $fdroid update
988 if [ $? -eq 0 ]; then
989     echo "This should have failed because this repo has a bad repo_keyalias!"
990     exit 1
991 else
992     echo '`fdroid update` prompted to add keystore'
993 fi
994 set -e
995
996 # try creating a new keystore, but fail because the old one is there
997 test -e $KEYSTORE
998 set +e
999 $fdroid update --create-key
1000 if [ $? -eq 0 ]; then
1001     echo "This should have failed because a keystore is already there!"
1002     exit 1
1003 else
1004     echo '`fdroid update` complained about existing keystore'
1005 fi
1006 set -e
1007
1008 # now actually create the key with the existing settings
1009 rm -f $KEYSTORE
1010 ! test -e $KEYSTORE
1011 $fdroid update --create-key
1012 test -e $KEYSTORE
1013
1014
1015 #------------------------------------------------------------------------------#
1016 echo_header "sign binary repo in offline box, then publishing from online box"
1017
1018 OFFLINE_ROOT=`create_test_dir`
1019 KEYSTORE=$WORKSPACE/tests/keystore.jks
1020 LOCAL_COPY_DIR=`create_test_dir`/fdroid
1021 mkdir $LOCAL_COPY_DIR
1022 ONLINE_ROOT=`create_test_dir`
1023 SERVERWEBROOT=`create_test_dir`
1024
1025 # create offline binary transparency log
1026 cd $OFFLINE_ROOT
1027 mkdir binary_transparency
1028 cd binary_transparency
1029 git init
1030
1031 # fake git remote server for binary transparency log
1032 BINARY_TRANSPARENCY_REMOTE=`create_test_dir`
1033
1034 # fake git remote server for repo mirror
1035 SERVER_GIT_MIRROR=`create_test_dir`
1036 cd $SERVER_GIT_MIRROR
1037 git init
1038 if have_git_2_3; then
1039     git config receive.denyCurrentBranch updateInstead
1040 fi
1041
1042 cd $OFFLINE_ROOT
1043 $fdroid init --keystore $KEYSTORE --repo-keyalias=sova
1044 cp -a $WORKSPACE/tests/metadata $WORKSPACE/tests/repo $WORKSPACE/tests/stats $OFFLINE_ROOT/
1045
1046 echo 'keystorepass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
1047 echo 'keypass = "r9aquRHYoI8+dYz6jKrLntQ5/NJNASFBacJh7Jv2BlI="' >> config.py
1048 echo "mirrors = ['http://foo.bar/fdroid', 'http://asdflkdsfjafdsdfhkjh.onion/fdroid']" >> config.py
1049 echo "servergitmirrors = '$SERVER_GIT_MIRROR'" >> config.py
1050 echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
1051 echo "accepted_formats = ['json', 'txt', 'yml']" >> config.py
1052 $fdroid update --pretty
1053 grep -F '<application id=' repo/index.xml > /dev/null
1054 grep -F '/fdroid/repo</mirror>' repo/index.xml
1055 grep -F '/fdroid/archive</mirror>' archive/index.xml
1056 test `grep '<mirror>' repo/index.xml | wc -l` -eq 2
1057 test `grep '<mirror>' archive/index.xml | wc -l` -eq 2
1058 cd binary_transparency
1059 [ `git rev-list --count HEAD` == "1" ]
1060 cd ..
1061 $fdroid server update --verbose
1062 grep -F '<application id=' $LOCAL_COPY_DIR/repo/index.xml > /dev/null
1063 cd $ONLINE_ROOT
1064 echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
1065 echo "sync_from_local_copy_dir = True" >> config.py
1066 echo "serverwebroots = '$SERVERWEBROOT'" >> config.py
1067 echo "servergitmirrors = '$SERVER_GIT_MIRROR'" >> config.py
1068 echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py
1069 echo "binary_transparency_remote = '$BINARY_TRANSPARENCY_REMOTE'" >> config.py
1070 $fdroid server update --verbose
1071 cd $BINARY_TRANSPARENCY_REMOTE
1072 [ `git rev-list --count HEAD` == "1" ]
1073 cd $SERVER_GIT_MIRROR
1074 [ `git rev-list --count HEAD` == "1" ]
1075
1076
1077 #------------------------------------------------------------------------------#
1078
1079 # remove this to prevent git conflicts and complaining
1080 rm -rf $WORKSPACE/fdroidserver.egg-info/
1081
1082 echo SUCCESS