Mercurial > treepkg
annotate recipes/kde_enterprise_3_5/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 | 12facd1b5f19 |
children | 2676abfc0e1d |
rev | line source |
---|---|
271
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
1 # Copyright (C) 2007, 2008, 2009 by Intevation GmbH |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
2 # Authors: |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
3 # Bernhard Herzog <bh@intevation.de> |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
4 # |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
5 # This program is free software under the GPL (>=v2) |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
6 # Read the file COPYING coming with the software for details. |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
7 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
8 """Base classes for all kdepim packagers""" |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
9 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
10 import os |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
11 import time |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
12 import logging |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
13 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
14 import treepkg.packager |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
15 import treepkg.subversion |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
16 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
17 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
18 class BaseSourcePackager(treepkg.packager.SourcePackager): |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
19 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
20 changemsg_template = None |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
21 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
22 def __init__(self, *args, **kw): |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
23 super(BaseSourcePackager, self).__init__(*args, **kw) |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
24 self.enterprise_version = (time.strftime("%Y%m%d", time.localtime()) \ |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
25 + "." + str(self.revision)) |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
26 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
27 def determine_package_version(self, directory): |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
28 enterprise_version = self.enterprise_version |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
29 return self.track.version_template % locals() |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
30 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
31 def do_package(self): |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
32 pkgbaseversion, pkgbasedir = self.export_sources() |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
33 self.update_version_numbers(pkgbasedir) |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
34 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
35 pkgbasename = self.pkg_basename + "_" + pkgbaseversion |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
36 origtargz = os.path.join(self.work_dir, |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
37 pkgbasename + ".orig.tar.gz") |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
38 self.create_tarball(origtargz, self.work_dir, |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
39 os.path.basename(pkgbasedir)) |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
40 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
41 changemsg = self.changemsg_template % dict(revision=self.revision) |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
42 self.copy_debian_directory(pkgbasedir, pkgbaseversion, |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
43 changemsg) |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
44 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
45 self.create_source_package(pkgbasedir, origtargz) |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
46 self.move_source_package(pkgbasename) |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
47 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
48 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
49 class BasePackageTrack(treepkg.packager.PackageTrack): |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
50 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
51 extra_config_desc = [("version_template", str, "%(enterprise_version)s"), |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
52 ("tags_url", str, ""), |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
53 ("tags_pattern", str, ""), |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
54 ("tags_subdir", str, "")] |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
55 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
56 def __init__(self, *args, **kw): |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
57 self.version_template = kw.pop("version_template") |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
58 tags_url = kw.pop("tags_url") |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
59 tags_pattern = kw.pop("tags_pattern") |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
60 tags_subdir = kw.pop("tags_subdir") |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
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:
271
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:
271
diff
changeset
|
63 tags_pattern, |
4b700b39c32f
Refactoring: Move the TagDetector class into the treepkg.subversion module
Bernhard Herzog <bh@intevation.de>
parents:
271
diff
changeset
|
64 tags_subdir) |
271
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
65 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
66 def packager_for_new_revision(self): |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
67 logging.info("Checking tags") |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
68 self.tag_url = None |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
69 tag_url, tag_revision = self.tag_detector.newest_tag_revision() |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
70 logging.info("Found: %s: %s", tag_url, tag_revision) |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
71 if tag_url is not None: |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
72 revision = (tag_revision, |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
73 self.rules_working_copy.last_changed_revision()) |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
74 logging.info("New revision is %s", revision) |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
75 if revision not in self.get_revision_numbers(): |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
76 logging.info("Revision %s has not been packaged yet", |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
77 revision) |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
78 self.tag_url = tag_url |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
79 return self.revision_packager_cls(self, tag=tag_url, *revision) |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
80 else: |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
81 logging.info("Revision %s has already been packaged.", |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
82 revision) |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
83 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
84 return super(BasePackageTrack, self).packager_for_new_revision() |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
85 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
86 def export_sources(self, to_dir): |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
87 if self.tag_url is not None: |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
88 self.export_tag(self.tag_url, to_dir) |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
89 else: |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
90 super(BasePackageTrack, self).export_sources(to_dir) |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
91 |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
92 def export_tag(self, tag_url, to_dir): |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
93 logging.info("Exporting sources from %s to %r", |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
94 tag_url, to_dir) |
12facd1b5f19
Implement tag detection for the KDEPIM enterprise 3.5 packages. This is
Bernhard Herzog <bh@intevation.de>
parents:
diff
changeset
|
95 treepkg.subversion.export(tag_url, to_dir) |