All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 1aaa383c authored by Leigh B. Stoller's avatar Leigh B. Stoller

The CVS repo will now have two subdirs, one called "setup" which is

where the current stuff goes (datastore, nsfile, etc.). The other
subdir is called "records" and will be populated with stuff that we
currently put into the archive (the contents of the experiment
directory).

There is a record for each run, currently named XXX,YY where XXX is
the instance ID and YY is the run number. I plan to add an XML file to
map these to the symbolic names, but these are not required to be
unique, which is why the directories are not named with them.
parent b42849ce
......@@ -366,7 +366,7 @@ print COOKIE "GUID: $guid/$vers\n";
print COOKIE "TIME: " . time() . "\n";
close(COOKIE);
if ($repotag) {
if (defined($repotag)) {
#
# We need to get a checkout from the repo for both the nsfile and
# the datastore directory.
......@@ -412,8 +412,9 @@ if ($repotag) {
$tokens[scalar(@tokens)-2] = 0;
my $branchrev = join(".", @tokens);
open(RLOG, "$RLOG -h $cvsdir/$guid/.template,v |")
or fatal(-1, "Could not run rlog on $cvsdir/$guid/.template,v!");
open(RLOG, "$RLOG -h $cvsdir/$guid/setup/.template,v |")
or fatal(-1,
"Could not run rlog on $cvsdir/$guid/setup/.template,v!");
my $intags = 0;
while (<RLOG>) {
if ($intags) {
......@@ -445,26 +446,27 @@ if ($repotag) {
$repobase = $branchtag;
# Checkout ...
System("cd $tmpdir; $CVSBIN -d $cvsdir checkout -r $repotag $guid")
System("cd $tmpdir; $CVSBIN -d $cvsdir checkout ".
" -r $repotag $guid/setup")
== 0 or fatal(-1, "Could not checkout '$repotag' from $cvsdir");
}
else {
# Checkout along trunk, no -r option cause then commit fails
System("cd $tmpdir; $CVSBIN -d $cvsdir checkout -r HEAD $guid")
System("cd $tmpdir; $CVSBIN -d $cvsdir checkout -r HEAD $guid/setup")
== 0 or fatal(-1, "Could not checkout trunk from $cvsdir");
#
# Clear the default branch so that checkout gives us the trunk.
#
System("cd $tmpdir; $CVSBIN -d $cvsdir admin -b")
System("cd $tmpdir/$guid; $CVSBIN -d $cvsdir admin -b")
== 0 or fatal(-1, "Could not clear default branch in $cvsdir");
# And clear the sticky tag so later commit works.
System("cd $tmpdir/$guid; $CVSBIN -d $cvsdir update -A")
System("cd $tmpdir/$guid/setup; $CVSBIN -d $cvsdir update -A")
== 0 or fatal(-1, "Could not update to head trunk from $cvsdir");
}
$inputfile = "$tmpdir/$guid/tbdata/nsfile.ns";
$inputfile = "$tmpdir/$guid/setup/tbdata/nsfile.ns";
fatal(-1, "NS file missing from repo checkout!")
if (!-e $inputfile);
}
......@@ -527,8 +529,8 @@ if ($modify) {
libArchive::TBCommitExperimentArchive($pid, $eid, "template_modify")
>= 0 or fatal(-1, "Failed to commit experiment archive!");
if ($repotag) {
$template->ImportDataStore("$tmpdir/$guid/datastore") == 0
if (defined($repotag)) {
$template->ImportDataStore("$tmpdir/$guid/setup/datastore") == 0
or fatal(-1, "Failed to import data store");
}
elsif (defined($frompath)) {
......@@ -566,7 +568,7 @@ if (!$modify) {
System("cd $template_dir; ".
"$CVSBIN -d $cvsdir import ".
" -m 'Initialize new cvs repo for template $guid' ".
" $guid T${guid}-1_import_branch T${guid}-1_import")
" $guid/setup T${guid}-1_import_branch T${guid}-1_import")
== 0 or fatal(-1, "Could not import new template into $cvsdir");
#
......@@ -580,6 +582,14 @@ if (!$modify) {
System("cd $tmpdir; $CVSBIN -d $cvsdir checkout $guid")
== 0 or fatal(-1, "Could not checkout from $cvsdir");
# Create the records directory.
System("cd $tmpdir/$guid; mkdir records; touch records/.ignore") == 0 or
fatal(-1, "Could not mkdir records directory in $tmpdir/$guid");
System("cd $tmpdir/$guid; $CVSBIN -d $cvsdir add records; ".
" $CVSBIN -d $cvsdir add records/.ignore")
== 0 or fatal(-1, "Could not cvs add $tmpdir/$guid/records!");
# Commit ...
System("cd $tmpdir; $CVSBIN -d $cvsdir commit -f -R ".
" -m 'Commit initial import back to head'")
......@@ -599,17 +609,17 @@ elsif ($frompath) {
#
# Not going to deal with this now.
}
elsif ($repotag) {
elsif (defined($repotag)) {
#
# Need to commit the new version of .template on the new branch so
# that when the user does a checkout of the branch, it says what
# template it is (and what to template to modify on the next branch).
#
System("cp -p $template_dir/.template $tmpdir/$guid") == 0
System("cp -p $template_dir/.template $tmpdir/$guid/setup") == 0
or fatal(-1, "Could not cp $template_dir/.template to $tmpdir/$guid");
# Check the file in.
System("cd $tmpdir/$guid; ".
System("cd $tmpdir/$guid/setup; ".
"$CVSBIN commit " . (defined($repobase) ? "-r $repobase " : " ") .
" -m 'Update guid after modify' .template")
== 0 or fatal(-1, "Could not commit final version in $cvsdir");
......@@ -619,7 +629,7 @@ elsif ($repotag) {
#
System("$CVSBIN -d $cvsdir rtag -n " .
(defined($repobase) ? "-r $repobase " : " ") .
" T${guid}-${vers} $guid")
" T${guid}-${vers} $guid/setup")
== 0 or fatal(-1, "Could not rtag final version in $cvsdir");
#
......@@ -636,7 +646,7 @@ else {
# Create a branch off the parent template.
#
System("$CVSBIN -d $cvsdir rtag -n -r T${parent_guid}-${parent_vers} ".
" -b T${parent_guid}-${vers}_branch $guid ")
" -b T${parent_guid}-${vers}_branch $guid/setup ")
== 0 or fatal(-1, "Could not rtag parent version in $cvsdir");
#
......@@ -645,24 +655,24 @@ else {
#
System("cd $template_dir; ".
"$CVSBIN -d $cvsdir import -b 1.1.${vers} ".
" -m 'Modify cvs repo for template $guid/$vers' ".
" $guid T${guid}-${vers}_import_branch T${guid}-${vers}_import")
" -m 'Modify cvs repo for template $guid/$vers' $guid/setup ".
" T${guid}-${vers}_import_branch T${guid}-${vers}_import")
== 0 or fatal(-1, "Could not import modified template into $cvsdir");
# Checkout and merge
System("cd $tmpdir; $CVSBIN -d $cvsdir checkout ".
" -r T${parent_guid}-${vers}_branch ".
" -j T${parent_guid}-${vers}_branch ".
" -j T${guid}-${vers}_import_branch $guid")
" -j T${guid}-${vers}_import_branch $guid/setup")
== 0 or fatal(-1, "Could not checkout/merge from $cvsdir");
# Need to clear the -b (default branch) or else the merge
# commit fails for some reason that makes no sense to me.
System("cd $tmpdir; $CVSBIN -d $cvsdir admin -b $guid")
System("cd $tmpdir/setup; $CVSBIN -d $cvsdir admin -b $guid")
== 0 or fatal(-1, "Could not clear default branch (-b) on $cvsdir");
# Commit ...
System("cd $tmpdir; $CVSBIN -d $cvsdir commit -f -R ".
System("cd $tmpdir/setup; $CVSBIN -d $cvsdir commit -f -R ".
" -r T${parent_guid}-${vers}_branch ".
" -m 'Commit merge with head'")
== 0 or fatal(-1, "Could not commit on $cvsdir");
......@@ -677,9 +687,11 @@ else {
# Now tag the CVS repo with the current guid/vers so we can find it easily.
#
System("$CVSBIN -d $cvsdir rtag -n ".
" -r T${parent_guid}-${vers}_branch T${guid}-${vers} $guid")
" -r T${parent_guid}-${vers}_branch T${guid}-${vers} $guid/setup")
== 0 or fatal(-1, "Could not rtag final version in $cvsdir");
}
System("/bin/rm -rf $tmpdir")
if (-e $tmpdir);
# Do a savepoint prior to the commit below. As noted above, this is
# not done in batchexp.
......@@ -915,6 +927,8 @@ sub cleanup()
# Delete repo but only if this is the initial template creation.
system("/bin/rm -rf $cvsdir")
if (!$modify && defined($cvsdir) && -e $cvsdir);
System("/bin/rm -rf $tmpdir")
if (defined($tmpdir) && -e $tmpdir);
$template->Delete()
if (defined($template));
}
......
......@@ -15,6 +15,8 @@ delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
# CVS sets this.
my $CVSROOT = $ENV{'CVSROOT'};
#print "logtag: @ARGV\n";
#
# Record any tags made to the .template file.
#
......@@ -34,7 +36,7 @@ while (@ARGV) {
if ($op eq "add") {
# Generate a marker to tell the post tag function
my $module = basename($repo);
my $module = basename(dirname($repo));
my $id = getpgrp();
my $docommit = "/tmp/#cvs.docommit.${id}";
open(COM, ">$docommit")
......
......@@ -70,9 +70,9 @@ else {
# See if the new tag is a branch tag. To do that, run rlog over the RCS
# file and look at the revision number. We count the dots. There is also
# a special case of x.y.0.z to look for.
my $revision = `$RLOG -h $CVSROOT/$module/.template,v |grep '$tag:'`;
my $revision = `$RLOG -h $CVSROOT/$module/setup/.template,v |grep '$tag:'`;
if ($?) {
die("rlog on $CVSROOT/$module/.template,v failed!\n");
die("rlog on $CVSROOT/$module/setup/.template,v failed!\n");
}
if ($revision =~ /^\s*$tag:\s*([\d.]+)$/) {
$revision = $1;
......@@ -116,17 +116,17 @@ if ((scalar(@tokens) & 1) || ($revision =~ /\d*\.0\.\d*$/)) {
$tokens[scalar(@tokens)-1] = 1;
my $branch = join(".", @tokens[0 .. scalar(@tokens)-2]);
system("$CO -r${baserev} $CVSROOT/$module/.template,v") == 0
system("$CO -r${baserev} $CVSROOT/$module/setup/.template,v") == 0
or die("Could not co -r${baserev} $CVSROOT/$module/.template,v!\n");
system("$RCS -b${branch} $CVSROOT/$module/.template,v") == 0
system("$RCS -b${branch} $CVSROOT/$module/setup/.template,v") == 0
or die("Could not rcs -b${branch} $CVSROOT/$module/.template,v");
system("$CI -f -r${branch} -m'Force checkin on new branch' ".
" $CVSROOT/$module/.template,v .template") == 0
" $CVSROOT/$module/setup/.template,v .template") == 0
or die("Could not ci -r${branch} $CVSROOT/$module/.template,v!\n");
system("$RCS -b $CVSROOT/$module/.template,v") == 0
system("$RCS -b $CVSROOT/$module/setup/.template,v") == 0
or die("Could not rcs -b $CVSROOT/$module/.template,v");
print "$tag/$revision is a branch revision.\n";
......@@ -138,7 +138,7 @@ if ((scalar(@tokens) & 1) || ($revision =~ /\d*\.0\.\d*$/)) {
# Checkout the .template file at the base revision, and get the guid from it.
# This is the template we are going to modify.
#
open(CO, "$CO -q -p${baserev} $CVSROOT/$module/.template,v |")
open(CO, "$CO -q -p${baserev} $CVSROOT/$module/setup/.template,v |")
or die("Could not run '$CO -p${baserev} $CVSROOT/$module/.template,v\n");
while (<CO>) {
if ($_ =~ /^GUID:\s*(\d+\/\d+)$/) {
......@@ -151,7 +151,7 @@ if (!defined($guid)) {
}
print "Running: template_commit -r $tag $guid\n";
if (0) {
if (1) {
exit(0);
}
......
......@@ -98,6 +98,7 @@ my $checkquota = "$TB/sbin/checkquota";
my $archcontrol = "$TB/bin/archive_control";
my $eventcontrol= "$TB/bin/eventsys_control";
my $tevc = "$TB/bin/tevc";
my $CVSBIN = "/usr/bin/cvs";
# Protos
sub ParseArgs();
......@@ -120,6 +121,9 @@ use Experiment;
use Archive;
use event;
# In libdb
my $projroot = PROJROOT();
#
# Turn off line buffering on output
#
......@@ -507,6 +511,31 @@ if (defined($instance->runidx())) {
system("$archcontrol -d -t stoprun_${this_runid} ".
"-c 'Stopping Run $this_runid' commit $pid $eid");
#
# Do the CVS stuff.
#
my $runidx = $oldrun->idx();
my $exptidx = $instance->exptidx();
my $instance_dir = $instance->path();
my $cvsdir = "$projroot/$pid/templates/$guid/cvsrepo";
my $tmpdir = "$projroot/$pid/templates/$guid/cvstmp.$$";
my $tag = "R${exptidx}-${runidx}_import";
my $instance_tag = "I${exptidx}";
# This imports the experiment directory into the records subdir.
System("cd $instance_dir; ".
"$CVSBIN -d $cvsdir import -I 'datastore/*' ".
" -m 'Import record for run $this_runid' ".
" $guid/records/$exptidx,$runidx ${tag}_branch $tag")
== 0 or fatal(-1, "Could not import new record into $cvsdir");
# Now tag it with the same tag that was applied for the instance.
# Apply to the branch tag directly instead of symbolically since that
# does not work properly for some reason.
System("$CVSBIN -d $cvsdir rtag -n -r 1.1.1 ".
" $instance_tag $guid/records/$exptidx,$runidx")
== 0 or fatal(-1, "Could not rtag new record in $cvsdir");
# This has to be done after the archive commit, so we can find the tag.
$instance->FinalizeCurrentRun() == 0
or fatal(-1, "Could not finalize run for $instance!");
......
......@@ -67,7 +67,6 @@ my %parameters;
my $pid;
my $run;
my $logname;
my $template_tag;
my @ExptStates = ();
# For the END block below.
my $cleaning = 0;
......@@ -81,6 +80,7 @@ my $swapexp = "$TB/bin/swapexp";
my $endexp = "$TB/bin/endexp";
my $dbcontrol = "$TB/sbin/opsdb_control";
my $archcontrol = "$TB/bin/archive_control";
my $CVSBIN = "/usr/bin/cvs";
# Protos
sub ParseArgs();
......@@ -101,6 +101,9 @@ use Experiment;
use event;
use libaudit;
# In libdb
my $projroot = PROJROOT();
# Be careful not to exit on transient error
$libdb::DBQUERY_MAXTRIES = 0;
......@@ -391,6 +394,20 @@ if ($?) {
fatal(-1, "Could not commit archive!");
}
#
# Do the CVS stuff.
#
my $exptidx = $instance->exptidx();
my $cvsdir = "$projroot/$pid/templates/$guid/cvsrepo";
my $instance_tag = "I${exptidx}";
my $template_tag = "T${guid}-$version";
# Tag the template with an instance tag. This tag is used to associate
# records with this instance with the actual template.
System("$CVSBIN -d $cvsdir rtag -n -r ".
" $template_tag $instance_tag $guid/setup") == 0
or fatal(-1, "Could not rtag with instance tag in $cvsdir");
$instance->StartRun(Template::STARTRUN_FLAGS_FIRSTRUN()) == 0
or fatal(-1, "Could not update start time in instance record!");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment