From afb98f9327dd85ba518df041aeba3459f029999c Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 30 Jun 2014 11:27:21 -0400 Subject: [PATCH 1/8] fix PEP8 fdroidserver/common.py:65:13: E126 continuation line over-indented for hanging indent --- fdroidserver/common.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 14e1f06d..c5f2aa1f 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -61,11 +61,11 @@ def get_default_config(): 'repo_url': "https://MyFirstFDroidRepo.org/fdroid/repo", 'repo_name': "My First FDroid Repo Demo", 'repo_icon': "fdroid-icon.png", - 'repo_description': + 'repo_description': ( "This is a repository of apps to be used with FDroid. Applications in this " - "repository are either official binaries built by the original application " - "developers, or are binaries built from source by the admin of f-droid.org " - "using the tools on https://gitlab.com/u/fdroid.", + + "repository are either official binaries built by the original application " + + "developers, or are binaries built from source by the admin of f-droid.org " + + "using the tools on https://gitlab.com/u/fdroid."), 'archive_older': 0, } From 40d4e300100998af04dab01b8f3d232a52076297 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 30 Jun 2014 11:28:38 -0400 Subject: [PATCH 2/8] tests: create_fake_android_home should create old build-tools version This is testing the build-tools version auto-detect in `fdroid init`, so it should be kept as an older version. This is not meant to test the current version of the build tools. --- tests/run-tests | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/run-tests b/tests/run-tests index 11aa2deb..ec9e2edc 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -23,10 +23,12 @@ copy_apks_into_repo() { set -x } +# keep this as an old version to test the automatic parsing of build-tools +# verion numbers in `fdroid init` create_fake_android_home() { mkdir $1/build-tools - mkdir $1/build-tools/20.0.0 - touch $1/build-tools/20.0.0/aapt + mkdir $1/build-tools/19.0.2 + touch $1/build-tools/19.0.2/aapt } create_test_dir() { From 7a3992aa1a231be2f48d2b8bbb4758c22a892dd1 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 30 Jun 2014 11:31:38 -0400 Subject: [PATCH 3/8] use 'python2' everywhere since fdroidserver has not been tested with 3.x --- README | 2 +- jenkins-build | 8 ++++---- tests/run-tests | 7 ++++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README b/README index 218deff8..6efc5cd8 100644 --- a/README +++ b/README @@ -27,4 +27,4 @@ install: virtualenv env/ . env/bin/activate pip install -e . - python setup.py install + python2 setup.py install diff --git a/jenkins-build b/jenkins-build index 35add775..4069d820 100755 --- a/jenkins-build +++ b/jenkins-build @@ -53,17 +53,17 @@ cd $WORKSPACE/tests #------------------------------------------------------------------------------# # test building the source tarball cd $WORKSPACE -python setup.py sdist +python2 setup.py sdist #------------------------------------------------------------------------------# # test install using site packages cd $WORKSPACE rm -rf $WORKSPACE/env -virtualenv --system-site-packages $WORKSPACE/env +virtualenv --python=python2 --system-site-packages $WORKSPACE/env . $WORKSPACE/env/bin/activate pip install -e $WORKSPACE -python setup.py install +python2 setup.py install # run tests in new pip+virtualenv install . $WORKSPACE/env/bin/activate @@ -81,7 +81,7 @@ sh hooks/pre-commit cd $WORKSPACE set +e # use the virtualenv python so pylint checks against its installed libs - PYTHONPATH=$WORKSPACE/.pylint-plugins python /usr/bin/pylint \ + PYTHONPATH=$WORKSPACE/.pylint-plugins python2 /usr/bin/pylint \ --output-format=parseable --reports=n \ --load-plugins astng_hashlib \ fdroidserver/*.py fdroid makebuildserver setup.py > $WORKSPACE/pylint.parseable diff --git a/tests/run-tests b/tests/run-tests index ec9e2edc..214233c2 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -77,12 +77,17 @@ if [ -z $aapt ]; then aapt=`ls -1 $ANDROID_HOME/build-tools/*/aapt | sort | tail -1` fi +# allow the location of python to be overridden +if [ -z $python ]; then + python=python2 +fi + #------------------------------------------------------------------------------# echo_header "create a source tarball and use that to build a repo" cd $WORKSPACE -python setup.py sdist +$python setup.py sdist REPOROOT=`create_test_dir` cd $REPOROOT From 3dbe503071ca34d514c40657ea2e2f678e61b232 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 30 Jun 2014 12:19:47 -0400 Subject: [PATCH 4/8] check repo icons exist now before running through all of `fdroid update` Before, if repo_icon or archive_icon pointed to a non-existent file, then `fdroid update` would run through the whole process of building a repo, then fail at the very end because of the non-existent file. On the next run, `fdroid update` then starts from the beginning. This just checks for those files at the beginning, and exits with an error if they are not found. --- fdroidserver/update.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 92ec3fab..952165b5 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -933,6 +933,13 @@ def main(): resize_all_icons(repodirs) sys.exit(0) + # check that icons exist now, rather than fail at the end of `fdroid update` + for k in ['repo_icon', 'archive_icon']: + if k in config: + if not os.path.exists(config[k]): + logging.error(k + ' "' + config[k] + '" does not exist! Correct it in config.py.') + sys.exit(1) + # Get all apps... apps = metadata.read_metadata() From 9dd138b25384e6b49b970b821f25fc119bdfd94b Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 30 Jun 2014 16:09:57 -0400 Subject: [PATCH 5/8] fix bad syncing from local copy, force trailing slash to make rsync happy It seems that paths for rsync must have a trailing slash in order to sync rather than make a subdir, i.e. this makes a duplicate subdir: rsync /tmp/fdroid/repo repo While this syncs the dirs rsync /tmp/fdroid/repo/ repo/ --- fdroidserver/server.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fdroidserver/server.py b/fdroidserver/server.py index 9b46de70..4e902304 100644 --- a/fdroidserver/server.py +++ b/fdroidserver/server.py @@ -157,9 +157,9 @@ def _local_sync(fromdir, todir): def sync_from_localcopy(repo_section, local_copy_dir): logging.info('Syncing from local_copy_dir to this repo.') # trailing slashes have a meaning in rsync which is not needed here, so - # remove them all - _local_sync(os.path.join(local_copy_dir, repo_section).rstrip('/'), - repo_section.rstrip('/')) + # make sure both paths have exactly one trailing slash + _local_sync(os.path.join(local_copy_dir, repo_section).rstrip('/') + '/', + repo_section.rstrip('/') + '/') def update_localcopy(repo_section, local_copy_dir): From 4d913d646a7d5d0511c23fb1dfd5560263452558 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 30 Jun 2014 21:37:46 -0400 Subject: [PATCH 6/8] replace redundant build_tools check that breaks `fdroid init` This reverts b637568a624cc75f4e67a0df59a017872e2129c6 since it added a redundant check that broke `fdroid init` when the default version dir of build_tools does not exist on the local system. It then uses the function that was already in place for checking the build_tools setup in a way that does not break `fdroid init`. Now that the fake android home version is not matching the default version, the tests will catch this bug in the future. --- fdroidserver/common.py | 6 +++--- tests/run-tests | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index c5f2aa1f..54c9736a 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -121,6 +121,9 @@ def read_config(opts, config_file='config.py'): if not test_sdk_exists(config): sys.exit(3) + if not test_build_tools_exists(config): + sys.exit(3) + for k in ["keystorepass", "keypass"]: if k in config: write_password_file(k) @@ -151,9 +154,6 @@ def test_sdk_exists(c): if not os.path.isdir(os.path.join(c['sdk_path'], 'build-tools')): logging.critical('Android SDK path "' + c['sdk_path'] + '" does not contain "build-tools/"!') return False - if not os.path.isdir(os.path.join(c['sdk_path'], 'build-tools', c['build_tools'])): - logging.critical('Configured build-tools version "' + c['build_tools'] + '" not found in the SDK!') - return False return True diff --git a/tests/run-tests b/tests/run-tests index 214233c2..f1f23c90 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -179,7 +179,7 @@ set -e #------------------------------------------------------------------------------# -echo_header "check that fake android home passes `fdroid init`" +echo_header "check that fake android home passes 'fdroid init'" REPOROOT=`create_test_dir` FAKE_ANDROID_HOME=`create_test_dir` From a58a9bff18265a07169db7b3ad09c4ecda7938ad Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 30 Jun 2014 21:40:31 -0400 Subject: [PATCH 7/8] run pre-commit hook as part of test suite --- tests/run-tests | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/run-tests b/tests/run-tests index f1f23c90..44ede13d 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -83,6 +83,13 @@ if [ -z $python ]; then fi +#------------------------------------------------------------------------------# +echo_header "run commit hooks" + +cd $WORKSPACE +./hooks/pre-commit + + #------------------------------------------------------------------------------# echo_header "create a source tarball and use that to build a repo" From d0c767ce5ebb0761ffbc4c137d058921881900ef Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 30 Jun 2014 21:47:47 -0400 Subject: [PATCH 8/8] only move GPG signature if APK exists The .asc moving code just needed to be indented so it only runs when 'srcname' exists in apk[], otherwise it just throws a KeyError --- fdroidserver/update.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 952165b5..18966b46 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -876,11 +876,11 @@ def archive_old_apks(apps, apks, archapks, repodir, archivedir, defaultkeepversi if 'srcname' in apk: shutil.move(os.path.join(repodir, apk['srcname']), os.path.join(archivedir, apk['srcname'])) - # Move GPG signature too... - sigfile = apk['srcname'] + '.asc' - sigsrc = os.path.join(repodir, sigfile) - if os.path.exists(sigsrc): - shutil.move(sigsrc, os.path.join(archivedir, sigfile)) + # Move GPG signature too... + sigfile = apk['srcname'] + '.asc' + sigsrc = os.path.join(repodir, sigfile) + if os.path.exists(sigsrc): + shutil.move(sigsrc, os.path.join(archivedir, sigfile)) archapks.append(apk) apks.remove(apk)