7 echo "=============================================================================="
11 copy_apks_into_repo() {
12 for f in `ls -1 ../../*/bin/*.apk`; do
13 name=$(basename $(dirname `dirname $f`))
15 apk=`aapt d badging "$f" | sed -n "s,^package: name='\(.*\)' versionCode='\([0-9][0-9]*\)' .*,\1_\2.apk,p"`
21 create_fake_android_home() {
23 mkdir $1/build-tools/19.0.1
24 touch $1/build-tools/19.0.1/aapt
28 test -e $WORKSPACE/.testfiles || mkdir $WORKSPACE/.testfiles
29 mktemp --directory --tmpdir=$WORKSPACE/.testfiles
33 test -e $WORKSPACE/.testfiles || mkdir $WORKSPACE/.testfiles
34 mktemp --tmpdir=$WORKSPACE/.testfiles
37 if [ -z $WORKSPACE ]; then
38 WORKSPACE=`dirname $(pwd)`
39 echo "Setting Workspace to $WORKSPACE"
42 # allow the location of the script to be overridden
43 if [ -z $fdroid ]; then
44 fdroid="$WORKSPACE/fdroid"
47 #------------------------------------------------------------------------------#
48 echo_header "setup a new repo from scratch using ANDROID_HOME"
50 REPOROOT=`create_test_dir`
53 copy_apks_into_repo $REPOROOT
54 $fdroid update --create-metadata
55 grep -F '<application id=' repo/index.xml
58 #------------------------------------------------------------------------------#
59 # check that --android-home fails when dir does not exist or is not a dir
61 REPOROOT=`create_test_dir`
62 KEYSTORE=$REPOROOT/keystore.jks
65 $fdroid init --keystore $KEYSTORE --android-home /opt/fakeandroidhome
67 echo "This should have failed because /opt/fakeandroidhome does not exist!"
70 echo "testing android-home path checker passed"
72 TESTFILE=`create_test_file`
73 $fdroid init --keystore $KEYSTORE --android-home $TESTFILE
75 echo "This should have failed because $TESTFILE is a file not a dir!"
78 echo "testing android-home not-dir checker passed"
83 #------------------------------------------------------------------------------#
84 echo_header "check that fake android home passes `fdroid init`"
86 REPOROOT=`create_test_dir`
87 FAKE_ANDROID_HOME=`create_test_dir`
88 create_fake_android_home $FAKE_ANDROID_HOME
89 KEYSTORE=$REPOROOT/keystore.jks
91 $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
94 #------------------------------------------------------------------------------#
95 echo_header "check that 'fdroid init' fails when build-tools cannot be found"
97 REPOROOT=`create_test_dir`
98 FAKE_ANDROID_HOME=`create_test_dir`
99 create_fake_android_home $FAKE_ANDROID_HOME
100 rm -f $FAKE_ANDROID_HOME/build-tools/*/aapt
101 KEYSTORE=$REPOROOT/keystore.jks
104 $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
105 [ $? -eq 0 ] && exit 1
109 #------------------------------------------------------------------------------#
110 echo_header "check that --android-home overrides ANDROID_HOME"
112 REPOROOT=`create_test_dir`
113 FAKE_ANDROID_HOME=`create_test_dir`
114 create_fake_android_home $FAKE_ANDROID_HOME
115 KEYSTORE=$REPOROOT/keystore.jks
117 $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
119 grep $FAKE_ANDROID_HOME $REPOROOT/config.py
120 if [ $? -ne 0 ]; then
121 echo "the value set in --android-home '$FAKE_ANDROID_HOME' should override ANDROID_HOME '$ANDROID_HOME'"
127 #------------------------------------------------------------------------------#
128 echo_header "setup a new repo from scratch with keystore and android-home set on cmd line"
130 REPOROOT=`create_test_dir`
131 KEYSTORE=$REPOROOT/keystore.jks
132 FAKE_ANDROID_HOME=`create_test_dir`
133 create_fake_android_home $FAKE_ANDROID_HOME
134 STORED_ANDROID_HOME=$ANDROID_HOME
136 echo "ANDROID_HOME: $ANDROID_HOME"
138 $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME --no-prompt
140 copy_apks_into_repo $REPOROOT
141 $fdroid update --create-metadata
142 grep -F '<application id=' repo/index.xml
143 test -e repo/index.xml
144 test -e repo/index.jar
145 export ANDROID_HOME=$STORED_ANDROID_HOME
148 #------------------------------------------------------------------------------#
149 echo_header "setup new repo from scratch using ANDROID_HOME, putting APKs in repo first"
151 REPOROOT=`create_test_dir`
154 copy_apks_into_repo $REPOROOT
156 $fdroid update --create-metadata
157 grep -F '<application id=' repo/index.xml
160 #------------------------------------------------------------------------------#
161 echo_header "setup a new repo from scratch and generate a keystore"
163 REPOROOT=`create_test_dir`
164 KEYSTORE=$REPOROOT/keystore.jks
166 $fdroid init --keystore $KEYSTORE
168 copy_apks_into_repo $REPOROOT
169 $fdroid update --create-metadata
170 test -e repo/index.xml
171 test -e repo/index.jar
172 grep -F '<application id=' repo/index.xml
175 #------------------------------------------------------------------------------#
176 echo_header "setup a new repo from scratch, generate a keystore, then add APK and update"
178 REPOROOT=`create_test_dir`
179 KEYSTORE=$REPOROOT/keystore.jks
181 $fdroid init --keystore $KEYSTORE
183 copy_apks_into_repo $REPOROOT
184 $fdroid update --create-metadata
185 test -e repo/index.xml
186 test -e repo/index.jar
187 grep -F '<application id=' repo/index.xml
188 cp $WORKSPACE/tests/urzip.apk $REPOROOT/
189 $fdroid update --create-metadata
190 test -e repo/index.xml
191 test -e repo/index.jar
192 grep -F '<application id=' repo/index.xml
195 #------------------------------------------------------------------------------#
196 echo_header "setup a new repo from scratch with a HSM/smartcard"
198 REPOROOT=`create_test_dir`
200 $fdroid init --keystore NONE
201 test -e opensc-fdroid.cfg