The following commit has been merged in the master branch: commit c1d25a121e547079d6b09b1e49d3f27c9316ea5a Author: Russ Allbery <r...@debian.org> Date: Thu Mar 25 15:28:35 2010 -0700
Track local diversions through other diversion checks * checks/scripts: + [RA] Track local diversions like other diversions for the purposes of checking for orphans and diversions of unknown files. Partly addresses #575361. diff --git a/checks/scripts b/checks/scripts index 62d4742..e82dc31 100644 --- a/checks/scripts +++ b/checks/scripts @@ -945,53 +945,51 @@ while (<SCRIPTS>) { if (m,$LEADIN(?:/usr/sbin/)?dpkg-divert\s, && ! /--(?:help|list|truename|version)/) { if (/--local/ or !/--package/) { tag 'package-uses-local-diversion', "$file:$."; + } + my $mode = /--remove/ ? 'remove' : 'add'; + my ($divert) = /dpkg-divert\s*(.*)$/; + $divert =~ s/\s*--(?:add|quiet|remove|rename|test|local|(:?admindir|divert|package)\s+\S+)\s*//g; + # Remove unpaired opening or closing parenthesis + 1 while($divert =~ m/\G.*?\(.+?\)/gc); + $divert =~ s/\G(.*?)[()]/$1/; + pos($divert) = undef; + # Remove unpaired opening or closing braces + 1 while($divert =~ m/\G.*?{.+?}/gc); + $divert =~ s/\G(.*?)[{}]/$1/; + pos($divert) = undef; + + # position after the last pair of quotation marks, if any + 1 while($divert =~ m/\G.*?(\"|\').+?\1/gc); + # Strip anything matching and after '&&', '||', ';', or '>' + # this is safe only after we are positioned after the last pair + # of quotation marks + $divert =~ s/\G.+?\K(?: && | \|\| | ; | \d*> ).*$//x; + pos($divert) = undef; + # Remove quotation marks, they affect: + # * our var to regex trick + # * stripping the initial slash if the path was quoted + $divert =~ s/[\"\']//g; + # remove the leading / because it's not in the index hash + $divert =~ s,^/,,; + + # remove any remaining leading or trailing whitespace. + $divert =~ s/^\s+//; + $divert =~ s/\s+$//; + + $divert = quotemeta($divert); + + # For now just replace variables, they will later be normalised + $expand_diversions = 1 if $divert =~ s/\\\$\w+/.+/g; + $expand_diversions = 1 if $divert =~ s/\\\$\\{\w+.*?\\}/.+/g; + # handle $() the same way: + $expand_diversions = 1 if $divert =~ s/\\\$\\\(.+?\\\)/.+/g; + + if ($mode eq 'add') { + $added_diversions{$divert} = {'script' => $file, 'line' => $.}; + } elsif ($mode eq 'remove') { + push @{$removed_diversions{$divert}}, {'script' => $file, 'line' => $.}; } else { - my $mode = /--remove/ ? 'remove' : 'add'; - my ($divert) = /dpkg-divert\s*(.*)$/; - $divert =~ s/\s*--(?:add|quiet|remove|rename|test|(:?admindir|divert|package)\s+\S+)\s*//g; - # Remove unpaired opening or closing parenthesis - 1 while($divert =~ m/\G.*?\(.+?\)/gc); - $divert =~ s/\G(.*?)[()]/$1/; - pos($divert) = undef; - # Remove unpaired opening or closing braces - 1 while($divert =~ m/\G.*?{.+?}/gc); - $divert =~ s/\G(.*?)[{}]/$1/; - pos($divert) = undef; - - # position after the last pair of quotation marks, if any - 1 while($divert =~ m/\G.*?(\"|\').+?\1/gc); - # Strip anything matching and after '&&', '||', ';', or '>' - # this is safe only after we are positioned after the last pair - # of quotation marks - $divert =~ s/\G.+?\K(?: && | \|\| | ; | \d*> ).*$//x; - pos($divert) = undef; - # Remove quotation marks, they affect: - # * our var to regex trick - # * stripping the initial slash if the path was quoted - $divert =~ s/[\"\']//g; - # remove the leading / because it's not in the index hash - $divert =~ s,^/,,; - - # remove any remaining leading or trailing whitespace. - $divert =~ s/^\s+//; - $divert =~ s/\s+$//; - - $divert = quotemeta($divert); - - # For now just replace variables, they will later be normalised - $expand_diversions = 1 if $divert =~ s/\\\$\w+/.+/g; - $expand_diversions = 1 if $divert =~ s/\\\$\\{\w+.*?\\}/.+/g; - # handle $() the same way: - $expand_diversions = 1 if $divert =~ s/\\\$\\\(.+?\\\)/.+/g; - - if ($mode eq 'add') { - $added_diversions{$divert} = {'script' => $file, 'line' => $.}; - } elsif ($mode eq 'remove') { - push @{$removed_diversions{$divert}}, {'script' => $file, 'line' => $.}; - } else { - fail "Internal error: \$mode has unknown value: ". - "$mode"; - } + fail "Internal error: \$mode has unknown value: $mode"; } } } diff --git a/debian/changelog b/debian/changelog index f0faa6f..1d4f5b9 100755 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,10 @@ lintian (2.3.5) UNRELEASED; urgency=low + [RA] Skip leading multi-author changelog lines when looking for things like non-maintainer upload notes at the start of the changelog entry. Thanks, Vincent Danjean. (Closes: #575192) + * checks/scripts: + + [RA] Track local diversions like other diversions for the purposes + of checking for orphans and diversions of unknown files. Partly + addresses #575361. * checks/watch-file{,.desc}: + [RA] Warn about use of dversionmangle instead of uversionmangle to handle tildes for upstream pre-releases. Patch from Peter diff --git a/t/tests/scripts-diversions-variables/tags b/t/tests/scripts-diversions-variables/tags index 3e321b3..ba22c9d 100644 --- a/t/tests/scripts-diversions-variables/tags +++ b/t/tests/scripts-diversions-variables/tags @@ -1,5 +1,7 @@ E: scripts-diversions-variables: diversion-for-unknown-file etc/scripts/* preinst:26 E: scripts-diversions-variables: diversion-for-unknown-file usr/share/foo/* preinst:30 +E: scripts-diversions-variables: diversion-for-unknown-file usr/share/scripts/other-file preinst:15 +E: scripts-diversions-variables: orphaned-diversion usr/share/scripts/other-file preinst E: scripts-diversions-variables: orphaned-diversion usr/share/scripts/t1/* preinst E: scripts-diversions-variables: package-uses-local-diversion preinst:15 E: scripts-diversions-variables: remove-of-unknown-diversion usr/lib/*/old-file postrm:13 diff --git a/t/tests/scripts-diversions/debian/debian/postrm b/t/tests/scripts-diversions/debian/debian/postrm index 383d0d2..26128e9 100644 --- a/t/tests/scripts-diversions/debian/debian/postrm +++ b/t/tests/scripts-diversions/debian/debian/postrm @@ -25,6 +25,10 @@ if [ remove = "$1" ]; then dpkg-divert --remove --package scripts-diversions \ --divert /usr/share/man/man1/foo.real.1.gz \ /usr/share/man/man1/foo.1.gz + + # Clean up a local diversion. + dpkg-divert --local --remove --divert /usr/share/scripts/other-file.real \ + /usr/share/scripts/other-file fi #DEBHELPER# diff --git a/t/tests/scripts-diversions/tags b/t/tests/scripts-diversions/tags index e154dfe..eecabfb 100644 --- a/t/tests/scripts-diversions/tags +++ b/t/tests/scripts-diversions/tags @@ -1,5 +1,9 @@ +E: scripts-diversions: diversion-for-unknown-file usr/share/scripts/another-file preinst:16 E: scripts-diversions: diversion-for-unknown-file usr/share/scripts/no-such-file preinst:32 +E: scripts-diversions: diversion-for-unknown-file usr/share/scripts/other-file preinst:12 +E: scripts-diversions: orphaned-diversion usr/share/scripts/another-file preinst E: scripts-diversions: orphaned-diversion usr/share/scripts/orphan preinst +E: scripts-diversions: package-uses-local-diversion postrm:31 E: scripts-diversions: package-uses-local-diversion preinst:12 E: scripts-diversions: package-uses-local-diversion preinst:16 E: scripts-diversions: remove-of-unknown-diversion usr/share/scripts/old-file postrm:12 -- Debian package checker -- To UNSUBSCRIBE, email to debian-lint-maint-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/e1nuvxy-0007kh...@alioth.debian.org