From: Benjamin Drung Date: Thu, 5 Jun 2014 17:20:50 +0000 (+0200) Subject: debian_build.py: Upload packages to archive01.pb.local, too. X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=40f24ce741fae0c656786ff94c8187ccb08f35a0;p=profitbricks%2Fjenkins-build-scripts.git debian_build.py: Upload packages to archive01.pb.local, too. --- diff --git a/debian_build.py b/debian_build.py index 4198325..1775a2d 100755 --- a/debian_build.py +++ b/debian_build.py @@ -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')