Mercurial > treepkg
annotate recipes/kde_enterprise_4/base.py @ 272:026dd7286431
Remove unused imports
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Thu, 07 May 2009 14:11:14 +0000 |
parents | bba100869221 |
children | 4b700b39c32f |
rev | line source |
---|---|
216
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
1 # Copyright (C) 2007, 2008, 2009 by Intevation GmbH |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
2 # Authors: |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
3 # Bernhard Herzog <bh@intevation.de> |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
4 # |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
5 # This program is free software under the GPL (>=v2) |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
6 # Read the file COPYING coming with the software for details. |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
7 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
8 """Base classes for all kdepim packagers""" |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
9 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
10 import os |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
11 import time |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
12 import inspect |
265
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
13 import re |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
14 import logging |
216
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
15 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
16 import treepkg.packager |
265
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
17 import treepkg.subversion |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
18 |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
19 |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
20 class TagDetector(object): |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
21 |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
22 """Class to automatically find SVN tags and help package them |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
23 |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
24 The tags are found using three parameters: |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
25 url -- The base url of the SVN tags directory to use |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
26 pattern -- A regular expression matching the subdirectories to |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
27 consider in the tag directory specified by the url |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
28 subdir -- A subdirectory of the directory matched by pattern to |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
29 export and use to determine revision number |
268
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
30 |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
31 The subdir parameter is there to cope with the kdepim enterprise |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
32 tags. The URL for a tag is of the form |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
33 .../tags/kdepim/enterprise4.0.<date>.<rev> . Each such tag has |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
34 subdirectories for kdepim, kdelibs, etc. The url and pattern are |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
35 used to match the URL for the tag, and the subdir is used to select |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
36 which part of the tag is meant. |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
37 |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
38 The subdir also determines which SVN directory's revision number is |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
39 used. Normally, just appending the subdir to the tag URL would be |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
40 enough for this, but the situation is more complex for |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
41 kdebase_workspace and kdebase_runtime, whose code comes from |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
42 different subdirectories of the kdebase-4.X-branch subdirectory (for |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
43 enterprise4 tags). Here the revision number must be taken from |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
44 kdebase-4.X-branch, but the URL to use when exporting the sources, |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
45 must refer to e.g. kdebase-4.1-branch/kdebase_workspace. To achieve |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
46 that, subdir may contain slashes to indicate subdirectories of |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
47 subdirectories, but only the first part of subdir (up to the first |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
48 slash) is used when determining the revision number. |
265
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
49 """ |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
50 |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
51 def __init__(self, url, pattern, subdir): |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
52 self.url = url |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
53 self.pattern = re.compile(pattern) |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
54 self.subdir = subdir |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
55 |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
56 def list_tags(self): |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
57 matches = [] |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
58 if self.url: |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
59 for tag in treepkg.subversion.list_url(self.url): |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
60 if self.pattern.match(tag.rstrip("/")): |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
61 matches.append(tag) |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
62 return sorted(matches) |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
63 |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
64 def newest_tag_revision(self): |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
65 """Determines the newest tag revision and returns (tagurl, revno) |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
66 If no tag can be found, the method returns the tuple (None, None). |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
67 """ |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
68 candidates = self.list_tags() |
268
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
69 urlrev = (None, None) |
265
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
70 if candidates: |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
71 newest = candidates[-1] |
268
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
72 urlrev = self.determine_revision(self.url + "/" + newest, |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
73 self.subdir) |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
74 return urlrev |
265
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
75 |
268
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
76 def determine_revision(self, baseurl, subdir): |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
77 urlrev = (None, None) |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
78 revision_url = baseurl + "/" + subdir.split("/")[0] |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
79 try: |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
80 revision = treepkg.subversion.last_changed_revision(revision_url) |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
81 urlrev = (baseurl + "/" + subdir, revision) |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
82 except treepkg.subversion.SubversionError: |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
83 pass |
bba100869221
Improve handling of nested subdirectories of tags in the enterprise4 tag
Bernhard Herzog <bh@intevation.de>
parents:
267
diff
changeset
|
84 return urlrev |
216
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
85 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
86 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
87 class BaseSourcePackager(treepkg.packager.SourcePackager): |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
88 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
89 def __init__(self, *args, **kw): |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
90 super(BaseSourcePackager, self).__init__(*args, **kw) |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
91 self.enterprise_version = (time.strftime("%Y%m%d", time.localtime()) \ |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
92 + "." + str(self.revision)) |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
93 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
94 def determine_package_version(self, directory): |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
95 enterprise_version = self.enterprise_version |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
96 return self.track.version_template % locals() |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
97 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
98 def do_package(self): |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
99 pkgbaseversion, pkgbasedir = self.export_sources() |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
100 self.update_version_numbers(pkgbasedir) |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
101 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
102 pkgbasename = self.pkg_basename + "_" + pkgbaseversion |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
103 origtargz = os.path.join(self.work_dir, |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
104 pkgbasename + ".orig.tar.gz") |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
105 self.create_tarball(origtargz, self.work_dir, |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
106 os.path.basename(pkgbasedir)) |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
107 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
108 changemsg = ("Update to SVN enterprise4 branch rev. %d" |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
109 % (self.revision,)) |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
110 self.copy_debian_directory(pkgbasedir, pkgbaseversion, |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
111 changemsg) |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
112 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
113 self.create_source_package(pkgbasedir, origtargz) |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
114 self.move_source_package(pkgbasename) |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
115 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
116 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
117 class BasePackageTrack(treepkg.packager.PackageTrack): |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
118 |
265
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
119 extra_config_desc = ["version_template", |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
120 ("tags_url", str, ""), |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
121 ("tags_pattern", str, ""), |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
122 ("tags_subdir", str, "")] |
216
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
123 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
124 def __init__(self, *args, **kw): |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
125 self.version_template = kw.pop("version_template") |
265
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
126 tags_url = kw.pop("tags_url") |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
127 tags_pattern = kw.pop("tags_pattern") |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
128 tags_subdir = kw.pop("tags_subdir") |
216
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
129 super(BasePackageTrack, self).__init__(*args, **kw) |
265
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
130 self.tag_detector = TagDetector(tags_url, tags_pattern, tags_subdir) |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
131 |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
132 def packager_for_new_revision(self): |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
133 logging.info("Checking tags") |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
134 self.tag_url = None |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
135 tag_url, tag_revision = self.tag_detector.newest_tag_revision() |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
136 logging.info("Found: %s: %s", tag_url, tag_revision) |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
137 if tag_url is not None: |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
138 revision = (tag_revision, |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
139 self.rules_working_copy.last_changed_revision()) |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
140 logging.info("New revision is %s", revision) |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
141 if revision not in self.get_revision_numbers(): |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
142 logging.info("Revision %s has not been packaged yet", |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
143 revision) |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
144 self.tag_url = tag_url |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
145 return self.revision_packager_cls(self, tag=tag_url, *revision) |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
146 else: |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
147 logging.info("Revision %s has already been packaged.", |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
148 revision) |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
149 |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
150 return super(BasePackageTrack, self).packager_for_new_revision() |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
151 |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
152 def export_sources(self, to_dir): |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
153 if self.tag_url is not None: |
267
fdee17d71778
Refactor the enterprise4 BasePackageTrack to make it possible to
Bernhard Herzog <bh@intevation.de>
parents:
265
diff
changeset
|
154 self.export_tag(self.tag_url, to_dir) |
265
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
155 else: |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
156 super(BasePackageTrack, self).export_sources(to_dir) |
216
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
157 |
267
fdee17d71778
Refactor the enterprise4 BasePackageTrack to make it possible to
Bernhard Herzog <bh@intevation.de>
parents:
265
diff
changeset
|
158 def export_tag(self, tag_url, to_dir): |
fdee17d71778
Refactor the enterprise4 BasePackageTrack to make it possible to
Bernhard Herzog <bh@intevation.de>
parents:
265
diff
changeset
|
159 logging.info("Exporting sources from %s to %r", |
fdee17d71778
Refactor the enterprise4 BasePackageTrack to make it possible to
Bernhard Herzog <bh@intevation.de>
parents:
265
diff
changeset
|
160 tag_url, to_dir) |
fdee17d71778
Refactor the enterprise4 BasePackageTrack to make it possible to
Bernhard Herzog <bh@intevation.de>
parents:
265
diff
changeset
|
161 treepkg.subversion.export(tag_url, to_dir) |
fdee17d71778
Refactor the enterprise4 BasePackageTrack to make it possible to
Bernhard Herzog <bh@intevation.de>
parents:
265
diff
changeset
|
162 |
216
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
163 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
164 def define_kdepim_packager(basename=None, external_subdirs=None): |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
165 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
166 caller_globals = inspect.currentframe().f_back.f_globals |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
167 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
168 SourcePackager = caller_globals.get("SourcePackager") |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
169 if SourcePackager is None: |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
170 class SourcePackager(BaseSourcePackager): |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
171 pkg_basename = basename |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
172 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
173 class RevisionPackager(treepkg.packager.RevisionPackager): |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
174 source_packager_cls = SourcePackager |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
175 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
176 class PackageTrack(BasePackageTrack): |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
177 revision_packager_cls = RevisionPackager |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
178 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
179 if external_subdirs is not None: |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
180 svn_external_subdirs = external_subdirs |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
181 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
182 caller_globals["PackageTrack"] = PackageTrack |