From e4a37c8f834f493320cab8f8521150ffc78bc5e1 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Mon, 17 Sep 2018 10:36:46 +0300 Subject: Refactor: how we configure dput on the fly, make is more debuggable --- ick2/actions.py | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/ick2/actions.py b/ick2/actions.py index 0c4aa7f..47fd757 100644 --- a/ick2/actions.py +++ b/ick2/actions.py @@ -598,26 +598,34 @@ class DputAction(Action): # pragma: no cover workspace = env.get_workspace_directory() apt_server = self._cc.get_apt_server() - config = self.configure_dput(apt_server) - argv = ['sh', '-c', 'dput -c {} ick *.changes'.format(config)] + config = self.get_dput_config_file(apt_server) + loggign.debug('dput config:\n%s', config) + filename = self.create_dput_cf(config) + argv = ['sh', '-c', 'dput -c {} ick *.changes'.format(filename)] + exit_code = env.host_runcmd(argv, cwd=workspace) env.report(exit_code, 'dput finished (exit code %d)\n' % exit_code) os.remove(config) return exit_code - def configure_dput(self, apt_server): + def create_dput_cf_file(self, config): fd, filename = tempfile.mkstemp() + os.write(fd, config) os.close(fd) - with open(filename, 'w') as f: - f.write('[ick]\n') - f.write('login = incoming\n') - f.write('fqdn = {}\n'.format(apt_server)) - f.write('method = scp\n') - f.write('incoming = /srv/apt/incoming\n') - f.write('allow_unsigned_uploads = 1\n') - f.write('check_version = 0\n') - f.write('run_dinstall = 0\n') - return filename + return filename + + def get_dput_config(self, apt_server): + template = '''\ +[ick] +login = incoming +fqdn = {apt_server} +method = scp +incoming = /srv/apt/incoming +allow_unsigned_uploads = 1 +check_version = 0 +run_dinstall = 0 +''' + return template.format(apt_server=apt_server) class NotifyAction(Action): # pragma: no cover -- cgit v1.2.1