#!/usr/bin/env perl ## Copyright © 2008-2009 by Daniel Friesel ## License: WTFPL use strict; use warnings; use AptPkg::Cache; use Switch; use Getopt::Long; my $cache = AptPkg::Cache->new; my $not = 0; my @deptypes; GetOptions( 'not' => \$not, 'deptype=s' => \@deptypes, ); my $packagename = shift or die("No packagename given"); my @known; @deptypes = split(/,/, join(',', @deptypes)); sub revdeps { my $name = shift; my $package = $cache->{$name}; my @return; my $rdeps = $package->{RevDependsList}; foreach (@$rdeps) { if ( $cache->{$_->{ParentPkg}{Name}}->{CurrentState} eq 'Installed' and ( (not @deptypes and $_->{DepType} !~ /^(Conflicts|Replaces|Obsoletes)$/) or (@deptypes and "$_->{DepType}" ~~ @deptypes) ) ) { next if ($_->{ParentPkg}{Name} ~~ @known); push(@return, $_->{ParentPkg}{Name}); } } push(@known, @return); return(@return); } sub recurse { my $name = shift; my $level = (shift) + 1; printf("%s%s\n", " " x ($level-1), $name); return if ($level >= 5); recurse($_, $level) foreach revdeps($name); } recurse($packagename, 0); __END__ =head1 NAME apt-why - filtered reverse dependency displayer using AptPkg::Cache =head1 SYNOPSIS B [ B<--not> ] I =head1 DESCRIPTION B displays various informations based on a Is reverse dependencies The output is prefixed by two charactes, the former representing the desired package state, the latter the current state. The states are Install, Iold, Iemove (deinstall), I

urge, Inpacked, halI configured, Ialf installed, Ionfigfiles installed. An empty field means not installed. If B<--not> is specified, reverse dependencies prohibiting the installation of I are shown. Else, reverse dependencies justifying the installation of I are shown =head1 AUTHOR Daniel Friesel =head1 LICENSE 0. You just DO WHAT THE FUCK YOU WANT TO.