#!/bin/perl if (@ARGV == 0) { print "Usage: perl alldeps.pl packgename\n"; print "Compute transitive closure of dependencies for a given debian package.\n"; print "Bug: always chooses first option when given a choice.\n"; print "Dan Kegel\n"; exit(1); } $deps{""} = $ARGV[0]; do { $added = 0; foreach $key (sort(keys(%deps))) { foreach $dep (split(" ", $deps{$key})) { if (!defined($deps{$dep})) { # The two sed commands that delete everything after | are # the ones that choose the first option. # You could switch to choosing all options # by mapping | to blank rather than deleting what follows it. $deps{$dep} = `dpkg-query -W -f '\${Depends}\n' $dep | sed 's/ ([^)]*)//g' | sed 's/|[^,]*,//g' | sed 's/|[^,]*\$//g' | sed 's/ / /g' | tr -d , | tr ' ' '\012'`; $added = 1; } } } } while ($added); foreach (sort(keys(%deps))) { print $_." "; $all{$_} = 1; foreach (split(" ", $keys{$_})) { $all{$_} = 1; } } print "\n";