]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
debian_build.py: Upload packages to archive01.pb.local, too.
authorBenjamin Drung <benjamin.drung@profitbricks.com>
Thu, 5 Jun 2014 17:20:50 +0000 (19:20 +0200)
committerBenjamin Drung <benjamin.drung@profitbricks.com>
Thu, 5 Jun 2014 17:20:50 +0000 (19:20 +0200)
debian_build.py

index 4198325e9e2b800edd07304afdfbdfec05cefd30..1775a2d1f8b60ae3ed649d4fcd089bcd63be4ebf 100755 (executable)
@@ -103,6 +103,31 @@ def getopts():
 
     return parser.parse_args()
 
+
+def upload_to_archive01(archive01_target, archive01_dist, changes_file, logger):
+    try:
+        # dpkg-genchanges -b -DDistribution=$dist > $changes_file
+        cmd = ['dpkg-genchanges', '-b', '-DDistribution=' + archive01_dist]
+        logger.debug('Executing "{command}" ...'.format(command=' '.join(cmd)))
+        process = subprocess.Popen(cmd, close_fds=True, stdout=subprocess.PIPE, cwd=os.getcwd())
+        changes = process.communicate()[0]
+
+        filehandler = open(changes_file, 'w')
+        filehandler.write(changes)
+        filehandler.close()
+
+        cmd = ['dput', archive01_target, changes_file]
+        command = ' '.join(cmd)
+        logger.debug('Executing "{command}" ...'.format(command=command))
+        if subprocess.call(cmd) == 0:
+            logger.debug('%s succeeded.' % command)
+        else:
+            logger.warn('%s failed.' % command)
+    except Exception as error:
+        logger.warning("Experimental upload to http://archive01.pb.local failed. "
+                       "See above for details.", exc_info=error)
+
+
 if __name__ == '__main__':
     logger.debug('Start-up environment:\n\n{env}\n'.format(env=pformat(ENV)))
 
@@ -188,6 +213,8 @@ if __name__ == '__main__':
         new_version = curr_version + options.version_suffix
         pb_suite = 'master-{dist}'.format(dist=curr_dist)
         reprepro_base = '/srv/pb-{dist}'.format(dist=curr_dist)
+        archive01_dist = curr_dist
+        archive01_target = "archive01-debian"
 
         # replace valid debian version chars that are invalid for git tagging
         new_tag = curr_version.replace('~', '_').replace(':', ',')
@@ -243,6 +270,8 @@ if __name__ == '__main__':
         )
         pb_suite = 'develop-{dist}'.format(dist=curr_dist)
         reprepro_base = '/srv/pb-{dist}'.format(dist=curr_dist)
+        archive01_dist = curr_dist + '-dev'
+        archive01_target = "archive01-debian"
         # reset actions
         # .. always include successful build packages into CIDB
         if curr_dist == 'squeeze':
@@ -269,6 +298,8 @@ if __name__ == '__main__':
             suffix=options.version_suffix,
         )
         reprepro_base = '/srv/dev-{dist}'.format(dist=curr_dist)
+        archive01_dist = curr_dist + "-" + local_branch.replace("/", "-")
+        archive01_target = "archive01-debian-dev"
 
     else:
         logger.error('Don\'t know how to handle branch "{branch}".'.format(
@@ -658,6 +689,8 @@ export {builder_env} FORCE_SHELL=TRUE
 
             figlet('Upload OK')
 
+            upload_to_archive01(archive01_target, archive01_dist, changes_file, logger)
+
         except Exception as error:
             logger.error('Upload failed. See above for details.', exc_info=error)
             figlet('Upload failed')