1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-10-05 18:50:09 +02:00

verify: --reuse-remote-apk to reuse local APKs

For something like a verification server, this avoids having `fdroid verify`
redownload the remote APK from f-droid.org every time its run.  For normal
users, it should download a fresh copy each time to avoid false errors
based on confusion over anything that might have changed the local copy of
the remote APK.

This patch has been used on verification.f-droid.org for a while now. It is
the last thing keeping verification.f-droid.org from using fdroidserver
straight from stretch-backports.
This commit is contained in:
Hans-Christoph Steiner 2018-05-25 11:29:44 +02:00
parent b0a5ec5c1a
commit a3a0b8dcf0

View File

@ -40,6 +40,8 @@ def main():
parser = ArgumentParser(usage="%(prog)s [options] [APPID[:VERCODE] [APPID[:VERCODE] ...]]")
common.setup_global_opts(parser)
parser.add_argument("appid", nargs='*', help=_("applicationId with optional versionCode in the form APPID[:VERCODE]"))
parser.add_argument("--reuse-remote-apk", action="store_true", default=False,
help=_("Verify against locally cached copy rather than redownloading."))
options = parser.parse_args()
config = common.read_config(options)
@ -74,18 +76,19 @@ def main():
logging.info("Processing {apkfilename}".format(apkfilename=apkfilename))
remoteapk = os.path.join(tmp_dir, apkfilename)
if os.path.exists(remoteapk):
os.remove(remoteapk)
url = 'https://f-droid.org/repo/' + apkfilename
logging.info("...retrieving " + url)
try:
net.download_file(url, dldir=tmp_dir)
except requests.exceptions.HTTPError as e:
if not options.reuse_remote_apk or not os.path.exists(remoteapk):
if os.path.exists(remoteapk):
os.remove(remoteapk)
url = 'https://f-droid.org/repo/' + apkfilename
logging.info("...retrieving " + url)
try:
net.download_file(url.replace('/repo', '/archive'), dldir=tmp_dir)
net.download_file(url, dldir=tmp_dir)
except requests.exceptions.HTTPError as e:
raise FDroidException(_('Downloading {url} failed. {error}')
.format(url=url, error=e))
try:
net.download_file(url.replace('/repo', '/archive'), dldir=tmp_dir)
except requests.exceptions.HTTPError as e:
raise FDroidException(_('Downloading {url} failed. {error}')
.format(url=url, error=e))
compare_result = common.verify_apks(
remoteapk,