[Treepkg-commits] r103 - in trunk: test treepkg

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Jun 24 19:59:49 CEST 2008


Author: bh
Date: 2008-06-24 19:59:49 +0200 (Tue, 24 Jun 2008)
New Revision: 103

Modified:
   trunk/test/test_builder.py
   trunk/treepkg/builder.py
Log:
PBuilder: refactor the "pbuilder update" call into a separate method


Modified: trunk/test/test_builder.py
===================================================================
--- trunk/test/test_builder.py	2008-06-24 17:52:14 UTC (rev 102)
+++ trunk/test/test_builder.py	2008-06-24 17:59:49 UTC (rev 103)
@@ -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.

Modified: trunk/treepkg/builder.py
===================================================================
--- trunk/treepkg/builder.py	2008-06-24 17:52:14 UTC (rev 102)
+++ trunk/treepkg/builder.py	2008-06-24 17:59:49 UTC (rev 103)
@@ -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



More information about the Treepkg-commits mailing list