[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#516221: Checks for dpkg-divert



Package: lintian
Version: 2.2.5
Severity: wishlist
Tags: patch

Hi,

I've made some mistakes while packaging and thought lintian can check for
these mistakes. I've uses /usr/bin instead of sbin in one of the
commands, which caused the package left a diversion stay after removal.

% wget http://alioth.debian.org/~jo-guest/debian/./etcgit_20090214-1_all.deb

% lintian --root /tmp/lintian -C ddiv etcgit_20090214-1_all.deb

E: etcgit: diversion-for-unknown-file usr/bin/ucf preinst
N: 
N:    The maintainer script adds a diversion for a file that is not provided
N:    by this package.
N:    
N:    Severity: important, Certainty: certain
N: 
E: etcgit: remove-of-unknown-diversion usr/sbin/ucf postrm
N: 
N:    The maintainer script removes a diversion that it didn't add.
N:    
N:    Severity: important, Certainty: certain
N: 
E: etcgit: orphaned-diversion usr/bin/ucf preinst
N: 
N:    A diversion was added for the file, but not removed. This means your
N:    package doesn't restore the previouse state after removal.
N:    
N:    Severity: important, Certainty: certain
N: 

I've selected the severity and certainty more arbitrary. You might adjust
them. It's my first lintian check, so please, have a close look to what
I've done.

What do you think about this idea?

Bye, Jörg.

-- System Information:
Debian Release: unstable/experimental
  APT prefers unstable
  APT policy: (900, 'unstable'), (700, 'experimental')
Architecture: powerpc (ppc)

Kernel: Linux 2.6.29-rc5
Locale: LANG=C, LC_CTYPE=C (charmap=UTF-8) (ignored: LC_ALL set to de_DE.UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages lintian depends on:
ii  binutils               2.19.1-1          The GNU assembler, linker and bina
ii  diffstat               1.46-1            produces graph of changes introduc
ii  dpkg-dev               1.14.25           Debian package development tools
ii  file                   4.26-2            Determines file type using "magic"
ii  gettext                0.17-6            GNU Internationalization utilities
ii  intltool-debian        0.35.0+20060710.1 Help i18n of RFC822 compliant conf
ii  libdigest-sha-perl     5.47-1            Perl extension for SHA-1/224/256/3
ii  libipc-run-perl        0.82-1            Perl module for running processes
ii  libparse-debianchangel 1.1.1-2           parse Debian changelogs and output
ii  libtimedate-perl       1.1600-9          Time and date functions for Perl
ii  liburi-perl            1.37+dfsg-1       Manipulates and accesses URI strin
ii  man-db                 2.5.2-4           on-line manual pager
ii  perl [libdigest-sha-pe 5.10.0-19         Larry Wall's Practical Extraction 

lintian recommends no packages.

Versions of packages lintian suggests:
pn  binutils-multiarch            <none>     (no description available)
ii  libtext-template-perl         1.44-1.2   Text::Template perl module
ii  man-db                        2.5.2-4    on-line manual pager

-- no debconf information
# dpkg-divert -- lintian check script -*- perl -*-

# Copyright © 2009 Jörg Sommer <joerg@alea.gnuu.de>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program.  If not, see <http://www.gnu.org/licenses/>.

package Lintian::dpkg_divert;
use strict;
use Tags;

sub run {

my $pkg = shift;
my $type = shift;
my $info = shift;

my %added_diversions;
foreach my $maintscript ('preinst', 'postrm')
{
    last unless (open (IN, '<', "control/$maintscript"));
    while (<IN>)
    {
        if (/[^#]*dpkg-divert/)
        {
            my $line = $_;
            $line = substr($line, $[, -2) . $_
              while ($line =~ /\\$/ && ($_ = <IN>));
            chomp($line);
            next if ($line =~ /--(?:help|list|truename|version)/);
            if ($line =~ /--local/)
            {
                tag('package-uses-local-diversion', $maintscript);
            }
            else
            {
                $line =~ s/^.*dpkg-divert\s*//;
                my $mode = ($line =~ /--remove/) ? 'remove' : 'add';
                $line =~ s/--(?:add|quiet|remove|rename|test|(:?admindir|divert|package)\s*\S+\s*)//g;
                $line =~ s/\s+//g;
                # remove the leading / because it's not in the index hash
                $line =~ s/^\///;
                unless (exists $info->index->{$line})
                {
                    tag('diversion-for-unknown-file', $line, $maintscript);
                }

                if ($mode eq 'add')
                {
                    $added_diversions{$line} = $maintscript;
                }
                elsif ($mode eq 'remove')
                {
                    if (exists $added_diversions{$line})
                    {
                        # do not really delete the entry, because a --remove
                        # might happen in two branches in the script, i.e. we
                        # see it twice, which is not a bug
                        undef $added_diversions{$line};
                    }
                    else
                    {
                        tag('remove-of-unknown-diversion', $line, $maintscript);
                    }
                }
                else
                {
                    die "Internal error: \$mode has unknown value: $mode";
                }
            }
        }
    }
    close(IN);
}

tag('orphaned-diversion', $_, $added_diversions{$_})
  foreach (grep {defined $added_diversions{$_}} keys %added_diversions);
}

1;
Check-Script: dpkg-divert
Author: Jörg Sommer <joerg@alea.gnuu.de>
Abbrev: ddiv
Type: binary, udeb
Unpack-Level: 1
Info: This script checks the usage of dpkg-divert.

Tag: package-uses-local-diversion
Severity: important
Certainty: possible
Info: The maintainer script calls dpkg-divert with --local while this
 option is for local admins.

Tag: diversion-for-unknown-file
Severity: important
Certainty: certain
Info: The maintainer script adds a diversion for a file that is not
 provided by this package.

Tag: orphaned-diversion
Severity: important
Certainty: certain
Info: A diversion was added for the file, but not removed. This means
 your package doesn't restore the previouse state after removal.

Tag: remove-of-unknown-diversion
Severity: important
Certainty: certain
Info: The maintainer script removes a diversion that it didn't add.

Attachment: signature.asc
Description: Digital signature http://en.wikipedia.org/wiki/OpenPGP


Reply to: