tag 290277 +patch
thanks

  Hello,

  A long time ago, I requested a recursive version of debsums that could
also check dependencies. It doesn't seem you found time to implement it,
which is perfectly fine. I did write a simple perl script that computes
dependencies of a package and calls debsums on them; it is attached,
along with a manual page.

  I believe they would make a valuable addition to debsums, but, of
course, this is up to you to choose.

  Regards,

        Vincent

-- 
Vincent Fourmond, Debian Developer
http://vince-debian.blogspot.com/
-- pretty boring signature, isn't it ?
#! /usr/bin/perl

# rdebsums: a wrapper around debsums to also check dependencies of a package
# Copyright 2007 by Vincent Fourmond <[EMAIL PROTECTED]>
# 
# 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, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

my $usage="rdebsums --help | --others [debsum options] package

Runs debsums on package and all its dependencies. 
\t--others\talso include Recommends and Suggests
";



if(grep(/^--others/, @ARGV)) {
    print "Also running debsums on suggests and recommends\n";
    $others = 1;
    @ARGV = grep(!/^--others/, @ARGV)
} else {
    $others = 0;
} 
if(! (scalar @ARGV) || grep(/^--help/, @ARGV) ) {
    print $usage;
    exit 1;
}

my $pack = pop;
my $options = join(" ", @ARGV);

for my $p (dependencies($pack, $others)) {
    print "\nRunning debsums $options $p:\n";
    system "debsums $options $p";
}

# Gets all the installed dependencies of a package, including
# recommends and suggests if the second argument is true.
sub dependencies {
    my $pack = shift;
    my $also_not_depends = shift || 0;
    my $ignore = shift || {};

    # We first sanitize $pack:
    if($pack =~ /([a-z0-9+.-]+)/) {
        $pack = $1;
    } else {
        return ();
    }
    # We first get direct children:
    my @direct_children;
    my $dpkg_query_cmd = "dpkg-query -W -f '\${Depends}".
        ($also_not_depends ? ' ${Recommends} ${Suggests}' : "").
        "' $pack 2> /dev/null";
    my $dpkg_query = `$dpkg_query_cmd`;
    while($dpkg_query =~ /\([^)]+\)|([a-z0-9+.-]+)/g) {
        if($1) {
            push @direct_children, $1;
        }
    }
        
    $ignore->{$pack} = 1;
    # Then, we add their dependencies
    for my $subp (@direct_children) {
        dependencies($subp, $also_not_depends, $ignore) unless 
            $ignore->{$subp};
        $ignore{$subp} = 1;
    }
    return (keys %{$ignore});
}

\" Man page for rdebsums, based on the one from man(1)
\"
\" Copyright 2007 by Vincent Fourmond <[EMAIL PROTECTED]>
\"
\" 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, write to the Free Software
\" Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

.pc
.TH RDEBSUMS 1 "2007-03-29" "Version 0.1" "Recursive debsums"
.SH NAME
rdebsums \- a recursive debsums

.SH SYNOPSIS
.B rdebsums --help \fR | [ \fI debsum options \fR ] [ \fB --others \fR ]
.I package

.SH DESCRIPTION

.B rdebsums
runs 
.BR debsums (1)
over a given package and all its dependencies. It can be used to make
sure a problem with a package is not due to file corruption. 

All but the last element of the command-line and options understood by 
.B rdebsums
are sent to
.BR debsums (1).


.SH OPTIONS

.TP 
.B --help
Prints a short help text

.TP
.B --others
Also runs
.B debsums
on Recommended and Suggested
packages.

.SH EXAMPLES

Check the package
.I aptitude
and all its dependencies:

.I rdebsums aptitude

The same while being significantly less verbose

.I rdebsums -s aptitude

.SH BUGS

.B rdebsums 
is quite slow - essentially due to
.B dpkg-query
not being extremely fast.

Currently, 
.B rdebsums
will be confused by virtual packages.

.B --others
is actually nearly useless, as you often end up checking nearly all
packages. You'll most probably win time by running 
.B debsums
without arguments.

.SH AUTHOR

.B rdebsums
was written by Vincent Fourmond <[EMAIL PROTECTED]>

.SH SEE ALSO

.BR debsums (1), \ dpkg-query (1)

Reply via email to