diff options
author | Guillem Jover <guillem@debian.org> | 2012-04-17 06:49:24 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2013-07-26 23:53:33 +0200 |
commit | 649c745f7ea21ec2628e2b039c7590f3934d7195 (patch) | |
tree | 80f2c469d04b82f3617b7f83e4968920c44d481c | |
parent | 01ad2ba537d7259f48ec942c007dd8448ffbf42f (diff) | |
download | dpkg-649c745f7ea21ec2628e2b039c7590f3934d7195.tar.gz |
Dpkg::Control::HashCore: Correctly apply substvar text cleanups
Use the new information to properly apply substvars when outputting
control stanzas, and avoid doing text cleanups on field values where
those changes are not relevant.
Closes: #659814
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | scripts/Dpkg/Control/HashCore.pm | 21 |
2 files changed, 18 insertions, 5 deletions
diff --git a/debian/changelog b/debian/changelog index 8093240d6..193cf7a27 100644 --- a/debian/changelog +++ b/debian/changelog @@ -138,6 +138,8 @@ dpkg (1.17.0) UNRELEASED; urgency=low * Add new dpkg-shlibdeps -l option to add private shared library directories. This should be used instead of abusing LD_LIBRARY_PATH to pass the paths, which might be problematic when cross-compiling. Closes: #698881 + * Only apply empy line and comma cleanups when doing substvar replacements + on fields where those are relevant. Closes: #659814 [ Raphaƫl Hertzog ] * Fix dpkg-maintscript-helper rm_conffile and mv_conffile to do nothing diff --git a/scripts/Dpkg/Control/HashCore.pm b/scripts/Dpkg/Control/HashCore.pm index 597ad371a..236e111b4 100644 --- a/scripts/Dpkg/Control/HashCore.pm +++ b/scripts/Dpkg/Control/HashCore.pm @@ -22,6 +22,7 @@ our $VERSION = '1.00'; use Dpkg::Gettext; use Dpkg::ErrorHandling; +use Dpkg::Control::FieldsCore; # This module cannot use Dpkg::Control::Fields, because that one makes use # of Dpkg::Vendor which at the same time uses this module, which would turn @@ -373,14 +374,24 @@ sub apply_substvars { foreach my $f (keys %$self) { my $v = $substvars->substvars($self->{$f}, %opts); if ($v ne $self->{$f}) { + my $sep; + + $sep = field_get_sep_type($f); + # If we replaced stuff, ensure we're not breaking # a dependency field by introducing empty lines, or multiple # commas - $v =~ s/\n[ \t]*(\n|$)/$1/; # Drop empty/whitespace-only lines - # TODO: do this only for dependency fields - $v =~ s/,[\s,]*,/,/g; - $v =~ s/^\s*,\s*//; - $v =~ s/\s*,\s*$//; + + if ($sep & (FIELD_SEP_COMMA | FIELD_SEP_LINE)) { + # Drop empty/whitespace-only lines + $v =~ s/\n[ \t]*(\n|$)/$1/; + } + + if ($sep & FIELD_SEP_COMMA) { + $v =~ s/,[\s,]*,/,/g; + $v =~ s/^\s*,\s*//; + $v =~ s/\s*,\s*$//; + } } $v =~ s/\$\{\}/\$/g; # XXX: what for? |