chiark / gitweb /
get_release_filename() to handle any file type, not just APKs
authorHans-Christoph Steiner <hans@eds.org>
Mon, 31 Oct 2016 15:51:34 +0000 (16:51 +0100)
committerHans-Christoph Steiner <hans@eds.org>
Thu, 3 Nov 2016 07:07:11 +0000 (08:07 +0100)
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
fdroidserver/common.py

index 37febba9fafdd2bb7979a019ab16f07aeac7b3c0..021c5da722167b0918aacadeddd511e41b9027a4 100644 (file)
@@ -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
 
index 1710c4055594c0c93ea79a8034b93b66818878e6..2ef58460a8ebb9d7b93d20c5af3718351e8b749c 100644 (file)
@@ -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):