From 8ecff5bd616f6c492a9b8779846cedc4b9c5b4c4 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 31 Oct 2016 16:51:34 +0100 Subject: [PATCH] get_release_filename() to handle any file type, not just APKs In order to support non-APK files that are built by `fdroid build`, this function that names the file releases needs to be generic. --- fdroidserver/build.py | 12 ++++++------ fdroidserver/common.py | 7 +++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/fdroidserver/build.py b/fdroidserver/build.py index 37febba9..021c5da7 100644 --- a/fdroidserver/build.py +++ b/fdroidserver/build.py @@ -412,7 +412,7 @@ def build_server(app, build, vcs, build_dir, output_dir, force): ftp.chdir(homedir + '/tmp') else: ftp.chdir(homedir + '/unsigned') - apkfile = common.getapkname(app, build) + apkfile = common.get_release_filename(app, build) tarball = common.getsrcname(app, build) try: ftp.get(apkfile, os.path.join(output_dir, apkfile)) @@ -884,7 +884,7 @@ def build_local(app, build, vcs, build_dir, output_dir, srclib_dir, extlib_dir, # Copy the unsigned apk to our destination directory for further # processing (by publish.py)... - dest = os.path.join(output_dir, common.getapkname(app, build)) + dest = os.path.join(output_dir, common.get_release_filename(app, build)) shutil.copyfile(src, dest) # Move the source tarball into the output directory... @@ -912,17 +912,17 @@ def trybuild(app, build, build_dir, output_dir, also_check_dir, srclib_dir, extl :returns: True if the build was done, False if it wasn't necessary. """ - dest_apk = common.getapkname(app, build) + dest_file = common.get_release_filename(app, build) - dest = os.path.join(output_dir, dest_apk) - dest_repo = os.path.join(repo_dir, dest_apk) + dest = os.path.join(output_dir, dest_file) + dest_repo = os.path.join(repo_dir, dest_file) if not test: if os.path.exists(dest) or os.path.exists(dest_repo): return False if also_check_dir: - dest_also = os.path.join(also_check_dir, dest_apk) + dest_also = os.path.join(also_check_dir, dest_file) if os.path.exists(dest_also): return False diff --git a/fdroidserver/common.py b/fdroidserver/common.py index 1710c405..2ef58460 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -459,8 +459,11 @@ def apknameinfo(filename): return result -def getapkname(app, build): - return "%s_%s.apk" % (app.id, build.vercode) +def get_release_filename(app, build): + if build.output: + return "%s_%s.%s" % (app.id, build.vercode, get_file_extension(build.output)) + else: + return "%s_%s.apk" % (app.id, build.vercode) def getsrcname(app, build): -- 2.30.2