changeset 181:81585486281b

Extend the PBuilder.run_script method so that the script can be called with arguments
author Bernhard Herzog <bh@intevation.de>
date Wed, 25 Jun 2008 13:36:38 +0000
parents 12e4efd5cc74
children 88c8f255b5a0
files recipes/gnupg/base.py test/test_builder.py treepkg/builder.py
diffstat 3 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/recipes/gnupg/base.py	Tue Jun 24 19:02:20 2008 +0000
+++ b/recipes/gnupg/base.py	Wed Jun 25 13:36:38 2008 +0000
@@ -154,7 +154,7 @@
 
         treepkg.util.ensure_directory(self.src_dir)
         treepkg.util.ensure_directory(self.log_dir)
-        self.track.builder.run_script(script_name,
+        self.track.builder.run_script([script_name],
                                       logfile=os.path.join(self.log_dir,
                                                            "tarball_log.txt"),
                                       bindmounts=[self.work_dir, self.src_dir])
--- a/test/test_builder.py	Tue Jun 24 19:02:20 2008 +0000
+++ b/test/test_builder.py	Wed Jun 25 13:36:38 2008 +0000
@@ -241,15 +241,23 @@
 
     def test_run_script(self):
         builder = PBuilder("my_pbuilderrc", self.root_command)
-        builder.run_script("my_script", logfile="the_logfile")
+        builder.run_script(["my_script"], logfile="the_logfile")
         self.check_command_line(['/usr/sbin/pbuilder', 'execute',
                                  '--configfile', 'my_pbuilderrc',
                                  '--logfile', 'the_logfile',
                                  'my_script'])
 
+    def test_run_script_with_arguments(self):
+        builder = PBuilder("my_pbuilderrc", self.root_command)
+        builder.run_script(["my_script", "--verbose"], logfile="the_logfile")
+        self.check_command_line(['/usr/sbin/pbuilder', 'execute',
+                                 '--configfile', 'my_pbuilderrc',
+                                 '--logfile', 'the_logfile',
+                                 'my_script', '--verbose'])
+
     def test_run_script_with_bindmounts(self):
         builder = PBuilder("my_pbuilderrc", self.root_command)
-        builder.run_script("my_script", logfile="the_logfile",
+        builder.run_script(["my_script"], logfile="the_logfile",
                            bindmounts=("/home/builder/foo",
                                        "/home/builder/treepkg"))
         self.check_command_line(['/usr/sbin/pbuilder', 'execute',
--- a/treepkg/builder.py	Tue Jun 24 19:02:20 2008 +0000
+++ b/treepkg/builder.py	Wed Jun 25 13:36:38 2008 +0000
@@ -186,7 +186,8 @@
     def run_script(self, script, logfile, bindmounts=()):
         """Execute a script in pbuilder's chroot environment
         Parameters:
-           script -- The filename of the script
+           script -- A list of strings with the command line to invoke the
+                     script
            logfile -- name of the logfile of the build
            bindmounts -- Sequence of directory names that should be
                          bind-mounted in the pbuilder chroot
@@ -205,7 +206,7 @@
             args.extend(["--bindmounts", mount])
 
         run.call(cmdexpand("@rootcmd /usr/sbin/pbuilder execute"
-                           " --configfile $pbuilderrc @args $script",
+                           " --configfile $pbuilderrc @args @script",
                            rootcmd=self.root_cmd, pbuilderrc=self.pbuilderrc,
                            args=args, script=script),
                  suppress_output=False)
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)