summaryrefslogtreecommitdiff
path: root/icklib
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2016-03-06 22:49:54 +0200
committerLars Wirzenius <liw@liw.fi>2016-03-06 22:49:54 +0200
commit0cfbdfc8d89a403ae915e8b1ab774fae121f26d5 (patch)
tree6e9c1bb3dce12b1bfd3a45f976d97c2cccba023f /icklib
parentc682869e6d3f0faa8eb96b6e4d08774840bb988c (diff)
downloadick-0cfbdfc8d89a403ae915e8b1ab774fae121f26d5.tar.gz
Move publishing of Debian packages to a module
Diffstat (limited to 'icklib')
-rw-r--r--icklib/__init__.py1
-rw-r--r--icklib/project.py58
-rw-r--r--icklib/step_debian_publish.py77
3 files changed, 79 insertions, 57 deletions
diff --git a/icklib/__init__.py b/icklib/__init__.py
index c6f6540..df37de1 100644
--- a/icklib/__init__.py
+++ b/icklib/__init__.py
@@ -34,6 +34,7 @@ from .step_debian_binary import (
from .step_debian_changes import FindDebianChangesFiles
from .step_debian_ci_upload import UploadDebianPackagesToCIRepo
from .step_debian_info import CollectDebianInfoAboutTargets
+from .step_debian_publish import PublishDebianPackages
from .step_debian_source import (
CreateDebianSourcePackagesForCI,
CreateDebianSourcePackagesForRelease,
diff --git a/icklib/project.py b/icklib/project.py
index 4331764..94f87bd 100644
--- a/icklib/project.py
+++ b/icklib/project.py
@@ -16,12 +16,9 @@
# =*= License: GPL-3+ =*=
-import glob
import os
-import shutil
import StringIO
import subprocess
-import tempfile
import time
import cliapp
@@ -218,59 +215,6 @@ class Project(object):
remote_git_dir)
-class PublishDebianPackages(icklib.BuildStep):
-
- def build(self):
- if not self.run_state.changes_files or not self.project.dput_targets:
- 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)
- for dput_target in self.project.dput_targets:
- self.project.run_locally(
- ['dput', dput_target] + files,
- 'dput {} *.changes'.format(dput_target),
- tempdir)
-
-
def create_projects_from_ick(ick, wanted_names):
pipelines = {
'shell': [
@@ -322,7 +266,7 @@ def create_projects_from_ick(ick, wanted_names):
icklib.FindDebianChangesFiles,
icklib.SetupAPTRepository,
icklib.UploadDebianPackagesToCIRepo,
- PublishDebianPackages,
+ icklib.PublishDebianPackages,
icklib.FinishBuildInfo,
icklib.SaveProjectInfo,
],
diff --git a/icklib/step_debian_publish.py b/icklib/step_debian_publish.py
new file mode 100644
index 0000000..fa58bdf
--- /dev/null
+++ b/icklib/step_debian_publish.py
@@ -0,0 +1,77 @@
+# 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 glob
+import os
+import shutil
+import tempfile
+
+import icklib
+
+
+class PublishDebianPackages(icklib.BuildStep):
+
+ def build(self):
+ if not self.run_state.changes_files or not self.project.dput_targets:
+ 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)
+ for dput_target in self.project.dput_targets:
+ self.project.run_locally(
+ ['dput', dput_target] + files,
+ 'dput {} *.changes'.format(dput_target),
+ tempdir)