# HG changeset patch # User Bernhard Herzog # Date 1214330389 0 # Node ID b2fa3b0926d02752a6fdb9ffa6f37ad605aaedd0 # Parent df7498d0bd9da9dbb4211e3383f718c5329611f8 PBuilder: refactor the "pbuilder update" call into a separate method diff -r df7498d0bd9d -r b2fa3b0926d0 test/test_builder.py --- a/test/test_builder.py Tue Jun 24 17:52:14 2008 +0000 +++ b/test/test_builder.py Tue Jun 24 17:59:49 2008 +0000 @@ -138,6 +138,12 @@ % os.path.join(basedir, "pbuilderrc"), captured_stderr.getvalue()) + def test_update(self): + """Tests the PBuilder.update method.""" + builder = PBuilder("my_pbuilderrc", self.root_command) + builder.update() + self.check_command_line(['/usr/sbin/pbuilder', 'update', + '--configfile', 'my_pbuilderrc']) def test_build(self): """Tests the PBuilder.build method. diff -r df7498d0bd9d -r b2fa3b0926d0 treepkg/builder.py --- a/treepkg/builder.py Tue Jun 24 17:52:14 2008 +0000 +++ b/treepkg/builder.py Tue Jun 24 17:59:49 2008 +0000 @@ -117,6 +117,15 @@ 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: + 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=suppress_output) + def build(self, dsc_file, binary_dir, logfile, bindmounts=(), extra_packages=(), extra_env=None): """Build a binary packager from a source package @@ -172,11 +181,7 @@ logging.info("Running apt-ftparchive in %s", self.extra_pkg_dir) self.update_extra_pkg_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) + self.update(suppress_output=True, log_info=True) def run_script(self, script, logfile, bindmounts=()): """Execute a script in pbuilder's chroot environment