#! /usr/bin/perl -w
# debtree version 1.0.2
# Copyright 2007-2009 Frans Pop <elendil@planet.nl>
# 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.
# Usage: debtree [options] <package name>
# The script produces a dot file for processing with 'dot'.
# Examples: debtree <package> > <package>.dot
# debtree <package> | dot -Tpng -o <package>.png
# debtree <package> | dot -Tps | kghostview -
sub usage {
warn join(" ", @_)."\n" if @_;
warn <<EOF;
Usage: $0 [options] package
For details, see man page.
EOF
exit(1);
}
use strict;
use Cwd;
use Getopt::Long;
### INITIALIZATION ###
my $HOME;
($HOME = $ENV{'HOME'}) or die "HOME not defined in environment!\n";
my @ARCHES = qw/alpha amd64 arm armel hppa i386 ia64 mips mipsel powerpc s390 sparc/;
push(@ARCHES, qw/hurd-i386 kfreebsd-i386 kfreebsd-amd64 m68k ppc64 sh all/);
my $ptype;
my $verbose = 0;
my $quiet = 0;
my $show_installed = 0;
my $show_rdeps = 0;
my $build_dep = 0;
my $with_alternatives = 1;
my $with_suggests = 0;
my $with_recommends = 1;
my $with_conflicts = 1;
my $with_vconflicts = 0;
my $with_provides = 1;
my $max_providers = 3;
my $with_versions = 1;
my $max_depth = 999999;
my $rdeps_depth = 0;
my $max_rdeps=5;
my $no_skip = 0;
my $show_all = 0;
my $do_rotate = 0;
my $do_condense = 0;
my $ARCH="";
my $download_size=0;
my $total_size=0;
# Hash containing skip and end packages read from config files
my %clist;
# Hash containing global package status info; used types are:
# skipped, ended, done, leaf, unknown, OR_seen, rdep, prov_rdeps
my %pstatus;
my (%OR_dep_list, %OR_virt_list, %pdep_set_list);
my $OR_dep_cnt = 0;
my $OR_virt_cnt = 0;
my $pdep_set_cnt = 0;
$Getopt::Long::ignorecase = 0;
GetOptions(
'show-installed|I' => \$show_installed,
'show-rdeps|R' => \$show_rdeps,
'build-dep|b' => \$build_dep,
'alternatives!' => \$with_alternatives,
'recommends!' => \$with_recommends,
'conflicts!' => \$with_conflicts,
'provides!' => \$with_provides,
'max-providers=i' => \$max_providers,
'with-suggests|S' => \$with_suggests,
'versioned-conflicts|VC' => \$with_vconflicts,
'versions!' => \$with_versions,
'max-depth=i' => \$max_depth,
'rdeps-depth=i' => \$rdeps_depth,
'max-rdeps=i' => \$max_rdeps,
'skip!' => \$no_skip,
'show-all' => \$show_all,
'rotate|r' => \$do_rotate,
'condense' => \$do_condense,
'arch=s' => \$ARCH,
'quiet|q' => \$quiet,
'verbose|v+' => \$verbose,
) or usage;
#usage if $help;
# Package for which to generate the graph