comparison recipes/kde/maemo/kde_l10n.py @ 362:7a1385c1207c

packageer for kde_l10n on maemo
author Bjoern Ricks <bricks@intevation.de>
date Fri, 21 May 2010 12:45:58 +0000
parents
children 51c447a6792e
comparison
equal deleted inserted replaced
361:72b39fcb6a24 362:7a1385c1207c
1 # Copyright (C) 2007, 2008, 2009 by Intevation GmbH
2 # Authors:
3 # Bernhard Herzog <bh@intevation.de>
4 # Bjoern Ricks <bjoern.ricks@intevation.de>
5 #
6 # This program is free software under the GPL (>=v2)
7 # Read the file COPYING coming with the software for details.
8
9 import os
10 import logging
11 import shutil
12 import time
13
14 import treepkg.util
15 from treepkg.cmdexpand import cmdexpand
16 from treepkg import run
17
18 import recipes.kde.maemo.generic as generic
19
20
21 class SourcePackager(generic.SourcePackager):
22
23 """Creates the debian source package for the l10n files
24
25 This is a bit more complicated than for other packages. The
26 orig.tar.gz file of the debian source package contains one .tar.bz2
27 file for every language. Those .tar.bz files are the kde-18n-<lang>
28 files released by the KDE project. For now, we only have the German
29 localization in the enterprise source package, so the orig.tar.gz
30 file will have the following contents:
31
32 kde-l10n-<version>/
33 kde-l10n-<version>/kde-l10n-de-<version>.tar.bz2
34
35 <version> is the same everywhere.
36 """
37
38 createtarball_script = """\
39 #! /bin/bash
40 set -e
41
42 #fakeroot apt-get --assume-yes --force-yes install %(builddeps)s
43
44 # copy the source tree to a directory that's under pbuilder control so
45 # that it gets removed along with the build environment. Otherwise we
46 # end up with a directory containing files that cannot be removed by
47 # treepkg
48 workdir=/tmp/work
49 cp -a %(basedir)s $workdir
50 cd $workdir
51
52 # only handle the de subdirectory
53 echo de > subdirs
54
55 # create the CMakeFiles
56 ./scripts/autogen.sh
57 mv de kde-l10n-de-%(version)s
58 tar cjf %(tarball)s kde-l10n-de-%(version)s
59 cd ..
60 rm -rf $workdir
61 """
62
63
64 def __init__(self, *args, **kw):
65 super(SourcePackager, self).__init__(*args, **kw)
66 self.enterprise_version = (time.strftime("%Y%m%d", time.localtime())
67 + "." + str(self.revision))
68 self.maemo_version = "%s.%s" % (self.revision,
69 self.parent.pkg_date)
70
71 def determine_package_version(self, directory):
72 enterprise_version = self.enterprise_version
73 maemo_version = self.maemo_version
74 revision = self.revision
75 rules_revision = self.parent.rules_revision
76 pkg_revision = self.parent.pkg_revision
77 pkg_date = self.parent.pkg_date
78
79 return self.track.version_template % locals()
80
81 def create_l10n_de_tarball(self, pkgbasedir, pkgbaseversion):
82 logging.info("Creating kde-l10n-de tarball")
83 de_tarball = os.path.join(self.work_dir,
84 "kde-l10n-de-" + pkgbaseversion + ".tar.bz2")
85 # xutils-dev is needed for the revpath script used by
86 # scripts/autogen.sh
87 script = (self.createtarball_script
88 % dict(builddeps="xutils-dev", tarball=de_tarball,
89 basedir=pkgbasedir, version=pkgbaseversion))
90 script_name = os.path.join(self.work_dir, "createtarball")
91 treepkg.util.writefile(script_name, script, 0755)
92 treepkg.util.ensure_directory(self.src_dir)
93 treepkg.util.ensure_directory(self.log_dir)
94 #self.track.builder.run_script([script_name],
95 # logfile=os.path.join(self.log_dir,
96 # "tarball_log.txt"),
97 # bindmounts=[self.work_dir])
98 self.run_script([script_name], logfile=os.path.join(self.log_dir,
99 "tarball_log.txt"))
100
101 return de_tarball
102
103 def run_script(self, script_name, logfile):
104 run.call(cmdexpand("@script", script=script_name),
105 suppress_output=False, logfile=logfile)
106
107 def prepare_sources_for_tarball(self, pkgbasedir, pkgbaseversion):
108 de_tarball = self.create_l10n_de_tarball(pkgbasedir, pkgbaseversion)
109 shutil.rmtree(pkgbasedir)
110 os.mkdir(pkgbasedir)
111 os.rename(de_tarball,
112 os.path.join(pkgbasedir, os.path.basename(de_tarball)))
113
114
115 class RevisionPackager(generic.RevisionPackager):
116
117 source_packager_cls = SourcePackager
118
119
120 class PackageTrack(generic.PackageTrack):
121
122 revision_packager_cls = RevisionPackager
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)