annotate recipes/kde_enterprise_3_5/kdepim.py @ 160:017179427c7f

Make treepkg/utilreplace_in_file return whether any substitutions were made. Add a corresponding test.
author Bernhard Herzog <bh@intevation.de>
date Thu, 19 Jun 2008 12:25:30 +0000
parents 3f2ec4314855
children 710538908609
rev   line source
111
7f6fb8103db0 Move the sed-like replacement code from enterprise/kdepim.py to treepkg/util.py
Bernhard Herzog <bh@intevation.de>
parents: 52
diff changeset
1 # Copyright (C) 2007, 2008 by Intevation GmbH
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
2 # Authors:
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
3 # Bernhard Herzog <bh@intevation.de>
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
4 #
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
5 # This program is free software under the GPL (>=v2)
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
6 # Read the file COPYING coming with the software for details.
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
7
159
3f2ec4314855 Changed matching string enterprise->enterprise35, so it matches
Bernhard Reiter <bernhard@intevation.de>
parents: 132
diff changeset
8 """Packager that builds KDE-PIM debian packages from the enterprise35 branch.
3f2ec4314855 Changed matching string enterprise->enterprise35, so it matches
Bernhard Reiter <bernhard@intevation.de>
parents: 132
diff changeset
9 """
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
10
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
11 import os
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
12 import time
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
13 import re
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
14
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
15 import treepkg.util
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
16 import treepkg.packager
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
17
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
18
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
19 class SourcePackager(treepkg.packager.SourcePackager):
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
20
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
21 pkg_basename = "kdepim"
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
22
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
23 def __init__(self, *args, **kw):
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
24 super(SourcePackager, self).__init__(*args, **kw)
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
25 self.enterprise_version = (time.strftime("%Y%m%d", time.localtime()) \
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
26 + "." + str(self.revision))
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
27
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
28 def kdepim_version(self, directory):
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
29 """Determine the kdepim version.
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
30
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
31 The version is taken from the kdepim.lsm file.
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
32 """
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
33 return treepkg.util.extract_lsm_version(os.path.join(directory,
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
34 "kdepim.lsm"))
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
35
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
36 def determine_package_version(self, directory):
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
37 enterprise_version = self.enterprise_version
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
38 kdepimversion = self.kdepim_version(directory)
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
39 version_template = "%(kdepimversion)s.enterprise.0.%(enterprise_version)s"
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
40 return version_template % locals()
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
41
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
42 def update_version_numbers(self, pkgbasedir):
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
43 """Overrides the inherited method to update version numbers in the code
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
44 """
159
3f2ec4314855 Changed matching string enterprise->enterprise35, so it matches
Bernhard Reiter <bernhard@intevation.de>
parents: 132
diff changeset
45 versionstring = "(enterprise35 %s)" % self.enterprise_version
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
46 for versionfile in ["kmail/kmversion.h", "kontact/src/main.cpp",
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
47 "korganizer/version.h"]:
159
3f2ec4314855 Changed matching string enterprise->enterprise35, so it matches
Bernhard Reiter <bernhard@intevation.de>
parents: 132
diff changeset
48 #FIXME: should check successful replacements
111
7f6fb8103db0 Move the sed-like replacement code from enterprise/kdepim.py to treepkg/util.py
Bernhard Herzog <bh@intevation.de>
parents: 52
diff changeset
49 treepkg.util.replace_in_file(os.path.join(pkgbasedir, versionfile),
159
3f2ec4314855 Changed matching string enterprise->enterprise35, so it matches
Bernhard Reiter <bernhard@intevation.de>
parents: 132
diff changeset
50 "\(enterprise35 ([^)]*)\)",
111
7f6fb8103db0 Move the sed-like replacement code from enterprise/kdepim.py to treepkg/util.py
Bernhard Herzog <bh@intevation.de>
parents: 52
diff changeset
51 versionstring)
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
52
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
53 def do_package(self):
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
54 pkgbaseversion, pkgbasedir = self.export_sources()
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
55 self.update_version_numbers(pkgbasedir)
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
56
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
57 pkgbasename = "kdepim_" + pkgbaseversion
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
58 origtargz = os.path.join(self.work_dir,
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
59 pkgbasename + ".orig.tar.gz")
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
60 self.create_tarball(origtargz, self.work_dir,
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
61 os.path.basename(pkgbasedir))
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
62
159
3f2ec4314855 Changed matching string enterprise->enterprise35, so it matches
Bernhard Reiter <bernhard@intevation.de>
parents: 132
diff changeset
63 changemsg = ("Update to SVN enterprise35 branch rev. %d"
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
64 % (self.revision,))
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
65 self.copy_debian_directory(pkgbasedir, pkgbaseversion,
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
66 changemsg)
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
67
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
68 self.create_source_package(pkgbasedir, origtargz)
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
69 self.move_source_package(pkgbasename)
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
70
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
71
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
72 class RevisionPackager(treepkg.packager.RevisionPackager):
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
73
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
74 source_packager_cls = SourcePackager
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
75
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
76
52
78cf5f6778ec Rename 'packagel ine' -> 'package track'
Bernhard Herzog <bh@intevation.de>
parents: 8
diff changeset
77 class PackageTrack(treepkg.packager.PackageTrack):
4
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
78
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
79 revision_packager_cls = RevisionPackager
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
80
fee641fec94e Separate the kolab specific parts.
Bernhard Herzog <bh@intevation.de>
parents:
diff changeset
81 svn_external_subdirs = ["admin"]
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)