comparison recipes/kde/maemo/generic.py @ 344:f06f707d9fda

merged branches/scratchbox into trunk #### IMPORTANT FOR ALL TREEPKGS ##### pbuilderrc config variable name changed to builderconfig
author Bjoern Ricks <bricks@intevation.de>
date Fri, 23 Apr 2010 07:43:29 +0000
parents
children b9c7e05aa3d9
comparison
equal deleted inserted replaced
343:c0808837fc64 344:f06f707d9fda
1 # Copyright (C) 2007, 2008, 2009, 2010 by Intevation GmbH
2 # Authors:
3 # Bernhard Herzog <bh@intevation.de>
4 # Bjoern Ricks <bjoern.ricks@intevation.de>
5 #
6 # This program is free software under the GPL (>=v2)
7 # Read the file COPYING coming with the software for details.
8
9 """Base classes for all kde maemo packagers"""
10
11 import re
12 import time
13 import logging
14
15 import treepkg.packager
16 import treepkg.subversion as subversion
17 import treepkg.sbuilder
18
19
20 class SourcePackager(treepkg.packager.SourcePackager):
21
22 def __init__(self, *args, **kw):
23 super(SourcePackager, self).__init__(*args, **kw)
24 self.enterprise_version = (self.parent.pkg_date + "."
25 + str(self.revision))
26 self.maemo_version = "%s.%s" % (self.revision,
27 self.parent.pkg_date)
28
29 def determine_package_version(self, directory):
30 enterprise_version = self.enterprise_version
31 maemo_version = self.maemo_version
32 revision = self.revision
33 rules_revision = self.parent.rules_revision
34 pkg_revision = self.parent.pkg_revision
35 pkg_date = self.parent.pkg_date
36
37 return self.track.version_template % locals()
38
39 def prepare_sources_for_tarball(self, pkgbasedir, pkgbaseversion):
40 self.update_version_numbers(pkgbasedir)
41
42 def update_version_numbers(self, pkgbasedir):
43 """Updates the version numbers in the code in pkgbasedir.
44 The default implementation does nothing. Derived classes should
45 override this method if necessary.
46 """
47
48 def get_change_msg(self):
49 return self.changemsg_template % dict(revision=self.revision,
50 pkg_date=self.parent.pkg_date,
51 rules_revision=self.parent.rules_revision)
52
53
54 class RevisionPackager(treepkg.packager.RevisionPackager):
55
56 source_packager_cls = SourcePackager
57
58 def __init__(self, *args, **kw):
59 self.pkg_date = kw.pop("pkg_date",
60 time.strftime("%Y%m%d", time.localtime()))
61 super(RevisionPackager, self).__init__(*args, **kw)
62
63
64 class PackageTrack(treepkg.packager.PackageTrack):
65
66 revision_packager_cls = RevisionPackager
67 builder_cls = treepkg.sbuilder.SbdmockBuilder
68
69 extra_config_desc = [("tags_url", str, ""),
70 ("tags_pattern", str, ""),
71 ("tags_subdir", str, "")]
72
73 def __init__(self, *args, **kw):
74 tags_url = kw.pop("tags_url")
75 tags_pattern = kw.pop("tags_pattern")
76 tags_subdir = kw.pop("tags_subdir")
77 super(PackageTrack, self).__init__(*args, **kw)
78 self.tag_detector = subversion.TagDetector(tags_url, tags_pattern,
79 tags_subdir)
80
81 def packager_for_new_revision(self):
82 logging.info("Checking tags")
83 self.tag_url = None
84 tag_url, tag_revision = self.tag_detector.newest_tag_revision()
85 logging.info("Found: %s: %s", tag_url, tag_revision)
86 if tag_url is not None:
87 revision = (tag_revision,
88 self.rules_working_copy.last_changed_revision())
89 logging.info("New revision is %s", revision)
90 if revision not in self.get_revision_numbers():
91 logging.info("Revision %s has not been packaged yet",
92 revision)
93 self.tag_url = tag_url
94 self.tag_revision = tag_revision
95 tag_date, tag_change_count = self.tag_pkg_parameters(tag_url)
96 pkg_revision = (self.pkg_revision_template
97 % dict(pkg_revision=tag_change_count))
98 return self.revision_packager_cls(self, tag=tag_url,
99 pkg_revision=pkg_revision,
100 pkg_date=tag_date,
101 *revision)
102 else:
103 logging.info("Revision %s has already been packaged.",
104 revision)
105
106 return super(PackageTrack, self).packager_for_new_revision()
107
108 def export_sources(self, to_dir):
109 if self.tag_url is not None:
110 logging.info("Exporting sources for tarball from %r to %r",
111 self.tag_url, to_dir)
112 self.working_copy.export_tag(self.tag_url, to_dir,
113 revision=self.tag_revision)
114 else:
115 super(PackageTrack, self).export_sources(to_dir)
116
117 def tag_pkg_parameters(self, tag_url):
118 match = re.search(r"/enterprise[^.]*\.[^.]*\."
119 r"(?P<date>[0-9]{8})\.(?P<baserev>[0-9]+)/",
120 tag_url)
121 if match:
122 date = match.group("date")
123 baserev = match.group("baserev")
124 xml_log = subversion.log_xml(tag_url, baserev)
125 revisions = subversion.extract_tag_revisions(xml_log)
126 tag_change_count = len(revisions)
127 return (date, tag_change_count)
128 else:
129 raise RuntimeError("Cannot determine tag parameters from %r"
130 % tag_url)
131
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)