Update of /cvsroot/fink/fink/perlmod/Fink In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17765/perlmod/Fink
Modified Files: ChangeLog Engine.pm Log Message: Implemented 'fink show-deps'. Index: Engine.pm =================================================================== RCS file: /cvsroot/fink/fink/perlmod/Fink/Engine.pm,v retrieving revision 1.199 retrieving revision 1.200 diff -u -d -r1.199 -r1.200 --- Engine.pm 29 Sep 2004 03:32:47 -0000 1.199 +++ Engine.pm 30 Sep 2004 04:17:28 -0000 1.200 @@ -92,6 +92,7 @@ 'splits' => [\&cmd_splitoffs, 1, 0], 'showparent' => [\&cmd_showparent, 1, 0], 'dumpinfo' => [\&cmd_dumpinfo, 1, 0], + 'show-deps' => [\&cmd_show_deps, 1, 0], ); END { } # module clean-up code here (global destructor) @@ -1944,5 +1945,113 @@ } } +# display the dependencies "from a user's perspective" of a given package +sub cmd_show_deps { + my( $field, $pkglist, $did_print ); # temps used in dep-listing loops + + my @plist = &expand_packages(@_); + if ($#plist < 0) { + die "no package specified for command 'show-deps'!\n"; + } + + print "\n"; + + foreach my $pkg (@plist) { + my @relatives = (); + if (exists $pkg->{_relatives}) { + @relatives = @{$pkg->{_relatives}}; + } + + printf "Package: %s (%s)\n", $pkg->get_name(), $pkg->get_fullversion(); + + print "To install the compiled package...\n"; + + print " The following other packages (and their dependencies) must be installed:\n"; + &show_deps_display_list( + [qw/ Depends Pre-Depends /], + [ $pkg ], + 0 + ); + + print " The following other packages must not be installed:\n"; + &show_deps_display_list( + [qw/ Conflicts /], + [ $pkg ], + 0 + ); + + print "To compile this package from source...\n"; + + print " The following packages are also compiled at the same time:\n"; + if (@relatives) { + foreach (@relatives) { + printf " %s (%s)\n", $_->get_name(), $_->get_fullversion(); + } + } else { + print " [none]\n"; + } + + print " The following other packages (and their dependencies) must be installed:\n"; + &show_deps_display_list( + [qw/ Depends Pre-Depends BuildDepends /], + [ $pkg, @relatives ], + 1 + ); + + print " The following other packages must not be installed:\n"; + &show_deps_display_list( + [qw/ Conflicts BuildConflicts /], + [ $pkg, @relatives ], + 1 + ); + + print "\n"; + } +} + +# pretty-print a set of PkgVersion::pkglist (each "or" group on its own line) +# pass: +# ref to list of field names +# ref to list of PkgVersion objects +# boolean whether to exclude packages themselves when printing +sub show_deps_display_list { + my $fields = shift; + my $pkgs = shift; + my $exclude_selves = shift; + + my $family_regex; + if ($exclude_selves) { + # regex for any ("or") package name from the given pkgs + $family_regex = join '|', map { qr/\Q$_\E/i } map { $_->get_name() } (@$pkgs); + } + + my $field_value; # used in dep processing loop (string from pkglist()) + + my $did_print = 0; # did we print anything at all? + foreach my $field (@$fields) { + foreach (@$pkgs) { + next unless defined( $field_value = $_->pkglist($field) ); + foreach (split /\s*,\s*/, $field_value) { + # take each requested field of each requested pkg + # and parse apart "and"-separated "or" groups + + if (defined $family_regex) { + # optionally remove own family from build-time deps + while (s/(\A|\|)\s*($family_regex)\s*(\(.*?\))?\s*(\||\Z)/|/) {}; + s/^\s*\|\s*//; + s/\s*\|\s*$//; + } + + if (length $_) { + printf " %s\n", $_; + $did_print++; + } + } + } + } + print " [none]\n" unless $did_print; + +} + ### EOF 1; Index: ChangeLog =================================================================== RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v retrieving revision 1.709 retrieving revision 1.710 diff -u -d -r1.709 -r1.710 --- ChangeLog 30 Sep 2004 03:56:34 -0000 1.709 +++ ChangeLog 30 Sep 2004 04:17:28 -0000 1.710 @@ -1,3 +1,8 @@ +2004-09-28 Daniel Macks <[EMAIL PROTECTED]> + + * Engine.pm: Implemented 'fink show-deps' (cmd_show_deps() and + show_deps_print_pkglist()). + 2004-09-27 Chris Zubrzycki <[EMAIL PROTECTED]> * Engine.pm: Implemented --keep-src for fink cleanup. ------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl _______________________________________________ Fink-commits mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/fink-commits