From: Benjamin Drung Date: Fri, 6 Jun 2014 15:12:15 +0000 (+0200) Subject: debian_build.py: Upload to apt01 first and store changed .changes file separately. X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=9a40a34bd6593ef755eee2bdd1ee169b0032ac8b;p=profitbricks%2Fjenkins-build-scripts.git debian_build.py: Upload to apt01 first and store changed .changes file separately. --- diff --git a/debian_build.py b/debian_build.py index d59a8a6..f255dfb 100755 --- a/debian_build.py +++ b/debian_build.py @@ -107,26 +107,35 @@ def getopts(): def upload_to_apt_repository(apt_target, apt_dist, changes_file, logger): try: # Change distribution for new apt repository in changes file - cmd = ['sed', '-i', r's/^\(Distribution: \).*$/\1' + apt_dist + '/', - changes_file] + cmd = ['sed', r's/^\(Distribution: \).*$/\1' + apt_dist + '/', changes_file] command = ' '.join(cmd) logger.debug('Executing "{command}" ...'.format(command=command)) - if subprocess.call(cmd) == 0: + 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('apt01 upload failed') return + new_changes_file = os.path.join(ENV['WORKSPACE'], apt_target + '.changes') + filehandle = open(new_changes_file, 'w') + filehandle.write(changes) + filehandle.close() - cmd = ['dput', apt_target, changes_file] + cmd = ['dput', apt_target, new_changes_file] command = ' '.join(cmd) logger.debug('Executing "{command}" ...'.format(command=command)) if subprocess.call(cmd) == 0: logger.debug('%s succeeded.' % command) + figlet('apt01 upload OK') else: logger.warn('%s failed.' % command) + figlet('apt01 upload failed') except Exception as error: logger.warning("Experimental upload to http://apt01.pb.local failed. " "See above for details.", exc_info=error) + figlet('apt01 upload failed') if __name__ == '__main__': @@ -684,14 +693,15 @@ export {builder_env} FORCE_SHELL=TRUE )) fh.close() + # upload to new apt01 archive + upload_to_apt_repository(apt_target, apt_dist, changes_file, logger) + # upload changes file dput_obj.configure() dput_obj.upload(changes_file) figlet('Upload OK') - upload_to_apt_repository(apt_target, apt_dist, changes_file, logger) - except Exception as error: logger.error('Upload failed. See above for details.', exc_info=error) figlet('Upload failed')