6 copy_apks_into_repo() {
7 for f in `ls -1 ../../*/bin/*.apk`; do
8 name=$(basename $(dirname `dirname $f`))
10 apk=`aapt d badging "$f" | sed -n "s,^package: name='\(.*\)' versionCode='\([0-9][0-9]*\)' .*,\1_\2.apk,p"`
16 create_fake_android_home() {
18 mkdir $1/build-tools/19.0.1
19 touch $1/build-tools/19.0.1/aapt
23 test -e $WORKSPACE/.testfiles || mkdir $WORKSPACE/.testfiles
24 mktemp --directory --tmpdir=$WORKSPACE/.testfiles
28 test -e $WORKSPACE/.testfiles || mkdir $WORKSPACE/.testfiles
29 mktemp --tmpdir=$WORKSPACE/.testfiles
32 if [ -z $WORKSPACE ]; then
33 WORKSPACE=`dirname $(pwd)`
34 echo "Setting Workspace to $WORKSPACE"
37 # allow the location of the script to be overridden
38 if [ -z $fdroid ]; then
39 fdroid="$WORKSPACE/fdroid"
42 #------------------------------------------------------------------------------#
43 echo "setup a new repo from scratch using ANDROID_HOME"
45 REPOROOT=`create_test_dir`
48 copy_apks_into_repo $REPOROOT
53 #------------------------------------------------------------------------------#
54 # check that --android-home fails when dir does not exist or is not a dir
56 REPOROOT=`create_test_dir`
57 KEYSTORE=$REPOROOT/keystore.jks
60 $fdroid init --keystore $KEYSTORE --android-home /opt/fakeandroidhome
62 echo "This should have failed because /opt/fakeandroidhome does not exist!"
65 echo "testing android-home path checker passed"
67 TESTFILE=`create_test_file`
68 $fdroid init --keystore $KEYSTORE --android-home $TESTFILE
70 echo "This should have failed because $TESTFILE is a file not a dir!"
73 echo "testing android-home not-dir checker passed"
78 #------------------------------------------------------------------------------#
79 echo "check that --android-home overrides ANDROID_HOME"
81 REPOROOT=`create_test_dir`
82 FAKE_ANDROID_HOME=`create_test_dir`
83 create_fake_android_home $FAKE_ANDROID_HOME
84 KEYSTORE=$REPOROOT/keystore.jks
86 $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
88 grep $FAKE_ANDROID_HOME $REPOROOT/config.py
90 echo "the value set in --android-home '$FAKE_ANDROID_HOME' should override ANDROID_HOME '$ANDROID_HOME'"
96 #------------------------------------------------------------------------------#
97 echo "setup a new repo from scratch with keystore and android-home set on cmd line"
99 REPOROOT=`create_test_dir`
100 KEYSTORE=$REPOROOT/keystore.jks
101 FAKE_ANDROID_HOME=`create_test_dir`
102 create_fake_android_home $FAKE_ANDROID_HOME
103 STORED_ANDROID_HOME=$ANDROID_HOME
105 echo "ANDROID_HOME: $ANDROID_HOME"
107 $fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME --no-prompt
109 copy_apks_into_repo $REPOROOT
112 test -e repo/index.xml
113 test -e repo/index.jar
114 export ANDROID_HOME=$STORED_ANDROID_HOME
117 #------------------------------------------------------------------------------#
118 echo "setup new repo from scratch using ANDROID_HOME, putting APKs in repo first"
120 REPOROOT=`create_test_dir`
123 copy_apks_into_repo $REPOROOT
129 #------------------------------------------------------------------------------#
130 echo "setup a new repo from scratch and generate a keystore"
132 REPOROOT=`create_test_dir`
133 KEYSTORE=$REPOROOT/keystore.jks
135 $fdroid init --keystore $KEYSTORE
137 copy_apks_into_repo $REPOROOT
140 test -e repo/index.xml
141 test -e repo/index.jar
144 #------------------------------------------------------------------------------#
145 echo "setup a new repo from scratch with a HSM/smartcard"
147 REPOROOT=`create_test_dir`
149 $fdroid init --keystore NONE
150 test -e opensc-fdroid.cfg