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

Modified Files:
        ChangeLog Config.pm Engine.pm PkgVersion.pm 
Log Message:
add Finally for buildlocks

Index: PkgVersion.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/PkgVersion.pm,v
retrieving revision 1.542
retrieving revision 1.543
diff -u -d -r1.542 -r1.543
--- PkgVersion.pm       22 Mar 2006 04:00:31 -0000      1.542
+++ PkgVersion.pm       22 Mar 2006 05:41:20 -0000      1.543
@@ -4549,41 +4549,22 @@
        $self->{_buildlock} = {
                lockfile => $lockfile,
                lock_FH  => $lock_FH,
-               lockpkg  => $lockpkg
+               lockpkg  => $lockpkg,
+               finalizer => Fink::Finally->new(sub { 
$self->_real_clear_buildlock }),
        };
 }
 
-# remove the lock created by set_buildlock
-# okay to call as a package method (will pull PkgVersion object from Config)
-# or as object method (will use its own PkgVersion object)
+# external wrapper for _real_clear_buildlock
 sub clear_buildlock {
-       my $self = shift;
-
+       my ($self) = @_;
+       
        # lock on parent pkg
        if ($self->has_parent) {
                return $self->get_parent->clear_buildlock();
        }
-
-       if (exists $self->{_buildlock}) {
-               # we were locked...
-               print "Removing runtime build-lock...\n";
-               close $self->{_buildlock}->{lock_FH};
-
-               print "Removing build-lock package...\n";
-               my $lockpkg = $self->{_buildlock}->{lockpkg};
-
-               # lockpkg's prerm deletes the lockfile
-               if (&execute(dpkg_lockwait() . " -r $lockpkg", ignore_INT=>1)) {
-                       &print_breaking("WARNING: Can't remove package ".
-                                                       "$lockpkg. ".
-                                                       "This is not fatal, but 
you may want to remove ".
-                                                       "the package manually 
as it may interfere with ".
-                                                       "further fink 
operations. ".
-                                                       "Continuing with normal 
procedure.");
-               }
-               Fink::PkgVersion->dpkg_changed;
-               delete $self->{_buildlock};
-       }
+       return unless $self->{_buildlock};
+       
+       $self->{_buildlock}->{finalizer}->run;
        
        # This should be a good time to scan the packages
        my $autoscan = !$config->has_param("AutoScanpackages")
@@ -4597,6 +4578,30 @@
        }
 }
 
+# remove the lock created by set_buildlock
+sub _real_clear_buildlock {
+       my $self = shift;
+
+       # we were locked...
+       print "Removing runtime build-lock...\n";
+       close $self->{_buildlock}->{lock_FH};
+
+       print "Removing build-lock package...\n";
+       my $lockpkg = $self->{_buildlock}->{lockpkg};
+
+       # lockpkg's prerm deletes the lockfile
+       if (&execute(dpkg_lockwait() . " -r $lockpkg", ignore_INT=>1)) {
+               &print_breaking("WARNING: Can't remove package ".
+                                               "$lockpkg. ".
+                                               "This is not fatal, but you may 
want to remove ".
+                                               "the package manually as it may 
interfere with ".
+                                               "further fink operations. ".
+                                               "Continuing with normal 
procedure.");
+       }
+       Fink::PkgVersion->dpkg_changed;
+       delete $self->{_buildlock};
+}
+
 =item ensure_gpp_prefix
 
   my $prefix_path = ensure_gpp_prefix $gpp_version;

Index: Engine.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Engine.pm,v
retrieving revision 1.361
retrieving revision 1.362
diff -u -d -r1.361 -r1.362
--- Engine.pm   22 Mar 2006 04:00:30 -0000      1.361
+++ Engine.pm   22 Mar 2006 05:41:19 -0000      1.362
@@ -633,14 +633,12 @@
 
 =cut
 
-{
-       sub finalize {
-               my ($name, $code) = @_;
-               my $group = $finalizers[-1];
-               return if exists $group->{$name};
-               $group->{$name} = Fink::Finally->new($code);
-       }
-}              
+sub finalize {
+       my ($name, $code) = @_;
+       my $group = $finalizers[-1];
+       return if exists $group->{$name};
+       $group->{$name} = Fink::Finally->new($code);
+}
 
 =item aptget_update
 
@@ -1613,7 +1611,6 @@
                        @deplist = $item->[PKGVER]->resolve_depends(0, 
"Depends", $forceoff);
                        
                        # Do not use BuildConflicts for packages which are not 
going to be built!
-#                      @conlist = $item->[PKGVER]->resolve_depends(0, 
"Conflicts", $forceoff);
                } else {
                        # We want to install this package and already have a 
.deb for it
                        # -> only include life-time dependencies
@@ -1623,7 +1620,6 @@
                        @deplist = $item->[PKGVER]->resolve_depends(0, 
"Depends", $forceoff);
                        
                        # Do not use BuildConflicts for packages which are not 
going to be built!
-#                      @conlist = $item->[PKGVER]->resolve_depends(0, 
"Conflicts", $forceoff);
                }
                # add essential packages (being careful about packages whose 
parent is essential)
                # dev-tools is not Essential but it must not depend on 
essentials because essentials must implicitly BDep:dev-tools

Index: Config.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Config.pm,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- Config.pm   17 Mar 2006 06:42:07 -0000      1.72
+++ Config.pm   22 Mar 2006 05:41:19 -0000      1.73
@@ -209,8 +209,9 @@
        
        my %opts = (
                map( { $_ => 0 } qw(dontask interactive verbosity keep_build 
keep_root
-                       use_binary build_as_nobody maintainermode showversion) 
),
+                       build_as_nobody maintainermode showversion) ),
                map ( { $_ => [] } qw(include_trees exclude_trees) ),
+               map( { $_ => -1 } qw(use_binary) ),
        );
        
        my $comlen =  14;
@@ -908,7 +909,7 @@
        my $runtime_request = get_option("use_binary");
        my $binary_request;
 
-       if ($runtime_request == -1) {
+       if ($runtime_request == 0) { # --no-use-binary-dist
                $binary_request = 0;
        } elsif ($runtime_request == 1) {
                $binary_request = 1;

Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.1288
retrieving revision 1.1289
diff -u -d -r1.1288 -r1.1289
--- ChangeLog   22 Mar 2006 04:00:29 -0000      1.1288
+++ ChangeLog   22 Mar 2006 05:41:19 -0000      1.1289
@@ -1,5 +1,12 @@
 2006-03-21  Dave Vasilevsky  <[EMAIL PROTECTED]>
 
+       * Engine.pm: De-blockify &finalize.
+       * Engine.pm, PkgVersion.pm: Add a finally to remove buildlocks on build
+       failure.
+       * Config.pm: Make --no-use-binary-dist actually work.
+
+2006-03-21  Dave Vasilevsky  <[EMAIL PROTECTED]>
+
        * Finally.pm: New way to create cleanup functions.
        * Engine.pm: Adapt to new Finally, add 'finalizer' method to schedule a
        function to run when process finishes.



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Fink-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fink-commits

Reply via email to