2014-04-10 18:31:14 +02:00
|
|
|
#!/bin/bash
|
2014-04-01 22:16:24 +02:00
|
|
|
|
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
|
2014-04-04 04:17:52 +02:00
|
|
|
copy_apks_into_repo() {
|
|
|
|
for f in `ls -1 ../../*/bin/*.apk`; do
|
|
|
|
name=$(basename $(dirname `dirname $f`))
|
|
|
|
echo "name $name"
|
2014-04-10 18:37:07 +02:00
|
|
|
apk=`aapt d badging "$f" | sed -n "s,^package: name='\(.*\)' versionCode='\([0-9][0-9]*\)' .*,\1_\2.apk,p"`
|
2014-04-04 04:17:52 +02:00
|
|
|
echo "apk $apk"
|
2014-04-10 18:37:07 +02:00
|
|
|
cp -f $f $1/repo/$apk
|
2014-04-04 04:17:52 +02:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2014-04-24 01:21:22 +02:00
|
|
|
create_fake_android_home() {
|
|
|
|
mkdir $1/build-tools
|
|
|
|
mkdir $1/build-tools/19.0.1
|
|
|
|
touch $1/build-tools/19.0.1/aapt
|
|
|
|
}
|
|
|
|
|
|
|
|
create_test_dir() {
|
|
|
|
test -e $WORKSPACE/.testfiles || mkdir $WORKSPACE/.testfiles
|
|
|
|
mktemp --directory --tmpdir=$WORKSPACE/.testfiles
|
|
|
|
}
|
|
|
|
|
|
|
|
create_test_file() {
|
|
|
|
test -e $WORKSPACE/.testfiles || mkdir $WORKSPACE/.testfiles
|
|
|
|
mktemp --tmpdir=$WORKSPACE/.testfiles
|
|
|
|
}
|
|
|
|
|
2014-04-01 22:16:24 +02:00
|
|
|
if [ -z $WORKSPACE ]; then
|
|
|
|
WORKSPACE=`dirname $(pwd)`
|
|
|
|
echo "Setting Workspace to $WORKSPACE"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# allow the location of the script to be overridden
|
|
|
|
if [ -z $fdroid ]; then
|
|
|
|
fdroid="$WORKSPACE/fdroid"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
2014-04-24 01:21:22 +02:00
|
|
|
echo "setup a new repo from scratch using ANDROID_HOME"
|
2014-04-01 22:16:24 +02:00
|
|
|
|
2014-04-24 01:21:22 +02:00
|
|
|
REPOROOT=`create_test_dir`
|
2014-04-01 22:16:24 +02:00
|
|
|
cd $REPOROOT
|
|
|
|
$fdroid init
|
2014-04-04 04:17:52 +02:00
|
|
|
copy_apks_into_repo $REPOROOT
|
|
|
|
$fdroid update -c
|
|
|
|
$fdroid update
|
2014-04-01 22:16:24 +02:00
|
|
|
|
|
|
|
|
2014-04-04 04:17:52 +02:00
|
|
|
#------------------------------------------------------------------------------#
|
2014-04-24 01:21:22 +02:00
|
|
|
# check that --android-home fails when dir does not exist or is not a dir
|
|
|
|
|
|
|
|
REPOROOT=`create_test_dir`
|
|
|
|
KEYSTORE=$REPOROOT/keystore.jks
|
|
|
|
cd $REPOROOT
|
|
|
|
set +e
|
|
|
|
$fdroid init --keystore $KEYSTORE --android-home /opt/fakeandroidhome
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "This should have failed because /opt/fakeandroidhome does not exist!"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "testing android-home path checker passed"
|
|
|
|
fi
|
|
|
|
TESTFILE=`create_test_file`
|
|
|
|
$fdroid init --keystore $KEYSTORE --android-home $TESTFILE
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "This should have failed because $TESTFILE is a file not a dir!"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "testing android-home not-dir checker passed"
|
|
|
|
fi
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
echo "check that --android-home overrides ANDROID_HOME"
|
|
|
|
|
|
|
|
REPOROOT=`create_test_dir`
|
|
|
|
FAKE_ANDROID_HOME=`create_test_dir`
|
|
|
|
create_fake_android_home $FAKE_ANDROID_HOME
|
|
|
|
KEYSTORE=$REPOROOT/keystore.jks
|
|
|
|
cd $REPOROOT
|
|
|
|
$fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
|
|
|
|
set +e
|
|
|
|
grep $FAKE_ANDROID_HOME $REPOROOT/config.py
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "the value set in --android-home '$FAKE_ANDROID_HOME' should override ANDROID_HOME '$ANDROID_HOME'"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
echo "setup a new repo from scratch with keystore and android-home set on cmd line"
|
|
|
|
|
|
|
|
REPOROOT=`create_test_dir`
|
|
|
|
KEYSTORE=$REPOROOT/keystore.jks
|
|
|
|
FAKE_ANDROID_HOME=`create_test_dir`
|
|
|
|
create_fake_android_home $FAKE_ANDROID_HOME
|
|
|
|
STORED_ANDROID_HOME=$ANDROID_HOME
|
|
|
|
unset ANDROID_HOME
|
|
|
|
echo "ANDROID_HOME: $ANDROID_HOME"
|
|
|
|
cd $REPOROOT
|
|
|
|
$fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
|
|
|
|
test -e $KEYSTORE
|
|
|
|
copy_apks_into_repo $REPOROOT
|
|
|
|
$fdroid update -c
|
|
|
|
$fdroid update
|
|
|
|
test -e repo/index.xml
|
|
|
|
test -e repo/index.jar
|
|
|
|
export ANDROID_HOME=$STORED_ANDROID_HOME
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
echo "setup new repo from scratch using ANDROID_HOME, putting APKs in repo first"
|
2014-04-04 04:17:52 +02:00
|
|
|
|
2014-04-24 01:21:22 +02:00
|
|
|
REPOROOT=`create_test_dir`
|
|
|
|
cd $REPOROOT
|
|
|
|
mkdir repo
|
|
|
|
copy_apks_into_repo $REPOROOT
|
|
|
|
$fdroid init
|
|
|
|
$fdroid update -c
|
|
|
|
$fdroid update
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
echo "setup a new repo from scratch and generate a keystore"
|
|
|
|
|
|
|
|
REPOROOT=`create_test_dir`
|
2014-04-04 04:17:52 +02:00
|
|
|
KEYSTORE=$REPOROOT/keystore.jks
|
|
|
|
cd $REPOROOT
|
|
|
|
$fdroid init --keystore $KEYSTORE
|
|
|
|
test -e $KEYSTORE
|
|
|
|
copy_apks_into_repo $REPOROOT
|
2014-04-01 22:16:24 +02:00
|
|
|
$fdroid update -c
|
|
|
|
$fdroid update
|
2014-04-04 04:17:52 +02:00
|
|
|
test -e repo/index.xml
|
|
|
|
test -e repo/index.jar
|
2014-04-04 06:05:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
2014-04-24 01:21:22 +02:00
|
|
|
echo "setup a new repo from scratch with a HSM/smartcard"
|
2014-04-04 06:05:22 +02:00
|
|
|
|
2014-04-24 01:21:22 +02:00
|
|
|
REPOROOT=`create_test_dir`
|
2014-04-04 06:05:22 +02:00
|
|
|
cd $REPOROOT
|
|
|
|
$fdroid init --keystore NONE
|
|
|
|
test -e opensc-fdroid.cfg
|
|
|
|
test ! -e NONE
|
2014-04-24 01:21:22 +02:00
|
|
|
|
|
|
|
|
|
|
|
echo SUCCESS
|