diff options
author | Lars Wirzenius <liw@liw.fi> | 2016-03-06 13:58:17 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2016-03-06 13:58:17 +0200 |
commit | 7c1bccc498132aa474dea7189ce08df00131f9aa (patch) | |
tree | 1f8a8eba3fed18aeed1baea5ce0eb7bc335aca31 | |
parent | 3c7884505deae9b728c33ee066fb38124035dae4 (diff) | |
download | ick-7c1bccc498132aa474dea7189ce08df00131f9aa.tar.gz |
Add build step to upload Debian packages
This version hardcodes an upload to a "foo" dput target.
-rw-r--r-- | icklib/project.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/icklib/project.py b/icklib/project.py index 46c1f72..c3d0f39 100644 --- a/icklib/project.py +++ b/icklib/project.py @@ -20,9 +20,11 @@ import glob import logging import os import re +import shutil import StringIO import subprocess import sys +import tempfile import time import urllib import urlparse @@ -1021,6 +1023,56 @@ class UploadDebianPackagesToCIRepo(icklib.BuildStep): sys.exit(exit_code) +class PublishDebianPackages(icklib.BuildStep): + + def build(self): + if not self.run_state.changes_files: + return + + self.run_state.progress['step'] = ( + 'Publish built release packages to public APT repositories') + self.run_state.logger.important( + 'Publish built release packages to public APT repositories') + with self.run_state.logger: + tempdir = self._copy_packages() + self._remove_dbgsym_packages_from_changes_files(tempdir) + self._debsign(tempdir) + self._dput(tempdir) + shutil.rmtree(tempdir) + + def _copy_packages(self): + tempdir = tempfile.mkdtemp() + artifacts_dir = self.run_state.build_info.get_artifacts_directory() + self.project.run_locally( + ['rsync', '-a', artifacts_dir + '/.', tempdir + '/.'], + 'rsync artifacts', '.') + return tempdir + + def _remove_dbgsym_packages_from_changes_files(self, tempdir): + for filename in self._changes_files(tempdir): + with open(filename) as f: + text = f.read() + modified = ''.join( + '{}\n'.format(line) + for line in text.splitlines() + if '-dbgsym' not in line) + with open(filename, 'w') as f: + f.write(modified) + + def _changes_files(self, tempdir): + return glob.glob(os.path.join(tempdir, '*.changes')) + + def _debsign(self, tempdir): + files = self._changes_files(tempdir) + self.project.run_locally( + ['debsign'] + files, 'debsign *.changes', tempdir) + + def _dput(self, tempdir): + files = self._changes_files(tempdir) + self.project.run_locally( + ['dput', 'foo'] + files, 'dput foo *.changes', tempdir) + + class LineLogger(object): # pragma: no cover def __init__(self, progress, logger): @@ -1113,6 +1165,7 @@ def create_projects_from_ick(ick, wanted_names): FindDebianChangesFiles, SetupAPTRepository, UploadDebianPackagesToCIRepo, + PublishDebianPackages, FinishBuildInfo, SaveProjectInfo, ], |