comparison recipes/kde_enterprise_3_5/kde_i18n.py @ 132:d7b3dac63ad0

Reorganize and rename the packager hierarchy. The packagers from enterprise/ are now in recipes/kde_enterprise_3_5/ .
author Bernhard Herzog <bh@intevation.de>
date Fri, 23 May 2008 19:16:08 +0000
parents enterprise/kdei18n.py@66cbfc772f84
children 12facd1b5f19
comparison
equal deleted inserted replaced
131:bea9f1cc0bef 132:d7b3dac63ad0
1 # Copyright (C) 2007, 2008 by Intevation GmbH
2 # Authors:
3 # Bernhard Herzog <bh@intevation.de>
4 #
5 # This program is free software under the GPL (>=v2)
6 # Read the file COPYING coming with the software for details.
7
8 import os
9 import logging
10 import shutil
11 import time
12
13 import treepkg.packager
14 import treepkg.util
15 import treepkg.run as run
16 from treepkg.cmdexpand import cmdexpand
17
18
19 class SourcePackager(treepkg.packager.SourcePackager):
20
21 """Creates the debian source package for the i18n files
22
23 This is quite complicated. The orig.tar.gz file of the debian
24 source package contains one .tar.bz2 file for every language. Those
25 .tar.bz files are the kde-18n-<lang> files released by the KDE
26 project. For now, we only have the German localization in the
27 enterprise source package, so the orig.tar.gz file will have the
28 following contents:
29
30 kde-i18n-<version>/
31 kde-i18n-<version>/kde-i18n-de-<version>.tar.bz2
32
33 <version> is the same everywhere.
34
35 The kde-i18n-de tarball contains the localization files for the
36 entire KDE project, including KDE-PIM. The SVN enterprise branch
37 only contains the localizations for KDE-PIM, though, so we have to
38 assemble a new .tar.bz2 from an original
39 kde-i18n-de-<version>.tar.bz and the new files from the enterprise
40 branch.
41 """
42
43 pkg_basename = "kde-i18n"
44
45 def determine_package_version(self, directory):
46 enterprise_version = (time.strftime("%Y%m%d", time.localtime()) \
47 + "." + str(self.revision))
48 kdepimversion = "3.5.5"
49 version_template = "%(kdepimversion)s.enterprise.0.%(enterprise_version)s"
50 return version_template % locals()
51
52 def unpack_orig_tarball(self):
53 orig_tarball = self.track.orig_tarball
54 run.call(cmdexpand("tar xjf $tarball -C $directory",
55 tarball=orig_tarball, directory=self.work_dir))
56 tarbasename = os.path.basename(orig_tarball)
57 splitext = os.path.splitext
58 return os.path.join(self.work_dir,
59 splitext(splitext(tarbasename)[0])[0])
60
61 def create_i18n_de_tarball(self, pkgbasedir, pkgbaseversion):
62 """Creates a new kde-i18n-de tarball and returns its filename
63
64 This is the tarball as it would be released by KDE. It is not
65 yet the tarball that will become the .orig.tar.gz for the debian
66 package.
67 """
68 logging.info("Creating kde-i18n-de tarball")
69 untarred_dir = self.unpack_orig_tarball()
70 new_de_dir = os.path.join(pkgbasedir, "new-de")
71 de_dir = os.path.join(pkgbasedir, "de")
72 os.rename(de_dir, new_de_dir)
73 treepkg.util.copytree(untarred_dir, de_dir)
74 treepkg.util.copytree(new_de_dir, de_dir)
75 logging.info("Running scripts/autogen.sh for kde-i18n-de tarball")
76 run.call(cmdexpand("/bin/sh scripts/autogen.sh de"), cwd=pkgbasedir,
77 suppress_output=True)
78
79 tarballdir = "kde-i18n-de-" + pkgbaseversion
80 os.rename(de_dir, os.path.join(pkgbasedir, tarballdir))
81
82 tarball = os.path.join(os.path.dirname(pkgbasedir),
83 tarballdir + ".tar.bz2")
84 run.call(cmdexpand("tar cjf $tarball -C $pkgbasedir $tarballdir",
85 **locals()))
86 logging.info("Created kde-i18n-de tarball")
87 return tarball
88
89 def do_package(self):
90 # Create a new kde-i18n-de tarball from current SVN and the base
91 # kde-i18n-de tarball.
92 pkgbaseversion, pkgbasedir = self.export_sources()
93 tarball = self.create_i18n_de_tarball(pkgbasedir, pkgbaseversion)
94
95 # We have to reuse the same directory when building the
96 # orig.tar.gz. However, we need to preserver the scripts
97 # sub-directory because it's not needed for the kde-i18n-de
98 # tarball but for the .orig.tar.gz.
99 pkg_scripts_dir = os.path.join(pkgbasedir, "scripts")
100 tmp_scripts_dir = os.path.join(self.work_dir, "scripts")
101 os.rename(pkg_scripts_dir, tmp_scripts_dir)
102 shutil.rmtree(pkgbasedir)
103 os.mkdir(pkgbasedir)
104 os.rename(tmp_scripts_dir, pkg_scripts_dir)
105
106 pkgbasename = self.pkg_basename + "_" + pkgbaseversion
107 origtargz = os.path.join(self.work_dir,
108 pkgbasename + ".orig.tar.gz")
109 os.rename(tarball, os.path.join(pkgbasedir,
110 os.path.basename(tarball)))
111 self.create_tarball(origtargz, self.work_dir,
112 os.path.basename(pkgbasedir))
113
114 changemsg = ("Update to SVN enterprise branch rev. %d"
115 % (self.revision,))
116 self.copy_debian_directory(pkgbasedir, pkgbaseversion,
117 changemsg)
118
119 self.create_source_package(pkgbasedir, origtargz)
120 self.move_source_package(pkgbasename)
121
122
123 class RevisionPackager(treepkg.packager.RevisionPackager):
124
125 source_packager_cls = SourcePackager
126
127
128 class PackageTrack(treepkg.packager.PackageTrack):
129
130 revision_packager_cls = RevisionPackager
131
132 svn_external_subdirs = ["scripts", "scripts/admin", "documentation/kdepim"]
133
134 extra_config_desc = ["orig_tarball"]
135
136 def __init__(self, *args, **kw):
137 self.orig_tarball = kw.pop("orig_tarball")
138 super(PackageTrack, self).__init__(*args, **kw)
139
140 def init_treepkg(self):
141 super(PackageTrack, self).init_treepkg()
142 if not os.path.exists(self.orig_tarball):
143 print ("TODO: The orig_tarball %s still has to be created"
144 % (self.orig_tarball,))
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)