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/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: diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 8f189052..facd82da 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, @@ -945,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) @@ -997,35 +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: - 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)) - else: - os.remove(rmf) - if len(repodirs) > 1: archive_old_apks(apps, apks, archapks, repodirs[0], repodirs[1], config['archive_older'])