[Treepkg-commits] r37 - trunk/treepkg
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Mar 20 21:21:34 CET 2008
Author: bh
Date: 2008-03-20 21:21:34 +0100 (Thu, 20 Mar 2008)
New Revision: 37
Added:
trunk/treepkg/builder.py
Modified:
trunk/treepkg/packager.py
Log:
Abstract the pbuilder calls into the new class treepkg.builder.PBuilder.
Use this class in treepkg.packager.
Added: trunk/treepkg/builder.py
===================================================================
--- trunk/treepkg/builder.py 2008-03-19 19:50:32 UTC (rev 36)
+++ trunk/treepkg/builder.py 2008-03-20 20:21:34 UTC (rev 37)
@@ -0,0 +1,50 @@
+# Copyright (C) 2007, 2008 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.
+
+"""Build binary packages from source packages"""
+
+import os
+
+import util
+import run
+from cmdexpand import cmdexpand
+
+
+class PBuilder(object):
+
+ """Represents a way to run and manage a specific pbuilder instance"""
+
+ def __init__(self, pbuilderrc, root_cmd):
+ """Initialize the PBuilder instance with the configuration file.
+ The root_cmd parameter should be a list with a command that can
+ be used to get root permissions to run pbuilder. It may be an
+ empty list if no command is needed. It's a list so that
+ commands with several shell-words can be used without having to
+ worry about quoting.
+ """
+ self.pbuilderrc = pbuilderrc
+ self.root_cmd = root_cmd
+
+ def build(self, dsc_file, binary_dir, logfile):
+ """Build a binary packager from a source package
+ Parameters:
+ dsc_file -- name of the debian .dsc file of the source package
+ binary_dir -- name of the directory to receive the binary packages
+ logfile -- name of the logfile of the build
+ """
+ util.ensure_directory(binary_dir)
+ run.call(cmdexpand("@rootcmd /usr/sbin/pbuilder build"
+ " --configfile $pbuilderrc"
+ " --logfile $logfile --buildresult $bindir $dsc",
+ rootcmd=self.root_cmd, pbuilderrc=self.pbuilderrc,
+ logfile=logfile, bindir=binary_dir, dsc=dsc_file),
+ suppress_output=True)
+ # remove the source package files put into the binary directory
+ # by pbuilder
+ for filename in os.listdir(binary_dir):
+ if os.path.splitext(filename)[1] not in (".deb", ".changes"):
+ os.remove(os.path.join(binary_dir, filename))
Property changes on: trunk/treepkg/builder.py
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Modified: trunk/treepkg/packager.py
===================================================================
--- trunk/treepkg/packager.py 2008-03-19 19:50:32 UTC (rev 36)
+++ trunk/treepkg/packager.py 2008-03-20 20:21:34 UTC (rev 37)
@@ -19,6 +19,7 @@
import run
import status
from cmdexpand import cmdexpand
+from builder import PBuilder
def _filenameproperty(relative_dir):
def get(self):
@@ -187,19 +188,7 @@
self.status.creating_binary_package()
util.ensure_directory(self.binary_dir)
logging.info("Building binary package; logging to %r", self.logfile)
- run.call(cmdexpand("@rootcmd /usr/sbin/pbuilder build"
- " --configfile $pbuilderrc"
- " --logfile $logfile --buildresult $bindir $dsc",
- rootcmd=self.track.root_cmd,
- pbuilderrc=self.track.pbuilderrc,
- logfile=self.logfile, bindir=self.binary_dir,
- dsc=self.dsc_file),
- suppress_output=True)
- # remove the source package files put into the binary directory
- # by pbuilder
- for filename in os.listdir(self.binary_dir):
- if os.path.splitext(filename)[1] not in (".deb", ".changes"):
- os.remove(os.path.join(self.binary_dir, filename))
+ self.track.builder.build(self.dsc_file, self.binary_dir, self.logfile)
self.status.binary_package_created()
@@ -291,8 +280,7 @@
self.name = name
self.base_dir = base_dir
self.svn_url = svn_url
- self.root_cmd = root_cmd
- self.pbuilderrc = pbuilderrc
+ self.builder = PBuilder(pbuilderrc, root_cmd)
self.deb_email = deb_email
self.deb_fullname = deb_fullname
self.debrevision_prefix = debrevision_prefix
More information about the Treepkg-commits
mailing list