annotate recipes/kde_enterprise_4/base.py @ 273:4b700b39c32f

Refactoring: Move the TagDetector class into the treepkg.subversion module
author Bernhard Herzog <bh@intevation.de>
date Thu, 07 May 2009 14:25:10 +0000
parents bba100869221
children 2676abfc0e1d
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
89ca9ba349e5 New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
21 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
22 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
23 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
24 + "." + str(self.revision))
89ca9ba349e5 New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
25
89ca9ba349e5 New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
26 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
27 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
28 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
29
89ca9ba349e5 New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
30 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
31 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
32 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
33
89ca9ba349e5 New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
34 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
35 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
36 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
37 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
38 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
39
89ca9ba349e5 New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
40 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
41 % (self.revision,))
89ca9ba349e5 New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
42 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
43 changemsg)
89ca9ba349e5 New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
44
89ca9ba349e5 New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
45 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
46 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
47
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 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
50
265
9c0131d2e0e1 Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents: 216
diff changeset
51 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
52 ("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
53 ("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
54 ("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
55
89ca9ba349e5 New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
56 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
57 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
58 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
59 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
60 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
61 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
62 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
63 tags_pattern,
4b700b39c32f Refactoring: Move the TagDetector class into the treepkg.subversion module
Bernhard Herzog <bh@intevation.de>
parents: 268
diff changeset
64 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
65
9c0131d2e0e1 Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents: 216
diff changeset
66 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
67 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
68 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
69 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
70 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
71 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
72 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
73 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
74 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
75 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
76 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
77 revision)
9c0131d2e0e1 Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents: 216
diff changeset
78 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
79 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
80 else:
9c0131d2e0e1 Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents: 216
diff changeset
81 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
82 revision)
9c0131d2e0e1 Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents: 216
diff changeset
83
9c0131d2e0e1 Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents: 216
diff changeset
84 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
85
9c0131d2e0e1 Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents: 216
diff changeset
86 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
87 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
88 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
89 else:
9c0131d2e0e1 Add automatic detection and builds of svn tags for the kdepim enterprise4
Bernhard Herzog <bh@intevation.de>
parents: 216
diff changeset
90 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
91
267
fdee17d71778 Refactor the enterprise4 BasePackageTrack to make it possible to
Bernhard Herzog <bh@intevation.de>
parents: 265
diff changeset
92 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
93 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
94 tag_url, to_dir)
fdee17d71778 Refactor the enterprise4 BasePackageTrack to make it possible to
Bernhard Herzog <bh@intevation.de>
parents: 265
diff changeset
95 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
96
216
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 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
99
89ca9ba349e5 New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
100 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
101
89ca9ba349e5 New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
102 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
103 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
104 class SourcePackager(BaseSourcePackager):
89ca9ba349e5 New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
105 pkg_basename = basename
89ca9ba349e5 New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
106
89ca9ba349e5 New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
107 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
108 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
109
89ca9ba349e5 New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
110 class PackageTrack(BasePackageTrack):
89ca9ba349e5 New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
111 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
112
89ca9ba349e5 New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
113 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
114 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
115
89ca9ba349e5 New module with code common to almost all kdepim enterprise 4 recipes
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
116 caller_globals["PackageTrack"] = PackageTrack
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)