changeset 178:b2fa3b0926d0

PBuilder: refactor the "pbuilder update" call into a separate method
author Bernhard Herzog <bh@intevation.de>
date Tue, 24 Jun 2008 17:59:49 +0000
parents df7498d0bd9d
children 952d366f7b14
files test/test_builder.py treepkg/builder.py
diffstat 2 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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.
--- 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
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)