From: Benjamin Drung Date: Wed, 23 Jul 2014 12:31:39 +0000 (+0200) Subject: debian_build.py: Make repo01 the default upload target, disable alexandria upload... X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=5c9fcb8123ef90f181c5750dce9a2c9e19732977;p=profitbricks%2Fjenkins-build-scripts.git debian_build.py: Make repo01 the default upload target, disable alexandria upload for wheezy --- diff --git a/debian_build.py b/debian_build.py index 70eac93..60e258e 100755 --- a/debian_build.py +++ b/debian_build.py @@ -109,40 +109,22 @@ def getopts(): return parser.parse_args() -def upload_to_apt_repository(apt_target, apt_dist, changes_file, logger): +def upload_to_apt_repository(apt_target, changes_file, logger): try: - # Change distribution for new apt repository in changes file - cmd = ['sed', r's/^\(Distribution: \).*$/\1' + apt_dist + '/', changes_file] - command = ' '.join(cmd) - logger.debug('Executing "{command}" ...'.format(command=command)) - process = subprocess.Popen(cmd, stdout=subprocess.PIPE) - changes = process.communicate()[0] - if process.returncode == 0: - logger.debug('%s succeeded.' % command) - else: - logger.warn('%s failed.' % command) - figlet('repo01 upload failed') - return False - (head, tail) = os.path.splitext(changes_file) - new_changes_file = head + '_repo01' + tail - filehandle = open(new_changes_file, 'w') - filehandle.write(changes) - filehandle.close() - - cmd = ['dput', apt_target, new_changes_file] + cmd = ['dput', apt_target, changes_file] command = ' '.join(cmd) logger.debug('Executing "{command}" ...'.format(command=command)) success = subprocess.call(cmd) == 0 if success: logger.debug('%s succeeded.' % command) - figlet('repo01 upload OK') + figlet('Upload OK') else: logger.warn('%s failed.' % command) - figlet('repo01 upload failed') + figlet('Upload failed') except Exception as error: logger.warning("Upload to http://repo.pb.local failed. " "See above for details.", exc_info=error) - figlet('repo01 upload failed') + figlet('Upload failed') success = False return success @@ -281,7 +263,7 @@ if __name__ == '__main__': # Act II: make decissions # compatibility until call_jenkins was replaced - if curr_dist not in ('squeeze', 'wheezy'): + if curr_dist not in ('squeeze', 'wheezy', 'jessie'): logger.warn('Compatibility Mode: Change distribution {old} => {new}.'.format( old=curr_dist, new='squeeze' @@ -294,11 +276,11 @@ if __name__ == '__main__': branch=local_branch, )) exit_error() - new_dist = 'stable' + new_dist = curr_dist + alexandria_dist = 'stable' new_version = curr_version + options.version_suffix pb_suite = 'master-{dist}'.format(dist=curr_dist) reprepro_base = '/srv/pb-{dist}'.format(dist=curr_dist) - apt_dist = curr_dist apt_target = "repo01-debian" # replace valid debian version chars that are invalid for git tagging @@ -345,7 +327,8 @@ if __name__ == '__main__': branch=local_branch, )) exit_error() - new_dist = 'unstable' + alexandria_dist = 'unstable' + new_dist = curr_dist + '-dev' if cl.distributions == "UNRELEASED": pattern = "{debversion}~develop{time:%Y%m%d+%H%M}+{build}+{git-commit}" else: @@ -354,7 +337,6 @@ if __name__ == '__main__': new_version = version_substitution(logger, pattern, curr_commit) pb_suite = 'develop-{dist}'.format(dist=curr_dist) reprepro_base = '/srv/pb-{dist}'.format(dist=curr_dist) - apt_dist = curr_dist + '-dev' apt_target = "repo01-debian-dev" # reset actions # .. always include successful build packages into CIDB @@ -368,12 +350,13 @@ if __name__ == '__main__': )) exit_error() + new_dist = curr_dist + "-" + local_branch.replace("/", "-") if curr_dist == "wheezy": - new_dist = "wheezy-dev-{0}".format(local_branch.replace("/", "-")) - pb_suite = new_dist + alexandria_dist = "wheezy-dev-{0}".format(local_branch.replace("/", "-")) + pb_suite = alexandria_dist else: - new_dist = 'dev-{0}'.format(local_branch.replace("/", "-")) - pb_suite = new_dist + alexandria_dist = 'dev-{0}'.format(local_branch.replace("/", "-")) + pb_suite = alexandria_dist if cl.distributions == "UNRELEASED": pattern = "{debversion}~experimental{time:%Y%m%d+%H%M}+{build}+{git-commit}" else: @@ -381,7 +364,6 @@ if __name__ == '__main__': pattern = re.sub('{build}', ENV['BUILD_NUMBER'], pattern) + options.version_suffix new_version = version_substitution(logger, pattern, curr_commit) reprepro_base = '/srv/dev-{dist}'.format(dist=curr_dist) - apt_dist = curr_dist + "-" + local_branch.replace("/", "-") apt_target = "repo01-debian-dev" else: @@ -770,15 +752,35 @@ export {builder_env} FORCE_SHELL=TRUE )) fh.close() - # upload to new repo01 archive - if not upload_to_apt_repository(apt_target, apt_dist, changes_file, logger): + # upload to Debian archive + if not upload_to_apt_repository(apt_target, changes_file, logger): exit_error() # upload changes file - dput_obj.configure() - dput_obj.upload(changes_file) + if curr_dist == 'squeeze': + # Legacy support: Upload to alexandria.pb.local + # Change distribution for new apt repository in changes file + cmd = ['sed', r's/^\(Distribution: \).*$/\1' + alexandria_dist + '/', changes_file] + command = ' '.join(cmd) + logger.debug('Executing "{command}" ...'.format(command=command)) + process = subprocess.Popen(cmd, stdout=subprocess.PIPE) + changes = process.communicate()[0] + if process.returncode == 0: + logger.debug('%s succeeded.' % command) + else: + logger.warn('%s failed.' % command) + figlet('Legacy upload failed') + exit_error() + (head, tail) = os.path.splitext(changes_file) + legacy_changes_file = head + '_alexandria' + tail + filehandle = open(legacy_changes_file, 'w') + filehandle.write(changes) + filehandle.close() - figlet('Upload OK') + dput_obj.configure() + dput_obj.upload(legacy_changes_file) + + figlet('Legacy upload OK') except Exception as error: logger.error('Upload failed. See above for details.', exc_info=error)