chiark / gitweb /
refactored publishing source tarball into a function
authorMichael Pöhn <michael.poehn@fsfe.org>
Thu, 8 Jun 2017 10:52:11 +0000 (12:52 +0200)
committerMichael Pöhn <michael.poehn@fsfe.org>
Tue, 26 Sep 2017 12:11:09 +0000 (14:11 +0200)
fdroidserver/publish.py

index bafa29f693f20ca297b2bc3b2259d32130701755..5fc2ff580f82e7d0fc5b2abb28986597dee9ae0a 100644 (file)
@@ -37,6 +37,18 @@ config = None
 options = None
 
 
+def publish_source_tarball(apkfilename, unsigned_dir, output_dir):
+    """Move the source tarball into the output directory..."""
+
+    tarfilename = apkfilename[:-4] + '_src.tar.gz'
+    tarfile = os.path.join(unsigned_dir, tarfilename)
+    if os.path.exists(tarfile):
+        shutil.move(tarfile, os.path.join(output_dir, tarfilename))
+        logging.debug('...published %s', tarfilename)
+    else:
+        logging.debug('...no source tarball for %s', apkfilename)
+
+
 def main():
 
     global config, options
@@ -138,18 +150,23 @@ def main():
             if compare_result:
                 logging.error("...verification failed - publish skipped : "
                               + compare_result)
-                continue
+            else:
 
-            # Success! So move the downloaded file to the repo, and remove
-            # our built version.
-            shutil.move(srcapk, os.path.join(output_dir, apkfilename))
-            os.remove(apkfile)
+                # Success! So move the downloaded file to the repo, and remove
+                # our built version.
+                shutil.move(srcapk, os.path.join(output_dir, apkfilename))
+                os.remove(apkfile)
+
+                publish_source_tarball(apkfilename, unsigned_dir, output_dir)
+                logging.info('Published ' + apkfilename)
 
         elif apkfile.endswith('.zip'):
 
             # OTA ZIPs built by fdroid do not need to be signed by jarsigner,
             # just to be moved into place in the repo
             shutil.move(apkfile, os.path.join(output_dir, apkfilename))
+            publish_source_tarball(apkfilename, unsigned_dir, output_dir)
+            logging.info('Published ' + apkfilename)
 
         else:
 
@@ -219,13 +236,8 @@ def main():
                 raise BuildException(_("Failed to align application"))
             os.remove(apkfile)
 
-        # Move the source tarball into the output directory...
-        tarfilename = apkfilename[:-4] + '_src.tar.gz'
-        tarfile = os.path.join(unsigned_dir, tarfilename)
-        if os.path.exists(tarfile):
-            shutil.move(tarfile, os.path.join(output_dir, tarfilename))
-
-        logging.info('Published ' + apkfilename)
+            publish_source_tarball(apkfilename, unsigned_dir, output_dir)
+            logging.info('Published ' + apkfilename)
 
 
 if __name__ == "__main__":