haver-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Haver-commits] r38 - dev-tools


From: dylan
Subject: [Haver-commits] r38 - dev-tools
Date: Wed, 14 Apr 2004 13:08:47 -0400 (EDT)

Author: dylan
Date: 2004-04-14 13:08:47 -0400 (Wed, 14 Apr 2004)
New Revision: 38

Added:
   dev-tools/haver-backup.pl
   dev-tools/haver-snap.pl
Removed:
   dev-tools/haversnap.pl
Log:
fun.


Added: dev-tools/haver-backup.pl
===================================================================
--- dev-tools/haver-backup.pl   2004-04-14 05:40:16 UTC (rev 37)
+++ dev-tools/haver-backup.pl   2004-04-14 17:08:47 UTC (rev 38)
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Fatal qw(open close);
+use Cwd;
+
+my $repos =  '/var/svn/haver/';
+my $backup = '/var/svn/haver.bak/';
+
+
+open my $hot, "/usr/lib/subversion/hot-backup.py $repos $backup|";
+while (<$hot>) {
+       chomp;
+       if (/Backing up repository to '(.+?)'\.\.\.$/) {
+               my $cur = $1;
+               symlink($cur, "$backup/temp");
+               rename("$backup/temp", "$backup/haver-current");
+               my $cwd = cwd();
+               chdir($backup);
+               system('tar', '-jcvhf', 'haver-current.tar.bz2', 
"haver-current/");
+               chdir($cwd);
+       }
+       print $_, "\n";
+}
+close $hot;

Copied: dev-tools/haver-snap.pl (from rev 29, dev-tools/haversnap.pl)

Deleted: dev-tools/haversnap.pl
===================================================================
--- dev-tools/haversnap.pl      2004-04-14 05:40:16 UTC (rev 37)
+++ dev-tools/haversnap.pl      2004-04-14 17:08:47 UTC (rev 38)
@@ -1,126 +0,0 @@
-#!/usr/bin/perl
-
-#Haver SVN snapshot script
-#By Muffin, with modifications by dylan.
-
-#Yes, it's hacky.  So woot.
-
-
-use XML::Simple;
-use Data::Dumper;
-use Text::ParseWords qw( shellwords );
-use POSIX            qw( strftime   );
-use File::Path       qw( rmtree     );
-
-sub debug (@);
-
-my %config = (
-       backlog => 10,
-       repo_url => "file:///var/svn/haver/",
-);
-
-
-#Grab date info and parse it into a useful format
-my $date = strftime('%Y%2d%2m', localtime);
-
-debug "Today is: $date\n";
-
-unless (-d 'haver') {
-       run("svn checkout $config{repo_url}")
-               or die "Can't checkout copy of repo!";
-}
-
-#Get the old revision number.
-my $oldrevision = get_revision("haver/.svn/entries");
-my $tempdir = "haver-old-$oldrevision-temp"; 
-
-
-
-#so some revision shuffling
-debug "Backing up old repository...";
-run("cp -a haver $tempdir");
-debug "Done.\n";
-debug "Updating repository from SVN server...";
-run("svn update -q haver");
-
-#Set the filename and check revision numbers
-debug "Done.\n";
-my $revision = get_revision("haver/.svn/entries");
-
-my $filename = "haver-$date-$revision.tar.gz";
-debug "Revision comparison: Old ($oldrevision) vs New ($revision)\n";
-
-if ($revision == $oldrevision) {
-  debug "The revisions are the same. ";
-  if (-e $filename) {
-         debug "Reverting... ";
-         collapse("Done."); 
-  } else {
-         debug "But it isn't tarred... Tarring. ";
-  }
-} elsif ($revision < $oldrevision) {
-  debug "Yikes, the downloaded revision is older.  Reverting... ";
-  collapse("Done.");
-} else {
-       debug "This is a new revision.  Tarring... ";
-}
-
-# tar up the archive
-run("tar -zcf $filename haver");
-# fail if the file doesn't exist.
-collapse("The file was tarred incorrectly. Hmm.") unless -e $filename;
-
-
-debug "Done.\n";
-
-
-#Delete the old files and repository.
-debug "Done.\n";
-debug "Removing old repository and files...";
-rmtree($tempdir);
-
-debug "Done.\n";
-
-debug "Removing old snapshots...\n";
-my @files = glob("haver-*.tar.gz");
address@hidden = sort {
-       my $na = $a =~ /-(\d+)\.tar\.gz/;
-       my $nb = $b =~ /-(\d+)\.tar\.gz/;
-       $na <=> $nb;
-} @files;
-
-while (@files > $config{backlog}) {
-       my $file = shift @files;
-       debug "Removing $file\n";
-       unlink($file);
-}
-       
-
-# subs
-sub collapse {
-       my $reason = shift;
-       rmtree('haver');
-       rename($tempdir, 'haver');
-#  unlink($filename) if -e $filename;  
-       debug "$reason\n";
-       exit 0;
-}
-
-
-
-sub get_revision {
-       my $file = shift;
-       my $entries = XMLin($file);
-       
-       return $entries->{entry}->{''}->{revision};
-       
-}
-
-sub debug (@) {
-       print STDERR @_;
-}
-
-sub run {
-       my $cmd = shift;
-       system(shellwords($cmd)) == 0;
-}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]