From 2f3022ff65fc47eba1b86320ef3ac35d397cf8e7 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 29 May 2014 13:10:28 -0400 Subject: [PATCH 1/3] fix PEP8 E128 continuation line under-indented for visual indent --- fdroidserver/checkupdates.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fdroidserver/checkupdates.py b/fdroidserver/checkupdates.py index 6b4831d4..c9405ad3 100644 --- a/fdroidserver/checkupdates.py +++ b/fdroidserver/checkupdates.py @@ -134,8 +134,8 @@ def check_tags(app, pattern): # Only process tags where the manifest exists... paths = common.manifest_paths(build_dir, flavour) - version, vercode, package = common.parse_androidmanifests(paths, - app['Update Check Ignore']) + version, vercode, package = \ + common.parse_androidmanifests(paths, app['Update Check Ignore']) if not package or package != appid or not version or not vercode: continue @@ -210,8 +210,8 @@ def check_repomanifest(app, branch=None): paths = common.manifest_paths(build_dir, flavour) - version, vercode, package = common.parse_androidmanifests(paths, - app['Update Check Ignore']) + version, vercode, package = \ + common.parse_androidmanifests(paths, app['Update Check Ignore']) if not package: return (None, "Couldn't find package ID") if package != appid: From af22962572363b16877dad86840ff616f2655109 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 29 May 2014 13:40:06 -0400 Subject: [PATCH 2/3] Fixes #8: if unknown APKs found, prompt to use -c or use --delete-unknown This adds the option --delete-unknown for the current default behavior of `fdroid update`: to delete any unknown APKs. Instead, it just outputs a warning about the unknown APKs and suggests -c for adding it. Fixes #8 https://gitlab.com/fdroid/fdroidserver/issues/8 --- completion/bash-completion | 2 +- fdroidserver/update.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/completion/bash-completion b/completion/bash-completion index 2b587ea7..ae47746e 100644 --- a/completion/bash-completion +++ b/completion/bash-completion @@ -129,7 +129,7 @@ __complete_install() { __complete_update() { opts="-h -c -v -q -b -i -I -e -w" lopts="--help --createmeta --verbose --quiet --buildreport --interactive - --icons --editor --wiki --pretty --clean" + --icons --editor --wiki --pretty --clean --delete-unknown" case "${prev}" in -e|--editor) _filedir diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 8f189052..f1506c81 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -884,6 +884,8 @@ def main(): parser = OptionParser() parser.add_option("-c", "--createmeta", action="store_true", default=False, help="Create skeleton metadata files that are missing") + parser.add_option("--delete-unknown", action="store_true", default=False, + help="Delete APKs without metadata from the repo") parser.add_option("-v", "--verbose", action="store_true", default=False, help="Spew out even more information than normal") parser.add_option("-q", "--quiet", action="store_true", default=False, @@ -1019,12 +1021,16 @@ def main(): f.close() logging.info("Generated skeleton metadata for " + apk['id']) else: - logging.warn(apk['apkname'] + " (" + apk['id'] + ") has no metadata - removing") - rmf = os.path.join(repodirs[0], apk['apkname']) - if not os.path.exists(rmf): - logging.error("Could not find {0} to remove it".format(rmf)) + msg = apk['apkname'] + " (" + apk['id'] + ") has no metadata!" + if options.delete_unknown: + logging.warn(msg + "\n\tdeleting: repo/" + apk['apkname']) + rmf = os.path.join(repodirs[0], apk['apkname']) + if not os.path.exists(rmf): + logging.error("Could not find {0} to remove it".format(rmf)) + else: + os.remove(rmf) else: - os.remove(rmf) + logging.warn(msg + "\n\tUse `fdroid update -c` to create it.") if len(repodirs) > 1: archive_old_apks(apps, apks, archapks, repodirs[0], repodirs[1], config['archive_older']) From 6839f9a9ed54be7e558bc353915340e1678d8ffb Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 29 May 2014 15:29:57 -0400 Subject: [PATCH 3/3] fixes #12: make `fdroid update -c` do complete update like `fdroid update` Since the new metadata created by -c is added after the existing metadata was already parsed, `fdroid update -c` was not doing a complete update of the repo. This moves the metadata creation as early as possible, then reruns the metadata parsing if new metadata was created. refs #12 https://gitlab.com/fdroid/fdroidserver/issues/12 --- fdroidserver/update.py | 72 +++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/fdroidserver/update.py b/fdroidserver/update.py index f1506c81..facd82da 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -947,6 +947,45 @@ def main(): if cc: cachechanged = True + # Generate warnings for apk's with no metadata (or create skeleton + # metadata files, if requested on the command line) + newmetadata = False + for apk in apks: + found = False + for app in apps: + if app['id'] == apk['id']: + found = True + break + if not found: + if options.createmeta: + f = open(os.path.join('metadata', apk['id'] + '.txt'), 'w') + f.write("License:Unknown\n") + f.write("Web Site:\n") + f.write("Source Code:\n") + f.write("Issue Tracker:\n") + f.write("Summary:" + apk['name'] + "\n") + f.write("Description:\n") + f.write(apk['name'] + "\n") + f.write(".\n") + f.close() + logging.info("Generated skeleton metadata for " + apk['id']) + newmetadata = True + else: + msg = apk['apkname'] + " (" + apk['id'] + ") has no metadata!" + if options.delete_unknown: + logging.warn(msg + "\n\tdeleting: repo/" + apk['apkname']) + rmf = os.path.join(repodirs[0], apk['apkname']) + if not os.path.exists(rmf): + logging.error("Could not find {0} to remove it".format(rmf)) + else: + os.remove(rmf) + else: + logging.warn(msg + "\n\tUse `fdroid update -c` to create it.") + + # update the metadata with the newly created ones included + if newmetadata: + apps = metadata.read_metadata() + # Scan the archive repo for apks as well if len(repodirs) > 1: archapks, cc = scan_apks(apps, apkcache, repodirs[1], knownapks) @@ -999,39 +1038,6 @@ def main(): # name comes from there!) apps = sorted(apps, key=lambda app: app['Name'].upper()) - # Generate warnings for apk's with no metadata (or create skeleton - # metadata files, if requested on the command line) - for apk in apks: - found = False - for app in apps: - if app['id'] == apk['id']: - found = True - break - if not found: - if options.createmeta: - f = open(os.path.join('metadata', apk['id'] + '.txt'), 'w') - f.write("License:Unknown\n") - f.write("Web Site:\n") - f.write("Source Code:\n") - f.write("Issue Tracker:\n") - f.write("Summary:" + apk['name'] + "\n") - f.write("Description:\n") - f.write(apk['name'] + "\n") - f.write(".\n") - f.close() - logging.info("Generated skeleton metadata for " + apk['id']) - else: - msg = apk['apkname'] + " (" + apk['id'] + ") has no metadata!" - if options.delete_unknown: - logging.warn(msg + "\n\tdeleting: repo/" + apk['apkname']) - rmf = os.path.join(repodirs[0], apk['apkname']) - if not os.path.exists(rmf): - logging.error("Could not find {0} to remove it".format(rmf)) - else: - os.remove(rmf) - else: - logging.warn(msg + "\n\tUse `fdroid update -c` to create it.") - if len(repodirs) > 1: archive_old_apks(apps, apks, archapks, repodirs[0], repodirs[1], config['archive_older'])