#!/usr/local/bin/perl # $Id: portdeps.pl 40 2007-10-20 09:18:22Z dleigh $ # # Dylan Leigh 2007 -=- This program is an awful hack and in the public domain # # portdeps.pl - Pretty print a BSD Port's dependencies, with # descriptions # # Usage: Change to the target's port dir (e.g. cd /usr/ports/www/apache22) # Run this script from there (probably a good idea to pipe it # to a file or mail it to yourself, # there can be a lot of output for # ports that depend on complex # stuff like X/Qt/GNOME/TeX) # use strict; use warnings; my $verbosity = 2; # trim off "this port requires..." "...to run/build" my @build_deps_all = split(' ', substr( `make pretty-print-build-depends-list`, 31, -12)); my @run_deps_all = split(' ', substr(` make pretty-print-run-depends-list`, 31, -10)); my %installed_ports; foreach my $line (`pkg_info`) { (my $pkg, my $desc) = split(' ',$line, 2); $installed_ports{$pkg} = $desc; } foreach my $dep (@build_deps_all) { if (!exists $installed_ports{$dep}) { print "$dep\n" if $verbosity == -1; print "$dep to build\n" if $verbosity == 0; if ($verbosity > 0) { my $glob=`ports_glob $dep`; chop $glob; print "$dep (/usr/ports/$glob/) to build\n"; if ($verbosity > 1) { open DESC, "; close DESC; print "----------------------------------------------------\n" } } } } foreach my $dep (@run_deps_all) { if (!exists $installed_ports{$dep}) { print "$dep\n" if $verbosity == -1; print "$dep to run\n" if $verbosity == 0; if ($verbosity > 0) { my $glob=`ports_glob $dep`; chop $glob; print "$dep (/usr/ports/$glob/) to run\n"; if ($verbosity > 1) { open DESC, "; close DESC; print "----------------------------------------------------\n" } } } } # for testing #foreach my $port (keys %installed_ports) #{ # print "$port is installed\n"; #}