mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-04 22:40:29 +03:00
add more SDK checks: build-tools/19.0.3 and presense of aapt
Make sure that fdroid can find aapt in the current config, otherwise exit with an error. Some users don't have build_tools set, and their SDK does not include the build-tools in the default versioned dir, so this should warn them of what is wrong.
This commit is contained in:
parent
3690b89e0a
commit
6ca060e10d
3 changed files with 66 additions and 15 deletions
|
|
@ -144,6 +144,23 @@ def test_sdk_exists(c):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def test_build_tools_exists(c):
|
||||||
|
if not test_sdk_exists(c):
|
||||||
|
return False
|
||||||
|
build_tools = os.path.join(c['sdk_path'], 'build-tools')
|
||||||
|
versioned_build_tools = os.path.join(build_tools, c['build_tools'])
|
||||||
|
if not os.path.isdir(versioned_build_tools):
|
||||||
|
logging.critical('Android Build Tools path "'
|
||||||
|
+ versioned_build_tools + '" does not exist!')
|
||||||
|
return False
|
||||||
|
if not os.path.exists(os.path.join(c['sdk_path'], 'build-tools', c['build_tools'], 'aapt')):
|
||||||
|
logging.critical('Android Build Tools "'
|
||||||
|
+ versioned_build_tools
|
||||||
|
+ '" does not contain "aapt"!')
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def write_password_file(pwtype, password=None):
|
def write_password_file(pwtype, password=None):
|
||||||
'''
|
'''
|
||||||
writes out passwords to a protected file instead of passing passwords as
|
writes out passwords to a protected file instead of passing passwords as
|
||||||
|
|
|
||||||
|
|
@ -155,18 +155,15 @@ def main():
|
||||||
logging.info('Try running `fdroid init` in an empty directory.')
|
logging.info('Try running `fdroid init` in an empty directory.')
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
# now that we have a local config.py, read configuration...
|
|
||||||
config = common.read_config(options)
|
|
||||||
|
|
||||||
# try to find a working aapt, in all the recent possible paths
|
# try to find a working aapt, in all the recent possible paths
|
||||||
build_tools = os.path.join(config['sdk_path'], 'build-tools')
|
build_tools = os.path.join(test_config['sdk_path'], 'build-tools')
|
||||||
aaptdirs = []
|
aaptdirs = []
|
||||||
aaptdirs.append(os.path.join(build_tools, config['build_tools']))
|
aaptdirs.append(os.path.join(build_tools, test_config['build_tools']))
|
||||||
aaptdirs.append(build_tools)
|
aaptdirs.append(build_tools)
|
||||||
for f in sorted(os.listdir(build_tools), reverse=True):
|
for f in os.listdir(build_tools):
|
||||||
if os.path.isdir(os.path.join(build_tools, f)):
|
if os.path.isdir(os.path.join(build_tools, f)):
|
||||||
aaptdirs.append(os.path.join(build_tools, f))
|
aaptdirs.append(os.path.join(build_tools, f))
|
||||||
for d in aaptdirs:
|
for d in sorted(aaptdirs, reverse=True):
|
||||||
if os.path.isfile(os.path.join(d, 'aapt')):
|
if os.path.isfile(os.path.join(d, 'aapt')):
|
||||||
aapt = os.path.join(d, 'aapt')
|
aapt = os.path.join(d, 'aapt')
|
||||||
break
|
break
|
||||||
|
|
@ -174,9 +171,15 @@ def main():
|
||||||
dirname = os.path.basename(os.path.dirname(aapt))
|
dirname = os.path.basename(os.path.dirname(aapt))
|
||||||
if dirname == 'build-tools':
|
if dirname == 'build-tools':
|
||||||
# this is the old layout, before versioned build-tools
|
# this is the old layout, before versioned build-tools
|
||||||
write_to_config('build_tools', '')
|
test_config['build_tools'] = ''
|
||||||
else:
|
else:
|
||||||
write_to_config('build_tools', dirname)
|
test_config['build_tools'] = dirname
|
||||||
|
write_to_config('build_tools', test_config['build_tools'])
|
||||||
|
if not common.test_build_tools_exists(test_config):
|
||||||
|
sys.exit(3)
|
||||||
|
|
||||||
|
# now that we have a local config.py, read configuration...
|
||||||
|
config = common.read_config(options)
|
||||||
|
|
||||||
# track down where the Android NDK is
|
# track down where the Android NDK is
|
||||||
ndk_path = '/opt/android-ndk'
|
ndk_path = '/opt/android-ndk'
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,11 @@
|
||||||
set -e
|
set -e
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
|
echo_header() {
|
||||||
|
echo "=============================================================================="
|
||||||
|
echo $1
|
||||||
|
}
|
||||||
|
|
||||||
copy_apks_into_repo() {
|
copy_apks_into_repo() {
|
||||||
for f in `ls -1 ../../*/bin/*.apk`; do
|
for f in `ls -1 ../../*/bin/*.apk`; do
|
||||||
name=$(basename $(dirname `dirname $f`))
|
name=$(basename $(dirname `dirname $f`))
|
||||||
|
|
@ -40,7 +45,7 @@ if [ -z $fdroid ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#------------------------------------------------------------------------------#
|
#------------------------------------------------------------------------------#
|
||||||
echo "setup a new repo from scratch using ANDROID_HOME"
|
echo_header "setup a new repo from scratch using ANDROID_HOME"
|
||||||
|
|
||||||
REPOROOT=`create_test_dir`
|
REPOROOT=`create_test_dir`
|
||||||
cd $REPOROOT
|
cd $REPOROOT
|
||||||
|
|
@ -76,7 +81,33 @@ set -e
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------#
|
#------------------------------------------------------------------------------#
|
||||||
echo "check that --android-home overrides ANDROID_HOME"
|
echo_header "check that fake android home passes `fdroid init`"
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------#
|
||||||
|
echo_header "check that 'fdroid init' fails when build-tools cannot be found"
|
||||||
|
|
||||||
|
REPOROOT=`create_test_dir`
|
||||||
|
FAKE_ANDROID_HOME=`create_test_dir`
|
||||||
|
create_fake_android_home $FAKE_ANDROID_HOME
|
||||||
|
rm -f $FAKE_ANDROID_HOME/build-tools/*/aapt
|
||||||
|
KEYSTORE=$REPOROOT/keystore.jks
|
||||||
|
cd $REPOROOT
|
||||||
|
set +e
|
||||||
|
$fdroid init --keystore $KEYSTORE --android-home $FAKE_ANDROID_HOME
|
||||||
|
[ $? -eq 0 ] && exit 1
|
||||||
|
set -e
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------#
|
||||||
|
echo_header "check that --android-home overrides ANDROID_HOME"
|
||||||
|
|
||||||
REPOROOT=`create_test_dir`
|
REPOROOT=`create_test_dir`
|
||||||
FAKE_ANDROID_HOME=`create_test_dir`
|
FAKE_ANDROID_HOME=`create_test_dir`
|
||||||
|
|
@ -94,7 +125,7 @@ set -e
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------#
|
#------------------------------------------------------------------------------#
|
||||||
echo "setup a new repo from scratch with keystore and android-home set on cmd line"
|
echo_header "setup a new repo from scratch with keystore and android-home set on cmd line"
|
||||||
|
|
||||||
REPOROOT=`create_test_dir`
|
REPOROOT=`create_test_dir`
|
||||||
KEYSTORE=$REPOROOT/keystore.jks
|
KEYSTORE=$REPOROOT/keystore.jks
|
||||||
|
|
@ -115,7 +146,7 @@ export ANDROID_HOME=$STORED_ANDROID_HOME
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------#
|
#------------------------------------------------------------------------------#
|
||||||
echo "setup new repo from scratch using ANDROID_HOME, putting APKs in repo first"
|
echo_header "setup new repo from scratch using ANDROID_HOME, putting APKs in repo first"
|
||||||
|
|
||||||
REPOROOT=`create_test_dir`
|
REPOROOT=`create_test_dir`
|
||||||
cd $REPOROOT
|
cd $REPOROOT
|
||||||
|
|
@ -127,7 +158,7 @@ $fdroid update
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------#
|
#------------------------------------------------------------------------------#
|
||||||
echo "setup a new repo from scratch and generate a keystore"
|
echo_header "setup a new repo from scratch and generate a keystore"
|
||||||
|
|
||||||
REPOROOT=`create_test_dir`
|
REPOROOT=`create_test_dir`
|
||||||
KEYSTORE=$REPOROOT/keystore.jks
|
KEYSTORE=$REPOROOT/keystore.jks
|
||||||
|
|
@ -142,7 +173,7 @@ test -e repo/index.jar
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------#
|
#------------------------------------------------------------------------------#
|
||||||
echo "setup a new repo from scratch with a HSM/smartcard"
|
echo_header "setup a new repo from scratch with a HSM/smartcard"
|
||||||
|
|
||||||
REPOROOT=`create_test_dir`
|
REPOROOT=`create_test_dir`
|
||||||
cd $REPOROOT
|
cd $REPOROOT
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue