comparison recipes/kde_enterprise_4/base.py @ 278:354fc60d90a4

Reuse most of the code from recipes/kde_enterprise_3_5/base.py for enterprise4
author Bernhard Herzog <bh@intevation.de>
date Thu, 07 May 2009 16:55:06 +0000
parents f3dee156e3e3
children 85eb9425c346
comparison
equal deleted inserted replaced
277:4441aff001ac 278:354fc60d90a4
13 import logging 13 import logging
14 14
15 import treepkg.packager 15 import treepkg.packager
16 import treepkg.subversion 16 import treepkg.subversion
17 17
18 import recipes.kde_enterprise_3_5.base as base35
18 19
19 class BaseSourcePackager(treepkg.packager.SourcePackager): 20 class BaseSourcePackager(base35.BaseSourcePackager):
20 21
21 changemsg_template = "Update to SVN enterprise4 branch rev. %(revision)d" 22 changemsg_template = "Update to SVN enterprise4 branch rev. %(revision)d"
22 23
23 def __init__(self, *args, **kw):
24 super(BaseSourcePackager, self).__init__(*args, **kw)
25 self.enterprise_version = (time.strftime("%Y%m%d", time.localtime()) \
26 + "." + str(self.revision))
27 24
28 def determine_package_version(self, directory): 25 BasePackageTrack = base35.BasePackageTrack
29 enterprise_version = self.enterprise_version
30 return self.track.version_template % locals()
31
32 def prepare_sources_for_tarball(self, pkgbasedir, pkgbaseversion):
33 self.update_version_numbers(pkgbasedir)
34
35 def update_version_numbers(self, pkgbasedir):
36 """Updates the version numbers in the code in pkgbasedir.
37 The default implementation does nothing. Derived classes should
38 override this method if necessary.
39 """
40
41
42 class BasePackageTrack(treepkg.packager.PackageTrack):
43
44 extra_config_desc = ["version_template",
45 ("tags_url", str, ""),
46 ("tags_pattern", str, ""),
47 ("tags_subdir", str, "")]
48
49 def __init__(self, *args, **kw):
50 self.version_template = kw.pop("version_template")
51 tags_url = kw.pop("tags_url")
52 tags_pattern = kw.pop("tags_pattern")
53 tags_subdir = kw.pop("tags_subdir")
54 super(BasePackageTrack, self).__init__(*args, **kw)
55 self.tag_detector = treepkg.subversion.TagDetector(tags_url,
56 tags_pattern,
57 tags_subdir)
58
59 def packager_for_new_revision(self):
60 logging.info("Checking tags")
61 self.tag_url = None
62 tag_url, tag_revision = self.tag_detector.newest_tag_revision()
63 logging.info("Found: %s: %s", tag_url, tag_revision)
64 if tag_url is not None:
65 revision = (tag_revision,
66 self.rules_working_copy.last_changed_revision())
67 logging.info("New revision is %s", revision)
68 if revision not in self.get_revision_numbers():
69 logging.info("Revision %s has not been packaged yet",
70 revision)
71 self.tag_url = tag_url
72 return self.revision_packager_cls(self, tag=tag_url, *revision)
73 else:
74 logging.info("Revision %s has already been packaged.",
75 revision)
76
77 return super(BasePackageTrack, self).packager_for_new_revision()
78
79 def export_sources(self, to_dir):
80 if self.tag_url is not None:
81 self.export_tag(self.tag_url, to_dir)
82 else:
83 super(BasePackageTrack, self).export_sources(to_dir)
84
85 def export_tag(self, tag_url, to_dir):
86 logging.info("Exporting sources from %s to %r",
87 tag_url, to_dir)
88 treepkg.subversion.export(tag_url, to_dir)
89 26
90 27
91 def define_kdepim_packager(basename=None, external_subdirs=None): 28 def define_kdepim_packager(basename=None, external_subdirs=None):
92 29
93 caller_globals = inspect.currentframe().f_back.f_globals 30 caller_globals = inspect.currentframe().f_back.f_globals
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)