Author: ranger
Date: Thu Jul 19 20:00:27 2007
New Revision: 904

URL: 
http://svn.finkproject.org/websvn/listing.php?sc=1&rev=904&repname=user%3a+ranger
Log:
fix logging so that a future cron job does not overwrite the running cron job

Modified:
    trunk/experimental/scripts/generate-distfiles-and-finkinfo-mirror.pl

Modified: trunk/experimental/scripts/generate-distfiles-and-finkinfo-mirror.pl
URL: 
http://svn.finkproject.org/websvn/diff.php?path=/trunk/experimental/scripts/generate-distfiles-and-finkinfo-mirror.pl&rev=904&repname=user%3a+ranger
==============================================================================
--- trunk/experimental/scripts/generate-distfiles-and-finkinfo-mirror.pl 
(original)
+++ trunk/experimental/scripts/generate-distfiles-and-finkinfo-mirror.pl Thu 
Jul 19 20:00:27 2007
@@ -35,10 +35,12 @@
 unshift(@INC, $WORKDIR);
 mkpath($WORKDIR . '/Fink');
 
-print "- $0 starting " . scalar(localtime(time)) . "\n";
 open (LOCKFILE, '>>' . $WORKDIR . '/mirror.lock') or die "could not open 
lockfile for append: $!";
 my $return = flock(LOCKFILE, LOCK_EX | LOCK_NB);
 die "another process is already running" if (not $return);
+
+open (LOG, '>/tmp/mirror.log');
+print LOG "- $0 starting " . scalar(localtime(time)) . "\n";
 
 use vars qw(
        $COUNT
@@ -85,7 +87,7 @@
 
 if (not grep(/^--s/, @ARGV))
 {
-       print "- updating cvs\n";
+       print LOG "- updating cvs\n";
        if (run_cvs_command('checkout', 'dists'))
        {
                system('rsync', '-avr', '--exclude=CVS', 
'--exclude=.cvsignore', '--delete-excluded', '--delete', '--delete-after', 
'dists/', 'dists.public/');
@@ -102,14 +104,14 @@
        }
 }
 
-print "- scanning info files\n";
+print LOG "- scanning info files\n";
 opendir(DIR, $CHECKOUTDIR . '/dists') or die "unable to read from 
$CHECKOUTDIR/dists: $!";
 for my $dir (readdir(DIR))
 {
        if ($dir =~ /^10/)
        {
                next if ($dir =~ /^10.2/);
-               print "searching $dir\n";
+               print LOG "searching $dir\n";
                finddepth( { wanted => \&find_fetch_infofile, follow => 1 }, 
$CHECKOUTDIR . '/dists/' . $dir);
        }
 }
@@ -117,7 +119,7 @@
 
 store($LAST_UPDATE_CACHE, $WORKDIR . '/update.cache');
 
-print "- $0 finished " . scalar(localtime(time)) . "\n";
+print LOG "- $0 finished " . scalar(localtime(time)) . "\n";
 
 sub find_fetch_infofile
 {
@@ -141,14 +143,14 @@
        $COUNT++;
        if ($DEBUG and $COUNT > 50)
        {
-               print "debug: already tried $COUNT files\n";
+               print LOG "debug: already tried $COUNT files\n";
                return;
        }
 
        my @stat = stat($File::Find::name);
        if (exists $LAST_UPDATE_CACHE->{$File::Find::name} and 
$LAST_UPDATE_CACHE->{$File::Find::name} == $stat[9])
        {
-               print $File::Find::name, " has not changed\n";
+               print LOG $File::Find::name, " has not changed\n";
                return;
        }
 
@@ -175,14 +177,14 @@
                $Fink::Config::libpath = $FINKROOT;
 
                my ($tree) = $File::Find::name =~ m#/dists/[^/]+/([^/]+)/#;
-               print "- fetching files for $shortname ($dist/$tree)\n";
+               print LOG "- fetching files for $shortname ($dist/$tree)\n";
                for my $package ( Fink::PkgVersion->pkgversions_from_info_file( 
$File::Find::name ) )
                {
                        next if ( $package->get_license() =~ /Restrictive$/ );
                        for my $suffix ($package->get_source_suffices)
                        {
                                my $tarball = $package->get_tarball($suffix);
-                               print "  - $tarball... ";
+                               print LOG "  - $tarball... ";
                                my $checksums = {};
                                $checksums->{'MD5'} = $package->param('Source' 
. $suffix . '-MD5');
                                my($checksum_type, $checksum) = 
Fink::Checksum->parse_checksum($package->get_checksum($suffix));
@@ -221,21 +223,21 @@
                                        my $check_file = $DOWNLOADDIR . '/' . 
lc($checksum_type) . '/' . lc($checksums->{$checksum_type}) . '/' . $tarball;
                                        if (not -f $check_file)
                                        {
-                                               print "$check_file does not 
exists, downloading\n";
+                                               print LOG "$check_file does not 
exists, downloading\n";
                                                $do_download = 1;
                                        }
                                        elsif ($VALIDATE_EXISTING_FILES)
                                        {
                                                if (not 
Fink::Checksum->validate($check_file, $checksums->{$checksum_type}, 
$checksum_type))
                                                {
-                                                       print "checksum on 
$check_file does not match, downloading\n";
+                                                       print LOG "checksum on 
$check_file does not match, downloading\n";
                                                        $do_download = 1;
                                                }
                                        }
                                }
                                if ($do_download)
                                {
-                                       print "downloading\n";
+                                       print LOG "downloading\n";
                                        my $master_checksum_type = 'MD5';
                                        if (not exists $checksums->{'MD5'})
                                        {
@@ -257,7 +259,7 @@
                                        if ($returnval != 0)
                                        {
                                                unlink($download_path . '/' . 
$tarball);
-                                               warn "unable to download $url 
to $download_path";
+                                               print LOG "unable to download 
$url to $download_path\n";
                                                $all_downloads_passed = 0;
                                                next;
                                        }
@@ -269,7 +271,7 @@
                                                {
                                                        if 
($file_checksums->{$checksum_type} ne $checksums->{$checksum_type})
                                                        {
-                                                               warn 
"downloaded file has a different checksum than expected 
($file_checksums->{$checksum_type} ne $checksums->{$checksum_type})";
+                                                               print LOG 
"downloaded file has a different checksum than expected 
($file_checksums->{$checksum_type} ne $checksums->{$checksum_type})\n";
                                                        }
                                                }
                                                else
@@ -289,7 +291,7 @@
                                }
                                else
                                {
-                                       print "exists\n";
+                                       print LOG "exists\n";
                                }
                        }
                }


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Fink-commits mailing list
Fink-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fink-commits

Reply via email to