diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-09-17 10:36:46 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-09-17 10:36:46 +0300 |
commit | e4a37c8f834f493320cab8f8521150ffc78bc5e1 (patch) | |
tree | 7cf7e62ab47f6ac6b91e70cb28a21d88671c35f7 | |
parent | e61c54196ead96b7efcdc0794ced2314de26d030 (diff) | |
download | ick2-e4a37c8f834f493320cab8f8521150ffc78bc5e1.tar.gz |
Refactor: how we configure dput on the fly, make is more debuggable
-rw-r--r-- | ick2/actions.py | 34 |
1 files 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 |