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