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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Nov 14 20:41:04 CET 2008


Author: bh
Date: 2008-11-14 20:41:03 +0100 (Fri, 14 Nov 2008)
New Revision: 135

Modified:
   trunk/test/test_builder.py
   trunk/treepkg/builder.py
Log:
Make logfile and binary_dir parameters of PBuilder.build optional.
Adapt test cases to changed order of pbuild command line arguments.


Modified: trunk/test/test_builder.py
===================================================================
--- trunk/test/test_builder.py	2008-11-06 15:59:50 UTC (rev 134)
+++ trunk/test/test_builder.py	2008-11-14 19:41:03 UTC (rev 135)
@@ -190,10 +190,10 @@
                                   "/home/builder/pbuilder"])
         self.check_command_line(['/usr/sbin/pbuilder', 'build',
                                  '--configfile', 'my_pbuilderrc',
+                                 '--logfile', logfilename,
+                                 '--buildresult', binary_dir_name,
                                  '--bindmounts', "/home/builder/tracks",
                                  '--bindmounts', "/home/builder/pbuilder",
-                                 '--logfile', logfilename,
-                                 '--buildresult', binary_dir_name,
                                  '--debbuildopts', '-b',
                                  'my_dsc_file'])
         self.failUnless(os.path.isdir(binary_dir_name))
@@ -213,10 +213,10 @@
                       extra_packages=["subversion", "texinfo"])
         self.check_command_line(['/usr/sbin/pbuilder', 'build',
                                  '--configfile', 'my_pbuilderrc',
+                                 '--logfile', logfilename,
+                                 '--buildresult', binary_dir_name,
                                  '--extrapackages', "subversion",
                                  '--extrapackages', "texinfo",
-                                 '--logfile', logfilename,
-                                 '--buildresult', binary_dir_name,
                                  '--debbuildopts', '-b',
                                  'my_dsc_file'])
         self.failUnless(os.path.isdir(binary_dir_name))

Modified: trunk/treepkg/builder.py
===================================================================
--- trunk/treepkg/builder.py	2008-11-06 15:59:50 UTC (rev 134)
+++ trunk/treepkg/builder.py	2008-11-14 19:41:03 UTC (rev 135)
@@ -152,7 +152,7 @@
         finally:
             script.close()
 
-    def build(self, dsc_file, binary_dir, logfile, bindmounts=(),
+    def build(self, dsc_file, binary_dir=None, logfile=None, bindmounts=(),
               extra_packages=(), extra_env=None):
         """Build a binary packager from a source package
         Parameters:
@@ -169,26 +169,29 @@
                         not remove these variables when it starts
                         pbuilder
         """
-        util.ensure_directory(binary_dir)
         args = []
+        if logfile is not None:
+            args.extend(["--logfile", logfile])
+        if binary_dir is not None:
+            args.extend(["--buildresult", binary_dir])
+            util.ensure_directory(binary_dir)
         for mount in bindmounts:
             args.extend(["--bindmounts", mount])
         for pkg in extra_packages:
             args.extend(["--extrapackages", pkg])
         run.call(cmdexpand("@rootcmd /usr/sbin/pbuilder build"
                            " --configfile $pbuilderrc @args"
-                           " --logfile $logfile --buildresult $bindir"
                            " --debbuildopts -b $dsc",
                            rootcmd=self.root_cmd, pbuilderrc=self.pbuilderrc,
-                           logfile=logfile, bindir=binary_dir, dsc=dsc_file,
-                           args=args),
+                           dsc=dsc_file, args=args),
                  suppress_output=True,
                  extra_env=extra_env)
         # 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))
+        if binary_dir is not None:
+            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))
 
     def add_binaries_to_extra_pkg(self, filenames):
         """Adds binary packages to the extra-pkg directory.



More information about the Treepkg-commits mailing list