This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch pu/reproducible_builds
in repository dh-python.

commit a617d883f519e924f487cc87f956f1bbaa1735da
Author: Piotr Ożarowski <pi...@debian.org>
Date:   Fri Aug 16 11:54:16 2013 +0200

    pybuild: directory paths escaping fixed
---
 debian/changelog       |  3 ++-
 dh/pybuild.pm          | 28 ++++++++++++++--------------
 dhpython/build/base.py | 12 +++++++++++-
 3 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 28de53a..5cb638a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-dh-python (1.20130809-1) UNRELEASED; urgency=low
+dh-python (1.20130818-1) UNRELEASED; urgency=low
 
   * Do not translate X-Python{,3}-Version into Depends if there are no Python
     files in the package
@@ -9,6 +9,7 @@ dh-python (1.20130809-1) UNRELEASED; urgency=low
   * pybuild: --test-nose/--test-pytest have higher priority than setup.py's
     test_suite now
   * pybuild.pm: remove .pyc files in clean target
+  * pybuild: directory paths escaping fixed
 
  -- Piotr Ożarowski <pi...@debian.org>  Fri, 09 Aug 2013 15:55:11 +0200
 
diff --git a/dh/pybuild.pm b/dh/pybuild.pm
index 66227ff..302d712 100644
--- a/dh/pybuild.pm
+++ b/dh/pybuild.pm
@@ -46,14 +46,14 @@ sub new {
 sub configure {
        my $this=shift;
        foreach my $command ($this->pybuild_commands('configure', @_)) {
-               $this->doit_in_sourcedir($command);
+               $this->doit_in_sourcedir(@$command);
        }
 }
 
 sub build {
        my $this=shift;
        foreach my $command ($this->pybuild_commands('build', @_)) {
-               $this->doit_in_sourcedir($command);
+               $this->doit_in_sourcedir(@$command);
        }
 }
 
@@ -61,21 +61,21 @@ sub install {
        my $this=shift;
        my $destdir=shift;
        foreach my $command ($this->pybuild_commands('install', @_)) {
-               $this->doit_in_sourcedir("$command --dest-dir '$destdir'");
+               $this->doit_in_sourcedir(@$command, '--dest-dir', $destdir);
        }
 }
 
 sub test {
        my $this=shift;
        foreach my $command ($this->pybuild_commands('test', @_)) {
-               $this->doit_in_sourcedir($command);
+               $this->doit_in_sourcedir(@$command);
        }
 }
 
 sub clean {
        my $this=shift;
        foreach my $command ($this->pybuild_commands('clean', @_)) {
-               $this->doit_in_sourcedir($command);
+               $this->doit_in_sourcedir(@$command);
        }
        $this->doit_in_sourcedir('rm', '-rf', '.pybuild/');
        $this->doit_in_sourcedir('find', '.', '-name', '*.pyc', '-exec', 'rm', 
'{}', ';');
@@ -106,19 +106,19 @@ sub pybuild_commands {
                if ($this->{pyvers}) {
                        if (grep {$_ eq 'python-all' or $_ eq 'python-all-dev'} 
@deps) {
                                $pyall = 1;
-                               push @result, "pybuild --$step -i $i -p 
'$this->{pyvers}' @options";
+                               push @result, ['pybuild', "--$step", '-i', $i, 
'-p', $this->{pyvers}, @options];
                        }
                        if (grep {$_ eq 'python-all-dbg'} @deps) {
                                $pyalldbg = 1;
-                               push @result, "pybuild --$step -i $i-dbg -p 
'$this->{pyvers}' @options";
+                               push @result, ['pybuild', "--$step", '-i', 
"$i-dbg", '-p', $this->{pyvers}, @options];
                        }
                }
                if ($this->{pydef}) {
                        if (not $pyall and grep {$_ eq 'python' or $_ eq 
'python-dev'} @deps) {
-                               push @result, "pybuild --$step -i $i -p 
'$this->{pydef}' @options";
+                               push @result, ['pybuild', "--$step", '-i', $i, 
'-p', $this->{pydef}, @options];
                        }
                        if (not $pyalldbg and grep {$_ eq 'python-dbg'} @deps) {
-                               push @result, "pybuild --$step -i $i-dbg -p 
'$this->{pydef}' @options";
+                               push @result, ['pybuild', "--$step", '-i', 
"$i-dbg", '-p', $this->{pydef}, @options];
                        }
                }
 
@@ -127,27 +127,27 @@ sub pybuild_commands {
                        my $i = 'python{version}';
                        if (grep {$_ eq 'python3-all' or $_ eq 
'python3-all-dev'} @deps) {
                                $py3all = 1;
-                               push @result, "pybuild --$step -i $i -p 
'$this->{py3vers}' @options";
+                               push @result, ['pybuild', "--$step", '-i', $i, 
'-p', $this->{py3vers}, @options];
                        }
                        if (grep {$_ eq 'python3-all-dbg'} @deps) {
                                $py3alldbg = 1;
-                               push @result, "pybuild --$step -i $i-dbg 
-p'$this->{py3vers}' @options";
+                               push @result, ['pybuild', "--$step", '-i', 
"$i-dbg", '-p', $this->{py3vers}, @options];
                        }
                }
                if ($this->{py3def}) {
                        if (not $py3all and grep {$_ eq 'python3' or $_ eq 
'python3-dev'} @deps) {
                                # TODO: "python3" case: should 
X-Python3-Version header in debian/control be also required here?
-                               push @result, "pybuild --$step -i $i -p 
'$this->{py3def}' @options";
+                               push @result, ['pybuild', "--$step", '-i', $i, 
'-p', $this->{py3def}, @options];
                        }
                        if (not $py3alldbg and grep {$_ eq 'python3-dbg'} 
@deps) {
-                               push @result, "pybuild --$step -i $i-dbg -p 
'$this->{py3def}' @options";
+                               push @result, ['pybuild', "--$step", '-i', 
"$i-dbg", '-p', $this->{py3def}, @options];
                        }
                }
                # TODO: pythonX.Y → `pybuild -i python{version} -p X.Y`
 
                # PyPy
                if ($this->{pypydef} and grep {$_ eq 'pypy'} @deps) {
-                       push @result, "pybuild --$step -i pypy -p 
'$this->{pypydef}' @options";
+                       push @result, ['pybuild', "--$step", '-i', 'pypy', 
'-p', $this->{pypydef}, @options];
                }
        }
        return @result;
diff --git a/dhpython/build/base.py b/dhpython/build/base.py
index 64e1ad0..c9e0781 100644
--- a/dhpython/build/base.py
+++ b/dhpython/build/base.py
@@ -26,6 +26,12 @@ from os.path import join
 from subprocess import Popen, PIPE
 from shutil import rmtree
 from dhpython.tools import execute
+try:
+    from shlex import quote
+except ImportError:
+    # shlex.quote is new in Python 3.3
+    def quote(s):
+        return ("'" + s.replace("'", "'\"'\"'") + "'") if "'" in s else s
 
 log = logging.getLogger('dhpython')
 
@@ -171,7 +177,11 @@ def shell_command(func):
         else:
             log_file = False
 
-        command = command.format(**args)
+        quoted_args = dict((k, quote(v)) if k in ('dir', 'destdir')
+                           or k.endswith('_dir') else (k, v)
+                           for k, v in args.items())
+        command = command.format(**quoted_args)
+
         output = self.execute(context, args, command, log_file)
         if output['returncode'] != 0:
             msg = 'exit code={}: {}'.format(output['returncode'], command)

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/reproducible/dh-python.git

_______________________________________________
Reproducible-builds mailing list
Reproducible-builds@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reproducible-builds

Reply via email to