[Treepkg-commits] r299 - in trunk: . bin recipes/kde test treepkg
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Apr 23 09:43:30 CEST 2010
Author: bricks
Date: 2010-04-23 09:43:29 +0200 (Fri, 23 Apr 2010)
New Revision: 299
Added:
trunk/bin/initbuilder.py
trunk/recipes/kde/maemo/
trunk/treepkg/sbuilder.py
Removed:
trunk/bin/initpbuilder.py
Modified:
trunk/bin/treepkgbuilder.py
trunk/demo.cfg
trunk/test/test_builder.py
trunk/test/test_listpackages.py
trunk/test/test_notifications.py
trunk/test/test_packager.py
trunk/test/test_readconfig.py
trunk/treepkg/builder.py
trunk/treepkg/packager.py
trunk/treepkg/readconfig.py
trunk/treepkg/util.py
Log:
merged branches/scratchbox into trunk
#### IMPORTANT FOR ALL TREEPKGS #####
pbuilderrc config variable name changed to builderconfig
Copied: trunk/bin/initbuilder.py (from rev 298, branches/scratchbox/bin/initbuilder.py)
Deleted: trunk/bin/initpbuilder.py
===================================================================
--- trunk/bin/initpbuilder.py 2010-04-22 19:25:02 UTC (rev 298)
+++ trunk/bin/initpbuilder.py 2010-04-23 07:43:29 UTC (rev 299)
@@ -1,55 +0,0 @@
-#! /usr/bin/python
-# Copyright (C) 2007, 2008, 2009 by Intevation GmbH
-# Authors:
-# Bernhard Herzog <bh at intevation.de>
-#
-# This program is free software under the GPL (>=v2)
-# Read the file COPYING coming with the software for details.
-
-"""Script to initialize the pbuilder environment for the tree packager
-
-The script assumes that the config file for the tree packager already
-contains the pbuilder settings. Also, this script assumes that there is
-only one pbuilder setting for all packagers.
-"""
-
-import sys
-
-import treepkgcmd
-from treepkg.options import create_parser
-from treepkg.packager import create_package_track, PackagerGroup
-from treepkg.readconfig import read_config
-
-
-def parse_commandline():
- parser = create_parser()
- parser.set_defaults(distribution="etch")
- parser.add_option("--mirrorsite",
- help=("The debian mirror site"
- " (pbuilder MIRRORSITE setting). Required."))
- parser.add_option("--othermirror",
- help=("Extra contents of the OTHERMIRROR setting."
- " See the pbuilder documentation for the format."))
- parser.add_option("--distribution",
- help=("The debian distribution for the pbuilder chroot."
- " Default is etch."))
- return parser.parse_args()
-
-
-def main():
- options, args = parse_commandline()
-
- if options.mirrorsite is None:
- print >>sys.stderr, "Missing required option --mirrorsite"
- sys.exit(1)
-
- treepkg_opts, packager_opts = read_config(options.config_file)
- group = PackagerGroup([create_package_track(**opts)
- for opts in packager_opts],
- **treepkg_opts)
- track = group.get_package_tracks()[0]
- track.builder.init_pbuilder(distribution=options.distribution,
- mirrorsite=options.mirrorsite,
- extramirrors=options.othermirror)
-
-main()
Modified: trunk/bin/treepkgbuilder.py
===================================================================
--- trunk/bin/treepkgbuilder.py 2010-04-22 19:25:02 UTC (rev 298)
+++ trunk/bin/treepkgbuilder.py 2010-04-23 07:43:29 UTC (rev 299)
@@ -76,7 +76,7 @@
def run(self):
builder = self.get_builder()
- builder.init_pbuilder(distribution=self.opts.distribution,
+ builder.init_builder(distribution=self.opts.distribution,
mirrorsite=self.opts.mirrorsite,
extramirrors=self.opts.othermirror)
Modified: trunk/demo.cfg
===================================================================
--- trunk/demo.cfg 2010-04-22 19:25:02 UTC (rev 298)
+++ trunk/demo.cfg 2010-04-23 07:43:29 UTC (rev 299)
@@ -26,12 +26,12 @@
# specific values
root_cmd: sudo
-# The pbuilder config file to use. It should be an absolute filename.
+# The builder config file to use. It should be an absolute filename.
# The script initpbuilder.py can create it and the rest of the pbuilder
# files and directories. You can override this in the pkg_ sections for
-# individual packagers if necessary. You will have to adapt pbuilder
+# individual packagers if necessary. You will have to adapt e.g. pbuilder
# yourself, then, though.
-pbuilderrc: %(treepkg_dir)s/pbuilder/pbuilderrc
+builderconfig: %(treepkg_dir)s/pbuilder/pbuilderrc
# Email address and name to use as the packager in the debian packages.
Copied: trunk/recipes/kde/maemo (from rev 298, branches/scratchbox/recipes/kde/maemo)
Modified: trunk/test/test_builder.py
===================================================================
--- trunk/test/test_builder.py 2010-04-22 19:25:02 UTC (rev 298)
+++ trunk/test/test_builder.py 2010-04-23 07:43:29 UTC (rev 299)
@@ -44,14 +44,14 @@
class TestPBuilder(PBuilderTests):
def test_init_pbuilder(self):
- """Tests the PBuilder.init_pbuilder method."""
+ """Tests the PBuilder.init_builder method."""
basedir = self.create_temp_dir("pbuilder")
pbuilderrc = os.path.join(basedir, "pbuilderrc")
builder = PBuilder(pbuilderrc, self.root_command)
old_stdout = sys.stdout
sys.stdout = captured_stdout = StringIO.StringIO()
try:
- builder.init_pbuilder(distribution="etch",
+ builder.init_builder(distribution="etch",
mirrorsite="http://example.com/debian",
extramirrors=None)
finally:
@@ -62,7 +62,7 @@
"aptcache", "extra-pkg"]
if not os.path.isdir(os.path.join(basedir, dirname))]
if missing:
- self.fail("init_pbuilder did not create these directories: %s"
+ self.fail("init_builder did not create these directories: %s"
% " ".join(missing))
# check the pbuilderrc. This test is a little too strict
@@ -104,7 +104,7 @@
% dict(basedir_repr=repr(basedir)[1:-1]))
def test_init_pbuilder_run_twice(self):
- """Tests whether PBuilder.init_pbuilder prints an error when run twice.
+ """Tests whether PBuilder.init_builder prints an error when run twice.
"""
basedir = self.create_temp_dir("pbuilder")
@@ -114,7 +114,7 @@
old_stdout = sys.stdout
sys.stdout = captured_stdout = StringIO.StringIO()
try:
- builder.init_pbuilder(distribution="etch",
+ builder.init_builder(distribution="etch",
mirrorsite="http://example.com/debian",
extramirrors=None)
finally:
@@ -127,7 +127,7 @@
sys.stderr = captured_stderr = StringIO.StringIO()
try:
try:
- builder.init_pbuilder(distribution="etch",
+ builder.init_builder(distribution="etch",
mirrorsite="http://example.com/debian",
extramirrors=None)
except SystemExit, exc:
Modified: trunk/test/test_listpackages.py
===================================================================
--- trunk/test/test_listpackages.py 2010-04-22 19:25:02 UTC (rev 298)
+++ trunk/test/test_listpackages.py 2010-04-23 07:43:29 UTC (rev 299)
@@ -64,7 +64,7 @@
[DEFAULT]
tracks_dir: %(tracksdir)s
root_cmd: true
-pbuilderrc:
+builderconfig:
deb_email: packager at example.com
deb_fullname: Sample Packager
pkg_revision_template: treepkg%%%%(pkg_revision)s
Modified: trunk/test/test_notifications.py
===================================================================
--- trunk/test/test_notifications.py 2010-04-22 19:25:02 UTC (rev 298)
+++ trunk/test/test_notifications.py 2010-04-23 07:43:29 UTC (rev 299)
@@ -21,7 +21,7 @@
[DEFAULT]
tracks_dir: %(tracksdir)s
root_cmd: true
-pbuilderrc:
+builderconfig:
deb_email: packager at example.com
deb_fullname: Sample Packager
pkg_revision_template: treepkg%%%%(pkg_revision)d
Modified: trunk/test/test_packager.py
===================================================================
--- trunk/test/test_packager.py 2010-04-22 19:25:02 UTC (rev 298)
+++ trunk/test/test_packager.py 2010-04-23 07:43:29 UTC (rev 299)
@@ -111,7 +111,7 @@
rootcmd = os.path.join(os.path.dirname(__file__), os.pardir, "test",
"mocksudopbuilder.py")
track = PackageTrack(name="testpkg", base_dir=self.trackdir,
- svn_url=self.svn_url, pbuilderrc="",
+ svn_url=self.svn_url, builderconfig="",
root_cmd=[sys.executable, rootcmd],
deb_email="treepkg at example.com",
deb_fullname="treepkg tester",
@@ -388,7 +388,7 @@
defaults = dict(base_dir="/home/builder/tracks/" + name,
svn_url="svn://example.com",
root_cmd=["false"],
- pbuilderrc="/home/builder/pbuilderrc",
+ builderconfig="/home/builder/pbuilderrc",
deb_email="treepkg at example.com", deb_fullname="treepkg",
handle_dependencies=handle_dependencies)
super(PackageTrackWithDependencies,
Modified: trunk/test/test_readconfig.py
===================================================================
--- trunk/test/test_readconfig.py 2010-04-22 19:25:02 UTC (rev 298)
+++ trunk/test/test_readconfig.py 2010-04-23 07:43:29 UTC (rev 299)
@@ -25,7 +25,7 @@
tracks_dir: %(treepkg_dir)s/tracks
root_cmd: sudo
pbuilder_dir: %(treepkg_dir)s/pbuilder
-pbuilderrc: %(pbuilder_dir)s/pbuilderrc
+builderconfig: %(pbuilder_dir)s/pbuilderrc
deb_email: treepkg at example.com
deb_fullname: TreePKG
pkg_revision_template: treepkg%%(pkg_revision)s
@@ -95,7 +95,7 @@
pkg_revision_template="treepkg%(pkg_revision)s",
handle_dependencies=False,
packager_class="readconfig_test.extraargs",
- pbuilderrc="/home/builder/mill/pbuilder/pbuilderrc",
+ builderconfig="/home/builder/mill/pbuilder/pbuilderrc",
# pkg_basename is passed as an empty string by default.
# The PackageTrack an empty pkg_basename it with the
# value of name
@@ -122,7 +122,7 @@
pkg_revision_template="treepkg%(pkg_revision)s",
handle_dependencies=True,
packager_class="readconfig_test.simple",
- pbuilderrc="/home/builder/mill/pbuilder/pbuilderrc",
+ builderconfig="/home/builder/mill/pbuilder/pbuilderrc",
pkg_basename="simple1",
root_cmd=['sudo'],
signing_key_id="abcd1234",
Modified: trunk/treepkg/builder.py
===================================================================
--- trunk/treepkg/builder.py 2010-04-22 19:25:02 UTC (rev 298)
+++ trunk/treepkg/builder.py 2010-04-23 07:43:29 UTC (rev 299)
@@ -17,9 +17,63 @@
import run
from cmdexpand import cmdexpand
+class Builder:
+
+ basetgz_dir = util.filenameproperty("base")
+ build_dir = util.filenameproperty("build")
+ result_dir = util.filenameproperty("result")
+ aptcache_dir = util.filenameproperty("aptcache")
+ extra_pkg_dir = util.filenameproperty("extra-pkg")
+
+ """ Parent class for all Builders """
+ def __init__(self):
+ pass
-class PBuilder(object):
+ def update_extra_pkg_dir(self):
+ run.call(cmdexpand("apt-ftparchive packages ."),
+ stdout=open(os.path.join(self.extra_pkg_dir, "Packages"), "w"),
+ cwd=self.extra_pkg_dir)
+ release_filename = os.path.join(self.extra_pkg_dir, "Release")
+ run.call(cmdexpand("apt-ftparchive release ."),
+ stdout=open(release_filename, "w"), cwd=self.extra_pkg_dir)
+ # handle signatures. remove any existing signature because it
+ # will be invalid now.
+ signature = release_filename + ".gpg"
+ try:
+ os.remove(signature)
+ except OSError:
+ pass
+ if self.release_signing_keyid:
+ run.call(cmdexpand("gpg --detach-sign --armor --local-user=$keyid"
+ " -o $sig $release",
+ keyid=self.release_signing_keyid,
+ sig=release_filename + ".gpg",
+ release=release_filename))
+ def add_binaries_to_extra_pkg(self, filenames, subdirectory="auto"):
+ """Adds binary packages to the extra-pkg directory.
+ The filenames parameter should be sequence of absolute
+ filenames. The files named will be copied to a subdirectory of
+ the extra-pkg directory which is assumed to reside in the same
+ directory as the pbuilderrc. The subdirectory is specified with
+ the subdirectory parameter and defaults to 'auto'. Afterwards,
+ the method generates a Packages file in the directory and runs
+ pbuilder update. All of this assumes that pbuilder was set up
+ the way bin/initpbuilder.py does.
+ """
+ target_dir = os.path.join(self.extra_pkg_dir, subdirectory)
+ util.ensure_directory(target_dir)
+ for filename in filenames:
+ logging.info("Copying %s into %s", filename, target_dir)
+ shutil.copy(filename, target_dir)
+
+ logging.info("Running apt-ftparchive in %s", self.extra_pkg_dir)
+ self.update_extra_pkg_dir()
+
+ self.update(suppress_output=True, log_info=True)
+
+class PBuilder(Builder):
+
"""Represents a way to run and manage a specific pbuilder instance"""
pbuilderrc_template = '''\
@@ -41,12 +95,6 @@
PKGNAME_LOGFILE=yes
'''
- basetgz_dir = util.filenameproperty("base")
- build_dir = util.filenameproperty("build")
- result_dir = util.filenameproperty("result")
- aptcache_dir = util.filenameproperty("aptcache")
- extra_pkg_dir = util.filenameproperty("extra-pkg")
-
def __init__(self, pbuilderrc, root_cmd, release_signing_keyid=None):
"""Initialize the PBuilder instance with the configuration file.
The root_cmd parameter should be a list with a command that can
@@ -60,7 +108,7 @@
self.release_signing_keyid = release_signing_keyid
self.base_dir = os.path.dirname(self.pbuilderrc)
- def init_pbuilder(self, distribution, mirrorsite, extramirrors):
+ def init_builder(self, distribution, mirrorsite, extramirrors):
"""Initializes the pbuilder instance"""
if not os.path.isabs(self.pbuilderrc):
print >>sys.stderr, "pbuilderrc must be an absolute filename"
@@ -104,27 +152,6 @@
run.call(cmdexpand("@root_cmd pbuilder create --configfile $pbuilderrc",
root_cmd=self.root_cmd, pbuilderrc=self.pbuilderrc))
- def update_extra_pkg_dir(self):
- run.call(cmdexpand("apt-ftparchive packages ."),
- stdout=open(os.path.join(self.extra_pkg_dir, "Packages"), "w"),
- cwd=self.extra_pkg_dir)
- release_filename = os.path.join(self.extra_pkg_dir, "Release")
- run.call(cmdexpand("apt-ftparchive release ."),
- stdout=open(release_filename, "w"), cwd=self.extra_pkg_dir)
- # handle signatures. remove any existing signature because it
- # will be invalid now.
- signature = release_filename + ".gpg"
- try:
- os.remove(signature)
- except OSError:
- pass
- if self.release_signing_keyid:
- run.call(cmdexpand("gpg --detach-sign --armor --local-user=$keyid"
- " -o $sig $release",
- keyid=self.release_signing_keyid,
- sig=release_filename + ".gpg",
- release=release_filename)),
-
def update(self, suppress_output=True, log_info=True):
"""Runs pbuilder update on this pbuilder instance"""
if log_info:
@@ -195,6 +222,8 @@
if logfile is not None and os.path.exists(logfile):
run.call(cmdexpand("gzip -9 $logfile", logfile=logfile))
+ if logfile is not None and os.path.exists(logfile):
+ run.call(cmdexpand("gzip -9 $logfile", logfile=logfile))
# remove the source package files put into the binary directory
# by pbuilder
if binary_dir is not None:
@@ -202,28 +231,7 @@
if os.path.splitext(filename)[1] not in (".deb", ".changes"):
os.remove(os.path.join(binary_dir, filename))
- def add_binaries_to_extra_pkg(self, filenames, subdirectory="auto"):
- """Adds binary packages to the extra-pkg directory.
- The filenames parameter should be sequence of absolute
- filenames. The files named will be copied to a subdirectory of
- the extra-pkg directory which is assumed to reside in the same
- directory as the pbuilderrc. The subdirectory is specified with
- the subdirectory parameter and defaults to 'auto'. Afterwards,
- the method generates a Packages file in the directory and runs
- pbuilder update. All of this assumes that pbuilder was set up
- the way bin/initpbuilder.py does.
- """
- target_dir = os.path.join(self.extra_pkg_dir, subdirectory)
- util.ensure_directory(target_dir)
- for filename in filenames:
- logging.info("Copying %s into %s", filename, target_dir)
- shutil.copy(filename, target_dir)
- logging.info("Running apt-ftparchive in %s", self.extra_pkg_dir)
- self.update_extra_pkg_dir()
-
- self.update(suppress_output=True, log_info=True)
-
def run_script(self, script, logfile, bindmounts=(), save_after_exec=False):
"""Execute a script in pbuilder's chroot environment
Parameters:
Modified: trunk/treepkg/packager.py
===================================================================
--- trunk/treepkg/packager.py 2010-04-22 19:25:02 UTC (rev 298)
+++ trunk/treepkg/packager.py 2010-04-23 07:43:29 UTC (rev 299)
@@ -171,7 +171,11 @@
def sign_package(self):
"""Signs the .dsc file created buy the instance"""
- self.track.sign_file(util.listdir_abs(self.src_dir, "*.dsc")[0])
+ src_files = util.listdir_abs(self.src_dir, "*.dsc")
+ if not src_files:
+ raise RuntimeError("Could not find .dsc file in source"
+ " directory %s" % self.src_dir)
+ self.track.sign_file(src_files[0])
def package(self):
"""Creates a source package from a subversion checkout.
@@ -203,13 +207,15 @@
self.create_tarball(origtargz, self.work_dir,
os.path.basename(pkgbasedir))
- changemsg = self.changemsg_template % dict(revision=self.revision)
+ changemsg = self.get_change_msg()
self.copy_debian_directory(pkgbasedir, pkgbaseversion,
changemsg)
self.create_source_package(pkgbasedir, origtargz)
self.move_source_package(pkgbasename)
+ def get_change_msg(self):
+ return self.changemsg_template % dict(revision=self.revision)
class BinaryPackager(object):
@@ -235,7 +241,10 @@
def sign_package(self):
"""Signs the .changes file created buy the instance"""
- self.track.sign_file(util.listdir_abs(self.binary_dir, "*.changes")[0])
+ dirs = util.listdir_abs(self.binary_dir, "*.changes")
+ if not dirs:
+ raise RuntimeError("Cannot find changes File in %r" % self.binary_dir)
+ self.track.sign_file(dirs[0])
class RevisionPackager(object):
@@ -342,11 +351,13 @@
revision_packager_cls = RevisionPackager
+ builder_cls = PBuilder
+
svn_external_subdirs = []
extra_config_desc = []
- def __init__(self, name, base_dir, root_cmd, pbuilderrc, deb_email,
+ def __init__(self, name, base_dir, root_cmd, builderconfig, deb_email,
deb_fullname, svn_url="", packager_class="treepkg.packager",
version_template="%(revision)s",
pkg_revision_template="treepkg%(pkg_revision)s",
@@ -360,7 +371,7 @@
self.pkg_basename = pkg_basename
self.changelog_msg_template = changelog_msg_template
self.base_dir = base_dir
- self.builder = PBuilder(pbuilderrc, root_cmd,
+ self.builder = self.builder_cls(builderconfig, root_cmd,
release_signing_keyid=signing_key_id)
self.deb_email = deb_email
self.deb_fullname = deb_fullname
Modified: trunk/treepkg/readconfig.py
===================================================================
--- trunk/treepkg/readconfig.py 2010-04-22 19:25:02 UTC (rev 298)
+++ trunk/treepkg/readconfig.py 2010-04-23 07:43:29 UTC (rev 299)
@@ -69,7 +69,7 @@
("svn_subset", convert_subversion_subset, ""),
("svn_externals", shlex.split, ""),
("rules_svn_url", str, ""), "packager_class",
- ("root_cmd", shlex.split, "sudo"), "pbuilderrc",
+ ("root_cmd", shlex.split, "sudo"), "builderconfig",
"deb_email", "deb_fullname", ("deb_build_options", str, ""),
("version_template", str, "%(revision)s"),
"pkg_revision_template", ("pkg_basename", str, ""),
Copied: trunk/treepkg/sbuilder.py (from rev 298, branches/scratchbox/treepkg/sbuilder.py)
Modified: trunk/treepkg/util.py
===================================================================
--- trunk/treepkg/util.py 2010-04-22 19:25:02 UTC (rev 298)
+++ trunk/treepkg/util.py 2010-04-23 07:43:29 UTC (rev 299)
@@ -12,6 +12,7 @@
import tempfile
import shutil
import fnmatch
+import pwd
import run
@@ -151,3 +152,7 @@
def get(self):
return os.path.join(getattr(self, dir_attr), filename)
return property(get)
+
+def getuser():
+ """Returns the login name of the current user owning the proccess"""
+ return pwd.getpwuid(os.getuid())[0]
More information about the Treepkg-commits
mailing list