--- apt-rdepends-1.3.0.orig/apt-rdepends +++ apt-rdepends-1.3.0/apt-rdepends @@ -42,6 +42,10 @@ my @follow = (); # Which types of dependencies do we show? my @show = (); +# Which configuration options do we want to pass to libapt-pkg. +# The syntax is -o Foo::Bar=bar +my @configoptions = (); + # We don't print package states by default. my $printstate = 0; @@ -53,6 +57,11 @@ # The object that knows how to display $output my $Print; +# This script depends highly on no function returning localized data. +require 5.004; +use POSIX qw(locale_h); +setlocale(LC_ALL, "C"); + GetOptions ('reverse|r' => \$reverse, 'build-depends|b' => \$builddep, 'dotty|d' => sub { $output = "dotty" }, @@ -62,6 +71,7 @@ 'print-state|p' => \$printstate, 'state-follow=s' => \@statefollow, 'state-show=s' => \@stateshow, + 'option|o=s' => \@configoptions, 'help|h|?' => \$help, 'version' => \$ver, 'man' => \$man) or pod2usage(verbose => 0); @@ -103,6 +113,12 @@ $_config->init(); $_system = $_config->system(); +# override config if asked to +for my $opt (@configoptions) { + my ($o, $v) = split(/\=/, $opt, 2); + $_config->set($o, $v); +} + # Choose whether we're searching Depends or Build-Depends. my $cache = AptPkg::Cache->new(); my $source; @@ -116,13 +132,47 @@ close(OLDOUT); select(STDOUT); $| = 0; +# Converts a string like "Depends" to the corresponding AptPkg::Dep::* enum. +sub depstr_to_enum { + my $depstr = shift(@_); + if ($depstr eq "Depends") { + return AptPkg::Dep::Depends; + } + if ($depstr eq "PreDepends") { + return AptPkg::Dep::PreDepends; + } + if ($depstr eq "Suggests") { + return AptPkg::Dep::Suggests; + } + if ($depstr eq "Recommends") { + return AptPkg::Dep::Recommends; + } + if ($depstr eq "Conflicts") { + return AptPkg::Dep::Conflicts; + } + if ($depstr eq "Replaces") { + return AptPkg::Dep::Replaces; + } + if ($depstr eq "Obsoletes") { + return AptPkg::Dep::Obsoletes; + } + print(STDERR "invalid argument given to -f (--follow): ${depstr}\n"); + exit 101; +} + # Set defaults if they weren't defined on the command line. if ($builddep) { @follow = ("Build-Depends", "Build-Depends-Indep") unless (@follow); @show = ("Build-Depends", "Build-Depends-Indep") unless (@show); } else { - @follow = (AptPkg::Dep::Depends, AptPkg::Dep::PreDepends) unless (@follow); + unless(@follow) { + @follow = (AptPkg::Dep::Depends, AptPkg::Dep::PreDepends); + } + else { + @follow = map{depstr_to_enum($_)}(@follow); + } + @show = (AptPkg::Dep::Depends, AptPkg::Dep::PreDepends) unless (@show); } my %deptype_dict; @@ -576,7 +626,7 @@ =item B<-d>, B<--dotty> dotty takes a list of packages on the command line and generates -output suitable for use by springgraph. The result will be a set of +output suitable for use by springgraph (1). The result will be a set of nodes and edges representing the relationships between the packages. By default the given packages will trace out all dependent packages which can produce a very large graph. @@ -658,11 +708,17 @@ are suggests, orange lines are recommends, red lines are replaces, and black lines are depends. +=item B<-o>, B<--option=>I