[Bio] / FigCommon / write_code_snapshot.pl Repository:
ViewVC logotype

View of /FigCommon/write_code_snapshot.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Fri Jan 16 17:51:37 2009 UTC (10 years, 10 months ago) by olson
Branch: MAIN
CVS Tags: mgrast_dev_08112011, rast_rel_2009_05_18, mgrast_dev_08022011, rast_rel_2014_0912, mgrast_dev_05262011, mgrast_dev_04082011, rast_rel_2010_0928, mgrast_version_3_2, mgrast_dev_12152011, help, mgrast_dev_06072011, rast_rel_2009_0925, rast_rel_2010_0526, rast_rel_2014_0729, mgrast_dev_02212011, rast_rel_2010_1206, mgrast_release_3_0, mgrast_dev_03252011, rast_rel_2010_0118, rast_rel_2009_02_05, rast_rel_2011_0119, mgrast_release_3_0_4, mgrast_release_3_0_2, mgrast_release_3_0_3, mgrast_release_3_0_1, mgrast_dev_03312011, mgrast_release_3_1_2, mgrast_release_3_1_1, mgrast_release_3_1_0, mgrast_dev_04132011, mgrast_dev_04012011, rast_rel_2009_07_09, rast_rel_2010_0827, myrast_33, rast_rel_2011_0928, mgrast_dev_04052011, mgrast_dev_02222011, rast_rel_2009_03_26, mgrast_dev_10262011, HEAD
Scripts for writing CVS snapshots to FTP directory.

use strict;
use Date::Parse;
use File::Basename;
use Cwd 'abs_path';

#
# The canonical source of this script lives in the FigCommon CVS module.
#
# Do a cvs export for the given date and write to a tarfile based on the name given
# on the commandline.
#
# The date can be given as "today" in which the snapshot is taken as of 12:01am today.
#
# e.g. write_code_snapshot 1/1/2009 snapshot_%s
#

@ARGV == 2 or die "Usage: $0 date snapshot-file\n";

my $date = shift;
my $file_fmt = shift;
my $co_time;
my $now;

my $base = basename($file_fmt);
my $dir = abs_path(dirname($file_fmt));

if ($date =~ /today/i)
{
    $now = time;
}
else
{
    $now = str2time($date);
    $now or die "Cannot parse date $date\n";
}

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($now);
$mon++;
$year += 1900;
$date = sprintf("%4d-%02d-%02d", $year, $mon, $mday);
$co_time = "$mon/$mday/$year 00:00:01";

my $file = sprintf($base, $date);

my $tmp = "/tmp/snaptmp.$$";
mkdir $tmp or die "mkdir $tmp failed: $!";
my $workdir = "$tmp/$file";
mkdir $workdir or die "mkdir $workdir failed: $!";

chdir $workdir;

my $rc = system("cvs export -D '$co_time' code_export 1>&2");
if ($rc != 0)
{
    &cleanup;
    system("cat", "$tmp/cvs.out");
    die "CVS export failed with rc=$rc";
}

chdir $tmp;
my $tarfile = "$dir/$file.tgz";
print "$tarfile\n";
$rc = system("tar", "-c", "-z", "-f", "$dir/$file.tgz", $file);
if ($rc != 0)
{
    &cleanup;
    die "Tarfile creation failed with rc=$rc";
}

&cleanup;

sub cleanup
{
    system("rm", "-rf", $tmp);
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3