annotate treepkg/packager.py @ 517:de78084fcbce

rename do_svn_update in do_update because we provide svn and git support now
author Bjoern Ricks <bricks@intevation.de>
date Wed, 10 Nov 2010 13:17:32 +0000
parents e5698096f1ec
children 9c8e2c05c775
rev   line source
495
ca95be9d033a add tests for determine debian upstream version
Bjoern Ricks <bricks@intevation.de>
parents: 494
diff changeset
1 # Copyright (C) 2007-2010 by Intevation GmbH
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
2 # Authors:
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
3 # Bernhard Herzog <bh@intevation.de>
495
ca95be9d033a add tests for determine debian upstream version
Bjoern Ricks <bricks@intevation.de>
parents: 494
diff changeset
4 # Bjoern Ricks <bjoern.ricks@intevation.de>
ca95be9d033a add tests for determine debian upstream version
Bjoern Ricks <bricks@intevation.de>
parents: 494
diff changeset
5 # Andre Heinecke <andre.heinecke@intevation.de>
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
6 #
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
7 # This program is free software under the GPL (>=v2)
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
8 # Read the file COPYING coming with the software for details.
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
9
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
10 """Classes to automatically build debian packages from subversion checkouts"""
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
11
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
12 import os
437
48577b11375f be more error prone in listing different files
Bjoern Ricks <bricks@intevation.de>
parents: 401
diff changeset
13 import os.path
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
14 import time
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
15 import re
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
16 import logging
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
17 import shutil
16
7c55f3879c4d Use the new status class and report start/stop time too
Bernhard Herzog <bh@intevation.de>
parents: 14
diff changeset
18 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
19 import new
464
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
20 import sys
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
21
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
22 import util
231
7dbf0a3443bb Use treepkg.subversion.ManualWorkingCopy for the debian directory in a
Bernhard Herzog <bh@intevation.de>
parents: 229
diff changeset
23 from subversion import SvnRepository, SvnWorkingCopy, ManualWorkingCopy
321
092925ff75d7 Added basic Git support, configuration options:
Andre Heinecke <aheinecke@intevation.de>
parents: 312
diff changeset
24 from git import GitRepository, GitWorkingCopy
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
25 import run
16
7c55f3879c4d Use the new status class and report start/stop time too
Bernhard Herzog <bh@intevation.de>
parents: 14
diff changeset
26 import status
128
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
27 import debian
45
3e610233ccfe use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents: 41
diff changeset
28 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
29 from builder import PBuilder
378
41226e427823 Added an option to configure the used builder class from the treepkg.cfg. This
Andre Heinecke <aheinecke@intevation.de>
parents: 372
diff changeset
30 from sbuilder import SbdmockBuilder
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
31
135
e5b4dea52297 Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents: 131
diff changeset
32 def _fromparent(attr):
e5b4dea52297 Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents: 131
diff changeset
33 """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
34 def get(self):
e5b4dea52297 Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents: 131
diff changeset
35 return getattr(self.parent, attr)
e5b4dea52297 Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents: 131
diff changeset
36 return property(get)
e5b4dea52297 Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents: 131
diff changeset
37
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
38
511
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
39
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
40 class PackagerError(Exception):
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
41
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
42 """Base class for Packager specific errors raised by TreePKG"""
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
43
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
44 class SourcePackager(object):
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
45
299
c32dc72ba979 Turn the SourcePackager class attribute pkg_basename into a per-track
Bernhard Herzog <bh@intevation.de>
parents: 297
diff changeset
46 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
47 changemsg_template = property(lambda self:
e82fb08781a2 Turn the SourcePackager class attribute changemsg_template into a
Bernhard Herzog <bh@intevation.de>
parents: 299
diff changeset
48 self.track.changelog_msg_template)
135
e5b4dea52297 Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents: 131
diff changeset
49 track = _fromparent("track")
e5b4dea52297 Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents: 131
diff changeset
50 revision = _fromparent("revision")
281
2b9d94f0ccad Pass the package revision as a parameter to the RevisionPackager
Bernhard Herzog <bh@intevation.de>
parents: 276
diff changeset
51 pkg_revision = _fromparent("pkg_revision")
135
e5b4dea52297 Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents: 131
diff changeset
52 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
53 log_dir = _fromparent("log_dir")
135
e5b4dea52297 Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents: 131
diff changeset
54 work_dir = _fromparent("work_dir")
e5b4dea52297 Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents: 131
diff changeset
55 src_dir = _fromparent("src_dir")
e5b4dea52297 Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents: 131
diff changeset
56
e5b4dea52297 Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents: 131
diff changeset
57 def __init__(self, parent):
e5b4dea52297 Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents: 131
diff changeset
58 self.parent = parent
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
59
495
ca95be9d033a add tests for determine debian upstream version
Bjoern Ricks <bricks@intevation.de>
parents: 494
diff changeset
60 def determine_upstream_version(self, directory=None):
494
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
61 """
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
62 Tries to parse the upstream version from a source directory
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
63 and returns it as a string.
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
64 """
495
ca95be9d033a add tests for determine debian upstream version
Bjoern Ricks <bricks@intevation.de>
parents: 494
diff changeset
65
ca95be9d033a add tests for determine debian upstream version
Bjoern Ricks <bricks@intevation.de>
parents: 494
diff changeset
66 if not directory:
ca95be9d033a add tests for determine debian upstream version
Bjoern Ricks <bricks@intevation.de>
parents: 494
diff changeset
67 directory = self.track.checkout_dir
494
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
68 # TODO: it should be possible to select which files should be searched
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
69 # for upstream_version
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
70
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
71 #if os.path.isfile(os.path.join(directory, "CMakeList.txt")):
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
72 # return util.extract_cmakefile_version(os.path.join(directory,
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
73 # "CMakeList.txt"))
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
74 if os.path.isfile(os.path.join(directory, "configure.ac")):
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
75 return util.extract_configureac_version(os.path.join(directory,
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
76 "configure.ac"))
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
77 changelog = os.path.join(self.track.debian_dir, "changelog")
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
78 if os.path.isfile(changelog):
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
79 debian_version = util.debian_changelog_version(
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
80 changelog)
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
81 # upstream version is debian version without epoch and
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
82 # debian revision
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
83 if ":" in debian_version:
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
84 debian_version = debian_version.split(":")[1]
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
85 if "-" in debian_version:
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
86 debian_version = debian_version.split("-")[0]
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
87 upstream_version = debian_version
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
88 else:
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
89 upstream_version = "0"
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
90
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
91 return upstream_version
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
92
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
93 def determine_package_version(self, directory, additionals=None):
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
94 """Returns the resolved version template of the package as a string
4
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 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
97 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
98 export_sources method.
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
99
494
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
100 The addionals parameter may contain a dictionary with additional
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
101 variables used in the version template.
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
102
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
103 Default variables that can be resolved are:
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
104 revision - The revision of the package
503
44a005311f62 * Only check the time once per version calculation
Andre Heinecke <aheinecke@intevation.de>
parents: 502
diff changeset
105 short_revision - The first seven characters of the revision
494
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
106 rules_revision - The revision of the packaging rules
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
107 pkg_date - The current date in the form: YYYYMMDD
502
35759274aeb4 Expose package time and a short revision to the version templates.
Andre Heinecke <aheinecke@intevation.de>
parents: 499
diff changeset
108 pkg_time - The current ime in the form: HHMM
494
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
109 pkg_revision - The number of times a new package has
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
110 been created from this track.
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
111 upstream_version - The version parsed from the sources or
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
112 package descriptions by
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
113 determine_upstream_version. Default: "0"
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
114 """
450
5c06e0a0d329 Enable more variables to be used in the version template.
Andre Heinecke <aheinecke@intevation.de>
parents: 441
diff changeset
115 revision = self.revision
5c06e0a0d329 Enable more variables to be used in the version template.
Andre Heinecke <aheinecke@intevation.de>
parents: 441
diff changeset
116 rules_revision = self.parent.rules_revision
5c06e0a0d329 Enable more variables to be used in the version template.
Andre Heinecke <aheinecke@intevation.de>
parents: 441
diff changeset
117 pkg_revision = self.parent.pkg_revision
502
35759274aeb4 Expose package time and a short revision to the version templates.
Andre Heinecke <aheinecke@intevation.de>
parents: 499
diff changeset
118 short_revision = revision
35759274aeb4 Expose package time and a short revision to the version templates.
Andre Heinecke <aheinecke@intevation.de>
parents: 499
diff changeset
119 if len(pkg_revision) > 7:
35759274aeb4 Expose package time and a short revision to the version templates.
Andre Heinecke <aheinecke@intevation.de>
parents: 499
diff changeset
120 short_revision = short_revision[:7]
503
44a005311f62 * Only check the time once per version calculation
Andre Heinecke <aheinecke@intevation.de>
parents: 502
diff changeset
121 localtime = time.localtime()
44a005311f62 * Only check the time once per version calculation
Andre Heinecke <aheinecke@intevation.de>
parents: 502
diff changeset
122 pkg_date = time.strftime("%Y%m%d", localtime)
44a005311f62 * Only check the time once per version calculation
Andre Heinecke <aheinecke@intevation.de>
parents: 502
diff changeset
123 pkg_time = time.strftime("%H%M", localtime)
495
ca95be9d033a add tests for determine debian upstream version
Bjoern Ricks <bricks@intevation.de>
parents: 494
diff changeset
124 upstream_version = self.determine_upstream_version(directory)
494
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
125 version_dict = locals().copy()
504
dcec034fed97 Remove the type for the additionals variable in determine_package_version
Andre Heinecke <aheinecke@intevation.de>
parents: 503
diff changeset
126 if additionals:
494
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
127 version_dict.update(additionals)
31b64ebe4b42 determine upstream_version of a package
Bjoern Ricks <bricks@intevation.de>
parents: 469
diff changeset
128 return self.track.version_template % version_dict
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
129
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
130 def export_sources(self):
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
131 """Export the sources from the subversion working directory
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
132
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
133 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
134 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
135
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
136 <pkg_basename>-<version>
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
137
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
138 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
139 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
140 """
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
141 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
142 self.track.export_sources(temp_dir)
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
143
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
144 pkgbaseversion = self.determine_package_version(temp_dir)
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
145 pkgbasedir = os.path.join(self.work_dir,
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
146 self.pkg_basename + "-" + pkgbaseversion)
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
147
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
148 os.rename(temp_dir, pkgbasedir)
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
149 return pkgbaseversion, pkgbasedir
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
150
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
151
276
f3dee156e3e3 Add pkgbaseversion parameter to the prepare_sources_for_tarball method
Bernhard Herzog <bh@intevation.de>
parents: 274
diff changeset
152 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
153 """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
154
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
155 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
156 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
157 numbers in the code.
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
158 """
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
159
207
b82fe4d25893 SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents: 202
diff changeset
160 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
161 """Creates a new tarball.
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
162
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
163 Parameters:
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
164
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
165 tarballname -- the filename of the new tarball
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
166 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
167 (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
168 basedir -- The basedirectory of the files that are packaged
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
169 into the tarfile. This should be a relative
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
170 filename directly in workdir.
207
b82fe4d25893 SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents: 202
diff changeset
171 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
172 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
173 default) and 'bz2' for bzip2.
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
174 """
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
175 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
176 if compression == "gz":
b82fe4d25893 SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents: 202
diff changeset
177 compression_flag = "z"
b82fe4d25893 SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents: 202
diff changeset
178 elif compression == "bz2":
b82fe4d25893 SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents: 202
diff changeset
179 compression_flag = "j"
b82fe4d25893 SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents: 202
diff changeset
180 else:
b82fe4d25893 SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents: 202
diff changeset
181 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
182
b82fe4d25893 SourcePackager.create_tarball: add parameter to specify compression method
Bernhard Herzog <bh@intevation.de>
parents: 202
diff changeset
183 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
184 " -C $workdir $basedir", **locals()))
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
185
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
186 def copy_debian_directory(self, pkgbasedir, pkgbaseversion, changemsg):
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
187 """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
188
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
189 Parameter:
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
190 pkgbasedir -- The directory holding the unpacked source package
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
191 pkgbaseversion -- The version to update the changelog to
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
192 changemsg -- The message for the changelog
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
193
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
194 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
195 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
196 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
197 prefix is prepended to the pkgbaseversion parameter. Debian
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
198 uses such prefixes for the kde packages.
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
199 """
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
200 debian_dir = os.path.join(pkgbasedir, "debian")
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
201 changelog = os.path.join(debian_dir, "changelog")
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
202
53
74cd21b6400b rename some variables from pkg_track to track
Bernhard Herzog <bh@intevation.de>
parents: 52
diff changeset
203 self.track.copy_debian_directory(debian_dir)
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
204
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
205 logging.info("Updating %r", changelog)
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
206 oldversion = util.debian_changelog_version(changelog)
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
207 if ":" in oldversion:
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
208 oldversionprefix = oldversion.split(":")[0] + ":"
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
209 else:
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
210 oldversionprefix = ""
281
2b9d94f0ccad Pass the package revision as a parameter to the RevisionPackager
Bernhard Herzog <bh@intevation.de>
parents: 276
diff changeset
211 debrev = self.pkg_revision
45
3e610233ccfe use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents: 41
diff changeset
212 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
213 " -v ${oldversionprefix}${pkgbaseversion}-${debrev}"
45
3e610233ccfe use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents: 41
diff changeset
214 " $changemsg", **locals()),
53
74cd21b6400b rename some variables from pkg_track to track
Bernhard Herzog <bh@intevation.de>
parents: 52
diff changeset
215 env=self.track.debian_environment())
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
216
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
217
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
218 def create_source_package(self, pkgbasedir, origtargz):
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
219 """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
220 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
221 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
222 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
223 dpkg_source_log)
367
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
224
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
225 format = self.get_debian_source_format(pkgbasedir)
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
226 if format == "1.0":
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
227 run.call(cmdexpand("dpkg-source -b $directory $tarball",
45
3e610233ccfe use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents: 41
diff changeset
228 directory=os.path.basename(pkgbasedir),
3e610233ccfe use cmdexpand when calling subprocesses
Bernhard Herzog <bh@intevation.de>
parents: 41
diff changeset
229 tarball=os.path.basename(origtargz)),
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
230 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
231 logfile=dpkg_source_log,
53
74cd21b6400b rename some variables from pkg_track to track
Bernhard Herzog <bh@intevation.de>
parents: 52
diff changeset
232 env=self.track.debian_environment())
367
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
233 elif format == "3.0 (quilt)":
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
234 run.call(cmdexpand("dpkg-source -b $directory",
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
235 directory=os.path.basename(pkgbasedir)),
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
236 cwd=os.path.dirname(pkgbasedir),
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
237 logfile=dpkg_source_log,
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
238 env=self.track.debian_environment())
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
239 else:
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
240 raise RuntimeError("debian source format %s is not supported by treepkg" % format)
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
241
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
242 def get_debian_source_format(self, pkgbasedir):
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
243 formatfile = os.path.join(pkgbasedir, "debian", "source", "format")
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
244 if not os.path.exists(formatfile):
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
245 return "1.0"
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
246 else:
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
247 file = open(formatfile, "r")
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
248 line = file.readline()
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
249 file.close()
fb92f3c1b238 treepkg is now able to handle debian source format 1.0 and source format 3.0 (quilt)
Bjoern Ricks <bricks@intevation.de>
parents: 344
diff changeset
250 return line.strip()
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
251
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
252 def move_source_package(self, pkgbasename):
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
253 """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
254 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
255 util.ensure_directory(self.src_dir)
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
256 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
257 if filename.startswith(pkgbasename)]:
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
258 os.rename(os.path.join(self.work_dir, filename),
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
259 os.path.join(self.src_dir, filename))
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
260
179
952d366f7b14 Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents: 176
diff changeset
261 def sign_package(self):
952d366f7b14 Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents: 176
diff changeset
262 """Signs the .dsc file created buy the instance"""
344
f06f707d9fda merged branches/scratchbox into trunk
Bjoern Ricks <bricks@intevation.de>
parents: 340
diff changeset
263 src_files = util.listdir_abs(self.src_dir, "*.dsc")
f06f707d9fda merged branches/scratchbox into trunk
Bjoern Ricks <bricks@intevation.de>
parents: 340
diff changeset
264 if not src_files:
f06f707d9fda merged branches/scratchbox into trunk
Bjoern Ricks <bricks@intevation.de>
parents: 340
diff changeset
265 raise RuntimeError("Could not find .dsc file in source"
f06f707d9fda merged branches/scratchbox into trunk
Bjoern Ricks <bricks@intevation.de>
parents: 340
diff changeset
266 " directory %s" % self.src_dir)
f06f707d9fda merged branches/scratchbox into trunk
Bjoern Ricks <bricks@intevation.de>
parents: 340
diff changeset
267 self.track.sign_file(src_files[0])
179
952d366f7b14 Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents: 176
diff changeset
268
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
269 def package(self):
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
270 """Creates a source package from a subversion checkout.
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
271
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
272 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
273 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
274 work directory is removed.
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
275 """
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
276 util.ensure_directory(self.work_dir)
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
277 try:
41
f7ec40638a06 use the enums for the status field of RevisionStatus
Bernhard Herzog <bh@intevation.de>
parents: 36
diff changeset
278 self.status.creating_source_package()
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
279 self.do_package()
179
952d366f7b14 Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents: 176
diff changeset
280 self.sign_package()
41
f7ec40638a06 use the enums for the status field of RevisionStatus
Bernhard Herzog <bh@intevation.de>
parents: 36
diff changeset
281 self.status.source_package_created()
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
282 finally:
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
283 logging.info("Removing workdir %r", self.work_dir)
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
284 shutil.rmtree(self.work_dir)
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
285
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
286 def do_package(self):
274
2676abfc0e1d Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents: 261
diff changeset
287 """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
288 pkgbaseversion, pkgbasedir = self.export_sources()
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
289
274
2676abfc0e1d Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents: 261
diff changeset
290 pkgbasename = self.pkg_basename + "_" + pkgbaseversion
2676abfc0e1d Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents: 261
diff changeset
291 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
292 pkgbasename + ".orig.tar.gz")
2676abfc0e1d Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents: 261
diff changeset
293
276
f3dee156e3e3 Add pkgbaseversion parameter to the prepare_sources_for_tarball method
Bernhard Herzog <bh@intevation.de>
parents: 274
diff changeset
294 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
295
2676abfc0e1d Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents: 261
diff changeset
296 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
297 os.path.basename(pkgbasedir))
2676abfc0e1d Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents: 261
diff changeset
298
344
f06f707d9fda merged branches/scratchbox into trunk
Bjoern Ricks <bricks@intevation.de>
parents: 340
diff changeset
299 changemsg = self.get_change_msg()
274
2676abfc0e1d Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents: 261
diff changeset
300 self.copy_debian_directory(pkgbasedir, pkgbaseversion,
2676abfc0e1d Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents: 261
diff changeset
301 changemsg)
2676abfc0e1d Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents: 261
diff changeset
302
2676abfc0e1d Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents: 261
diff changeset
303 self.create_source_package(pkgbasedir, origtargz)
2676abfc0e1d Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents: 261
diff changeset
304 self.move_source_package(pkgbasename)
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
305
344
f06f707d9fda merged branches/scratchbox into trunk
Bjoern Ricks <bricks@intevation.de>
parents: 340
diff changeset
306 def get_change_msg(self):
f06f707d9fda merged branches/scratchbox into trunk
Bjoern Ricks <bricks@intevation.de>
parents: 340
diff changeset
307 return self.changemsg_template % dict(revision=self.revision)
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
308
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
309 class BinaryPackager(object):
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
310
135
e5b4dea52297 Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents: 131
diff changeset
311 track = _fromparent("track")
e5b4dea52297 Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents: 131
diff changeset
312 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
313 log_dir = _fromparent("log_dir")
135
e5b4dea52297 Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents: 131
diff changeset
314 binary_dir = _fromparent("binary_dir")
e5b4dea52297 Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents: 131
diff changeset
315
e5b4dea52297 Make more of RevisionPackager available to SourcePackager and
Bernhard Herzog <bh@intevation.de>
parents: 131
diff changeset
316 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
317 self.parent = parent
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
318 self.dsc_file = dsc_file
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
319 self.logfile = logfile
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
320
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
321 def package(self):
41
f7ec40638a06 use the enums for the status field of RevisionStatus
Bernhard Herzog <bh@intevation.de>
parents: 36
diff changeset
322 self.status.creating_binary_package()
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
323 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
324 util.ensure_directory(self.log_dir)
54
b0014b8f6029 fix typo in log message
Bernhard Herzog <bh@intevation.de>
parents: 53
diff changeset
325 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
326 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
327 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
328 self.sign_package()
41
f7ec40638a06 use the enums for the status field of RevisionStatus
Bernhard Herzog <bh@intevation.de>
parents: 36
diff changeset
329 self.status.binary_package_created()
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
330
179
952d366f7b14 Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents: 176
diff changeset
331 def sign_package(self):
370
0bee91b435ab Fix typos in doc-strings.
Bernhard Herzog <bh@intevation.de>
parents: 367
diff changeset
332 """Signs the .changes file created by the instance"""
344
f06f707d9fda merged branches/scratchbox into trunk
Bjoern Ricks <bricks@intevation.de>
parents: 340
diff changeset
333 dirs = util.listdir_abs(self.binary_dir, "*.changes")
f06f707d9fda merged branches/scratchbox into trunk
Bjoern Ricks <bricks@intevation.de>
parents: 340
diff changeset
334 if not dirs:
f06f707d9fda merged branches/scratchbox into trunk
Bjoern Ricks <bricks@intevation.de>
parents: 340
diff changeset
335 raise RuntimeError("Cannot find changes File in %r" % self.binary_dir)
f06f707d9fda merged branches/scratchbox into trunk
Bjoern Ricks <bricks@intevation.de>
parents: 340
diff changeset
336 self.track.sign_file(dirs[0])
179
952d366f7b14 Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents: 176
diff changeset
337
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
338
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
339 class RevisionPackager(object):
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
340
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
341 source_packager_cls = SourcePackager
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
342 binary_packager_cls = BinaryPackager
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
343
281
2b9d94f0ccad Pass the package revision as a parameter to the RevisionPackager
Bernhard Herzog <bh@intevation.de>
parents: 276
diff changeset
344 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
345 tag=""):
53
74cd21b6400b rename some variables from pkg_track to track
Bernhard Herzog <bh@intevation.de>
parents: 52
diff changeset
346 self.track = track
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
347 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
348 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
349
2b9d94f0ccad Pass the package revision as a parameter to the RevisionPackager
Bernhard Herzog <bh@intevation.de>
parents: 276
diff changeset
350 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
351 pkg_revision = (self.track.pkg_revision_template
338
28df50b267f6 Expanded the pkg_revision_template dictionary to include rules revision
Andre Heinecke <aheinecke@intevation.de>
parents: 336
diff changeset
352 % dict(pkg_revision=1,
28df50b267f6 Expanded the pkg_revision_template dictionary to include rules revision
Andre Heinecke <aheinecke@intevation.de>
parents: 336
diff changeset
353 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
354 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
355
229
653a45adda50 Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents: 224
diff changeset
356 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
357 rules_revision)
36
086c68ca51d2 rename Status to RevisionStatus
Bernhard Herzog <bh@intevation.de>
parents: 26
diff changeset
358 self.status = status.RevisionStatus(os.path.join(self.base_dir,
464
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
359 "status"),
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
360 self.after_setattr)
260
6aeae11ca7fe Add tag parameter to RevisionPackager constructor. The tag is stored in
Bernhard Herzog <bh@intevation.de>
parents: 238
diff changeset
361 if tag:
6aeae11ca7fe Add tag parameter to RevisionPackager constructor. The tag is stored in
Bernhard Herzog <bh@intevation.de>
parents: 238
diff changeset
362 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
363 self.status.tags = tag
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
364
172
06af36f915f2 Move the filenameproperty factory from treepkg/packager.py to
Bernhard Herzog <bh@intevation.de>
parents: 168
diff changeset
365 log_dir = util.filenameproperty("log")
06af36f915f2 Move the filenameproperty factory from treepkg/packager.py to
Bernhard Herzog <bh@intevation.de>
parents: 168
diff changeset
366 work_dir = util.filenameproperty("work")
06af36f915f2 Move the filenameproperty factory from treepkg/packager.py to
Bernhard Herzog <bh@intevation.de>
parents: 168
diff changeset
367 binary_dir = util.filenameproperty("binary")
06af36f915f2 Move the filenameproperty factory from treepkg/packager.py to
Bernhard Herzog <bh@intevation.de>
parents: 168
diff changeset
368 src_dir = util.filenameproperty("src")
06af36f915f2 Move the filenameproperty factory from treepkg/packager.py to
Bernhard Herzog <bh@intevation.de>
parents: 168
diff changeset
369 build_log = util.filenameproperty("build_log.txt", dir_attr="log_dir")
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
370
464
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
371 def after_setattr(self, status, attr):
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
372 '''
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
373 Execute a hook set in the source_hook configuration attribute
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
374 every time the status changes.
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
375 '''
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
376 if not self.track.status_hook: return
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
377 logging.info("Executing status hook: %s" % self.track.status_hook )
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
378 status_env = {
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
379 "TREEPKG_TRACK" : self.track.name,
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
380 "TREEPKG_BASE_DIR" : self.base_dir,
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
381 "TREEPKG_STATE" : attr,
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
382 "TREEPKG_STATENAME" : status.status.name
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
383 }
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
384 run.call(cmdexpand(self.track.status_hook), extra_env=status_env)
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
385
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
386 def find_dsc_file(self):
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
387 for filename in os.listdir(self.src_dir):
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
388 if filename.endswith(".dsc"):
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
389 return os.path.join(self.src_dir, filename)
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
390 return None
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
391
18
d5c24cfce05e Improve access to a RevisionPackager's build_log
Bernhard Herzog <bh@intevation.de>
parents: 16
diff changeset
392 def has_build_log(self):
336
5fa56edeb606 Changed the Build Logs to be gziped before they are published
Andre Heinecke <aheinecke@intevation.de>
parents: 328
diff changeset
393 return os.path.exists(self.get_log_file())
5fa56edeb606 Changed the Build Logs to be gziped before they are published
Andre Heinecke <aheinecke@intevation.de>
parents: 328
diff changeset
394
372
ef87d30468b6 Added the option to expose additional log files from the log directory.
Andre Heinecke <aheinecke@intevation.de>
parents: 370
diff changeset
395 def get_log_title(self, f):
ef87d30468b6 Added the option to expose additional log files from the log directory.
Andre Heinecke <aheinecke@intevation.de>
parents: 370
diff changeset
396 if not os.path.isfile(f):
ef87d30468b6 Added the option to expose additional log files from the log directory.
Andre Heinecke <aheinecke@intevation.de>
parents: 370
diff changeset
397 return None
ef87d30468b6 Added the option to expose additional log files from the log directory.
Andre Heinecke <aheinecke@intevation.de>
parents: 370
diff changeset
398 title = os.path.basename(f)
ef87d30468b6 Added the option to expose additional log files from the log directory.
Andre Heinecke <aheinecke@intevation.de>
parents: 370
diff changeset
399 title = title.replace("_"," ")
ef87d30468b6 Added the option to expose additional log files from the log directory.
Andre Heinecke <aheinecke@intevation.de>
parents: 370
diff changeset
400 title = title[:title.find(".")]
ef87d30468b6 Added the option to expose additional log files from the log directory.
Andre Heinecke <aheinecke@intevation.de>
parents: 370
diff changeset
401 title = title.title()
ef87d30468b6 Added the option to expose additional log files from the log directory.
Andre Heinecke <aheinecke@intevation.de>
parents: 370
diff changeset
402 return title
ef87d30468b6 Added the option to expose additional log files from the log directory.
Andre Heinecke <aheinecke@intevation.de>
parents: 370
diff changeset
403
336
5fa56edeb606 Changed the Build Logs to be gziped before they are published
Andre Heinecke <aheinecke@intevation.de>
parents: 328
diff changeset
404 def get_log_file(self):
5fa56edeb606 Changed the Build Logs to be gziped before they are published
Andre Heinecke <aheinecke@intevation.de>
parents: 328
diff changeset
405 if os.path.exists(self.build_log + ".gz"):
5fa56edeb606 Changed the Build Logs to be gziped before they are published
Andre Heinecke <aheinecke@intevation.de>
parents: 328
diff changeset
406 return self.build_log + ".gz"
5fa56edeb606 Changed the Build Logs to be gziped before they are published
Andre Heinecke <aheinecke@intevation.de>
parents: 328
diff changeset
407 return self.build_log
18
d5c24cfce05e Improve access to a RevisionPackager's build_log
Bernhard Herzog <bh@intevation.de>
parents: 16
diff changeset
408
393
5fe26e7f6e2d get all log files
Bjoern Ricks <bricks@intevation.de>
parents: 389
diff changeset
409 def get_log_files(self, logs=None):
372
ef87d30468b6 Added the option to expose additional log files from the log directory.
Andre Heinecke <aheinecke@intevation.de>
parents: 370
diff changeset
410 files = []
437
48577b11375f be more error prone in listing different files
Bjoern Ricks <bricks@intevation.de>
parents: 401
diff changeset
411 if os.path.isdir(self.log_dir):
48577b11375f be more error prone in listing different files
Bjoern Ricks <bricks@intevation.de>
parents: 401
diff changeset
412 for f in os.listdir(self.log_dir):
48577b11375f be more error prone in listing different files
Bjoern Ricks <bricks@intevation.de>
parents: 401
diff changeset
413 if logs is None or f in logs:
48577b11375f be more error prone in listing different files
Bjoern Ricks <bricks@intevation.de>
parents: 401
diff changeset
414 f = os.path.join(self.log_dir,f)
48577b11375f be more error prone in listing different files
Bjoern Ricks <bricks@intevation.de>
parents: 401
diff changeset
415 if os.path.isfile(f):
48577b11375f be more error prone in listing different files
Bjoern Ricks <bricks@intevation.de>
parents: 401
diff changeset
416 files.append((self.get_log_title(f),f))
372
ef87d30468b6 Added the option to expose additional log files from the log directory.
Andre Heinecke <aheinecke@intevation.de>
parents: 370
diff changeset
417 return files
464
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
418
372
ef87d30468b6 Added the option to expose additional log files from the log directory.
Andre Heinecke <aheinecke@intevation.de>
parents: 370
diff changeset
419 def list_log_files(self, logs):
140
0da76aee8035 Add RevisionPackager method list_log_files which returns a description
Bernhard Herzog <bh@intevation.de>
parents: 139
diff changeset
420 """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
421 Each list item is a tuple of the form (TITLE, FILENAME) where
372
ef87d30468b6 Added the option to expose additional log files from the log directory.
Andre Heinecke <aheinecke@intevation.de>
parents: 370
diff changeset
422 TITLE is a string with the filename without directory or ending in
ef87d30468b6 Added the option to expose additional log files from the log directory.
Andre Heinecke <aheinecke@intevation.de>
parents: 370
diff changeset
423 which _ is replaced with a whitespace and words are capitalized.
140
0da76aee8035 Add RevisionPackager method list_log_files which returns a description
Bernhard Herzog <bh@intevation.de>
parents: 139
diff changeset
424 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
425 """
372
ef87d30468b6 Added the option to expose additional log files from the log directory.
Andre Heinecke <aheinecke@intevation.de>
parents: 370
diff changeset
426 files = self.get_log_files(logs)
ef87d30468b6 Added the option to expose additional log files from the log directory.
Andre Heinecke <aheinecke@intevation.de>
parents: 370
diff changeset
427 if not files:
ef87d30468b6 Added the option to expose additional log files from the log directory.
Andre Heinecke <aheinecke@intevation.de>
parents: 370
diff changeset
428 return []
140
0da76aee8035 Add RevisionPackager method list_log_files which returns a description
Bernhard Herzog <bh@intevation.de>
parents: 139
diff changeset
429 return files
0da76aee8035 Add RevisionPackager method list_log_files which returns a description
Bernhard Herzog <bh@intevation.de>
parents: 139
diff changeset
430
88
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 85
diff changeset
431 def list_source_files(self):
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 85
diff changeset
432 """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
433 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
434 to the source package.
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 85
diff changeset
435 """
437
48577b11375f be more error prone in listing different files
Bjoern Ricks <bricks@intevation.de>
parents: 401
diff changeset
436 files = []
48577b11375f be more error prone in listing different files
Bjoern Ricks <bricks@intevation.de>
parents: 401
diff changeset
437 if os.path.isdir(self.src_dir):
48577b11375f be more error prone in listing different files
Bjoern Ricks <bricks@intevation.de>
parents: 401
diff changeset
438 files = sorted(util.listdir_abs(self.src_dir))
48577b11375f be more error prone in listing different files
Bjoern Ricks <bricks@intevation.de>
parents: 401
diff changeset
439 return files
88
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 85
diff changeset
440
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 85
diff changeset
441 def list_binary_files(self):
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 85
diff changeset
442 """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
443 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
444 to the binary packages.
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 85
diff changeset
445 """
437
48577b11375f be more error prone in listing different files
Bjoern Ricks <bricks@intevation.de>
parents: 401
diff changeset
446 files = []
48577b11375f be more error prone in listing different files
Bjoern Ricks <bricks@intevation.de>
parents: 401
diff changeset
447 if os.path.isdir(self.binary_dir):
48577b11375f be more error prone in listing different files
Bjoern Ricks <bricks@intevation.de>
parents: 401
diff changeset
448 files = sorted(util.listdir_abs(self.binary_dir))
48577b11375f be more error prone in listing different files
Bjoern Ricks <bricks@intevation.de>
parents: 401
diff changeset
449 return files
88
3ae54f99db26 Add methods RevisionPackager.list_source_files and
Bernhard Herzog <bh@intevation.de>
parents: 85
diff changeset
450
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
451 def package(self):
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
452 try:
462
058856954e2d Make the compress_all_logs call builder independent and also compress
Andre Heinecke <aheinecke@intevation.de>
parents: 450
diff changeset
453 try:
058856954e2d Make the compress_all_logs call builder independent and also compress
Andre Heinecke <aheinecke@intevation.de>
parents: 450
diff changeset
454 util.ensure_directory(self.work_dir)
058856954e2d Make the compress_all_logs call builder independent and also compress
Andre Heinecke <aheinecke@intevation.de>
parents: 450
diff changeset
455 self.status.start = datetime.datetime.utcnow()
058856954e2d Make the compress_all_logs call builder independent and also compress
Andre Heinecke <aheinecke@intevation.de>
parents: 450
diff changeset
456 src_packager = self.source_packager_cls(self)
058856954e2d Make the compress_all_logs call builder independent and also compress
Andre Heinecke <aheinecke@intevation.de>
parents: 450
diff changeset
457 src_packager.package()
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
458
462
058856954e2d Make the compress_all_logs call builder independent and also compress
Andre Heinecke <aheinecke@intevation.de>
parents: 450
diff changeset
459 dsc_file = self.find_dsc_file()
058856954e2d Make the compress_all_logs call builder independent and also compress
Andre Heinecke <aheinecke@intevation.de>
parents: 450
diff changeset
460 if dsc_file is None:
058856954e2d Make the compress_all_logs call builder independent and also compress
Andre Heinecke <aheinecke@intevation.de>
parents: 450
diff changeset
461 raise RuntimeError("Cannot find dsc File in %r" % self.src_dir)
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
462
462
058856954e2d Make the compress_all_logs call builder independent and also compress
Andre Heinecke <aheinecke@intevation.de>
parents: 450
diff changeset
463 bin_packager = self.binary_packager_cls(self, dsc_file, self.build_log)
058856954e2d Make the compress_all_logs call builder independent and also compress
Andre Heinecke <aheinecke@intevation.de>
parents: 450
diff changeset
464 bin_packager.package()
058856954e2d Make the compress_all_logs call builder independent and also compress
Andre Heinecke <aheinecke@intevation.de>
parents: 450
diff changeset
465 finally:
058856954e2d Make the compress_all_logs call builder independent and also compress
Andre Heinecke <aheinecke@intevation.de>
parents: 450
diff changeset
466 util.compress_all_logs(self.log_dir)
469
b207d63f305a Update the stop time after all logs are compressed
Andre Heinecke <aheinecke@intevation.de>
parents: 464
diff changeset
467 self.status.stop = datetime.datetime.utcnow()
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
468 except:
41
f7ec40638a06 use the enums for the status field of RevisionStatus
Bernhard Herzog <bh@intevation.de>
parents: 36
diff changeset
469 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
470 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
471 # 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
472 # 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
473 # 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
474 # 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
475 # "notification_sent")
7888fe374e11 Add support for notification mails in case of build errors
Bernhard Herzog <bh@intevation.de>
parents: 98
diff changeset
476 self.status.notification_pending()
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
477 raise
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
478
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
479 def remove_package_dir(self):
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
480 logging.info("Removing pkgdir %r", self.base_dir)
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
481 shutil.rmtree(self.base_dir)
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
482
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
483
52
78cf5f6778ec Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents: 49
diff changeset
484 class PackageTrack(object):
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
485
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
486 revision_packager_cls = RevisionPackager
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
487
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
488 svn_external_subdirs = []
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
489
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
490 extra_config_desc = []
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
491
344
f06f707d9fda merged branches/scratchbox into trunk
Bjoern Ricks <bricks@intevation.de>
parents: 340
diff changeset
492 def __init__(self, name, base_dir, root_cmd, builderconfig, deb_email,
511
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
493 deb_fullname, url="", packager_class="treepkg.packager",
378
41226e427823 Added an option to configure the used builder class from the treepkg.cfg. This
Andre Heinecke <aheinecke@intevation.de>
parents: 372
diff changeset
494 version_template="%(revision)s", builder_cls="PBuilder",
340
a83a78a93fd6 Changed default message templates to the correct types
Andre Heinecke <aheinecke@intevation.de>
parents: 338
diff changeset
495 pkg_revision_template="treepkg%(pkg_revision)s",
293
faeeac2c4c71 Replace debrevision_prefix with pkg_revision_template. Their meaning is
Bernhard Herzog <bh@intevation.de>
parents: 281
diff changeset
496 handle_dependencies=False, signing_key_id="", do_build=True,
511
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
497 rules_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
498 changelog_msg_template="Update to r%(revision)s",
511
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
499 svn_subset=(), svn_externals=(), branch="",
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
500 scm_type="svn", rules_scm_type="svn",
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
501 os="", status_hook="", svn_url=None):
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
502 self.name = name
378
41226e427823 Added an option to configure the used builder class from the treepkg.cfg. This
Andre Heinecke <aheinecke@intevation.de>
parents: 372
diff changeset
503
41226e427823 Added an option to configure the used builder class from the treepkg.cfg. This
Andre Heinecke <aheinecke@intevation.de>
parents: 372
diff changeset
504 # Convert the builder_cls option to a class
41226e427823 Added an option to configure the used builder class from the treepkg.cfg. This
Andre Heinecke <aheinecke@intevation.de>
parents: 372
diff changeset
505 if builder_cls.upper() == "SBDMOCKBUILDER" or \
41226e427823 Added an option to configure the used builder class from the treepkg.cfg. This
Andre Heinecke <aheinecke@intevation.de>
parents: 372
diff changeset
506 builder_cls.upper() == "SBDMOCK":
41226e427823 Added an option to configure the used builder class from the treepkg.cfg. This
Andre Heinecke <aheinecke@intevation.de>
parents: 372
diff changeset
507 builder_class = SbdmockBuilder
41226e427823 Added an option to configure the used builder class from the treepkg.cfg. This
Andre Heinecke <aheinecke@intevation.de>
parents: 372
diff changeset
508 elif builder_cls.upper() == "PBUILDER":
41226e427823 Added an option to configure the used builder class from the treepkg.cfg. This
Andre Heinecke <aheinecke@intevation.de>
parents: 372
diff changeset
509 builder_class = PBuilder
41226e427823 Added an option to configure the used builder class from the treepkg.cfg. This
Andre Heinecke <aheinecke@intevation.de>
parents: 372
diff changeset
510 else:
41226e427823 Added an option to configure the used builder class from the treepkg.cfg. This
Andre Heinecke <aheinecke@intevation.de>
parents: 372
diff changeset
511 # If the builder option is explicitly set with an unknown builder
41226e427823 Added an option to configure the used builder class from the treepkg.cfg. This
Andre Heinecke <aheinecke@intevation.de>
parents: 372
diff changeset
512 # a warning is printed.
41226e427823 Added an option to configure the used builder class from the treepkg.cfg. This
Andre Heinecke <aheinecke@intevation.de>
parents: 372
diff changeset
513 logging.warning("Track: %s Builder option %s could not be parsed \
41226e427823 Added an option to configure the used builder class from the treepkg.cfg. This
Andre Heinecke <aheinecke@intevation.de>
parents: 372
diff changeset
514 defaulting to pbuilder" % (name, builder_cls))
41226e427823 Added an option to configure the used builder class from the treepkg.cfg. This
Andre Heinecke <aheinecke@intevation.de>
parents: 372
diff changeset
515 builder_class = PBuilder
299
c32dc72ba979 Turn the SourcePackager class attribute pkg_basename into a per-track
Bernhard Herzog <bh@intevation.de>
parents: 297
diff changeset
516 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
517 pkg_basename = name
c32dc72ba979 Turn the SourcePackager class attribute pkg_basename into a per-track
Bernhard Herzog <bh@intevation.de>
parents: 297
diff changeset
518 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
519 self.changelog_msg_template = changelog_msg_template
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
520 self.base_dir = base_dir
378
41226e427823 Added an option to configure the used builder class from the treepkg.cfg. This
Andre Heinecke <aheinecke@intevation.de>
parents: 372
diff changeset
521 self.builder = builder_class(builderconfig, root_cmd,
176
7bde59aa611e Make PBuilder.update_extra_pkg_dir create Release and Release.gpg files
Bernhard Herzog <bh@intevation.de>
parents: 172
diff changeset
522 release_signing_keyid=signing_key_id)
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
523 self.deb_email = deb_email
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
524 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
525 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
526 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
527 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
528 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
529 self.do_build = do_build
128
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
530 self.handle_dependencies = handle_dependencies
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
531 self.dependencies = None
401
2db42a2a9db9 add os config statement
Bjoern Ricks <bricks@intevation.de>
parents: 393
diff changeset
532 self.os = os
328
dd2bd0ccd674 Revisions are now handled as strings
Andre Heinecke <aheinecke@intevation.de>
parents: 321
diff changeset
533 self.pkg_dir_template = "%(revision)s-%(rules_revision)s"
dd2bd0ccd674 Revisions are now handled as strings
Andre Heinecke <aheinecke@intevation.de>
parents: 321
diff changeset
534 self.pkg_dir_regex = re.compile(r"(?P<revision>[0-9a-f]+)"
dd2bd0ccd674 Revisions are now handled as strings
Andre Heinecke <aheinecke@intevation.de>
parents: 321
diff changeset
535 r"-(?P<rules_revision>[0-9a-f]+)$")
464
5fda6768bef6 Enable a status_hook to be set and executed on status changes
Andre Heinecke <aheinecke@intevation.de>
parents: 462
diff changeset
536 self.status_hook = status_hook
515
e5698096f1ec fix indentation
Bjoern Ricks <bricks@intevation.de>
parents: 514
diff changeset
537 self.scm_type = scm_type
e5698096f1ec fix indentation
Bjoern Ricks <bricks@intevation.de>
parents: 514
diff changeset
538 self.rules_scm_type = rules_scm_type
511
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
539
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
540 if svn_url:
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
541 url = svn_url
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
542 scm_type = "svn"
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
543 logging.warning("Track: %s options contain svn_url which is " \
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
544 "deprecated. Please use url together with scm_type " \
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
545 "svn instead." % name)
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
546
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
547 # use local debian dir if rules url is not set
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
548 if not rules_url:
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
549 rules_scm_type = "local"
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
550
306
163f0d8b64eb Make the svn external subdirectories configurable in the configuration
Bernhard Herzog <bh@intevation.de>
parents: 305
diff changeset
551 externals = svn_externals
163f0d8b64eb Make the svn external subdirectories configurable in the configuration
Bernhard Herzog <bh@intevation.de>
parents: 305
diff changeset
552 if not externals:
163f0d8b64eb Make the svn external subdirectories configurable in the configuration
Bernhard Herzog <bh@intevation.de>
parents: 305
diff changeset
553 externals = self.svn_external_subdirs
511
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
554 if scm_type == "svn":
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
555 repo = SvnRepository(url, externals, subset=svn_subset)
321
092925ff75d7 Added basic Git support, configuration options:
Andre Heinecke <aheinecke@intevation.de>
parents: 312
diff changeset
556 self.working_copy = SvnWorkingCopy(repo, self.checkout_dir,
092925ff75d7 Added basic Git support, configuration options:
Andre Heinecke <aheinecke@intevation.de>
parents: 312
diff changeset
557 logger=logging)
511
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
558 elif scm_type == "git":
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
559 repo = GitRepository(url, branch=branch)
321
092925ff75d7 Added basic Git support, configuration options:
Andre Heinecke <aheinecke@intevation.de>
parents: 312
diff changeset
560 self.working_copy = GitWorkingCopy(repo, self.checkout_dir,
092925ff75d7 Added basic Git support, configuration options:
Andre Heinecke <aheinecke@intevation.de>
parents: 312
diff changeset
561 logger=logging)
511
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
562 else:
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
563 raise PackagerError("Unknown scm type \"%s\" for sources" %
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
564 scm_type)
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
565
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
566 if rules_scm_type == "svn":
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
567 repo = SvnRepository(rules_url)
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
568 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
569 logger=logging)
511
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
570 elif rules_scm_type == "git":
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
571 repo = GitRepository(rules_url)
510
1f04bd88fca3 provide a possibility to use rules from a git repo
Bjoern Ricks <bricks@intevation.de>
parents: 504
diff changeset
572 self.rules_working_copy = GitWorkingCopy(repo, self.debian_dir,
1f04bd88fca3 provide a possibility to use rules from a git repo
Bjoern Ricks <bricks@intevation.de>
parents: 504
diff changeset
573 loggger=logging)
511
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
574 elif rules_scm_type == "local":
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
575 self.rules_working_copy = ManualWorkingCopy(self.debian_dir)
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
576
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
577 else:
511
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
578 raise PackagerError("Unknown scm type \"%s\" for rules" %
e5b66539f893 new variable to set choose the scm for sources and debian dirs
Bjoern Ricks <bricks@intevation.de>
parents: 510
diff changeset
579 scm_type)
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
580
172
06af36f915f2 Move the filenameproperty factory from treepkg/packager.py to
Bernhard Herzog <bh@intevation.de>
parents: 168
diff changeset
581 checkout_dir = util.filenameproperty("checkout")
06af36f915f2 Move the filenameproperty factory from treepkg/packager.py to
Bernhard Herzog <bh@intevation.de>
parents: 168
diff changeset
582 debian_dir = util.filenameproperty("debian")
06af36f915f2 Move the filenameproperty factory from treepkg/packager.py to
Bernhard Herzog <bh@intevation.de>
parents: 168
diff changeset
583 pkg_dir = util.filenameproperty("pkg")
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
584
106
66cbfc772f84 Add bin/inittreepkg.py, a script to automate some of the installation
Bernhard Herzog <bh@intevation.de>
parents: 99
diff changeset
585 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
586 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
587 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
588 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
589 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
590 # 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
591 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
592 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
593 % (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
594
128
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
595 def determine_dependencies(self):
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
596 if self.dependencies is not None:
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
597 return
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 requires = ()
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
600 provides = ()
131
bea9f1cc0bef Try to determine dependencies only when treepkg is fully configured.
Bernhard Herzog <bh@intevation.de>
parents: 128
diff changeset
601 # 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
602 # 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
603 # 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
604 # 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
605 # 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
606 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
607 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
608 "control"))
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
609 requires = control.build_depends
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
610 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
611 self.dependencies = (set(requires), set(provides))
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
612 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
613 " ".join(self.dependencies[0]))
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
614 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
615 " ".join(self.dependencies[1]))
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
616
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
617 def dependencies_required(self):
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
618 """Returns a list of required packages"""
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
619 self.determine_dependencies()
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
620 return self.dependencies[0]
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
621
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
622 def dependencies_provided(self):
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
623 """Returns a list of provided packages"""
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
624 self.determine_dependencies()
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
625 return self.dependencies[1]
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
626
229
653a45adda50 Prepare for svn managed debian rules directories. So far, the directory
Bernhard Herzog <bh@intevation.de>
parents: 224
diff changeset
627 def pkg_dir_for_revision(self, revision, rules_revision):
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
628 return os.path.join(self.pkg_dir,
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
629 self.pkg_dir_template % locals())
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
630
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
631 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
632 return self.working_copy.last_changed_revision()
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
633
11
6efe0bd3d8c1 Add method RevisionPackager.get_revision_numbers
Bernhard Herzog <bh@intevation.de>
parents: 10
diff changeset
634 def get_revision_numbers(self):
328
dd2bd0ccd674 Revisions are now handled as strings
Andre Heinecke <aheinecke@intevation.de>
parents: 321
diff changeset
635 """Returns a list of the packaged revisions"""
11
6efe0bd3d8c1 Add method RevisionPackager.get_revision_numbers
Bernhard Herzog <bh@intevation.de>
parents: 10
diff changeset
636 revisions = []
6efe0bd3d8c1 Add method RevisionPackager.get_revision_numbers
Bernhard Herzog <bh@intevation.de>
parents: 10
diff changeset
637 if os.path.exists(self.pkg_dir):
6efe0bd3d8c1 Add method RevisionPackager.get_revision_numbers
Bernhard Herzog <bh@intevation.de>
parents: 10
diff changeset
638 for filename in os.listdir(self.pkg_dir):
6efe0bd3d8c1 Add method RevisionPackager.get_revision_numbers
Bernhard Herzog <bh@intevation.de>
parents: 10
diff changeset
639 match = self.pkg_dir_regex.match(filename)
6efe0bd3d8c1 Add method RevisionPackager.get_revision_numbers
Bernhard Herzog <bh@intevation.de>
parents: 10
diff changeset
640 if match:
328
dd2bd0ccd674 Revisions are now handled as strings
Andre Heinecke <aheinecke@intevation.de>
parents: 321
diff changeset
641 revisions.append((match.group("revision"),
dd2bd0ccd674 Revisions are now handled as strings
Andre Heinecke <aheinecke@intevation.de>
parents: 321
diff changeset
642 match.group("rules_revision")))
dd2bd0ccd674 Revisions are now handled as strings
Andre Heinecke <aheinecke@intevation.de>
parents: 321
diff changeset
643 return sorted(revisions)
11
6efe0bd3d8c1 Add method RevisionPackager.get_revision_numbers
Bernhard Herzog <bh@intevation.de>
parents: 10
diff changeset
644
80
0af2fa3790e0 Add revision parameter to PackagerGroup.__init__ and some other methods
Bernhard Herzog <bh@intevation.de>
parents: 78
diff changeset
645 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
646 """Updates the working copy.
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
647
224
6bac65dcf258 Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents: 222
diff changeset
648 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
649 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
650 passed through to the update method.
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
651 """
224
6bac65dcf258 Handle the svn repositories and working copies in a more object oriented way
Bernhard Herzog <bh@intevation.de>
parents: 222
diff changeset
652 self.working_copy.update_or_checkout(revision=revision)
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
653
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
654 def export_sources(self, to_dir):
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
655 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
656 self.working_copy.export(to_dir)
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
657
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
658 def copy_debian_directory(self, to_dir):
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
659 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
660 self.rules_working_copy.export(to_dir)
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
661
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
662 def debian_environment(self):
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
663 """Returns the environment variables for the debian commands"""
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
664 env = os.environ.copy()
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
665 env["DEBFULLNAME"] = self.deb_fullname
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
666 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
667 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
668 # 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
669 # 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
670 # 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
671 env["DEB_BUILD_PARALLEL"] = "true"
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
672 return env
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
673
499
e44c9c3f69f8 consolidate enterprise packagers
Bjoern Ricks <bricks@intevation.de>
parents: 495
diff changeset
674 def new_revsision_packager(self):
e44c9c3f69f8 consolidate enterprise packagers
Bjoern Ricks <bricks@intevation.de>
parents: 495
diff changeset
675 """ Checks if a new revision is available and returns a new
e44c9c3f69f8 consolidate enterprise packagers
Bjoern Ricks <bricks@intevation.de>
parents: 495
diff changeset
676 revision packager class. Don't override this method in a subclass.
e44c9c3f69f8 consolidate enterprise packagers
Bjoern Ricks <bricks@intevation.de>
parents: 495
diff changeset
677 Use packager_for_new_revision() instead."""
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
678 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
679 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
680 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
681 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
682 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
683 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
684 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
685 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
686 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
687 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
688
499
e44c9c3f69f8 consolidate enterprise packagers
Bjoern Ricks <bricks@intevation.de>
parents: 495
diff changeset
689 def packager_for_new_revision(self):
e44c9c3f69f8 consolidate enterprise packagers
Bjoern Ricks <bricks@intevation.de>
parents: 495
diff changeset
690 return self.new_revsision_packager()
e44c9c3f69f8 consolidate enterprise packagers
Bjoern Ricks <bricks@intevation.de>
parents: 495
diff changeset
691
517
de78084fcbce rename do_svn_update in do_update because we provide svn and git support now
Bjoern Ricks <bricks@intevation.de>
parents: 515
diff changeset
692 def package_if_updated(self, revision=None, do_update=True):
190
e83db4482aab Add runtreepkg.py command line option --no-svn-update to inhibit updates
Bernhard Herzog <bh@intevation.de>
parents: 179
diff changeset
693 """Returns a new packager if the working copy has not been packaged yet.
517
de78084fcbce rename do_svn_update in do_update because we provide svn and git support now
Bjoern Ricks <bricks@intevation.de>
parents: 515
diff changeset
694 If do_update is true -- the default -- update the working
370
0bee91b435ab Fix typos in doc-strings.
Bernhard Herzog <bh@intevation.de>
parents: 367
diff changeset
695 copy to the revision specified with the revision parameter
190
e83db4482aab Add runtreepkg.py command line option --no-svn-update to inhibit updates
Bernhard Herzog <bh@intevation.de>
parents: 179
diff changeset
696 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
697 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
698 return None
517
de78084fcbce rename do_svn_update in do_update because we provide svn and git support now
Bjoern Ricks <bricks@intevation.de>
parents: 515
diff changeset
699 if do_update:
190
e83db4482aab Add runtreepkg.py command line option --no-svn-update to inhibit updates
Bernhard Herzog <bh@intevation.de>
parents: 179
diff changeset
700 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
701 # 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
702 # 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
703 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
704 return self.packager_for_new_revision()
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
705
14
dfd89f81e66c Add simple status report tool. Still using the old status files
Bernhard Herzog <bh@intevation.de>
parents: 11
diff changeset
706 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
707 """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
708 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
709 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
710
179
952d366f7b14 Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents: 176
diff changeset
711 def sign_file(self, filename):
952d366f7b14 Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents: 176
diff changeset
712 """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
713 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
714 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
715 signed.
952d366f7b14 Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents: 176
diff changeset
716 """
952d366f7b14 Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents: 176
diff changeset
717 if self.signing_key_id:
952d366f7b14 Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents: 176
diff changeset
718 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
719 self.signing_key_id)
952d366f7b14 Implement optional signing of .dsc and .changes files
Bernhard Herzog <bh@intevation.de>
parents: 176
diff changeset
720 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
721
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
722
113
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 112
diff changeset
723 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
724 """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
725
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 112
diff changeset
726 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
727 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
728 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
729
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 113
diff changeset
730 - 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
731
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 113
diff changeset
732 - 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
733 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
734
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 113
diff changeset
735 - 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
736 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
737 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
738 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
739 used.
113
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 112
diff changeset
740 """
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 112
diff changeset
741 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
742 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
743 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
744 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
745 module.RevisionPackager \
34e08d52956e Make the import_packager_module function more flexible. The modules may
Bernhard Herzog <bh@intevation.de>
parents: 113
diff changeset
746 = 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
747 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
748 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
749 module.PackageTrack \
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 112
diff changeset
750 = 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
751 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
752 return module
312949e7628d Add a smarter way to load the packager modules: Add the function
Bernhard Herzog <bh@intevation.de>
parents: 112
diff changeset
753
52
78cf5f6778ec Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents: 49
diff changeset
754 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
755 module = import_packager_module(packager_class)
52
78cf5f6778ec Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents: 49
diff changeset
756 return module.PackageTrack(**kw)
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents: 2
diff changeset
757
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
758
128
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
759 class CyclicDependencyError(Exception):
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
760
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
761 """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
762
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
763 def __init__(self, tracks):
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
764 Exception.__init__(self,
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
765 "Cyclic dependencies between" " tracks (%s)"
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
766 % ", ".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
767
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
768
7
96f4f58c62b5 Rename the Packager class to PackagerGroup
Bernhard Herzog <bh@intevation.de>
parents: 4
diff changeset
769 class PackagerGroup(object):
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
770
91
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
771 def __init__(self, package_tracks, check_interval, revision=None,
517
de78084fcbce rename do_svn_update in do_update because we provide svn and git support now
Bjoern Ricks <bricks@intevation.de>
parents: 515
diff changeset
772 instructions_file=None, do_update=True,
389
a690fc689f2f added treepkg_dir andd tracks_dir attributes to PackageGroup
Bjoern Ricks <bricks@intevation.de>
parents: 387
diff changeset
773 stop_on_error=False, name="", treepkg_dir=None,
a690fc689f2f added treepkg_dir andd tracks_dir attributes to PackageGroup
Bjoern Ricks <bricks@intevation.de>
parents: 387
diff changeset
774 tracks_dir=None):
52
78cf5f6778ec Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents: 49
diff changeset
775 self.package_tracks = package_tracks
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
776 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
777 self.revision = revision
517
de78084fcbce rename do_svn_update in do_update because we provide svn and git support now
Bjoern Ricks <bricks@intevation.de>
parents: 515
diff changeset
778 self.do_update = do_update
307
5f442b0cf3a4 New command line argument --stop-on-error for runtreepkg.py and
Bernhard Herzog <bh@intevation.de>
parents: 306
diff changeset
779 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
780 self.instructions_file = instructions_file
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
781 self.instructions_file_removed = False
387
c1f3be727f9d renamed new status dir to info because of a naming conflict with status.py
Bjoern Ricks <bricks@intevation.de>
parents: 378
diff changeset
782 self.name = name
389
a690fc689f2f added treepkg_dir andd tracks_dir attributes to PackageGroup
Bjoern Ricks <bricks@intevation.de>
parents: 387
diff changeset
783 self.treepkg_dir = treepkg_dir
a690fc689f2f added treepkg_dir andd tracks_dir attributes to PackageGroup
Bjoern Ricks <bricks@intevation.de>
parents: 387
diff changeset
784 self.tracks_dir = tracks_dir
128
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
785 self.sort_tracks()
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
786
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
787 def sort_tracks(self):
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
788 """Sorts tracks for dependency handling"""
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
789 todo = self.package_tracks[:]
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
790 sorted = []
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
791 seen = set()
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
792
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
793 # 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
794 known = set()
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
795 for track in todo:
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
796 known |= track.dependencies_provided()
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
797
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
798 while todo:
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
799 todo_again = []
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
800 for track in todo:
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
801 if not track.handle_dependencies:
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
802 sorted.append(track)
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
803 continue
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
804
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
805 unmet = (track.dependencies_required() & known) - seen
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
806 if unmet:
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
807 todo_again.append(track)
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
808 else:
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
809 sorted.append(track)
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
810 seen |= track.dependencies_provided()
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
811 if todo_again == todo:
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
812 raise CyclicDependencyError(todo)
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
813 todo = todo_again
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
814
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
815 self.package_tracks = sorted
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
816 self.needed_binaries = set()
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
817 for track in self.package_tracks:
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
818 self.needed_binaries |= track.dependencies_required()
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
819 self.needed_binaries &= known
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
820
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
821 logging.info("sorted track order: %s",
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
822 " ".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
823 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
824 " ".join(self.needed_binaries))
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
825
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
826 def run(self):
7
96f4f58c62b5 Rename the Packager class to PackagerGroup
Bernhard Herzog <bh@intevation.de>
parents: 4
diff changeset
827 """Runs the packager group indefinitely"""
78
9a602d8eaa60 initial revision of the subversion repository
Thomas Arendsen Hein <thomas@intevation.de>
parents: 55
diff changeset
828 logging.info("Starting in periodic check mode."
9a602d8eaa60 initial revision of the subversion repository
Thomas Arendsen Hein <thomas@intevation.de>
parents: 55
diff changeset
829 " Will check every %d seconds", self.check_interval)
312
2d6915bce473 Rework the packager mainloop. it's a bit simpler now and stopping should
Bernhard Herzog <bh@intevation.de>
parents: 310
diff changeset
830 next_check = time.time()
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
831 while 1:
312
2d6915bce473 Rework the packager mainloop. it's a bit simpler now and stopping should
Bernhard Herzog <bh@intevation.de>
parents: 310
diff changeset
832 if self.should_stop():
2d6915bce473 Rework the packager mainloop. it's a bit simpler now and stopping should
Bernhard Herzog <bh@intevation.de>
parents: 310
diff changeset
833 logging.info("Received stop instruction. Stopping.")
2d6915bce473 Rework the packager mainloop. it's a bit simpler now and stopping should
Bernhard Herzog <bh@intevation.de>
parents: 310
diff changeset
834 return
2d6915bce473 Rework the packager mainloop. it's a bit simpler now and stopping should
Bernhard Herzog <bh@intevation.de>
parents: 310
diff changeset
835
2d6915bce473 Rework the packager mainloop. it's a bit simpler now and stopping should
Bernhard Herzog <bh@intevation.de>
parents: 310
diff changeset
836 this_check = time.time()
2d6915bce473 Rework the packager mainloop. it's a bit simpler now and stopping should
Bernhard Herzog <bh@intevation.de>
parents: 310
diff changeset
837 if this_check >= next_check:
2d6915bce473 Rework the packager mainloop. it's a bit simpler now and stopping should
Bernhard Herzog <bh@intevation.de>
parents: 310
diff changeset
838 logging.info("Next check is now")
91
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
839 if self.check_package_tracks():
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
840 break
312
2d6915bce473 Rework the packager mainloop. it's a bit simpler now and stopping should
Bernhard Herzog <bh@intevation.de>
parents: 310
diff changeset
841 last_check = this_check
2d6915bce473 Rework the packager mainloop. it's a bit simpler now and stopping should
Bernhard Herzog <bh@intevation.de>
parents: 310
diff changeset
842 next_check = this_check + self.check_interval
2d6915bce473 Rework the packager mainloop. it's a bit simpler now and stopping should
Bernhard Herzog <bh@intevation.de>
parents: 310
diff changeset
843 else:
2d6915bce473 Rework the packager mainloop. it's a bit simpler now and stopping should
Bernhard Herzog <bh@intevation.de>
parents: 310
diff changeset
844 to_sleep = next_check - this_check
2d6915bce473 Rework the packager mainloop. it's a bit simpler now and stopping should
Bernhard Herzog <bh@intevation.de>
parents: 310
diff changeset
845 logging.info("Next check at %s",
2d6915bce473 Rework the packager mainloop. it's a bit simpler now and stopping should
Bernhard Herzog <bh@intevation.de>
parents: 310
diff changeset
846 time.strftime("%Y-%m-%d %H:%M:%S",
2d6915bce473 Rework the packager mainloop. it's a bit simpler now and stopping should
Bernhard Herzog <bh@intevation.de>
parents: 310
diff changeset
847 time.localtime(next_check)))
2d6915bce473 Rework the packager mainloop. it's a bit simpler now and stopping should
Bernhard Herzog <bh@intevation.de>
parents: 310
diff changeset
848 time.sleep(to_sleep)
0
f78a02e79c84 initial checkin
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
849
52
78cf5f6778ec Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents: 49
diff changeset
850 def check_package_tracks(self):
78cf5f6778ec Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents: 49
diff changeset
851 logging.info("Checking package tracks")
91
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
852 self.clear_instruction()
128
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
853 repeat = True
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
854 while repeat:
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
855 repeat = False
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
856 for track in self.package_tracks:
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
857 try:
190
e83db4482aab Add runtreepkg.py command line option --no-svn-update to inhibit updates
Bernhard Herzog <bh@intevation.de>
parents: 179
diff changeset
858 packager = track.package_if_updated(revision=self.revision,
517
de78084fcbce rename do_svn_update in do_update because we provide svn and git support now
Bjoern Ricks <bricks@intevation.de>
parents: 515
diff changeset
859 do_update=self.do_update)
128
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
860 if packager:
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
861 packager.package()
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
862 repeat = self.install_dependencies(track, packager)
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
863 except:
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
864 logging.exception("An error occurred while"
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
865 " 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
866 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
867 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
868 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
869 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
870 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
871 return True
128
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
872 if repeat:
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
873 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
874 " Starting over to ensure all dependencies"
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
875 " are met")
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
876 break
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
877
52
78cf5f6778ec Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents: 49
diff changeset
878 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
879
128
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
880
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
881 def install_dependencies(self, track, packager):
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
882 """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
883 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
884 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
885 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
886 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
887 -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
888 at the same time.
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
889 """
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
890 if (track.handle_dependencies
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
891 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
892 # 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
893 # 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
894 # 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
895 # 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
896 # 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
897 # them
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
898 binaries = packager.list_binary_files()
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
899 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
900 return True
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
901 return False
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
902
5155b4f9443d Add basic dependency handling to PackageTrack and PackagerGroup.
Bernhard Herzog <bh@intevation.de>
parents: 125
diff changeset
903
52
78cf5f6778ec Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents: 49
diff changeset
904 def get_package_tracks(self):
78cf5f6778ec Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents: 49
diff changeset
905 return self.package_tracks
91
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
906
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
907 def read_instruction(self):
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
908 if not self.instructions_file:
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
909 return ""
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
910 try:
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
911 f = open(self.instructions_file)
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
912 except (IOError, OSError):
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
913 return ""
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
914 try:
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
915 return f.read().strip()
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
916 finally:
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
917 f.close()
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
918 self.clear_instruction()
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
919
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
920 def clear_instruction(self, force=False):
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
921 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
922 or force):
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
923 util.writefile(self.instructions_file, "")
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
924 self.instructions_file_removed = True
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
925
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
926 def should_stop(self):
3ed079a7174a Implement a way to stop a running treepackager.
Bernhard Herzog <bh@intevation.de>
parents: 90
diff changeset
927 return self.read_instruction() == "stop"
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)