Update of /cvsroot/fink/fink/perlmod/Fink
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19243

Modified Files:
        ChangeLog Engine.pm 
Log Message:
revamp prefetching code, someone please check this for correctness

Index: Engine.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Engine.pm,v
retrieving revision 1.309
retrieving revision 1.310
diff -u -d -r1.309 -r1.310
--- Engine.pm   24 Aug 2005 06:28:52 -0000      1.309
+++ Engine.pm   26 Aug 2005 06:47:19 -0000      1.310
@@ -1860,22 +1860,9 @@
                        }
                }
        }
-
-       &call_queue_clear;
-       # 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) {
-                       &call_queue_add([
-                               $item->[PKGVER],
-                               $deb_from_binary_dist && 
$item->[PKGVER]->is_aptgetable()
-                                       ? 'phase_fetch_deb'
-                                       : 'phase_fetch',
-                                1, $dryrun ]);
-               }
-       }
-       &call_queue_clear;
+       
+       # Pre-fetch all the stuff we'll need
+       prefetch($deb_from_binary_dist, $dryrun, values %deps);
 
        # if we were really in fetch or dry-run modes, stop here
        return if $fetch_only || $dryrun;
@@ -2858,6 +2845,62 @@
        choose_pkgversion_by_package($deps, $queue, $item, @pvs);       
 }
 
+=item prefetch
+
+  prefetch $use_bindist, $dryrun, @dep_items;
+
+For each of the given deps, determine if we'll need to fetch the source or
+download the .deb via apt-get, and then do all the fetching.
+
+=cut
+
+sub prefetch {
+       my ($use_bindist, $dryrun, @dep_items) = @_;
+       
+       &call_queue_clear;
+       
+       my ($FETCH_NONE, $FETCH_SRC, $FETCH_APTGET) = 0..2;
+       foreach my $dep (@dep_items) {
+               my $action;
+               
+               # What action do we take?
+               if (grep { $dep->[OP] == $_ } ($OP_REINSTALL, $OP_INSTALL)) {
+                       if ($dep->[PKGVER]->is_installed || 
$dep->[PKGVER]->is_present) {
+                               $action = $FETCH_NONE;
+                       } elsif ($use_bindist && $dep->[PKGVER]->is_aptgetable) 
{
+                               $action = $FETCH_APTGET;
+                       } elsif ($dep->[OP] == $OP_REINSTALL) {
+                               # Shouldn't get here!
+                               die "Can't reinstall a package without a 
.deb\n";
+                       } else {
+                               $action = $FETCH_SRC;
+                       }
+               } elsif (grep { $dep->[OP] == $_ }
+                                               ($OP_FETCH, $OP_BUILD, 
$OP_REBUILD)) {
+                       $action = $FETCH_SRC;
+               } else {
+                       die "Don't know about operation number $dep->[OP]!\n";
+               }
+               
+               # Find the corresponding function
+               my $func_name;
+               if ($action == $FETCH_NONE) {
+                       next;
+               } elsif ($action == $FETCH_SRC) {
+                       $func_name = 'phase_fetch';
+               } elsif ($action == $FETCH_APTGET) {
+                       $func_name = 'phase_fetch_deb';
+               } else {
+                       die "Don't know about fetch action number $action!\n";
+               }
+               
+               # Queue it
+               &call_queue_add([ $dep->[PKGVER], $func_name, 1, $dryrun ]);
+       }
+       
+       &call_queue_clear;
+}
+
 =back
 
 =cut

Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.1104
retrieving revision 1.1105
diff -u -d -r1.1104 -r1.1105
--- ChangeLog   26 Aug 2005 05:29:54 -0000      1.1104
+++ ChangeLog   26 Aug 2005 06:47:19 -0000      1.1105
@@ -1,5 +1,10 @@
 2005-08-26  Dave Vasilevsky  <[EMAIL PROTECTED]>
 
+       * Engine.pm: Attempt to make prefetching work the way it should, someone
+       who knows the dep engine should look at this.
+
+2005-08-26  Dave Vasilevsky  <[EMAIL PROTECTED]>
+
        * Package.pm: Don't exit method with 'next'.
        * Services.pm, FinkVersion.pm.in: Remove RFC-822 from Info3, yay!
 



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Fink-commits mailing list
Fink-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fink-commits

Reply via email to