Mercurial > treepkg > treepkg
annotate treepkg/packager.py @ 310:26c15a0f0e52
When stopping because of an error, do not raise the exception again as
it leads to confusing double tracebacks in the log. Instead, simply log
the reason for the stopping and stop in the same way a stop instruction
is handled.
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Wed, 02 Dec 2009 14:46:37 +0000 |
parents | 61d1daac23d4 |
children | 2d6915bce473 |
rev | line source |
---|---|
222
01c043f13f13
Remove the unused PackageTrack.last_packaged_revision method and
Bernhard Herzog <bh@intevation.de>
parents:
207
diff
changeset
|
1 # Copyright (C) 2007, 2008, 2009 by Intevation GmbH |
0 | 2 # Authors: |
3 # Bernhard Herzog <bh@intevation.de> | |
4 # | |
5 # This program is free software under the GPL (>=v2) | |
6 # Read the file COPYING coming with the software for details. | |
7 | |
8 """Classes to automatically build debian packages from subversion checkouts""" | |
9 | |
10 import os | |
11 import time | |
12 import re | |
13 import logging | |
14 import shutil | |
16
7c55f3879c4d
Use the new status class and report start/stop time too
Bernhard Herzog <bh@intevation.de>
parents:
14
diff
changeset
|
15 import datetime |
113
312949e7628d
Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents:
112
diff
changeset
|
16 import new |
0 | 17 |
18 import util | |
231
7dbf0a3443bb
Use treepkg.subversion.ManualWorkingCopy for the debian directory in a
Bernhard Herzog <bh@intevation.de>
parents:
229
diff
changeset
|
19 from subversion import SvnRepository, SvnWorkingCopy, ManualWorkingCopy |
0 | 20 import run |
16
7c55f3879c4d
Use the new status class and report start/stop time too
Bernhard Herzog <bh@intevation.de>
parents:
14
diff
changeset
|
21 import status |
128
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
22 import debian |
45
3e610233ccfe
use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents:
41
diff
changeset
|
23 from cmdexpand import cmdexpand |
112
cea98d4e4a6a
Abstract the pbuilder calls into the new class treepkg.builder.PBuilder.
Bernhard Herzog <bh@intevation.de>
parents:
106
diff
changeset
|
24 from builder import PBuilder |
0 | 25 |
135
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
26 def _fromparent(attr): |
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
27 """Creates a property that delegates its value to self.parent.<attr>""" |
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
28 def get(self): |
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
29 return getattr(self.parent, attr) |
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
30 return property(get) |
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
31 |
0 | 32 |
33 class SourcePackager(object): | |
34 | |
299
c32dc72ba979
Turn the SourcePackager class attribute pkg_basename into a per-track
Bernhard Herzog <bh@intevation.de>
parents:
297
diff
changeset
|
35 pkg_basename = property(lambda self: self.track.pkg_basename) |
300
e82fb08781a2
Turn the SourcePackager class attribute changemsg_template into a
Bernhard Herzog <bh@intevation.de>
parents:
299
diff
changeset
|
36 changemsg_template = property(lambda self: |
e82fb08781a2
Turn the SourcePackager class attribute changemsg_template into a
Bernhard Herzog <bh@intevation.de>
parents:
299
diff
changeset
|
37 self.track.changelog_msg_template) |
135
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
38 track = _fromparent("track") |
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
39 revision = _fromparent("revision") |
281
2b9d94f0ccad
Pass the package revision as a parameter to the RevisionPackager
Bernhard Herzog <bh@intevation.de>
parents:
276
diff
changeset
|
40 pkg_revision = _fromparent("pkg_revision") |
135
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
41 status = _fromparent("status") |
136
5598014b2a1d
Add a log/ subdir for each revision. The filename is available as the
Bernhard Herzog <bh@intevation.de>
parents:
135
diff
changeset
|
42 log_dir = _fromparent("log_dir") |
135
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
43 work_dir = _fromparent("work_dir") |
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
44 src_dir = _fromparent("src_dir") |
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
45 |
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
46 def __init__(self, parent): |
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
47 self.parent = parent |
0 | 48 |
49 def determine_package_version(self, directory): | |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
50 """Returns the version number of the new package as a string |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
51 |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
52 The directory parameter is the name of the directory containing |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
53 the newly exported sources. The sources were exported with the |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
54 export_sources method. |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
55 |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
56 The default implementation simply returns the revision converted |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
57 to a string. |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
58 """ |
305
3781e9958eba
Add per-track configuration option version_template used by the
Bernhard Herzog <bh@intevation.de>
parents:
304
diff
changeset
|
59 return self.track.version_template % dict(revision=self.revision) |
0 | 60 |
61 def export_sources(self): | |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
62 """Export the sources from the subversion working directory |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
63 |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
64 This method first exports the sources to a temporary directory |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
65 and then renames the directory. The new name is of the form |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
66 |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
67 <pkg_basename>-<version> |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
68 |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
69 Where pkg_basename is the value of self.pkg_basename and version |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
70 is the return value of the determine_package_version() method. |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
71 """ |
0 | 72 temp_dir = os.path.join(self.work_dir, "temp") |
53
74cd21b6400b
rename some variables from pkg_track to track
Bernhard Herzog <bh@intevation.de>
parents:
52
diff
changeset
|
73 self.track.export_sources(temp_dir) |
0 | 74 |
75 pkgbaseversion = self.determine_package_version(temp_dir) | |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
76 pkgbasedir = os.path.join(self.work_dir, |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
77 self.pkg_basename + "-" + pkgbaseversion) |
0 | 78 |
79 os.rename(temp_dir, pkgbasedir) | |
80 return pkgbaseversion, pkgbasedir | |
81 | |
82 | |
276
f3dee156e3e3
Add pkgbaseversion parameter to the prepare_sources_for_tarball method
Bernhard Herzog <bh@intevation.de>
parents:
274
diff
changeset
|
83 def prepare_sources_for_tarball(self, pkgbasedir, pkgbaseversion): |
274
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
261
diff
changeset
|
84 """Prepare the exported sources prior to creating the tarball. |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
85 |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
86 The default implementation does nothing. Derived classes should |
274
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
261
diff
changeset
|
87 override this method if necessary to e.g. update the version |
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
261
diff
changeset
|
88 numbers in the code. |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
89 """ |
0 | 90 |
207
b82fe4d25893
SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents:
202
diff
changeset
|
91 def create_tarball(self, tarballname, workdir, basedir, compression="gz"): |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
92 """Creates a new tarball. |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
93 |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
94 Parameters: |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
95 |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
96 tarballname -- the filename of the new tarball |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
97 workdir -- The directory into which to change before running tar. |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
98 (actually this is done with GNUI tar's -C option) |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
99 basedir -- The basedirectory of the files that are packaged |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
100 into the tarfile. This should be a relative |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
101 filename directly in workdir. |
207
b82fe4d25893
SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents:
202
diff
changeset
|
102 compression -- The compression method to use as a string. |
b82fe4d25893
SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents:
202
diff
changeset
|
103 Suported are 'gz' for gzip compression (the |
b82fe4d25893
SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents:
202
diff
changeset
|
104 default) and 'bz2' for bzip2. |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
105 """ |
0 | 106 logging.info("Creating tarball %r", tarballname) |
207
b82fe4d25893
SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents:
202
diff
changeset
|
107 if compression == "gz": |
b82fe4d25893
SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents:
202
diff
changeset
|
108 compression_flag = "z" |
b82fe4d25893
SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents:
202
diff
changeset
|
109 elif compression == "bz2": |
b82fe4d25893
SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents:
202
diff
changeset
|
110 compression_flag = "j" |
b82fe4d25893
SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents:
202
diff
changeset
|
111 else: |
b82fe4d25893
SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents:
202
diff
changeset
|
112 raise ValueError("Unknown compression method %r" % compression) |
b82fe4d25893
SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents:
202
diff
changeset
|
113 |
b82fe4d25893
SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents:
202
diff
changeset
|
114 run.call(cmdexpand("tar c -$compression_flag -f $tarballname" |
b82fe4d25893
SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents:
202
diff
changeset
|
115 " -C $workdir $basedir", **locals())) |
0 | 116 |
117 def copy_debian_directory(self, pkgbasedir, pkgbaseversion, changemsg): | |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
118 """Copies the debian directory and updates the copy's changelog |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
119 |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
120 Parameter: |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
121 pkgbasedir -- The directory holding the unpacked source package |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
122 pkgbaseversion -- The version to update the changelog to |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
123 changemsg -- The message for the changelog |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
124 |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
125 When determining the actual version for the new package, this |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
126 function looks at the previous version in the changelog. If it |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
127 has a prefix separated from the version number by a colon this |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
128 prefix is prepended to the pkgbaseversion parameter. Debian |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
129 uses such prefixes for the kde packages. |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
130 """ |
0 | 131 debian_dir = os.path.join(pkgbasedir, "debian") |
132 changelog = os.path.join(debian_dir, "changelog") | |
133 | |
53
74cd21b6400b
rename some variables from pkg_track to track
Bernhard Herzog <bh@intevation.de>
parents:
52
diff
changeset
|
134 self.track.copy_debian_directory(debian_dir) |
0 | 135 |
136 logging.info("Updating %r", changelog) | |
137 oldversion = util.debian_changelog_version(changelog) | |
138 if ":" in oldversion: | |
139 oldversionprefix = oldversion.split(":")[0] + ":" | |
140 else: | |
141 oldversionprefix = "" | |
281
2b9d94f0ccad
Pass the package revision as a parameter to the RevisionPackager
Bernhard Herzog <bh@intevation.de>
parents:
276
diff
changeset
|
142 debrev = self.pkg_revision |
45
3e610233ccfe
use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents:
41
diff
changeset
|
143 run.call(cmdexpand("debchange -c $changelog" |
93
73c67372c7f7
Make the prefix used in the debian revision number configurable.
Bernhard Herzog <bh@intevation.de>
parents:
91
diff
changeset
|
144 " -v ${oldversionprefix}${pkgbaseversion}-${debrev}" |
45
3e610233ccfe
use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents:
41
diff
changeset
|
145 " $changemsg", **locals()), |
53
74cd21b6400b
rename some variables from pkg_track to track
Bernhard Herzog <bh@intevation.de>
parents:
52
diff
changeset
|
146 env=self.track.debian_environment()) |
0 | 147 |
148 | |
149 def create_source_package(self, pkgbasedir, origtargz): | |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
150 """Creates a new source package from pkgbasedir and origtargz""" |
194
86360f3d5611
Log the output of the dpkg-source call to dpkg_source.txt.
Bernhard Herzog <bh@intevation.de>
parents:
191
diff
changeset
|
151 util.ensure_directory(self.log_dir) |
86360f3d5611
Log the output of the dpkg-source call to dpkg_source.txt.
Bernhard Herzog <bh@intevation.de>
parents:
191
diff
changeset
|
152 dpkg_source_log = os.path.join(self.log_dir, "dpkg_source.txt") |
86360f3d5611
Log the output of the dpkg-source call to dpkg_source.txt.
Bernhard Herzog <bh@intevation.de>
parents:
191
diff
changeset
|
153 logging.info("Creating new source package; logging to %s", |
86360f3d5611
Log the output of the dpkg-source call to dpkg_source.txt.
Bernhard Herzog <bh@intevation.de>
parents:
191
diff
changeset
|
154 dpkg_source_log) |
45
3e610233ccfe
use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents:
41
diff
changeset
|
155 run.call(cmdexpand("dpkg-source -b $directory $tarball", |
3e610233ccfe
use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents:
41
diff
changeset
|
156 directory=os.path.basename(pkgbasedir), |
3e610233ccfe
use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents:
41
diff
changeset
|
157 tarball=os.path.basename(origtargz)), |
0 | 158 cwd=os.path.dirname(pkgbasedir), |
194
86360f3d5611
Log the output of the dpkg-source call to dpkg_source.txt.
Bernhard Herzog <bh@intevation.de>
parents:
191
diff
changeset
|
159 logfile=dpkg_source_log, |
53
74cd21b6400b
rename some variables from pkg_track to track
Bernhard Herzog <bh@intevation.de>
parents:
52
diff
changeset
|
160 env=self.track.debian_environment()) |
0 | 161 |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
162 def move_source_package(self, pkgbasename): |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
163 """Moves the new source package from the work_dir to the src_dir""" |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
164 logging.info("Moving source package to %r", self.src_dir) |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
165 util.ensure_directory(self.src_dir) |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
166 for filename in [filename for filename in os.listdir(self.work_dir) |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
167 if filename.startswith(pkgbasename)]: |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
168 os.rename(os.path.join(self.work_dir, filename), |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
169 os.path.join(self.src_dir, filename)) |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
170 |
179
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
171 def sign_package(self): |
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
172 """Signs the .dsc file created buy the instance""" |
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
173 self.track.sign_file(util.listdir_abs(self.src_dir, "*.dsc")[0]) |
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
174 |
0 | 175 def package(self): |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
176 """Creates a source package from a subversion checkout. |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
177 |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
178 After setting up the working directory, this method calls the |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
179 do_package method to do the actual packaging. Afterwards the |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
180 work directory is removed. |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
181 """ |
0 | 182 util.ensure_directory(self.work_dir) |
183 try: | |
41
f7ec40638a06
use the enums for the status field of RevisionStatus
Bernhard Herzog <bh@intevation.de>
parents:
36
diff
changeset
|
184 self.status.creating_source_package() |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
185 self.do_package() |
179
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
186 self.sign_package() |
41
f7ec40638a06
use the enums for the status field of RevisionStatus
Bernhard Herzog <bh@intevation.de>
parents:
36
diff
changeset
|
187 self.status.source_package_created() |
0 | 188 finally: |
189 logging.info("Removing workdir %r", self.work_dir) | |
190 shutil.rmtree(self.work_dir) | |
191 | |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
192 def do_package(self): |
274
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
261
diff
changeset
|
193 """Does the work of creating a source package.""" |
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
261
diff
changeset
|
194 pkgbaseversion, pkgbasedir = self.export_sources() |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
195 |
274
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
261
diff
changeset
|
196 pkgbasename = self.pkg_basename + "_" + pkgbaseversion |
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
261
diff
changeset
|
197 origtargz = os.path.join(self.work_dir, |
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
261
diff
changeset
|
198 pkgbasename + ".orig.tar.gz") |
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
261
diff
changeset
|
199 |
276
f3dee156e3e3
Add pkgbaseversion parameter to the prepare_sources_for_tarball method
Bernhard Herzog <bh@intevation.de>
parents:
274
diff
changeset
|
200 self.prepare_sources_for_tarball(pkgbasedir, pkgbaseversion) |
274
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
261
diff
changeset
|
201 |
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
261
diff
changeset
|
202 self.create_tarball(origtargz, self.work_dir, |
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
261
diff
changeset
|
203 os.path.basename(pkgbasedir)) |
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
261
diff
changeset
|
204 |
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
261
diff
changeset
|
205 changemsg = self.changemsg_template % dict(revision=self.revision) |
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
261
diff
changeset
|
206 self.copy_debian_directory(pkgbasedir, pkgbaseversion, |
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
261
diff
changeset
|
207 changemsg) |
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
261
diff
changeset
|
208 |
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
261
diff
changeset
|
209 self.create_source_package(pkgbasedir, origtargz) |
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
261
diff
changeset
|
210 self.move_source_package(pkgbasename) |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
211 |
0 | 212 |
213 class BinaryPackager(object): | |
214 | |
135
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
215 track = _fromparent("track") |
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
216 status = _fromparent("status") |
136
5598014b2a1d
Add a log/ subdir for each revision. The filename is available as the
Bernhard Herzog <bh@intevation.de>
parents:
135
diff
changeset
|
217 log_dir = _fromparent("log_dir") |
135
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
218 binary_dir = _fromparent("binary_dir") |
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
219 |
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
220 def __init__(self, parent, dsc_file, logfile): |
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
221 self.parent = parent |
0 | 222 self.dsc_file = dsc_file |
223 self.logfile = logfile | |
224 | |
225 def package(self): | |
41
f7ec40638a06
use the enums for the status field of RevisionStatus
Bernhard Herzog <bh@intevation.de>
parents:
36
diff
changeset
|
226 self.status.creating_binary_package() |
0 | 227 util.ensure_directory(self.binary_dir) |
149
4526105f81a7
Make sure the log dir exists before attempting to run pbuilder build
Bernhard Herzog <bh@intevation.de>
parents:
143
diff
changeset
|
228 util.ensure_directory(self.log_dir) |
54 | 229 logging.info("Building binary package; logging to %r", self.logfile) |
297
4dd6ec3a1151
Make it possible to use parallel builds for packages that support it:
Bernhard Herzog <bh@intevation.de>
parents:
293
diff
changeset
|
230 self.track.builder.build(self.dsc_file, self.binary_dir, self.logfile, |
4dd6ec3a1151
Make it possible to use parallel builds for packages that support it:
Bernhard Herzog <bh@intevation.de>
parents:
293
diff
changeset
|
231 extra_env=self.track.debian_environment()) |
179
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
232 self.sign_package() |
41
f7ec40638a06
use the enums for the status field of RevisionStatus
Bernhard Herzog <bh@intevation.de>
parents:
36
diff
changeset
|
233 self.status.binary_package_created() |
0 | 234 |
179
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
235 def sign_package(self): |
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
236 """Signs the .changes file created buy the instance""" |
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
237 self.track.sign_file(util.listdir_abs(self.binary_dir, "*.changes")[0]) |
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
238 |
0 | 239 |
240 class RevisionPackager(object): | |
241 | |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
242 source_packager_cls = SourcePackager |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
243 binary_packager_cls = BinaryPackager |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
244 |
281
2b9d94f0ccad
Pass the package revision as a parameter to the RevisionPackager
Bernhard Herzog <bh@intevation.de>
parents:
276
diff
changeset
|
245 def __init__(self, track, revision, rules_revision, pkg_revision=None, |
2b9d94f0ccad
Pass the package revision as a parameter to the RevisionPackager
Bernhard Herzog <bh@intevation.de>
parents:
276
diff
changeset
|
246 tag=""): |
53
74cd21b6400b
rename some variables from pkg_track to track
Bernhard Herzog <bh@intevation.de>
parents:
52
diff
changeset
|
247 self.track = track |
0 | 248 self.revision = revision |
229
653a45adda50
Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents:
224
diff
changeset
|
249 self.rules_revision = rules_revision |
281
2b9d94f0ccad
Pass the package revision as a parameter to the RevisionPackager
Bernhard Herzog <bh@intevation.de>
parents:
276
diff
changeset
|
250 |
2b9d94f0ccad
Pass the package revision as a parameter to the RevisionPackager
Bernhard Herzog <bh@intevation.de>
parents:
276
diff
changeset
|
251 if pkg_revision is None: |
293
faeeac2c4c71
Replace debrevision_prefix with pkg_revision_template. Their meaning is
Bernhard Herzog <bh@intevation.de>
parents:
281
diff
changeset
|
252 pkg_revision = (self.track.pkg_revision_template |
faeeac2c4c71
Replace debrevision_prefix with pkg_revision_template. Their meaning is
Bernhard Herzog <bh@intevation.de>
parents:
281
diff
changeset
|
253 % dict(pkg_revision=1)) |
281
2b9d94f0ccad
Pass the package revision as a parameter to the RevisionPackager
Bernhard Herzog <bh@intevation.de>
parents:
276
diff
changeset
|
254 self.pkg_revision = pkg_revision |
2b9d94f0ccad
Pass the package revision as a parameter to the RevisionPackager
Bernhard Herzog <bh@intevation.de>
parents:
276
diff
changeset
|
255 |
229
653a45adda50
Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents:
224
diff
changeset
|
256 self.base_dir = self.track.pkg_dir_for_revision(self.revision, |
653a45adda50
Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents:
224
diff
changeset
|
257 rules_revision) |
36
086c68ca51d2
rename Status to RevisionStatus
Bernhard Herzog <bh@intevation.de>
parents:
26
diff
changeset
|
258 self.status = status.RevisionStatus(os.path.join(self.base_dir, |
086c68ca51d2
rename Status to RevisionStatus
Bernhard Herzog <bh@intevation.de>
parents:
26
diff
changeset
|
259 "status")) |
260
6aeae11ca7fe
Add tag parameter to RevisionPackager constructor. The tag is stored in
Bernhard Herzog <bh@intevation.de>
parents:
238
diff
changeset
|
260 if tag: |
6aeae11ca7fe
Add tag parameter to RevisionPackager constructor. The tag is stored in
Bernhard Herzog <bh@intevation.de>
parents:
238
diff
changeset
|
261 util.ensure_directory(self.base_dir) |
6aeae11ca7fe
Add tag parameter to RevisionPackager constructor. The tag is stored in
Bernhard Herzog <bh@intevation.de>
parents:
238
diff
changeset
|
262 self.status.tags = tag |
0 | 263 |
172
06af36f915f2
Move the filenameproperty factory from treepkg/packager.py to
Bernhard Herzog <bh@intevation.de>
parents:
168
diff
changeset
|
264 log_dir = util.filenameproperty("log") |
06af36f915f2
Move the filenameproperty factory from treepkg/packager.py to
Bernhard Herzog <bh@intevation.de>
parents:
168
diff
changeset
|
265 work_dir = util.filenameproperty("work") |
06af36f915f2
Move the filenameproperty factory from treepkg/packager.py to
Bernhard Herzog <bh@intevation.de>
parents:
168
diff
changeset
|
266 binary_dir = util.filenameproperty("binary") |
06af36f915f2
Move the filenameproperty factory from treepkg/packager.py to
Bernhard Herzog <bh@intevation.de>
parents:
168
diff
changeset
|
267 src_dir = util.filenameproperty("src") |
06af36f915f2
Move the filenameproperty factory from treepkg/packager.py to
Bernhard Herzog <bh@intevation.de>
parents:
168
diff
changeset
|
268 build_log = util.filenameproperty("build_log.txt", dir_attr="log_dir") |
0 | 269 |
270 def find_dsc_file(self): | |
271 for filename in os.listdir(self.src_dir): | |
272 if filename.endswith(".dsc"): | |
273 return os.path.join(self.src_dir, filename) | |
274 return None | |
275 | |
18
d5c24cfce05e
Improve access to a RevisionPackager's build_log
Bernhard Herzog <bh@intevation.de>
parents:
16
diff
changeset
|
276 def has_build_log(self): |
d5c24cfce05e
Improve access to a RevisionPackager's build_log
Bernhard Herzog <bh@intevation.de>
parents:
16
diff
changeset
|
277 return os.path.exists(self.build_log) |
d5c24cfce05e
Improve access to a RevisionPackager's build_log
Bernhard Herzog <bh@intevation.de>
parents:
16
diff
changeset
|
278 |
140
0da76aee8035
Add RevisionPackager method list_log_files which returns a description
Bernhard Herzog <bh@intevation.de>
parents:
139
diff
changeset
|
279 def list_log_files(self): |
0da76aee8035
Add RevisionPackager method list_log_files which returns a description
Bernhard Herzog <bh@intevation.de>
parents:
139
diff
changeset
|
280 """Returns a list describing the logfiles available for the revision. |
0da76aee8035
Add RevisionPackager method list_log_files which returns a description
Bernhard Herzog <bh@intevation.de>
parents:
139
diff
changeset
|
281 Each list item is a tuple of the form (TITLE, FILENAME) where |
0da76aee8035
Add RevisionPackager method list_log_files which returns a description
Bernhard Herzog <bh@intevation.de>
parents:
139
diff
changeset
|
282 TITLE is a string with a title usable in e. g. a web-page, and |
0da76aee8035
Add RevisionPackager method list_log_files which returns a description
Bernhard Herzog <bh@intevation.de>
parents:
139
diff
changeset
|
283 FILENAME is the absolute filename of the log file. |
0da76aee8035
Add RevisionPackager method list_log_files which returns a description
Bernhard Herzog <bh@intevation.de>
parents:
139
diff
changeset
|
284 """ |
0da76aee8035
Add RevisionPackager method list_log_files which returns a description
Bernhard Herzog <bh@intevation.de>
parents:
139
diff
changeset
|
285 files = [] |
0da76aee8035
Add RevisionPackager method list_log_files which returns a description
Bernhard Herzog <bh@intevation.de>
parents:
139
diff
changeset
|
286 if self.has_build_log(): |
0da76aee8035
Add RevisionPackager method list_log_files which returns a description
Bernhard Herzog <bh@intevation.de>
parents:
139
diff
changeset
|
287 files.append(("build log", self.build_log)) |
0da76aee8035
Add RevisionPackager method list_log_files which returns a description
Bernhard Herzog <bh@intevation.de>
parents:
139
diff
changeset
|
288 return files |
0da76aee8035
Add RevisionPackager method list_log_files which returns a description
Bernhard Herzog <bh@intevation.de>
parents:
139
diff
changeset
|
289 |
88
3ae54f99db26
Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents:
85
diff
changeset
|
290 def list_source_files(self): |
3ae54f99db26
Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents:
85
diff
changeset
|
291 """Returns a list with the names of the files of the source package. |
3ae54f99db26
Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents:
85
diff
changeset
|
292 The implementation assumes that all files in self.src_dir belong |
3ae54f99db26
Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents:
85
diff
changeset
|
293 to the source package. |
3ae54f99db26
Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents:
85
diff
changeset
|
294 """ |
3ae54f99db26
Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents:
85
diff
changeset
|
295 return sorted(util.listdir_abs(self.src_dir)) |
3ae54f99db26
Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents:
85
diff
changeset
|
296 |
3ae54f99db26
Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents:
85
diff
changeset
|
297 def list_binary_files(self): |
3ae54f99db26
Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents:
85
diff
changeset
|
298 """Returns a list with the names of the files of the binary packages. |
3ae54f99db26
Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents:
85
diff
changeset
|
299 The implementation assumes that all files in self.binary_dir belong |
3ae54f99db26
Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents:
85
diff
changeset
|
300 to the binary packages. |
3ae54f99db26
Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents:
85
diff
changeset
|
301 """ |
3ae54f99db26
Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents:
85
diff
changeset
|
302 return sorted(util.listdir_abs(self.binary_dir)) |
3ae54f99db26
Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents:
85
diff
changeset
|
303 |
0 | 304 def package(self): |
305 try: | |
16
7c55f3879c4d
Use the new status class and report start/stop time too
Bernhard Herzog <bh@intevation.de>
parents:
14
diff
changeset
|
306 util.ensure_directory(self.work_dir) |
7c55f3879c4d
Use the new status class and report start/stop time too
Bernhard Herzog <bh@intevation.de>
parents:
14
diff
changeset
|
307 self.status.start = datetime.datetime.utcnow() |
135
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
308 src_packager = self.source_packager_cls(self) |
0 | 309 src_packager.package() |
310 | |
311 dsc_file = self.find_dsc_file() | |
312 if dsc_file is None: | |
313 raise RuntimeError("Cannot find dsc File in %r" % self.src_dir) | |
314 | |
135
e5b4dea52297
Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents:
131
diff
changeset
|
315 bin_packager = self.binary_packager_cls(self, dsc_file, |
18
d5c24cfce05e
Improve access to a RevisionPackager's build_log
Bernhard Herzog <bh@intevation.de>
parents:
16
diff
changeset
|
316 self.build_log) |
0 | 317 bin_packager.package() |
16
7c55f3879c4d
Use the new status class and report start/stop time too
Bernhard Herzog <bh@intevation.de>
parents:
14
diff
changeset
|
318 self.status.stop = datetime.datetime.utcnow() |
0 | 319 except: |
41
f7ec40638a06
use the enums for the status field of RevisionStatus
Bernhard Herzog <bh@intevation.de>
parents:
36
diff
changeset
|
320 self.status.error() |
16
7c55f3879c4d
Use the new status class and report start/stop time too
Bernhard Herzog <bh@intevation.de>
parents:
14
diff
changeset
|
321 self.status.stop = datetime.datetime.utcnow() |
99
7888fe374e11
Add support for notification mails in case of build errors
Bernhard Herzog <bh@intevation.de>
parents:
98
diff
changeset
|
322 # set the notification status last to avoid race conditions. |
7888fe374e11
Add support for notification mails in case of build errors
Bernhard Herzog <bh@intevation.de>
parents:
98
diff
changeset
|
323 # The pending notification is for now the only situation |
7888fe374e11
Add support for notification mails in case of build errors
Bernhard Herzog <bh@intevation.de>
parents:
98
diff
changeset
|
324 # where another process might modify the status file (the |
7888fe374e11
Add support for notification mails in case of build errors
Bernhard Herzog <bh@intevation.de>
parents:
98
diff
changeset
|
325 # listpendingnotifications program will set it to |
7888fe374e11
Add support for notification mails in case of build errors
Bernhard Herzog <bh@intevation.de>
parents:
98
diff
changeset
|
326 # "notification_sent") |
7888fe374e11
Add support for notification mails in case of build errors
Bernhard Herzog <bh@intevation.de>
parents:
98
diff
changeset
|
327 self.status.notification_pending() |
0 | 328 raise |
329 | |
330 def remove_package_dir(self): | |
331 logging.info("Removing pkgdir %r", self.base_dir) | |
332 shutil.rmtree(self.base_dir) | |
333 | |
334 | |
52
78cf5f6778ec
Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents:
49
diff
changeset
|
335 class PackageTrack(object): |
0 | 336 |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
337 revision_packager_cls = RevisionPackager |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
338 |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
339 svn_external_subdirs = [] |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
340 |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
341 extra_config_desc = [] |
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
342 |
47
2802be410156
add config options pbuilderrc and use it when calling pbuilder
Bernhard Herzog <bh@intevation.de>
parents:
16
diff
changeset
|
343 def __init__(self, name, base_dir, svn_url, root_cmd, pbuilderrc, deb_email, |
93
73c67372c7f7
Make the prefix used in the debian revision number configurable.
Bernhard Herzog <bh@intevation.de>
parents:
91
diff
changeset
|
344 deb_fullname, packager_class="treepkg.packager", |
305
3781e9958eba
Add per-track configuration option version_template used by the
Bernhard Herzog <bh@intevation.de>
parents:
304
diff
changeset
|
345 version_template="%(revision)s", |
293
faeeac2c4c71
Replace debrevision_prefix with pkg_revision_template. Their meaning is
Bernhard Herzog <bh@intevation.de>
parents:
281
diff
changeset
|
346 pkg_revision_template="treepkg%(pkg_revision)d", |
faeeac2c4c71
Replace debrevision_prefix with pkg_revision_template. Their meaning is
Bernhard Herzog <bh@intevation.de>
parents:
281
diff
changeset
|
347 handle_dependencies=False, signing_key_id="", do_build=True, |
300
e82fb08781a2
Turn the SourcePackager class attribute changemsg_template into a
Bernhard Herzog <bh@intevation.de>
parents:
299
diff
changeset
|
348 rules_svn_url=None, deb_build_options="", pkg_basename="", |
304
6cffb43a28ca
Add a way to specify svn subset checkouts where only parts of a source
Bernhard Herzog <bh@intevation.de>
parents:
300
diff
changeset
|
349 changelog_msg_template="Update to r%(revision)s", |
306
163f0d8b64eb
Make the svn external subdirectories configurable in the configuration
Bernhard Herzog <bh@intevation.de>
parents:
305
diff
changeset
|
350 svn_subset=(), svn_externals=()): |
0 | 351 self.name = name |
299
c32dc72ba979
Turn the SourcePackager class attribute pkg_basename into a per-track
Bernhard Herzog <bh@intevation.de>
parents:
297
diff
changeset
|
352 if not pkg_basename: |
c32dc72ba979
Turn the SourcePackager class attribute pkg_basename into a per-track
Bernhard Herzog <bh@intevation.de>
parents:
297
diff
changeset
|
353 pkg_basename = name |
c32dc72ba979
Turn the SourcePackager class attribute pkg_basename into a per-track
Bernhard Herzog <bh@intevation.de>
parents:
297
diff
changeset
|
354 self.pkg_basename = pkg_basename |
300
e82fb08781a2
Turn the SourcePackager class attribute changemsg_template into a
Bernhard Herzog <bh@intevation.de>
parents:
299
diff
changeset
|
355 self.changelog_msg_template = changelog_msg_template |
0 | 356 self.base_dir = base_dir |
176
7bde59aa611e
Make PBuilder.update_extra_pkg_dir create Release and Release.gpg files
Bernhard Herzog <bh@intevation.de>
parents:
172
diff
changeset
|
357 self.builder = PBuilder(pbuilderrc, root_cmd, |
7bde59aa611e
Make PBuilder.update_extra_pkg_dir create Release and Release.gpg files
Bernhard Herzog <bh@intevation.de>
parents:
172
diff
changeset
|
358 release_signing_keyid=signing_key_id) |
0 | 359 self.deb_email = deb_email |
360 self.deb_fullname = deb_fullname | |
297
4dd6ec3a1151
Make it possible to use parallel builds for packages that support it:
Bernhard Herzog <bh@intevation.de>
parents:
293
diff
changeset
|
361 self.deb_build_options = deb_build_options |
305
3781e9958eba
Add per-track configuration option version_template used by the
Bernhard Herzog <bh@intevation.de>
parents:
304
diff
changeset
|
362 self.version_template = version_template |
293
faeeac2c4c71
Replace debrevision_prefix with pkg_revision_template. Their meaning is
Bernhard Herzog <bh@intevation.de>
parents:
281
diff
changeset
|
363 self.pkg_revision_template = pkg_revision_template |
167
36004ee0b3a1
Introduce package track config option signing_key_id to specify the
Bernhard Herzog <bh@intevation.de>
parents:
149
diff
changeset
|
364 self.signing_key_id = signing_key_id |
191
94fb3f3ab58b
When building a subset of tracks, make sure new packages are added to
Bernhard Herzog <bh@intevation.de>
parents:
190
diff
changeset
|
365 self.do_build = do_build |
128
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
366 self.handle_dependencies = handle_dependencies |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
367 self.dependencies = None |
229
653a45adda50
Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents:
224
diff
changeset
|
368 self.pkg_dir_template = "%(revision)d-%(rules_revision)d" |
653a45adda50
Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents:
224
diff
changeset
|
369 self.pkg_dir_regex = re.compile(r"(?P<revision>[0-9]+)" |
653a45adda50
Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents:
224
diff
changeset
|
370 r"-(?P<rules_revision>[0-9]+)$") |
306
163f0d8b64eb
Make the svn external subdirectories configurable in the configuration
Bernhard Herzog <bh@intevation.de>
parents:
305
diff
changeset
|
371 externals = svn_externals |
163f0d8b64eb
Make the svn external subdirectories configurable in the configuration
Bernhard Herzog <bh@intevation.de>
parents:
305
diff
changeset
|
372 if not externals: |
163f0d8b64eb
Make the svn external subdirectories configurable in the configuration
Bernhard Herzog <bh@intevation.de>
parents:
305
diff
changeset
|
373 externals = self.svn_external_subdirs |
163f0d8b64eb
Make the svn external subdirectories configurable in the configuration
Bernhard Herzog <bh@intevation.de>
parents:
305
diff
changeset
|
374 repo = SvnRepository(svn_url, externals, subset=svn_subset) |
224
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
222
diff
changeset
|
375 self.working_copy = SvnWorkingCopy(repo, self.checkout_dir, |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
222
diff
changeset
|
376 logger=logging) |
234
eaa696629a91
Add a way to specify the svn URL of the repository with the debian rules
Bernhard Herzog <bh@intevation.de>
parents:
232
diff
changeset
|
377 if rules_svn_url: |
eaa696629a91
Add a way to specify the svn URL of the repository with the debian rules
Bernhard Herzog <bh@intevation.de>
parents:
232
diff
changeset
|
378 repo = SvnRepository(rules_svn_url) |
eaa696629a91
Add a way to specify the svn URL of the repository with the debian rules
Bernhard Herzog <bh@intevation.de>
parents:
232
diff
changeset
|
379 self.rules_working_copy = SvnWorkingCopy(repo, self.debian_dir, |
eaa696629a91
Add a way to specify the svn URL of the repository with the debian rules
Bernhard Herzog <bh@intevation.de>
parents:
232
diff
changeset
|
380 logger=logging) |
eaa696629a91
Add a way to specify the svn URL of the repository with the debian rules
Bernhard Herzog <bh@intevation.de>
parents:
232
diff
changeset
|
381 else: |
eaa696629a91
Add a way to specify the svn URL of the repository with the debian rules
Bernhard Herzog <bh@intevation.de>
parents:
232
diff
changeset
|
382 self.rules_working_copy = ManualWorkingCopy(self.debian_dir) |
0 | 383 |
172
06af36f915f2
Move the filenameproperty factory from treepkg/packager.py to
Bernhard Herzog <bh@intevation.de>
parents:
168
diff
changeset
|
384 checkout_dir = util.filenameproperty("checkout") |
06af36f915f2
Move the filenameproperty factory from treepkg/packager.py to
Bernhard Herzog <bh@intevation.de>
parents:
168
diff
changeset
|
385 debian_dir = util.filenameproperty("debian") |
06af36f915f2
Move the filenameproperty factory from treepkg/packager.py to
Bernhard Herzog <bh@intevation.de>
parents:
168
diff
changeset
|
386 pkg_dir = util.filenameproperty("pkg") |
0 | 387 |
106
66cbfc772f84
Add bin/inittreepkg.py, a script to automate some of the installation
Bernhard Herzog <bh@intevation.de>
parents:
99
diff
changeset
|
388 def init_treepkg(self): |
66cbfc772f84
Add bin/inittreepkg.py, a script to automate some of the installation
Bernhard Herzog <bh@intevation.de>
parents:
99
diff
changeset
|
389 print "Initializing", self.name |
66cbfc772f84
Add bin/inittreepkg.py, a script to automate some of the installation
Bernhard Herzog <bh@intevation.de>
parents:
99
diff
changeset
|
390 if not os.path.exists(self.base_dir): |
66cbfc772f84
Add bin/inittreepkg.py, a script to automate some of the installation
Bernhard Herzog <bh@intevation.de>
parents:
99
diff
changeset
|
391 print "creating %s" % (self.base_dir,) |
66cbfc772f84
Add bin/inittreepkg.py, a script to automate some of the installation
Bernhard Herzog <bh@intevation.de>
parents:
99
diff
changeset
|
392 util.ensure_directory(self.base_dir) |
234
eaa696629a91
Add a way to specify the svn URL of the repository with the debian rules
Bernhard Herzog <bh@intevation.de>
parents:
232
diff
changeset
|
393 # TODO: handle case where debian directory is in version control |
106
66cbfc772f84
Add bin/inittreepkg.py, a script to automate some of the installation
Bernhard Herzog <bh@intevation.de>
parents:
99
diff
changeset
|
394 if not os.path.exists(self.debian_dir): |
66cbfc772f84
Add bin/inittreepkg.py, a script to automate some of the installation
Bernhard Herzog <bh@intevation.de>
parents:
99
diff
changeset
|
395 print ("TODO: the debian directory %s still has to be created" |
66cbfc772f84
Add bin/inittreepkg.py, a script to automate some of the installation
Bernhard Herzog <bh@intevation.de>
parents:
99
diff
changeset
|
396 % (self.debian_dir,)) |
66cbfc772f84
Add bin/inittreepkg.py, a script to automate some of the installation
Bernhard Herzog <bh@intevation.de>
parents:
99
diff
changeset
|
397 |
128
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
398 def determine_dependencies(self): |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
399 if self.dependencies is not None: |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
400 return |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
401 |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
402 requires = () |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
403 provides = () |
131
bea9f1cc0bef
Try to determine dependencies only when treepkg is fully configured.
Bernhard Herzog <bh@intevation.de>
parents:
128
diff
changeset
|
404 # only try to parse the control file if the debian directory |
bea9f1cc0bef
Try to determine dependencies only when treepkg is fully configured.
Bernhard Herzog <bh@intevation.de>
parents:
128
diff
changeset
|
405 # exists. If the debian directory doesn't exist yet, the tree |
bea9f1cc0bef
Try to determine dependencies only when treepkg is fully configured.
Bernhard Herzog <bh@intevation.de>
parents:
128
diff
changeset
|
406 # packager is likely still being configured and this code may be |
bea9f1cc0bef
Try to determine dependencies only when treepkg is fully configured.
Bernhard Herzog <bh@intevation.de>
parents:
128
diff
changeset
|
407 # run indirectly from e. g. bin/inittreepkg.py in which case the |
bea9f1cc0bef
Try to determine dependencies only when treepkg is fully configured.
Bernhard Herzog <bh@intevation.de>
parents:
128
diff
changeset
|
408 # init_treepkg method will report the missing debian |
bea9f1cc0bef
Try to determine dependencies only when treepkg is fully configured.
Bernhard Herzog <bh@intevation.de>
parents:
128
diff
changeset
|
409 if self.handle_dependencies and os.path.exists(self.debian_dir): |
128
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
410 control = debian.DebianControlFile(os.path.join(self.debian_dir, |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
411 "control")) |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
412 requires = control.build_depends |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
413 provides = (pkg[0] for pkg in control.packages) |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
414 self.dependencies = (set(requires), set(provides)) |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
415 logging.debug("Track %s: build depends: %s", self.name, |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
416 " ".join(self.dependencies[0])) |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
417 logging.debug("Track %s: provides: %s", self.name, |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
418 " ".join(self.dependencies[1])) |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
419 |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
420 def dependencies_required(self): |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
421 """Returns a list of required packages""" |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
422 self.determine_dependencies() |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
423 return self.dependencies[0] |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
424 |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
425 def dependencies_provided(self): |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
426 """Returns a list of provided packages""" |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
427 self.determine_dependencies() |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
428 return self.dependencies[1] |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
429 |
229
653a45adda50
Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents:
224
diff
changeset
|
430 def pkg_dir_for_revision(self, revision, rules_revision): |
0 | 431 return os.path.join(self.pkg_dir, |
432 self.pkg_dir_template % locals()) | |
433 | |
434 def last_changed_revision(self): | |
224
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
222
diff
changeset
|
435 return self.working_copy.last_changed_revision() |
0 | 436 |
11
6efe0bd3d8c1
Add method RevisionPackager.get_revision_numbers
Bernhard Herzog <bh@intevation.de>
parents:
10
diff
changeset
|
437 def get_revision_numbers(self): |
6efe0bd3d8c1
Add method RevisionPackager.get_revision_numbers
Bernhard Herzog <bh@intevation.de>
parents:
10
diff
changeset
|
438 """Returns a list of the numbers of the packaged revisions""" |
6efe0bd3d8c1
Add method RevisionPackager.get_revision_numbers
Bernhard Herzog <bh@intevation.de>
parents:
10
diff
changeset
|
439 revisions = [] |
6efe0bd3d8c1
Add method RevisionPackager.get_revision_numbers
Bernhard Herzog <bh@intevation.de>
parents:
10
diff
changeset
|
440 if os.path.exists(self.pkg_dir): |
6efe0bd3d8c1
Add method RevisionPackager.get_revision_numbers
Bernhard Herzog <bh@intevation.de>
parents:
10
diff
changeset
|
441 for filename in os.listdir(self.pkg_dir): |
6efe0bd3d8c1
Add method RevisionPackager.get_revision_numbers
Bernhard Herzog <bh@intevation.de>
parents:
10
diff
changeset
|
442 match = self.pkg_dir_regex.match(filename) |
6efe0bd3d8c1
Add method RevisionPackager.get_revision_numbers
Bernhard Herzog <bh@intevation.de>
parents:
10
diff
changeset
|
443 if match: |
229
653a45adda50
Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents:
224
diff
changeset
|
444 revisions.append((int(match.group("revision")), |
653a45adda50
Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents:
224
diff
changeset
|
445 int(match.group("rules_revision")))) |
85
31b0567df051
Make PackageTrack.get_revision_numbers return the revisions as a sorted
Bernhard Herzog <bh@intevation.de>
parents:
84
diff
changeset
|
446 revisions.sort() |
11
6efe0bd3d8c1
Add method RevisionPackager.get_revision_numbers
Bernhard Herzog <bh@intevation.de>
parents:
10
diff
changeset
|
447 return revisions |
6efe0bd3d8c1
Add method RevisionPackager.get_revision_numbers
Bernhard Herzog <bh@intevation.de>
parents:
10
diff
changeset
|
448 |
80
0af2fa3790e0
Add revision parameter to PackagerGroup.__init__ and some other methods
Bernhard Herzog <bh@intevation.de>
parents:
78
diff
changeset
|
449 def update_checkout(self, revision=None): |
224
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
222
diff
changeset
|
450 """Updates the working copy. |
0 | 451 |
224
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
222
diff
changeset
|
452 If the checkout_dir doesn't exist yet, a new checkout is made |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
222
diff
changeset
|
453 into that directory. The value of the revision parameter is |
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
222
diff
changeset
|
454 passed through to the update method. |
0 | 455 """ |
224
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
222
diff
changeset
|
456 self.working_copy.update_or_checkout(revision=revision) |
0 | 457 |
458 def export_sources(self, to_dir): | |
459 logging.info("Exporting sources for tarball to %r", to_dir) | |
224
6bac65dcf258
Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents:
222
diff
changeset
|
460 self.working_copy.export(to_dir) |
0 | 461 |
462 def copy_debian_directory(self, to_dir): | |
463 logging.info("Copying debian directory to %r", to_dir) | |
231
7dbf0a3443bb
Use treepkg.subversion.ManualWorkingCopy for the debian directory in a
Bernhard Herzog <bh@intevation.de>
parents:
229
diff
changeset
|
464 self.rules_working_copy.export(to_dir) |
0 | 465 |
466 def debian_environment(self): | |
467 """Returns the environment variables for the debian commands""" | |
468 env = os.environ.copy() | |
469 env["DEBFULLNAME"] = self.deb_fullname | |
470 env["DEBEMAIL"] = self.deb_email | |
297
4dd6ec3a1151
Make it possible to use parallel builds for packages that support it:
Bernhard Herzog <bh@intevation.de>
parents:
293
diff
changeset
|
471 env["DEB_BUILD_OPTIONS"] = self.deb_build_options |
4dd6ec3a1151
Make it possible to use parallel builds for packages that support it:
Bernhard Herzog <bh@intevation.de>
parents:
293
diff
changeset
|
472 # cdbs requires DEB_BUILD_PARALLEL set to something non-empty, |
4dd6ec3a1151
Make it possible to use parallel builds for packages that support it:
Bernhard Herzog <bh@intevation.de>
parents:
293
diff
changeset
|
473 # otherwise it will ignore any parallel=<n> setting in |
4dd6ec3a1151
Make it possible to use parallel builds for packages that support it:
Bernhard Herzog <bh@intevation.de>
parents:
293
diff
changeset
|
474 # DEB_BUILD_OPTIONS. |
4dd6ec3a1151
Make it possible to use parallel builds for packages that support it:
Bernhard Herzog <bh@intevation.de>
parents:
293
diff
changeset
|
475 env["DEB_BUILD_PARALLEL"] = "true" |
0 | 476 return env |
477 | |
261
e574b03a2957
Move the code that creates the builder for a new revision to a separate method.
Bernhard Herzog <bh@intevation.de>
parents:
260
diff
changeset
|
478 def packager_for_new_revision(self): |
e574b03a2957
Move the code that creates the builder for a new revision to a separate method.
Bernhard Herzog <bh@intevation.de>
parents:
260
diff
changeset
|
479 current_revision = (self.last_changed_revision(), |
e574b03a2957
Move the code that creates the builder for a new revision to a separate method.
Bernhard Herzog <bh@intevation.de>
parents:
260
diff
changeset
|
480 self.rules_working_copy.last_changed_revision()) |
e574b03a2957
Move the code that creates the builder for a new revision to a separate method.
Bernhard Herzog <bh@intevation.de>
parents:
260
diff
changeset
|
481 logging.info("New revision is %s", current_revision) |
e574b03a2957
Move the code that creates the builder for a new revision to a separate method.
Bernhard Herzog <bh@intevation.de>
parents:
260
diff
changeset
|
482 if current_revision not in self.get_revision_numbers(): |
e574b03a2957
Move the code that creates the builder for a new revision to a separate method.
Bernhard Herzog <bh@intevation.de>
parents:
260
diff
changeset
|
483 logging.info("Revision %s has not been packaged yet", |
e574b03a2957
Move the code that creates the builder for a new revision to a separate method.
Bernhard Herzog <bh@intevation.de>
parents:
260
diff
changeset
|
484 current_revision) |
e574b03a2957
Move the code that creates the builder for a new revision to a separate method.
Bernhard Herzog <bh@intevation.de>
parents:
260
diff
changeset
|
485 return self.revision_packager_cls(self, *current_revision) |
e574b03a2957
Move the code that creates the builder for a new revision to a separate method.
Bernhard Herzog <bh@intevation.de>
parents:
260
diff
changeset
|
486 else: |
e574b03a2957
Move the code that creates the builder for a new revision to a separate method.
Bernhard Herzog <bh@intevation.de>
parents:
260
diff
changeset
|
487 logging.info("Revision %s has already been packaged.", |
e574b03a2957
Move the code that creates the builder for a new revision to a separate method.
Bernhard Herzog <bh@intevation.de>
parents:
260
diff
changeset
|
488 current_revision) |
e574b03a2957
Move the code that creates the builder for a new revision to a separate method.
Bernhard Herzog <bh@intevation.de>
parents:
260
diff
changeset
|
489 |
190
e83db4482aab
Add runtreepkg.py command line option --no-svn-update to inhibit updates
Bernhard Herzog <bh@intevation.de>
parents:
179
diff
changeset
|
490 def package_if_updated(self, revision=None, do_svn_update=True): |
e83db4482aab
Add runtreepkg.py command line option --no-svn-update to inhibit updates
Bernhard Herzog <bh@intevation.de>
parents:
179
diff
changeset
|
491 """Returns a new packager if the working copy has not been packaged yet. |
e83db4482aab
Add runtreepkg.py command line option --no-svn-update to inhibit updates
Bernhard Herzog <bh@intevation.de>
parents:
179
diff
changeset
|
492 If do_svn_update is true -- the default -- update the working |
e83db4482aab
Add runtreepkg.py command line option --no-svn-update to inhibit updates
Bernhard Herzog <bh@intevation.de>
parents:
179
diff
changeset
|
493 copy to the the revision specified with the revision parameter |
e83db4482aab
Add runtreepkg.py command line option --no-svn-update to inhibit updates
Bernhard Herzog <bh@intevation.de>
parents:
179
diff
changeset
|
494 or if revision is None, the latest revision in the repository.""" |
191
94fb3f3ab58b
When building a subset of tracks, make sure new packages are added to
Bernhard Herzog <bh@intevation.de>
parents:
190
diff
changeset
|
495 if not self.do_build: |
94fb3f3ab58b
When building a subset of tracks, make sure new packages are added to
Bernhard Herzog <bh@intevation.de>
parents:
190
diff
changeset
|
496 return None |
190
e83db4482aab
Add runtreepkg.py command line option --no-svn-update to inhibit updates
Bernhard Herzog <bh@intevation.de>
parents:
179
diff
changeset
|
497 if do_svn_update: |
e83db4482aab
Add runtreepkg.py command line option --no-svn-update to inhibit updates
Bernhard Herzog <bh@intevation.de>
parents:
179
diff
changeset
|
498 self.update_checkout(revision=revision) |
232
e3cda08d2619
When checking whether to build a new revision, also update the rules
Bernhard Herzog <bh@intevation.de>
parents:
231
diff
changeset
|
499 # TODO: what should happen with the debian checkout, if a |
e3cda08d2619
When checking whether to build a new revision, also update the rules
Bernhard Herzog <bh@intevation.de>
parents:
231
diff
changeset
|
500 # revision for the source checkoute was given? |
e3cda08d2619
When checking whether to build a new revision, also update the rules
Bernhard Herzog <bh@intevation.de>
parents:
231
diff
changeset
|
501 self.rules_working_copy.update_or_checkout() |
261
e574b03a2957
Move the code that creates the builder for a new revision to a separate method.
Bernhard Herzog <bh@intevation.de>
parents:
260
diff
changeset
|
502 return self.packager_for_new_revision() |
0 | 503 |
14
dfd89f81e66c
Add simple status report tool. Still using the old status files
Bernhard Herzog <bh@intevation.de>
parents:
11
diff
changeset
|
504 def get_revisions(self): |
dfd89f81e66c
Add simple status report tool. Still using the old status files
Bernhard Herzog <bh@intevation.de>
parents:
11
diff
changeset
|
505 """Returns RevisionPackager objects for each packaged revision""" |
229
653a45adda50
Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents:
224
diff
changeset
|
506 return [self.revision_packager_cls(self, revision, rules_revision) |
653a45adda50
Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents:
224
diff
changeset
|
507 for revision, rules_revision in self.get_revision_numbers()] |
14
dfd89f81e66c
Add simple status report tool. Still using the old status files
Bernhard Herzog <bh@intevation.de>
parents:
11
diff
changeset
|
508 |
179
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
509 def sign_file(self, filename): |
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
510 """Signs a file using the debian.sign_file function. |
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
511 The file is signed with the key indicated by the track's |
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
512 signing_key_id attribute. If that is empty, the file is not |
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
513 signed. |
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
514 """ |
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
515 if self.signing_key_id: |
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
516 logging.info("Signing %r with key %r", filename, |
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
517 self.signing_key_id) |
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
518 debian.sign_file(filename, self.signing_key_id) |
952d366f7b14
Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents:
176
diff
changeset
|
519 |
0 | 520 |
113
312949e7628d
Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents:
112
diff
changeset
|
521 def import_packager_module(packager_class): |
312949e7628d
Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents:
112
diff
changeset
|
522 """Import the packager module named by packager_class. |
312949e7628d
Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents:
112
diff
changeset
|
523 |
312949e7628d
Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents:
112
diff
changeset
|
524 The packager_class must be the full absolute module name for the |
125
34e08d52956e
Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents:
113
diff
changeset
|
525 packager. The function tries to find or create a suitable |
34e08d52956e
Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents:
113
diff
changeset
|
526 PackageTrack class from this module using the following rules: |
34e08d52956e
Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents:
113
diff
changeset
|
527 |
34e08d52956e
Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents:
113
diff
changeset
|
528 - If the module contains a class called PackageTrack, use that. |
34e08d52956e
Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents:
113
diff
changeset
|
529 |
34e08d52956e
Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents:
113
diff
changeset
|
530 - Otherwise create one using the module's RevisionPackager class, |
34e08d52956e
Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents:
113
diff
changeset
|
531 creating RevisionPackager if necessary. |
34e08d52956e
Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents:
113
diff
changeset
|
532 |
34e08d52956e
Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents:
113
diff
changeset
|
533 - If RevisionPackager needs to be created, it uses the module's |
34e08d52956e
Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents:
113
diff
changeset
|
534 SourcePackager as source_packager_cls and if present also the |
34e08d52956e
Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents:
113
diff
changeset
|
535 module's BinaryPackager as binary_packager_cls. If the module |
34e08d52956e
Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents:
113
diff
changeset
|
536 does not have a BinaryPackager, the default BinaryPackager is |
34e08d52956e
Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents:
113
diff
changeset
|
537 used. |
113
312949e7628d
Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents:
112
diff
changeset
|
538 """ |
312949e7628d
Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents:
112
diff
changeset
|
539 module = util.import_dotted_name(packager_class) |
312949e7628d
Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents:
112
diff
changeset
|
540 if not hasattr(module, "PackageTrack"): |
125
34e08d52956e
Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents:
113
diff
changeset
|
541 if not hasattr(module, "RevisionPackager"): |
34e08d52956e
Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents:
113
diff
changeset
|
542 binary_packager = getattr(module, "BinaryPackager", BinaryPackager) |
34e08d52956e
Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents:
113
diff
changeset
|
543 module.RevisionPackager \ |
34e08d52956e
Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents:
113
diff
changeset
|
544 = new.classobj("RevisionPackager", (RevisionPackager,), |
34e08d52956e
Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents:
113
diff
changeset
|
545 dict(source_packager_cls=module.SourcePackager, |
34e08d52956e
Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents:
113
diff
changeset
|
546 binary_packager_cls=binary_packager)) |
113
312949e7628d
Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents:
112
diff
changeset
|
547 module.PackageTrack \ |
312949e7628d
Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents:
112
diff
changeset
|
548 = new.classobj("PackageTrack", (PackageTrack,), |
312949e7628d
Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents:
112
diff
changeset
|
549 dict(revision_packager_cls=module.RevisionPackager)) |
312949e7628d
Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents:
112
diff
changeset
|
550 return module |
312949e7628d
Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents:
112
diff
changeset
|
551 |
52
78cf5f6778ec
Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents:
49
diff
changeset
|
552 def create_package_track(packager_class, **kw): |
113
312949e7628d
Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents:
112
diff
changeset
|
553 module = import_packager_module(packager_class) |
52
78cf5f6778ec
Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents:
49
diff
changeset
|
554 return module.PackageTrack(**kw) |
4
fee641fec94e
Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
2
diff
changeset
|
555 |
0 | 556 |
128
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
557 class CyclicDependencyError(Exception): |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
558 |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
559 """Exception thrown when a cycle is detected in the track dependencies""" |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
560 |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
561 def __init__(self, tracks): |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
562 Exception.__init__(self, |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
563 "Cyclic dependencies between" " tracks (%s)" |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
564 % ", ".join([track.name for track in tracks])) |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
565 |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
566 |
7
96f4f58c62b5
Rename the Packager class to PackagerGroup
Bernhard Herzog <bh@intevation.de>
parents:
4
diff
changeset
|
567 class PackagerGroup(object): |
0 | 568 |
91
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
569 def __init__(self, package_tracks, check_interval, revision=None, |
307
5f442b0cf3a4
New command line argument --stop-on-error for runtreepkg.py and
Bernhard Herzog <bh@intevation.de>
parents:
306
diff
changeset
|
570 instructions_file=None, do_svn_update=True, |
5f442b0cf3a4
New command line argument --stop-on-error for runtreepkg.py and
Bernhard Herzog <bh@intevation.de>
parents:
306
diff
changeset
|
571 stop_on_error=False): |
52
78cf5f6778ec
Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents:
49
diff
changeset
|
572 self.package_tracks = package_tracks |
0 | 573 self.check_interval = check_interval |
80
0af2fa3790e0
Add revision parameter to PackagerGroup.__init__ and some other methods
Bernhard Herzog <bh@intevation.de>
parents:
78
diff
changeset
|
574 self.revision = revision |
190
e83db4482aab
Add runtreepkg.py command line option --no-svn-update to inhibit updates
Bernhard Herzog <bh@intevation.de>
parents:
179
diff
changeset
|
575 self.do_svn_update = do_svn_update |
307
5f442b0cf3a4
New command line argument --stop-on-error for runtreepkg.py and
Bernhard Herzog <bh@intevation.de>
parents:
306
diff
changeset
|
576 self.stop_on_error = stop_on_error |
91
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
577 self.instructions_file = instructions_file |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
578 self.instructions_file_removed = False |
128
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
579 self.sort_tracks() |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
580 |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
581 def sort_tracks(self): |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
582 """Sorts tracks for dependency handling""" |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
583 todo = self.package_tracks[:] |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
584 sorted = [] |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
585 seen = set() |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
586 |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
587 # dependencies that can be solved by one of the tracks |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
588 known = set() |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
589 for track in todo: |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
590 known |= track.dependencies_provided() |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
591 |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
592 while todo: |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
593 todo_again = [] |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
594 for track in todo: |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
595 if not track.handle_dependencies: |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
596 sorted.append(track) |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
597 continue |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
598 |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
599 unmet = (track.dependencies_required() & known) - seen |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
600 if unmet: |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
601 todo_again.append(track) |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
602 else: |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
603 sorted.append(track) |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
604 seen |= track.dependencies_provided() |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
605 if todo_again == todo: |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
606 raise CyclicDependencyError(todo) |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
607 todo = todo_again |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
608 |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
609 self.package_tracks = sorted |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
610 self.needed_binaries = set() |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
611 for track in self.package_tracks: |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
612 self.needed_binaries |= track.dependencies_required() |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
613 self.needed_binaries &= known |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
614 |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
615 logging.info("sorted track order: %s", |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
616 " ".join(track.name for track in sorted)) |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
617 logging.info("binary packages needed as build dependencies: %s", |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
618 " ".join(self.needed_binaries)) |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
619 |
0 | 620 |
621 def run(self): | |
7
96f4f58c62b5
Rename the Packager class to PackagerGroup
Bernhard Herzog <bh@intevation.de>
parents:
4
diff
changeset
|
622 """Runs the packager group indefinitely""" |
78
9a602d8eaa60
initial revision of the subversion repository
Thomas Arendsen Hein <thomas@intevation.de>
parents:
55
diff
changeset
|
623 logging.info("Starting in periodic check mode." |
9a602d8eaa60
initial revision of the subversion repository
Thomas Arendsen Hein <thomas@intevation.de>
parents:
55
diff
changeset
|
624 " Will check every %d seconds", self.check_interval) |
0 | 625 last_check = -1 |
626 while 1: | |
627 now = time.time() | |
628 if now > last_check + self.check_interval: | |
91
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
629 if self.check_package_tracks(): |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
630 break |
0 | 631 last_check = now |
632 next_check = now + self.check_interval | |
633 to_sleep = next_check - time.time() | |
634 if to_sleep > 0: | |
635 logging.info("Next check at %s", | |
636 time.strftime("%Y-%m-%d %H:%M:%S", | |
637 time.localtime(next_check))) | |
638 time.sleep(to_sleep) | |
639 else: | |
640 logging.info("Next check now") | |
91
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
641 if self.should_stop(): |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
642 logging.info("Received stop instruction. Stopping.") |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
643 return |
0 | 644 |
52
78cf5f6778ec
Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents:
49
diff
changeset
|
645 def check_package_tracks(self): |
78cf5f6778ec
Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents:
49
diff
changeset
|
646 logging.info("Checking package tracks") |
91
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
647 self.clear_instruction() |
128
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
648 repeat = True |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
649 while repeat: |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
650 repeat = False |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
651 for track in self.package_tracks: |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
652 try: |
190
e83db4482aab
Add runtreepkg.py command line option --no-svn-update to inhibit updates
Bernhard Herzog <bh@intevation.de>
parents:
179
diff
changeset
|
653 packager = track.package_if_updated(revision=self.revision, |
e83db4482aab
Add runtreepkg.py command line option --no-svn-update to inhibit updates
Bernhard Herzog <bh@intevation.de>
parents:
179
diff
changeset
|
654 do_svn_update=self.do_svn_update) |
128
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
655 if packager: |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
656 packager.package() |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
657 repeat = self.install_dependencies(track, packager) |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
658 except: |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
659 logging.exception("An error occurred while" |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
660 " checking packager track %r", track.name) |
307
5f442b0cf3a4
New command line argument --stop-on-error for runtreepkg.py and
Bernhard Herzog <bh@intevation.de>
parents:
306
diff
changeset
|
661 if self.stop_on_error: |
310
26c15a0f0e52
When stopping because of an error, do not raise the exception again as
Bernhard Herzog <bh@intevation.de>
parents:
308
diff
changeset
|
662 logging.info("Stopping because of errors.") |
26c15a0f0e52
When stopping because of an error, do not raise the exception again as
Bernhard Herzog <bh@intevation.de>
parents:
308
diff
changeset
|
663 return True |
308
61d1daac23d4
Move the should_stop check out of the try/except block so that it's not
Bernhard Herzog <bh@intevation.de>
parents:
307
diff
changeset
|
664 if self.should_stop(): |
61d1daac23d4
Move the should_stop check out of the try/except block so that it's not
Bernhard Herzog <bh@intevation.de>
parents:
307
diff
changeset
|
665 logging.info("Received stop instruction. Stopping.") |
61d1daac23d4
Move the should_stop check out of the try/except block so that it's not
Bernhard Herzog <bh@intevation.de>
parents:
307
diff
changeset
|
666 return True |
128
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
667 if repeat: |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
668 logging.info("Built binaries needed by other tracks." |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
669 " Starting over to ensure all dependencies" |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
670 " are met") |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
671 break |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
672 |
52
78cf5f6778ec
Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents:
49
diff
changeset
|
673 logging.info("Checked all package tracks") |
14
dfd89f81e66c
Add simple status report tool. Still using the old status files
Bernhard Herzog <bh@intevation.de>
parents:
11
diff
changeset
|
674 |
128
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
675 |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
676 def install_dependencies(self, track, packager): |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
677 """Add the binaries built by packager to the builder, if necessary. |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
678 It is necessary if any track depends on the packages. The |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
679 method simply installs all binary files built by the packger |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
680 instead of only those which are immediately required by a track. |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
681 This is done because tracks usually depend directly only on the |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
682 -dev packages which usually require another binary package built |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
683 at the same time. |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
684 """ |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
685 if (track.handle_dependencies |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
686 and track.dependencies_provided() & self.needed_binaries): |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
687 # FIXME: this basically assumes that all tracks use the same |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
688 # builder. This is true for now, but it is possible to |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
689 # configure treepkg with different builders for different |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
690 # tracks and we really should be installing the newly built |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
691 # binaries into the builder of the tracks which depends on |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
692 # them |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
693 binaries = packager.list_binary_files() |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
694 track.builder.add_binaries_to_extra_pkg(binaries) |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
695 return True |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
696 return False |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
697 |
5155b4f9443d
Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents:
125
diff
changeset
|
698 |
52
78cf5f6778ec
Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents:
49
diff
changeset
|
699 def get_package_tracks(self): |
78cf5f6778ec
Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents:
49
diff
changeset
|
700 return self.package_tracks |
91
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
701 |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
702 def read_instruction(self): |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
703 if not self.instructions_file: |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
704 return "" |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
705 try: |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
706 f = open(self.instructions_file) |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
707 except (IOError, OSError): |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
708 return "" |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
709 try: |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
710 return f.read().strip() |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
711 finally: |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
712 f.close() |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
713 self.clear_instruction() |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
714 |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
715 def clear_instruction(self, force=False): |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
716 if self.instructions_file and (not self.instructions_file_removed |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
717 or force): |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
718 util.writefile(self.instructions_file, "") |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
719 self.instructions_file_removed = True |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
720 |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
721 def should_stop(self): |
3ed079a7174a
Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents:
90
diff
changeset
|
722 return self.read_instruction() == "stop" |