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