]> git.donarmstrong.com Git - debhelper.git/commitdiff
r472: * Fixed issues with extended parameters to dh_gencontrol including spaces
authorjoey <joey>
Tue, 29 May 2001 22:24:20 +0000 (22:24 +0000)
committerjoey <joey>
Tue, 29 May 2001 22:24:20 +0000 (22:24 +0000)
     and quotes. This was some histirical cruft that deals with splitting up
     the string specified by -u, and it should not have applied to the set
     of options after --. Now that it's fixed, any and all programs that
     support a -- and options after it, do not require any special quoting
     of the succeeding options. Quote just like you would in whatever
     program those options go to. So, for example,
     dh_gencontrol -Vblah:Depends='foo, bar (>= 1.2)' will work just as you
     would hope. This fix does NOT apply to -u; don't use -u if you must do
     something complex. Closes: #89311
   * Made escape_shell output a lot better.

Debian/Debhelper/Dh_Getopt.pm
Debian/Debhelper/Dh_Lib.pm
debian/changelog
debian/rules
dh_gencontrol

index 6d545e3675d927d9dde8f9ad6ff1528b7b6a0087..191227da2e2f4d9a752a515039d837993fbd687e 100644 (file)
@@ -177,10 +177,17 @@ sub parseopts {
                error("I have no package to build");
        }
 
+       if (defined $options{U_PARAMS}) {
+               # Split the U_PARAMS up into an array.
+               my $u=$options{U_PARAMS};
+               undef $options{U_PARAMS};
+                push @{$options{U_PARAMS}}, split(/\s+/,$u);
+        }
+
        # Anything left in @ARGV is options that appeared after a --
-       # These options are added to U_PARAMS, while the non-option
-       # values we collected replace them in @ARGV;
-       $options{U_PARAMS}.=join(' ', @ARGV);
+       # These options are added to the U_PARAMS array, while the
+       # non-option values we collected replace them in @ARGV;
+       push @{$options{U_PARAMS}}, @ARGV;
        @ARGV=@{$options{ARGV}} if exists $options{ARGV};
 
        return %options;
index 6185e19cd7ed2dbd07756c893545a9ef7d279b9d..92eae0c7af567d56a955998027062bfc02ab843c 100644 (file)
@@ -75,21 +75,34 @@ sub init {
        # This package gets special treatement: files and directories specified on
        # the command line may affect it.
        $dh{FIRSTPACKAGE}=${$dh{DOPACKAGES}}[0];
-
-       # Split the U_PARAMS up into an array.
-       my $u=$dh{U_PARAMS};
-       undef $dh{U_PARAMS};
-       if (defined $u) {
-               push @{$dh{U_PARAMS}}, split(/\s+/,$u);
-       }
 }
 
-# Escapes out shell metacharacters in a line of shell script.
+# Pass it an array containing the arguments of a shell command like would
+# be run by exec(). It turns that into a line like you might enter at the
+# shell, escaping metacharacters and quoting qrguments that contain spaces.
 sub escape_shell {
-       my $line=shift;
-       # This list is from _Unix in a Nutshell_. (except '#')
-       $line=~s/([\s!"\$()*+#;<>?@\[\]\\`|~])/\\$1/g;
-       return $line;
+       my @args=@_;
+       my $line="";
+       my @ret;
+       foreach my $word (@args) {
+               if ($word=~/\s/) {
+                       # Escape only a few things since it will be quoted.
+                       # Note we use double quotes because you cannot
+                       # escape ' in qingle quotes, while " can be escaped
+                       # in double.
+                       # This does make -V"foo bar" turn into "-Vfoo bar",
+                       # but that will be parsed identically by the shell
+                       # anyway..
+                       $word=~s/([\n`\$"\\])/\$1/g;
+                       push @ret, "\"$word\"";
+               }
+               else {
+                       # This list is from _Unix in a Nutshell_. (except '#')
+                       $word=~s/([\s!"\$()*+#;<>?@\[\]\\`|~])/\\$1/g;
+                       push @ret,$word;
+               }
+       }
+       return join(' ', @ret);
 }
 
 # Run a command, and display the command to stdout if verbose mode is on.
@@ -99,8 +112,8 @@ sub escape_shell {
 # Note that this cannot handle complex commands, especially anything
 # involving redirection. Use complex_doit instead.
 sub doit {
-       verbose_print(join(" ",map { escape_shell($_) } @_));
-       
+       verbose_print(escape_shell(@_));
+
        if (! $dh{NO_ACT}) {
                system(@_) == 0 || error("command returned error code");
        }
index 915a8dd0f5502ed032203d44ab7719af44d3416e..588dc726b3631f1b5ee33c861a04a82467a74987 100644 (file)
@@ -1,3 +1,19 @@
+debhelper (3.0.27) unstable; urgency=low
+
+  * Fixed issues with extended parameters to dh_gencontrol including spaces
+    and quotes. This was some histirical cruft that deals with splitting up
+    the string specified by -u, and it should not have applied to the set
+    of options after --. Now that it's fixed, any and all programs that
+    support a -- and options after it, do not require any special quoting
+    of the succeeding options. Quote just like you would in whatever
+    program those options go to. So, for example, 
+    dh_gencontrol -Vblah:Depends='foo, bar (>= 1.2)' will work just as you
+    would hope. This fix does NOT apply to -u; don't use -u if you must do
+    something complex. Closes: #89311
+  * Made escape_shell output a lot better.
+ -- Joey Hess <joeyh@debian.org>  Tue, 29 May 2001 17:54:19 -0400
+
 debhelper (3.0.26) unstable; urgency=low
 
   * Always include package name in maintainer script fragment filenames 
index 9ec7d17c2619c86621e38d0316b0d18ef509e8d3..bf37bcab11cb1e37bb93f367e84a55ca14f8833b 100755 (executable)
@@ -17,7 +17,7 @@ export DH_AUTOSCRIPTDIR=autoscripts
 # Use most recent compatability level.
 export DH_COMPAT=3
 
-# Figure out the current debhelper version.
+# Figure out the `current debhelper version.
 VERSION=$(shell expr "`dpkg-parsechangelog 2>/dev/null |grep Version:`" : '.*Version: \(.*\)')
 
 PERLLIBDIR=$(shell perl -MConfig -e 'print $$Config{vendorlib}')
index d1fdd943ad28ea8ce6bb489678b4234ccc84e3d5..bb39780cb4dd3369dddf0ba0de4f6b5cf74c511f 100755 (executable)
@@ -52,9 +52,10 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
                doit("install","-o",0,"-g",0,"-d","$tmp/DEBIAN");
        }
 
-       # Generate and install control file.
+       # Generate and install control file. Use complex_doit to allow for
+       # wild and wonderful U_PARAMS quoting.
        doit("dpkg-gencontrol","-l$changelog","-isp","-p$package",
-               "-Tdebian/${ext}substvars","-P$tmp",@{$dh{U_PARAMS}});
+                    "-Tdebian/${ext}substvars","-P$tmp",@{$dh{U_PARAMS}});
 
        # This chmod is only necessary if the user sets the umask to something odd.
        doit("chmod","644","$tmp/DEBIAN/control");