Update of /cvsroot/fink/fink/perlmod/Fink
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28939
Modified Files:
ChangeLog Engine.pm Services.pm
Log Message:
New Services::do_calls() function processes a list of method and
function calls. Converted Engine:: cmd_fetch, cmd_fetch_missing, and
real_install to use it.
Index: Services.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Services.pm,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -d -r1.143 -r1.144
--- Services.pm 18 Jan 2005 07:59:11 -0000 1.143
+++ Services.pm 19 Jan 2005 22:34:45 -0000 1.144
@@ -50,7 +50,7 @@
&file_MD5_checksum &get_arch
&get_sw_vers &enforce_gcc
&get_system_perl_version &get_path
&eval_conditional &count_files
- &growl);
+ &growl &do_calls);
}
our @EXPORT_OK;
@@ -1355,6 +1355,57 @@
return 1;
}
+=item do_calls
+
+ &do_calls([EMAIL PROTECTED]);
+
+Loop through the method and function calls specified in @call_list,
+running each one in turn. Each element of @call_list is a ref to a
+list having one of two forms:
+
+ $call_list[n] = [ $object, $method, @params ]
+
+ In this form, a call will be made to the specified $method name
+ (given as a string, i.e., a symbolic ref) of (blessed) object
+ $obj, that is, $object->$method(@params).
+
+ $call_list[n] = [ \&function, @params ]
+
+ In this form, a call will be made to function &function (unblessed
+ CODE ref), that is, &$function(@params).
+
+In both cases, the thing is called with parameter list @params (if
+given, otherwise an empty list). Return values are discarded.
+
+The anonymous list referenced from $call_list[n] will be clobbered. At
+some point, this function may be rewritten using fork(), so you should
+not expect sane results if your functions and methods change
+parameters passed by reference, (object) instance variables, or other
+runtime data structures.
+
+=cut
+
+sub do_calls {
+ my $call_list = shift;
+ my( $object, $method, $function );
+
+ foreach my $call (@$call_list) {
+ $function = shift @$call;
+ if (ref($function) ne 'CODE') {
+ # not an unblessed CODE ref so assume it is an object
+ $object = $function;
+ $method = shift @$call;
+ $function = $object->can($method); # CODE ref for pkg
function
+ unshift @$call, $object; # handle $obj->$method as
&function($obj)
+ if (not defined $function) {
+ warn "$object does not appear to have a
\"$method\" method...will skip\n";
+ next;
+ }
+ }
+ &$function(@$call);
+ }
+}
+
=back
=cut
Index: Engine.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Engine.pm,v
retrieving revision 1.221
retrieving revision 1.222
diff -u -d -r1.221 -r1.222
--- Engine.pm 18 Jan 2005 07:59:13 -0000 1.221
+++ Engine.pm 19 Jan 2005 22:34:45 -0000 1.222
@@ -23,7 +23,7 @@
package Fink::Engine;
-use Fink::Services qw(&latest_version &sort_versions &execute
&file_MD5_checksum &get_arch &expand_percent &count_files);
+use Fink::Services qw(&latest_version &sort_versions &execute
&file_MD5_checksum &get_arch &expand_percent &count_files &do_calls);
use Fink::CLI qw(&print_breaking &prompt_boolean &prompt_selection_new
&get_term_width);
use Fink::Package;
use Fink::PkgVersion;
@@ -599,7 +599,7 @@
### package-related commands
sub cmd_fetch {
- my ($package, @plist);
+ my ($package, @plist, @fetch_calls);
my (%options, $norestrictive, $dryrun);
my @sav = @_;
@@ -620,14 +620,16 @@
die "no package specified for command 'fetch'!\n";
}
+ @fetch_calls = ();
foreach $package (@plist) {
my $pname = $package->get_name();
if ($norestrictive && $package->has_param("license") &&
$package->param("license") =~ m/Restrictive\s*$/i) {
print "Ignoring $pname due to License:
Restrictive\n";
next;
}
- $package->phase_fetch(0, $dryrun);
+ push @fetch_calls, [ $package, 'phase_fetch', 0, $dryrun ];
}
+ &do_calls([EMAIL PROTECTED]);
}
sub cmd_description {
@@ -691,15 +693,14 @@
#This sub is currently only used for bootstrap. No command line parsing needed
sub cmd_fetch_missing {
- my ($package, $options, @plist);
+ my (@plist, @fetch_calls);
@plist = &expand_packages(@_);
if ($#plist < 0) {
die "no package specified for command 'fetch'!\n";
}
- foreach $package (@plist) {
- $package->phase_fetch(1, 0);
- }
+ @fetch_calls = map { [ $_, 'phase_fetch', 1, 0 ] } @plist;
+ &do_calls([EMAIL PROTECTED]);
}
sub cmd_fetch_all {
@@ -1242,6 +1243,7 @@
my ($oversion, $opackage, $v, $ep, $dp, $dname);
my ($answer, $s);
my (%to_be_rebuilt, %already_activated);
+ my @fetch_calls;
if (Fink::Config::verbosity_level() > -1) {
$showlist = 1;
@@ -1681,20 +1683,21 @@
# remove buildconfilcts before new builds reinstall after build
Fink::Engine::cmd_remove("remove", @removals) if (scalar(@removals) >
0);
+ @fetch_calls = ();
# fetch all packages that need fetching
foreach $pkgname (sort keys %deps) {
$item = $deps{$pkgname};
next if $item->[OP] == $OP_INSTALL and
$item->[PKGVER]->is_installed();
- if (not $item->[PKGVER]->is_present() and $item->[OP] !=
$OP_REBUILD
- and $deb_from_binary_dist and
$item->[PKGVER]->is_aptgetable()) {
- # download the deb
- $item->[PKGVER]->phase_fetch_deb(1, 0);
- }
-
- if ($item->[OP] == $OP_REBUILD or not
$item->[PKGVER]->is_present()) {
- $item->[PKGVER]->phase_fetch(1, 0);
+ if (not $item->[PKGVER]->is_present() and $item->[OP] !=
$OP_REBUILD) {
+ push @fetch_calls, [
+ $item->[PKGVER],
+ $deb_from_binary_dist &&
$item->[PKGVER]->is_aptgetable()
+ ? 'phase_fetch_deb'
+ : 'phase_fetch',
+ 1, 0 ];
}
}
+ &do_calls([EMAIL PROTECTED]);
# install in correct order...
while (1) {
Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.811
retrieving revision 1.812
diff -u -d -r1.811 -r1.812
--- ChangeLog 18 Jan 2005 07:59:14 -0000 1.811
+++ ChangeLog 19 Jan 2005 22:34:44 -0000 1.812
@@ -1,3 +1,10 @@
+2005-01-19 Daniel Macks <[EMAIL PROTECTED]>
+
+ * Services.pm: New do_calls() function processes a list of method
+ and function calls.
+ * Engine.pm: cmd_fetch, cmd_fetch_missing, and real_install now
+ use do_calls() to handle phase_fetch*() calls.
+
2005-01-18 Daniel Macks <[EMAIL PROTECTED]>
* Services.pm: add new param to expand_percent() to reduce
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Fink-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fink-commits