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

Modified Files:
      Tag: selfupdate_classes
        ChangeLog Config.pm FinkVersion.pm.in SelfUpdate.pm 
Log Message:
Overhaul use of VERSION file


Index: FinkVersion.pm.in
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/FinkVersion.pm.in,v
retrieving revision 1.36
retrieving revision 1.36.2.1
diff -u -d -r1.36 -r1.36.2.1
--- FinkVersion.pm.in   4 Mar 2007 22:03:13 -0000       1.36
+++ FinkVersion.pm.in   20 Mar 2007 00:25:07 -0000      1.36.2.1
@@ -33,6 +33,7 @@
 
 use Fink::Config qw($basepath);
 use Fink::Command qw(cat);
+require Fink::SelfUpdate;
 
 
 =head1 NAME
@@ -85,7 +86,10 @@
 
 sub distribution_version {
        my $dv;
-       if (-f "$basepath/fink/dists/VERSION") {
+       my ($method, $timestamp) = &Fink::SelfUpdate::last_done;
+       if (defined $method) {
+               $dv = "selfupdate-$method at " . localtime($timestamp);
+       } elsif (-f "$basepath/fink/dists/VERSION") {
                chomp($dv = cat "$basepath/fink/dists/VERSION");
        } elsif (-f "$basepath/fink/VERSION") {
                chomp($dv = cat "$basepath/fink/VERSION");

Index: Config.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Config.pm,v
retrieving revision 1.87
retrieving revision 1.87.4.1
diff -u -d -r1.87 -r1.87.4.1
--- Config.pm   12 Jan 2007 02:18:22 -0000      1.87
+++ Config.pm   20 Mar 2007 00:25:07 -0000      1.87.4.1
@@ -314,7 +314,8 @@
                        . Fink::FinkVersion::fink_version() . "\n";
                print "Distribution version: "
                        . Fink::FinkVersion::distribution_version()
-                       . ' ' . $config->param('Architecture')
+                       . ', ' . $config->param('Distribution')
+                       . ', ' . $config->param('Architecture')
                        . ($config->mixed_arch() ? ' (forged)' : '')
                        . "\n";
                print <<"EOF";

Index: SelfUpdate.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/SelfUpdate.pm,v
retrieving revision 1.117.2.9
retrieving revision 1.117.2.10
diff -u -d -r1.117.2.9 -r1.117.2.10
--- SelfUpdate.pm       9 Mar 2007 07:54:10 -0000       1.117.2.9
+++ SelfUpdate.pm       20 Mar 2007 00:25:07 -0000      1.117.2.10
@@ -25,11 +25,13 @@
 
 use Fink::Services qw(&execute &find_subpackages);
 use Fink::Bootstrap qw(&additional_packages);
-use Fink::CLI qw(&print_breaking &prompt_boolean &prompt_selection);
-use Fink::Config qw($config $basepath);
+use Fink::CLI qw(&print_breaking &prompt_boolean &prompt_selection 
print_breaking_stderr);
+use Fink::Config qw($basepath $config $distribution);
 use Fink::Engine;  # &aptget_update &cmd_install, but they aren't EXPORT_OK
 use Fink::Package;
 
+use POSIX qw(strftime);
+
 use strict;
 use warnings;
 
@@ -202,6 +204,7 @@
        # Let's do this thang!
        $subclass_use->do_direct();
        $subclass_use->stamp_set();
+       &update_version_file($method);
        &do_finish();
 }
 
@@ -305,6 +308,75 @@
        print "\n";
 }
 
+=item update_version_file
+
+       &update_version_file($method);
+
+Marks the %p/fink/$distribution/VERSION file with information about
+the just-done selfupdate using method $method. Returns nothing useful.
+
+=cut
+
+sub update_version_file {
+       my $method = shift;
+
+       my $filename = "$basepath/fink/$distribution/VERSION";
+       my @lines = ();
+
+       # read old file
+       if (open my $FH, '<', $filename) {
+               @lines = <$FH>;
+               close $FH;
+       }
+
+       # remove ".cvs" from server file
+       map s/^(\d|\.)+\.cvs$/$1/, @lines;
+
+       # remove old selfupdate info
+       @lines = grep { $_ !~ /^\s*SelfUpdate\s*:/i } @lines;
+
+       # add new selfupdate info
+       push @lines, "SelfUpdate: $method\@".time()."\n";
+
+       # save new file contents atomically
+       if (open my $FH, '>', "$filename.tmp") {
+               print $FH @lines;
+               close $FH;
+       } else {
+               print_breaking_stderr "WARNING: Not saving timestamp of 
selfupdate because could not write $filename.tmp: $!\n";
+       }
+}
+
+=item last_done
+
+       my ($last_method,$last_time) = Fink::SelfUpdate::last_done();
+       if (defined $last_method) {
+               $last_time = time() - $last_time;
+               print "Last selfupdate was by $last_method, $age seconds ago\n";
+       } else {
+               print "Could not determine last selfupdate information\n";
+       }
+
+Returns the method and time of the last selfupdate, or undefs if the
+info could not be determined.
+
+=cut
+
+sub last_done {
+       my $filename = "$basepath/fink/$distribution/VERSION";
+
+       if (open my $FH, '<', $filename) {
+               while (<$FH>) {
+                       if (/^\s*SelfUpdate\s*:\s*(\.+?)\@(\d+)/i) {
+                               return ($1, $2);
+                       }
+               }
+               close $FH;
+       }
+
+       return (undef, undef);
+}
+
 =back
 
 =cut

Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.1439.2.10
retrieving revision 1.1439.2.11
diff -u -d -r1.1439.2.10 -r1.1439.2.11
--- ChangeLog   9 Mar 2007 07:54:09 -0000       1.1439.2.10
+++ ChangeLog   20 Mar 2007 00:25:07 -0000      1.1439.2.11
@@ -1,3 +1,12 @@
+2007-03-19  Daniel Macks  <[EMAIL PROTECTED]>
+
+       * Config.pm: Add fink.conf:Distribution to 'fink -V' output.
+       * FinkVersion.pm.in: Try asking SelfUpdate about package-distro
+       versioning, which would add selfupdate method and timestamp data
+       to 'fink -V' output.
+       * SelfUpdate.pm, SelfUpdate/rsync.pm: Unified and overhauled
+       handling of %p/fink/$dist/VERSION file.
+
 2007-03-09  Daniel Macks  <[EMAIL PROTECTED]>
 
        * SelfUpdate.pm: Auto-detect all available subclasses


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Fink-commits mailing list
Fink-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fink-commits

Reply via email to