From: joey Date: Tue, 29 May 2001 22:24:20 +0000 (+0000) Subject: r472: * Fixed issues with extended parameters to dh_gencontrol including spaces X-Git-Tag: version_2.0.101~127 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=a524668098e5215a64ac4cc466b3de6590d13cfe;p=debhelper.git r472: * 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. --- diff --git a/Debian/Debhelper/Dh_Getopt.pm b/Debian/Debhelper/Dh_Getopt.pm index 6d545e3..191227d 100644 --- a/Debian/Debhelper/Dh_Getopt.pm +++ b/Debian/Debhelper/Dh_Getopt.pm @@ -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; diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm index 6185e19..92eae0c 100644 --- a/Debian/Debhelper/Dh_Lib.pm +++ b/Debian/Debhelper/Dh_Lib.pm @@ -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"); } diff --git a/debian/changelog b/debian/changelog index 915a8dd..588dc72 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 Tue, 29 May 2001 17:54:19 -0400 + debhelper (3.0.26) unstable; urgency=low * Always include package name in maintainer script fragment filenames diff --git a/debian/rules b/debian/rules index 9ec7d17..bf37bca 100755 --- a/debian/rules +++ b/debian/rules @@ -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}') diff --git a/dh_gencontrol b/dh_gencontrol index d1fdd94..bb39780 100755 --- a/dh_gencontrol +++ b/dh_gencontrol @@ -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");