# HG changeset patch # User Bernhard Herzog # Date 1214400998 0 # Node ID 81585486281b0bfd5b6bd914ba24b96b5f182ee2 # Parent 12e4efd5cc741c2b8ac06c1032ae2c7ec7e06b2e Extend the PBuilder.run_script method so that the script can be called with arguments diff -r 12e4efd5cc74 -r 81585486281b recipes/gnupg/base.py --- 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]) diff -r 12e4efd5cc74 -r 81585486281b test/test_builder.py --- 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', diff -r 12e4efd5cc74 -r 81585486281b treepkg/builder.py --- 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)