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

Modified Files:
        Bootstrap.pm ChangeLog Engine.pm PkgVersion.pm SelfUpdate.pm 
        Services.pm 
Log Message:
dpkg and apt-get wait for other instances to finish instead of bombing out

Index: PkgVersion.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/PkgVersion.pm,v
retrieving revision 1.401
retrieving revision 1.402
diff -u -d -r1.401 -r1.402
--- PkgVersion.pm       26 Apr 2005 20:25:20 -0000      1.401
+++ PkgVersion.pm       27 Apr 2005 18:30:26 -0000      1.402
@@ -29,7 +29,8 @@
                                          &pkglist2lol &lol2pkglist &cleanup_lol
                                          &file_MD5_checksum &version_cmp
                                          &get_arch &get_system_perl_version
-                                         &get_path &eval_conditional 
&enforce_gcc);
+                                         &get_path &eval_conditional 
&enforce_gcc
+                                         &dpkg_lockwait &aptget_lockwait);
 use Fink::CLI qw(&print_breaking &prompt_boolean &prompt_selection);
 use Fink::Config qw($config $basepath $libpath $debarch $buildpath 
$ignore_errors);
 use Fink::NetAccess qw(&fetch_url_to_file);
@@ -1874,7 +1875,7 @@
        if (Fink::Config::verbosity_level() > 2) {
                print "Downloading " . $self->get_debname() . " from binary 
dist.\n";
        }
-       my $aptcmd = "$basepath/bin/apt-get ";
+       my $aptcmd = aptget_lockwait() . " ";
        if (Fink::Config::verbosity_level() == 0) {
                $aptcmd .= "-qq ";
        }
@@ -3138,7 +3139,7 @@
        }
 
        my @deb_installable = map { $_->find_debfile() } @installable;
-       if (&execute("dpkg -i @deb_installable", ignore_INT=>1)) {
+       if (&execute(dpkg_lockwait() . " -i @deb_installable", ignore_INT=>1)) {
                if (@installable == 1) {
                        my $error = "can't install package 
".$installable[0]->get_fullname();
                        $notifier->notify(event => 
'finkPackageInstallationFailed', description => $error);
@@ -3166,7 +3167,7 @@
 
        my $notifier = Fink::Notify->new();
 
-       if (&execute("dpkg --remove @packages", ignore_INT=>1)) {
+       if (&execute(dpkg_lockwait() . " --remove @packages", ignore_INT=>1)) {
                &print_breaking("ERROR: Can't remove package(s). If the above 
error message " .
                                "mentions dependency problems, you can try\n" .
                                "  fink remove --recursive @packages\n" .
@@ -3197,7 +3198,7 @@
 sub phase_deactivate_recursive {
        my @packages = @_;
 
-       if (&execute("apt-get remove @packages")) {
+       if (&execute(aptget_lockwait() . " remove @packages")) {
                if (@packages == 1) {
                        die "can't remove package ".$packages[0]."\n";
                } else {
@@ -3212,7 +3213,7 @@
 sub phase_purge {
        my @packages = @_;
 
-       if (&execute("dpkg --purge @packages", ignore_INT=>1)) {
+       if (&execute(dpkg_lockwait() . " --purge @packages", ignore_INT=>1)) {
                &print_breaking("ERROR: Can't purge package(s). Try 'fink purge 
--recursive " .
                                "@packages', which will also purge packages 
that depend " .
                                "on the package to be purged.");
@@ -3230,7 +3231,7 @@
 sub phase_purge_recursive {
        my @packages = @_;
 
-       if (&execute("apt-get remove --purge @packages")) {
+       if (&execute(aptget_lockwait() . " remove --purge @packages")) {
                if (@packages == 1) {
                        die "can't purge package ".$packages[0]."\n";
                } else {
@@ -3357,7 +3358,7 @@
        # install lockpkg (== set lockfile for building ourself)
        print "Setting build lock...\n";
        my $debfile = 
$buildpath.'/'.$lockpkg.'_'.$timestamp.'_'.$debarch.'.deb';
-       my $lock_failed = &execute("dpkg -i $debfile", ignore_INT=>1);
+       my $lock_failed = &execute(dpkg_lockwait() . " -i $debfile", 
ignore_INT=>1);
        if ($lock_failed) {
                &print_breaking(<<EOMSG);
 Can't set build lock for $pkgname ($pkgvers)
@@ -3380,7 +3381,7 @@
                chomp $old_lock;
                if ($old_lock eq "$lockpkg\t$timestamp") {
                        # only clean up residue from our exact lockpkg
-                       &execute("dpkg -r $lockpkg", ignore_INT=>1) and
+                       &execute(dpkg_lockwait() . " -r $lockpkg", 
ignore_INT=>1) and
                                &print_breaking('You can probably ignore that 
last message from "dpkg -r"');
                }
        }
@@ -3448,7 +3449,7 @@
                                                "removing it, as it likely 
belongs to a different ".
                                                "fink process. This should not 
ever happen.");
        } else {
-               if (&execute("dpkg -r $lockpkg", ignore_INT=>1)) {
+               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 ".

Index: Engine.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Engine.pm,v
retrieving revision 1.269
retrieving revision 1.270
diff -u -d -r1.269 -r1.270
--- Engine.pm   27 Apr 2005 07:02:04 -0000      1.269
+++ Engine.pm   27 Apr 2005 18:30:24 -0000      1.270
@@ -27,7 +27,8 @@
                                          &pkglist2lol &cleanup_lol
                                          &execute &expand_percent
                                          &file_MD5_checksum &count_files 
&get_arch
-                                         &call_queue_clear &call_queue_add 
&lock_wait);
+                                         &call_queue_clear &call_queue_add 
&lock_wait
+                                         &aptget_lockwait);
 use Fink::CLI qw(&print_breaking &print_breaking_stderr
                                 &prompt_boolean &prompt_selection
                                 &get_term_width);
@@ -1250,7 +1251,7 @@
        if ($config->binary_requested()) {
                # Delete obsolete .deb files in 
$basepath/var/cache/apt/archives using 
                # 'apt-get autoclean'
-               my $aptcmd = "$basepath/bin/apt-get ";
+               my $aptcmd = aptget_lockwait() . " ";
                if (Fink::Config::verbosity_level() == 0) {
                        $aptcmd .= "-qq ";
                }

Index: SelfUpdate.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/SelfUpdate.pm,v
retrieving revision 1.93
retrieving revision 1.94
diff -u -d -r1.93 -r1.94
--- SelfUpdate.pm       26 Apr 2005 05:17:59 -0000      1.93
+++ SelfUpdate.pm       27 Apr 2005 18:30:27 -0000      1.94
@@ -23,7 +23,7 @@
 
 package Fink::SelfUpdate;
 
-use Fink::Services qw(&execute &version_cmp);
+use Fink::Services qw(&execute &version_cmp &aptget_lockwait);
 use Fink::Bootstrap qw(&additional_packages);
 use Fink::CLI qw(&print_breaking &prompt &prompt_boolean &prompt_selection);
 use Fink::Config qw($config $basepath $dbpath $distribution);
@@ -471,7 +471,7 @@
        # update apt-get's database if using -b mode
        if ($config->binary_requested()) {
                print "Downloading the indexes of available packages in the 
binary distribution.\n";
-               my $aptcmd = "$basepath/bin/apt-get ";
+               my $aptcmd = aptget_lockwait() . " ";
                if (Fink::Config::verbosity_level() == 0) {
                        $aptcmd .= "-qq ";
                }

Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.979
retrieving revision 1.980
diff -u -d -r1.979 -r1.980
--- ChangeLog   27 Apr 2005 07:02:01 -0000      1.979
+++ ChangeLog   27 Apr 2005 18:30:23 -0000      1.980
@@ -1,3 +1,8 @@
+2005-04-27  Dave Vasilevsky  <[EMAIL PROTECTED]>
+
+       * Bootstrap.pm, Engine.pm, PkgVersion.pm, SelfUpdate.pm, Services.pm: 
Use
+       -lockwait versions of dpkg and apt-get.
+
 2005-04-27  Daniel Macks  <[EMAIL PROTECTED]>
 
        * Engine.pm: Better accessor usage in dumpinfo

Index: Services.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Services.pm,v
retrieving revision 1.160
retrieving revision 1.161
diff -u -d -r1.160 -r1.161
--- Services.pm 27 Apr 2005 01:57:31 -0000      1.160
+++ Services.pm 27 Apr 2005 18:30:28 -0000      1.161
@@ -51,7 +51,8 @@
                                          &file_MD5_checksum &get_arch 
&get_sw_vers &enforce_gcc
                                          &get_system_perl_version &get_path
                                          &eval_conditional &count_files
-                                         &call_queue_clear &call_queue_add 
&lock_wait);
+                                         &call_queue_clear &call_queue_add 
&lock_wait
+                                         &dpkg_lockwait &aptget_lockwait);
 }
 our @EXPORT_OK;
 
@@ -1526,16 +1527,13 @@
                eval {
                        # If non-root, we could be stuck here forever with no 
way to 
                        # stop a broken root process. Need a timeout!
-                       alarm $timeout if $really_timeout;
+                       local $SIG{ALRM} = sub { die "alarm\n" };
                        $success = flock $lockfile_FH, $mode;
                        alarm 0;
                };
                if ($@) {
-                       if ($@ !~ /alarm clock restart/) {
-                               $alarm = 1;
-                       } else {
-                               die;
-                       }
+                       die unless $@ eq "alarm\n";
+                       $alarm = 1;
                }
                
                if ($success) {
@@ -1553,6 +1551,39 @@
        }
 }
 
+=item dpkg_lockwait
+
+  my $path = dpkg_lockwait;
+  
+Gets the path to dpkg-lockwait (a dpkg which will wait for a lock rather than
+just dying). Safely falls back to regular dpkg if dpkg-lockwait is not
+available.
+
+=cut
+
+sub dpkg_lockwait {
+       require Fink::Config;
+       my $path = "$Fink::Config::basepath/bin/dpkg-lockwait";
+       return $path if -x $path;
+       return "$Fink::Config::basepath/bin/dpkg";
+}
+
+=item aptget_lockwait
+
+  my $path = aptget_lockwait;
+  
+Just like dpkg_lockwait, but for apt-get.
+
+=cut
+
+sub aptget_lockwait {
+       require Fink::Config;
+       my $path = "$Fink::Config::basepath/bin/apt-get-lockwait";
+       return $path if -x $path;
+       return "$Fink::Config::basepath/bin/apt-get";
+}
+
+
 =back
 
 =cut

Index: Bootstrap.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Bootstrap.pm,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- Bootstrap.pm        27 Apr 2005 04:44:39 -0000      1.100
+++ Bootstrap.pm        27 Apr 2005 18:30:22 -0000      1.101
@@ -505,7 +505,7 @@
 my $packagefiles = "COPYING INSTALL INSTALL.html README README.html USAGE 
USAGE.html Makefile ".
   "ChangeLog VERSION REVISION fink.in fink.8.in fink.conf.5.in images 
install.sh setup.sh ".
   "shlibs.default.in pathsetup.sh.in postinstall.pl.in perlmod update t ".
-  "fink-virtual-pkgs.in fink.shlibs";
+  "fink-virtual-pkgs.in fink.shlibs lockwait.in";
 
 return $packagefiles;
 



-------------------------------------------------------
SF.Net email is sponsored by: Tell us your software development plans!
Take this survey and enter to win a one-year sub to SourceForge.net
Plus IDC's 2005 look-ahead and a copy of this survey
Click here to start!  http://www.idcswdc.com/cgi-bin/survey?id=105hix
_______________________________________________
Fink-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fink-commits

Reply via email to