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()
+ # Change distribution for archive01 in changes file
+ cmd = ['sed', '-i', r's/^\(Distribution: \).*$/\1' + archive01_dist + '/',
+ 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)
+ return
cmd = ['dput', archive01_target, changes_file]
command = ' '.join(cmd)