Mercurial > treepkg > treepkg
diff treepkg/builder.py @ 121:890bb70920d6
Add the PBuilder.add_binaries_to_extra_pkg method. It allows automatic
installation of extra packages that should be available in the pbuilder
chroot. Also add corresponding tests.
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Wed, 21 May 2008 16:47:34 +0000 |
parents | 92116333ef77 |
children | 6e34fc4ebe39 |
line wrap: on
line diff
--- a/treepkg/builder.py Wed May 21 16:46:16 2008 +0000 +++ b/treepkg/builder.py Wed May 21 16:47:34 2008 +0000 @@ -8,6 +8,7 @@ """Build binary packages from source packages""" import os +import shutil import logging import util @@ -50,6 +51,31 @@ 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): + """Adds binary packages to the extra-pkg directory. + The filenames parameter should be sequence of absolute + filenames. The files named will be copied to the extra-pkg + directory which is assumed to reside in the same directory as + the pbuilderrc. 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. + """ + extrapkg_dir = os.path.join(os.path.dirname(self.pbuilderrc), + "extra-pkg") + for filename in filenames: + logging.info("Copying %s into %s", filename, extrapkg_dir) + shutil.copy(filename, extrapkg_dir) + logging.info("Running apt-ftparchive in %s", extrapkg_dir) + run.call(cmdexpand("apt-ftparchive packages ."), + stdout=open(os.path.join(extrapkg_dir, "Packages"), "w"), + cwd=extrapkg_dir) + logging.info("Running pbuilder update for %s", self.pbuilderrc) + run.call(cmdexpand("@rootcmd /usr/sbin/pbuilder update" + " --configfile $pbuilderrc", + rootcmd=self.root_cmd, pbuilderrc=self.pbuilderrc), + suppress_output=True) + def run_script(self, script, logfile, bindmounts=()): """Execute a script in pbuilder's chroot environment Parameters: