diff options
author | Lars Wirzenius <liw@liw.fi> | 2016-03-06 22:43:01 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2016-03-06 22:43:01 +0200 |
commit | 85e1778a83b6dbc1557c9dded363f6f43531b80e (patch) | |
tree | e4809ef21014a0edf72957f6081887c5df69c82c | |
parent | f626be6dcc489ab9cd5ff27fef285673423b2e19 (diff) | |
download | ick-85e1778a83b6dbc1557c9dded363f6f43531b80e.tar.gz |
Move APT setup step to its own module
-rw-r--r-- | icklib/__init__.py | 1 | ||||
-rw-r--r-- | icklib/project.py | 97 | ||||
-rw-r--r-- | icklib/step_debian_apt_setup.py | 114 | ||||
-rw-r--r-- | without-tests | 1 |
4 files changed, 118 insertions, 95 deletions
diff --git a/icklib/__init__.py b/icklib/__init__.py index cada16d..88dbe96 100644 --- a/icklib/__init__.py +++ b/icklib/__init__.py @@ -25,6 +25,7 @@ from .pipeline import BuildPipeline from .os_release import parse_os_release, OsRelease, NoOsReleaseInformation from .step_build_info import CreateBuildInfo, FinishBuildInfo from .step_create_tarball import CreateCITarball, CreateReleaseTarballs +from .step_debian_apt_setup import SetupAPTRepository from .step_debian_binary import ( CreateCIDebianBinaryPackages, CreateDebianBinaryPackagesForRelease, diff --git a/icklib/project.py b/icklib/project.py index b6ea875..66fdf90 100644 --- a/icklib/project.py +++ b/icklib/project.py @@ -222,99 +222,6 @@ class Project(object): remote_git_dir) -class SetupAPTRepository(icklib.BuildStep): - - def build(self): - if not self.run_state.changes_files: - return - - self.run_state.progress['step'] = 'Prepare APT repository' - self.run_state.logger.important('Prepare APT repository') - repopath = self.statedir.get_apt_directory() - confpath = os.path.join(repopath, 'conf') - if not os.path.exists(confpath): - os.makedirs(confpath) - - self._refresh_file( - os.path.join(confpath, 'distributions'), - self._make_reprepro_distributions(self.targets)) - - self._refresh_file( - os.path.join(confpath, 'incoming'), - self._make_reprepro_incoming(self.targets)) - - for base in ('incoming', 'incoming.temp'): - path = os.path.join(repopath, base) - if not os.path.exists(path): - os.makedirs(path) - - def _make_reprepro_distributions(self, targets): - archs = set(t.debian_arch for t in targets) - codenames = set(t.debian_codename for t in targets) - - if self.project.repo_signing_key is None: - signwith = '' - else: - signwith = 'SignWith: {}\n'.format(self.project.repo_signing_key) - - result = '' - for codename in codenames: - ci_stanza = ( - 'Codename: {codename}-ci\n' - 'Suite: {codename}\n' - 'Origin: ick\n' - 'Description: packages built by ick for CI\n' - 'Architectures: source {archlist}\n' - 'Components: main\n' - '{signwith}' - '\n' - ) - result += ci_stanza.format( - codename=codename, - archlist=' '.join(archs), - signwith=signwith) - - release_stanza = ( - 'Codename: {codename}\n' - 'Suite: {codename}\n' - 'Origin: ick\n' - 'Description: packages built by ick for release\n' - 'Architectures: source {archlist}\n' - 'Components: main\n' - '{signwith}' - '\n' - ) - result += release_stanza.format( - codename=codename, - archlist=' '.join(archs), - signwith=signwith) - - return result - - def _make_reprepro_incoming(self, targets): - release_codenames = [t.debian_codename for t in targets] - ci_codenames = [x + '-ci' for x in release_codenames] - codenames = ' '.join(release_codenames + ci_codenames) - - stanza = ( - 'Name: default\n' - 'IncomingDir: incoming\n' - 'TempDir: incoming.temp\n' - 'Cleanup: on_error\n' - 'Allow: {codenames}\n') - return stanza.format(codenames=codenames) - - def _refresh_file(self, pathname, contents): - if os.path.exists(pathname): - with open(pathname) as f: - old_contents = f.read() - else: - old_contents = None - if old_contents != contents: - with open(pathname, 'w') as f: - f.write(contents) - - class UploadDebianPackagesToCIRepo(icklib.BuildStep): def build(self): @@ -485,7 +392,7 @@ def create_projects_from_ick(ick, wanted_names): icklib.CreateDebianSourcePackagesForCI, icklib.CreateCIDebianBinaryPackages, icklib.FindDebianChangesFiles, - SetupAPTRepository, + icklib.SetupAPTRepository, UploadDebianPackagesToCIRepo, icklib.FinishBuildInfo, icklib.SaveProjectInfo, @@ -501,7 +408,7 @@ def create_projects_from_ick(ick, wanted_names): icklib.CreateDebianSourcePackagesForRelease, icklib.CreateDebianBinaryPackagesForRelease, icklib.FindDebianChangesFiles, - SetupAPTRepository, + icklib.SetupAPTRepository, UploadDebianPackagesToCIRepo, PublishDebianPackages, icklib.FinishBuildInfo, diff --git a/icklib/step_debian_apt_setup.py b/icklib/step_debian_apt_setup.py new file mode 100644 index 0000000..6e7304b --- /dev/null +++ b/icklib/step_debian_apt_setup.py @@ -0,0 +1,114 @@ +# Copyright 2016 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# =*= License: GPL-3+ =*= + + +import os + +import icklib + + +class SetupAPTRepository(icklib.BuildStep): + + def build(self): + if not self.run_state.changes_files: + return + + self.run_state.progress['step'] = 'Prepare APT repository' + self.run_state.logger.important('Prepare APT repository') + repopath = self.statedir.get_apt_directory() + confpath = os.path.join(repopath, 'conf') + if not os.path.exists(confpath): + os.makedirs(confpath) + + self._refresh_file( + os.path.join(confpath, 'distributions'), + self._make_reprepro_distributions(self.targets)) + + self._refresh_file( + os.path.join(confpath, 'incoming'), + self._make_reprepro_incoming(self.targets)) + + for base in ('incoming', 'incoming.temp'): + path = os.path.join(repopath, base) + if not os.path.exists(path): + os.makedirs(path) + + def _make_reprepro_distributions(self, targets): + archs = set(t.debian_arch for t in targets) + codenames = set(t.debian_codename for t in targets) + + if self.project.repo_signing_key is None: + signwith = '' + else: + signwith = 'SignWith: {}\n'.format(self.project.repo_signing_key) + + result = '' + for codename in codenames: + ci_stanza = ( + 'Codename: {codename}-ci\n' + 'Suite: {codename}\n' + 'Origin: ick\n' + 'Description: packages built by ick for CI\n' + 'Architectures: source {archlist}\n' + 'Components: main\n' + '{signwith}' + '\n' + ) + result += ci_stanza.format( + codename=codename, + archlist=' '.join(archs), + signwith=signwith) + + release_stanza = ( + 'Codename: {codename}\n' + 'Suite: {codename}\n' + 'Origin: ick\n' + 'Description: packages built by ick for release\n' + 'Architectures: source {archlist}\n' + 'Components: main\n' + '{signwith}' + '\n' + ) + result += release_stanza.format( + codename=codename, + archlist=' '.join(archs), + signwith=signwith) + + return result + + def _make_reprepro_incoming(self, targets): + release_codenames = [t.debian_codename for t in targets] + ci_codenames = [x + '-ci' for x in release_codenames] + codenames = ' '.join(release_codenames + ci_codenames) + + stanza = ( + 'Name: default\n' + 'IncomingDir: incoming\n' + 'TempDir: incoming.temp\n' + 'Cleanup: on_error\n' + 'Allow: {codenames}\n') + return stanza.format(codenames=codenames) + + def _refresh_file(self, pathname, contents): + if os.path.exists(pathname): + with open(pathname) as f: + old_contents = f.read() + else: + old_contents = None + if old_contents != contents: + with open(pathname, 'w') as f: + f.write(contents) diff --git a/without-tests b/without-tests index 2a4e242..32a4a2b 100644 --- a/without-tests +++ b/without-tests @@ -6,6 +6,7 @@ icklib/version.py icklib/progress.py icklib/step_build_info.py icklib/step_create_tarball.py +icklib/step_debian_apt_setup.py icklib/step_debian_binary.py icklib/step_debian_changes.py icklib/step_debian_info.py |