From 751fd3fb0a708f3eb38a19247c88a4b2cdf577c8 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 11 Feb 2016 23:49:54 +0100 Subject: [PATCH 1/4] common: do not crash if the java_paths are not what is expected Many commands work without the JDK installed, and it is also possible that someone is using only JDK 8 or 9. --- fdroidserver/common.py | 2 ++ tests/run-tests | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 120ef2aa..4772abc8 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -157,6 +157,8 @@ def fill_config_defaults(thisconfig): thisconfig['java_paths'][m.group(1)] = d for java_version in ('7', '8', '9'): + if not java_version in thisconfig['java_paths']: + continue java_home = thisconfig['java_paths'][java_version] jarsigner = os.path.join(java_home, 'bin', 'jarsigner') if os.path.exists(jarsigner): diff --git a/tests/run-tests b/tests/run-tests index c770091f..7629f431 100755 --- a/tests/run-tests +++ b/tests/run-tests @@ -156,6 +156,41 @@ fi set -e +#------------------------------------------------------------------------------# +echo_header "ensure commands that don't need the JDK work without a JDK configed" + +REPOROOT=`create_test_dir` +cd $REPOROOT +mkdir repo +mkdir metadata +echo "License:GPL" >> metadata/fake.txt +echo "Summary:Yup still fake" >> metadata/fake.txt +echo "Categories:Internet" >> metadata/fake.txt +echo "Description:" >> metadata/fake.txt +echo "this is fake" >> metadata/fake.txt +echo "." >> metadata/fake.txt + +# fake that no JDKs are available +echo 'java_paths = {}' > config.py + +LOCAL_COPY_DIR=`create_test_dir`/fdroid +mkdir -p $LOCAL_COPY_DIR/repo +echo "local_copy_dir = '$LOCAL_COPY_DIR'" >> config.py + +$fdroid checkupdates +$fdroid gpgsign +$fdroid lint +$fdroid readmeta +$fdroid rewritemeta fake +$fdroid server update +$fdroid scanner + +# run these to get their output, but the are not setup, so don't fail +$fdroid build || true +$fdroid import || true +$fdroid install || true + + #------------------------------------------------------------------------------# echo_header "create a source tarball and use that to build a repo" From 8489047bcfecd332bd10044269c8ab90a284da89 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 4 Aug 2015 16:09:44 +0200 Subject: [PATCH 2/4] build: check that metadata is present before creating tmp dirs Before, `fdroid build` would create some subdirs, then fail when it could not read the metadata via metadata.read_metadata(). This checks before whether there is any metadata available, and warns the user accordingly. --- fdroidserver/build.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fdroidserver/build.py b/fdroidserver/build.py index 021e1041..12cc61c1 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -1001,6 +1001,15 @@ def main(): global options, config options, parser = parse_commandline() + + metadata_files = glob.glob('.fdroid.*[a-z]') # ignore files ending in ~ + if len(metadata_files) > 1: + raise FDroidException("Only one local metadata file allowed! Found: " + + " ".join(metadata_files)) + + if not os.path.isdir('metadata') and len(metadata_files) == 0: + raise FDroidException("No app metadata found, nothing to process!") + if not options.appid and not options.all: parser.error("option %s: If you really want to build all the apps, use --all" % "all") From dfca237329439b8bb62e2142a60113d563f89e4a Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 12 Feb 2016 00:27:17 +0100 Subject: [PATCH 3/4] fix errors in pre-commit hook when run in test suite --- hooks/pre-commit | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hooks/pre-commit b/hooks/pre-commit index d33c7018..6dd0049d 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -83,13 +83,13 @@ else err "pep8 is not installed!" fi -if [ ! -z $PY_FILES $PY_TEST_FILES ]; then +if [ "$PY_FILES $PY_TEST_FILES" != " " ]; then if ! $PYFLAKES $PY_FILES $PY_TEST_FILES; then err "pyflakes tests failed!" fi fi -if [ ! -z $PY_FILES ]; then +if [ "$PY_FILES" != "" ]; then if ! $PEP8 --ignore=$PEP8_IGNORE $PY_FILES; then err "pep8 tests failed!" fi @@ -98,7 +98,7 @@ fi # The tests use a little hack in order to cleanly import the fdroidserver # package locally like a regular package. pep8 doesn't see that, so this # makes pep8 skip E402 on the test files that need that hack. -if [ ! -z $PY_TEST_FILES ]; then +if [ "$PY_TEST_FILES" != "" ]; then if ! $PEP8 --ignore=$PEP8_IGNORE,E402 $PY_TEST_FILES; then err "pep8 tests failed!" fi From 5780c14df281f12089214358c7e52acc51d2b248 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 12 Feb 2016 00:39:54 +0100 Subject: [PATCH 4/4] fix PEP9 E713 test for membership should be 'not in' --- fdroidserver/common.py | 2 +- fdroidserver/signindex.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 4772abc8..0463db29 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -157,7 +157,7 @@ def fill_config_defaults(thisconfig): thisconfig['java_paths'][m.group(1)] = d for java_version in ('7', '8', '9'): - if not java_version in thisconfig['java_paths']: + if java_version not in thisconfig['java_paths']: continue java_home = thisconfig['java_paths'][java_version] jarsigner = os.path.join(java_home, 'bin', 'jarsigner') diff --git a/fdroidserver/signindex.py b/fdroidserver/signindex.py index 82f2216a..1d0c3200 100644 --- a/fdroidserver/signindex.py +++ b/fdroidserver/signindex.py @@ -40,7 +40,7 @@ def main(): config = common.read_config(options) - if not 'jarsigner' in config: + if 'jarsigner' not in config: logging.critical('Java jarsigner not found! Install in standard location or set java_paths!') sys.exit(1)