Update of /cvsroot/fink/fink/perlmod/Fink
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9217
Modified Files:
Engine.pm ChangeLog
Log Message:
Implement cleanup_buildlocks
Index: Engine.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Engine.pm,v
retrieving revision 1.317
retrieving revision 1.318
diff -u -d -r1.317 -r1.318
--- Engine.pm 1 Sep 2005 01:42:14 -0000 1.317
+++ Engine.pm 2 Sep 2005 15:28:09 -0000 1.318
@@ -1217,8 +1217,6 @@
# current version of any package; etc.
# Delete all .deb and delete all src?
Not really needed, this can be
# achieved each with single line CLI
commands.
- # TODO - document --keep-src in the man page, and add a fink.conf entry
for defaults
- # TODO - document --dry-run option that prints out what actions would
be performed
my(%opts, %modes, $wanthelp);
@@ -1249,7 +1247,7 @@
--sources, --srcs
- Delete source files
--buildlocks, --bl
- - Delete buildlock packages (not implemented)
+ - Delete stale buildlock packages
Options:
-k, --keep-src - Move old source files to $basepath/src/old/ instead
@@ -1510,15 +1508,17 @@
=item cleanup_buildlocks
-*NOT YET IMPLEMENTED*
-
-Remove any installed buildlock packages. The following option is known:
+Check for all processes corresponding to each buildlock pid-file.
+Optionally remove those buildlocks whose processes do not
+exist. Returns a boolean indicating whether there any active
+buildlocks are still present after cleanup. The following option is
+known:
=over 4
=item dryrun
-If true, just list them.
+If true, don't actually remove the locks.
=back
@@ -1526,8 +1526,74 @@
sub cleanup_buildlocks {
my %opts = (dryrun => 0, @_);
-
- print "fink cleanup --bl is not implemented yet.\n\n";
+
+ # gather all .pid files
+
+ print "Reading buildlocks...\n";
+ my $pidfile_dir = "$basepath/var/run/fink";
+ my @pidfiles = ();
+ if (opendir my $dirhandle, $pidfile_dir) {
+ @pidfiles = grep { /^fink-buildlock-.+\.pid$/ } readdir
$dirhandle;
+ close $dirhandle;
+ } else {
+ print "Warning: could not read buildlock pid directory
$pidfile_dir: $!\n";
+ return 0;
+ }
+
+ # collect pid from each .pid file
+
+ my %pids; # pid of each buildlock pkg
+ foreach my $pidfile (@pidfiles) {
+ if ($pidfile =~ /^fink-buildlock-(.+)\.pid$/) {
+ my $fullname = $1;
+ if (open my $pidhandle, '<', "$pidfile_dir/$pidfile") {
+ my $pid = <$pidhandle>;
+ chomp $pid;
+ if ($pid =~ /^\d+$/) {
+ $pids{$fullname} = $pid;
+ } else {
+ print "Warning: skipping pidfile
$pidfile: could not parse it.\n";
+ }
+ close $pidhandle;
+ } else {
+ print "Warning: skipping pidfile $pidfile:
could not read it: $!\n";
+ }
+ } else {
+ # should never get here!
+ print "Warning: skipping pidfile $pidfile: could not
parse its name.\n";
+ }
+ }
+
+ if (!%pids) {
+ print "No buildlocks found\n";
+ return 0;
+ }
+
+ # check if each pid is still present
+
+ my $locks_left = 0;
+ foreach my $pkg (sort keys %pids) {
+ print "Found buildlock for $pkg...\n";
+ if (kill 0, $pids{$pkg}) {
+ # successfully signaled, so pid still exists
+ &execute("ps -p $pids{$pkg}");
+ print "Not removing lock\n" if not $opts{dryrun};
+ $locks_left++;
+ } else {
+ my $msg = "Process $pids{$pkg} does not exist.";
+ if ($opts{dryrun}) {
+ print $msg, "\n";
+ } else {
+ if (&prompt_boolean("$msg Remove the lock?",
default => 1)) {
+
Fink::PkgVersion::phase_deactivate("fink-buildlock-$pkg");
+ } else {
+ $locks_left++;
+ }
+ }
+ }
+ }
+
+ return $locks_left;
}
=back
Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.1122
retrieving revision 1.1123
diff -u -d -r1.1122 -r1.1123
--- ChangeLog 1 Sep 2005 15:48:15 -0000 1.1122
+++ ChangeLog 2 Sep 2005 15:28:09 -0000 1.1123
@@ -1,3 +1,7 @@
+2005-09-02 Daniel Macks <[EMAIL PROTECTED]>
+
+ * Engine.pm: Implement cleanup_buildlocks
+
2005-09-01 Daniel Macks <[EMAIL PROTECTED]>
* Validation: dpkg validation now performed on an unpacked archive
-------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/fink-commits