bricks@381: # Copyright (C) 2007 - 2010 by Intevation GmbH bricks@362: # Authors: bricks@362: # Bernhard Herzog bricks@362: # Bjoern Ricks bricks@362: # bricks@362: # This program is free software under the GPL (>=v2) bricks@362: # Read the file COPYING coming with the software for details. bricks@362: bricks@362: import os bricks@362: import logging bricks@362: import shutil bricks@362: import time bricks@362: bricks@362: import treepkg.util bricks@362: from treepkg.cmdexpand import cmdexpand bricks@362: from treepkg import run bricks@362: bricks@381: import recipes.kde.enterprise.kde_l10n as generic bricks@362: bricks@362: bricks@362: class SourcePackager(generic.SourcePackager): bricks@362: bricks@362: """Creates the debian source package for the l10n files bricks@362: bricks@362: This is a bit more complicated than for other packages. The bricks@362: orig.tar.gz file of the debian source package contains one .tar.bz2 bricks@362: file for every language. Those .tar.bz files are the kde-18n- bricks@362: files released by the KDE project. For now, we only have the German bricks@362: localization in the enterprise source package, so the orig.tar.gz bricks@362: file will have the following contents: bricks@362: bricks@362: kde-l10n-/ bricks@362: kde-l10n-/kde-l10n-de-.tar.bz2 bricks@362: bricks@362: is the same everywhere. bricks@362: """ bricks@362: bricks@362: createtarball_script = """\ bricks@362: #! /bin/bash bricks@362: set -e bricks@362: bricks@362: #fakeroot apt-get --assume-yes --force-yes install %(builddeps)s bricks@362: bricks@362: # copy the source tree to a directory that's under pbuilder control so bricks@362: # that it gets removed along with the build environment. Otherwise we bricks@362: # end up with a directory containing files that cannot be removed by bricks@362: # treepkg bricks@362: workdir=/tmp/work bricks@362: cp -a %(basedir)s $workdir bricks@362: cd $workdir bricks@362: bricks@362: # only handle the de subdirectory bricks@362: echo de > subdirs bricks@362: bricks@362: # create the CMakeFiles bricks@362: ./scripts/autogen.sh bricks@362: mv de kde-l10n-de-%(version)s bricks@362: tar cjf %(tarball)s kde-l10n-de-%(version)s bricks@362: cd .. bricks@362: rm -rf $workdir bricks@362: """ bricks@362: bricks@362: bricks@362: def __init__(self, *args, **kw): bricks@362: super(SourcePackager, self).__init__(*args, **kw) bricks@362: bricks@362: def create_l10n_de_tarball(self, pkgbasedir, pkgbaseversion): bricks@362: logging.info("Creating kde-l10n-de tarball") bricks@362: de_tarball = os.path.join(self.work_dir, bricks@362: "kde-l10n-de-" + pkgbaseversion + ".tar.bz2") bricks@362: # xutils-dev is needed for the revpath script used by bricks@362: # scripts/autogen.sh bricks@362: script = (self.createtarball_script bricks@362: % dict(builddeps="xutils-dev", tarball=de_tarball, bricks@362: basedir=pkgbasedir, version=pkgbaseversion)) bricks@362: script_name = os.path.join(self.work_dir, "createtarball") bricks@362: treepkg.util.writefile(script_name, script, 0755) bricks@362: treepkg.util.ensure_directory(self.src_dir) bricks@362: treepkg.util.ensure_directory(self.log_dir) bricks@381: # do not run scratchbox bricks@362: #self.track.builder.run_script([script_name], bricks@362: # logfile=os.path.join(self.log_dir, bricks@362: # "tarball_log.txt"), bricks@362: # bindmounts=[self.work_dir]) bricks@362: self.run_script([script_name], logfile=os.path.join(self.log_dir, bricks@362: "tarball_log.txt")) bricks@362: bricks@362: return de_tarball bricks@362: bricks@362: def run_script(self, script_name, logfile): bricks@381: ''' run script outside of scratchbox ''' bricks@362: run.call(cmdexpand("@script", script=script_name), bricks@362: suppress_output=False, logfile=logfile) bricks@362: bricks@362: class RevisionPackager(generic.RevisionPackager): bricks@362: bricks@362: source_packager_cls = SourcePackager bricks@362: bricks@362: bricks@362: class PackageTrack(generic.PackageTrack): bricks@362: bricks@362: revision_packager_cls = RevisionPackager