Mercurial > treepkg
annotate recipes/kde_enterprise_4/base.py @ 275:c0cbd133b607
Define changemsg_template in BaseSourcePackager and not in the kdepim
specific derived classe
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Thu, 07 May 2009 15:35:28 +0000 |
parents | 2676abfc0e1d |
children | f3dee156e3e3 |
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 logging |
216
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
14 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
15 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
|
16 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
|
17 |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
18 |
216
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
19 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
|
20 |
274
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
273
diff
changeset
|
21 changemsg_template = "Update to SVN enterprise4 branch rev. %(revision)d" |
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
273
diff
changeset
|
22 |
216
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
23 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
|
24 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
|
25 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
|
26 + "." + str(self.revision)) |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
27 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
28 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
|
29 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
|
30 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
|
31 |
274
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
273
diff
changeset
|
32 def prepare_sources_for_tarball(self, pkgbasedir): |
216
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
33 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
|
34 |
274
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
273
diff
changeset
|
35 def update_version_numbers(self, pkgbasedir): |
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
273
diff
changeset
|
36 """Updates the version numbers in the code in pkgbasedir. |
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
273
diff
changeset
|
37 The default implementation does nothing. Derived classes should |
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
273
diff
changeset
|
38 override this method if necessary. |
2676abfc0e1d
Refactoring: Implement do_package in treepkg.packager.SourcePackager.
Bernhard Herzog <bh@intevation.de>
parents:
273
diff
changeset
|
39 """ |
216
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
40 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
41 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
42 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
|
43 |
265
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
44 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
|
45 ("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
|
46 ("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
|
47 ("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
|
48 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 super(BasePackageTrack, self).__init__(*args, **kw) |
273
4b700b39c32f
Refactoring: Move the TagDetector class into the treepkg.subversion module
Bernhard Herzog <bh@intevation.de>
parents:
268
diff
changeset
|
55 self.tag_detector = treepkg.subversion.TagDetector(tags_url, |
4b700b39c32f
Refactoring: Move the TagDetector class into the treepkg.subversion module
Bernhard Herzog <bh@intevation.de>
parents:
268
diff
changeset
|
56 tags_pattern, |
4b700b39c32f
Refactoring: Move the TagDetector class into the treepkg.subversion module
Bernhard Herzog <bh@intevation.de>
parents:
268
diff
changeset
|
57 tags_subdir) |
265
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
58 |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
59 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
|
60 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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 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
|
66 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
|
67 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
|
68 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
|
69 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
|
70 revision) |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
71 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
|
72 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
|
73 else: |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
74 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
|
75 revision) |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
76 |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
77 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
|
78 |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
79 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
|
80 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
|
81 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
|
82 else: |
9c0131d2e0e1
Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents:
216
diff
changeset
|
83 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
|
84 |
267
fdee17d71778
Refactor the enterprise4 BasePackageTrack to make it possible to
Bernhard Herzog <bh@intevation.de>
parents:
265
diff
changeset
|
85 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
|
86 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
|
87 tag_url, to_dir) |
fdee17d71778
Refactor the enterprise4 BasePackageTrack to make it possible to
Bernhard Herzog <bh@intevation.de>
parents:
265
diff
changeset
|
88 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
|
89 |
216
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
90 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
91 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
|
92 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
93 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
|
94 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
95 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
|
96 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
|
97 class SourcePackager(BaseSourcePackager): |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
98 pkg_basename = basename |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
99 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
100 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
|
101 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
|
102 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
103 class PackageTrack(BasePackageTrack): |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
104 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
|
105 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
106 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
|
107 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
|
108 |
89ca9ba349e5
New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
109 caller_globals["PackageTrack"] = PackageTrack |