bh@111: # Copyright (C) 2007, 2008 by Intevation GmbH bh@4: # Authors: bh@4: # Bernhard Herzog bh@4: # bh@4: # This program is free software under the GPL (>=v2) bh@4: # Read the file COPYING coming with the software for details. bh@4: bernhard@159: """Packager that builds KDE-PIM debian packages from the enterprise35 branch. bernhard@159: """ bh@4: bh@4: import os bh@4: import time bh@4: import re bh@4: bh@4: import treepkg.util bh@4: import treepkg.packager bh@4: bh@4: bh@4: class SourcePackager(treepkg.packager.SourcePackager): bh@4: bh@4: pkg_basename = "kdepim" bh@4: bh@4: def __init__(self, *args, **kw): bh@4: super(SourcePackager, self).__init__(*args, **kw) bh@4: self.enterprise_version = (time.strftime("%Y%m%d", time.localtime()) \ bh@4: + "." + str(self.revision)) bh@4: bh@4: def kdepim_version(self, directory): bh@4: """Determine the kdepim version. bh@4: bh@4: The version is taken from the kdepim.lsm file. bh@4: """ bh@4: return treepkg.util.extract_lsm_version(os.path.join(directory, bh@4: "kdepim.lsm")) bh@4: bh@4: def determine_package_version(self, directory): bh@4: enterprise_version = self.enterprise_version bh@4: kdepimversion = self.kdepim_version(directory) bh@4: version_template = "%(kdepimversion)s.enterprise.0.%(enterprise_version)s" bh@4: return version_template % locals() bh@4: bh@4: def update_version_numbers(self, pkgbasedir): bh@4: """Overrides the inherited method to update version numbers in the code bh@4: """ bernhard@159: versionstring = "(enterprise35 %s)" % self.enterprise_version bh@4: for versionfile in ["kmail/kmversion.h", "kontact/src/main.cpp", bh@4: "korganizer/version.h"]: bernhard@159: #FIXME: should check successful replacements bh@111: treepkg.util.replace_in_file(os.path.join(pkgbasedir, versionfile), bernhard@159: "\(enterprise35 ([^)]*)\)", bh@111: versionstring) bh@4: bh@4: def do_package(self): bh@4: pkgbaseversion, pkgbasedir = self.export_sources() bh@4: self.update_version_numbers(pkgbasedir) bh@4: bh@4: pkgbasename = "kdepim_" + pkgbaseversion bh@4: origtargz = os.path.join(self.work_dir, bh@4: pkgbasename + ".orig.tar.gz") bh@4: self.create_tarball(origtargz, self.work_dir, bh@4: os.path.basename(pkgbasedir)) bh@4: bernhard@159: changemsg = ("Update to SVN enterprise35 branch rev. %d" bh@4: % (self.revision,)) bh@4: self.copy_debian_directory(pkgbasedir, pkgbaseversion, bh@4: changemsg) bh@4: bh@4: self.create_source_package(pkgbasedir, origtargz) bh@4: self.move_source_package(pkgbasename) bh@4: bh@4: bh@4: class RevisionPackager(treepkg.packager.RevisionPackager): bh@4: bh@4: source_packager_cls = SourcePackager bh@4: bh@4: bh@52: class PackageTrack(treepkg.packager.PackageTrack): bh@4: bh@4: revision_packager_cls = RevisionPackager bh@4: bh@4: svn_external_subdirs = ["admin"]