aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rwxr-xr-xsrc/util/git-add-thorn.pl59
-rwxr-xr-xsrc/util/git-commit-everything.pl58
-rwxr-xr-xsrc/util/git-gc-repo.pl65
-rwxr-xr-xsrc/util/git-init-master-repo.pl71
-rwxr-xr-xsrc/util/git-init-repo.pl71
-rwxr-xr-xsrc/util/git-lock.pl3
-rwxr-xr-xsrc/util/git-push-everything.pl74
-rwxr-xr-xsrc/util/git-rm-thorn.pl40
-rwxr-xr-xsrc/util/makeblob.pl2
9 files changed, 441 insertions, 2 deletions
diff --git a/src/util/git-add-thorn.pl b/src/util/git-add-thorn.pl
new file mode 100755
index 0000000..9c83a33
--- /dev/null
+++ b/src/util/git-add-thorn.pl
@@ -0,0 +1,59 @@
+#! /usr/bin/perl -w
+
+# Add a thorn to the repository
+
+# 2010-01-29 Erik Schnetter <schnetter@cct.lsu.edu>
+
+use strict;
+use File::Path;
+
+
+
+$#ARGV >= 3 or die;
+my ($git_cmd, $git_repo, $git_root, $thorn, @files) = @ARGV;
+
+my $scratch = $ENV{'SCRATCH_BUILD'};
+defined $scratch or die;
+
+my $silent = $ENV{'SILENT'};
+$silent = 'yes' if ! defined $silent;
+$silent = $silent !~ /^no$/i;
+my $silencer = $silent ? '> /dev/null 2>&1' : '';
+
+
+
+# Ensure that the repository exists
+die unless -e "$git_repo/.git";
+$ENV{'GIT_DIR'} = "$git_repo/.git";
+
+
+
+# This does not work, because arrangements or thorns may be symbolic
+# links, and git refuses to follow them. Instad, we copy the whole
+# thorn (using hard links), and then add the copy.
+
+# system "cd $git_root && $git_cmd add @files" or die;
+
+my $srcdir = $git_root;
+my $dstdir = "$scratch/tmp-$thorn";
+
+rmtree $dstdir; # ignore errors
+
+for my $file (@files) {
+ my $dir = $file;
+ if ($dir =~ m+/+) {
+ $dir =~ s+/[^/]*$++;
+ } else {
+ $dir = '.';
+ }
+ mkpath "$dstdir/$dir"; # ignore errors
+ link "$srcdir/$file", "$dstdir/$file" or die;
+}
+
+print "Executing: cd $dstdir && $git_cmd add @files\n" unless $silent;
+system "cd $dstdir && $git_cmd add @files $silencer";
+if ($?) {
+ die "Could not add thorn $thorn to git repository";
+}
+
+rmtree $dstdir or die;
diff --git a/src/util/git-commit-everything.pl b/src/util/git-commit-everything.pl
new file mode 100755
index 0000000..d972218
--- /dev/null
+++ b/src/util/git-commit-everything.pl
@@ -0,0 +1,58 @@
+#! /usr/bin/perl -w
+
+# Commit everything to the repository
+
+# 2010-01-29 Erik Schnetter <schnetter@cct.lsu.edu>
+
+use strict;
+
+
+
+$#ARGV == 4 or die;
+my ($git_cmd, $git_repo, $git_root, $build_id, $config_id) = @ARGV;
+
+# Path where the git-*.pl commands are installed
+my $bindir = $ENV{'SCRATCH_BUILD'} . '/formaline-bin';
+
+my $silent = $ENV{'SILENT'};
+$silent = 'yes' if ! defined $silent;
+$silent = $silent !~ /^no$/i;
+my $silencer = $silent ? '> /dev/null 2>&1' : '';
+
+
+
+# Ensure that the repository exists
+die unless -e "$git_repo/.git";
+$ENV{'GIT_DIR'} = "$git_repo/.git";
+
+
+
+print "Formaline: Committing source tree to git repository...\n";
+
+# Try to use the previous commit as parent, if possible
+print "Executing: $git_cmd commit -m $build_id\n" unless $silent;
+system "$git_cmd commit -m $build_id $silencer";
+# Ignore errors
+#if ($?) {
+# die "Could not commit";
+#}
+
+print "Executing: $git_cmd tag $build_id\n" unless $silent;
+system "$git_cmd tag $build_id $silencer";
+if ($?) {
+ die "Could not tag";
+}
+print "Formaline: Created git tag $build_id\n";
+
+print "Executing: $git_cmd branch -f $config_id\n" unless $silent;
+system "$git_cmd branch -f $config_id $silencer";
+if ($?) {
+ die "Could not update branch";
+}
+print "Formaline: Updated git branch $config_id\n";
+
+print "Executing: $bindir/git-gc-repo.pl '$git_cmd' $git_repo\n" unless $silent;
+system "$bindir/git-gc-repo.pl '$git_cmd' $git_repo $silencer";
+if ($?) {
+ die "Could not collect garbage";
+}
diff --git a/src/util/git-gc-repo.pl b/src/util/git-gc-repo.pl
new file mode 100755
index 0000000..21bb03f
--- /dev/null
+++ b/src/util/git-gc-repo.pl
@@ -0,0 +1,65 @@
+#! /usr/bin/perl -w
+
+# Collect garbage in the repository if it grown in size by more than a
+# factor of 10.
+
+# 2010-01-29 Erik Schnetter <schnetter@cct.lsu.edu>
+
+use strict;
+
+
+
+$#ARGV == 1 or die;
+my ($git_cmd, $git_repo) = @ARGV;
+
+my $silent = $ENV{'SILENT'};
+$silent = 'yes' if ! defined $silent;
+$silent = $silent !~ /^no$/i;
+my $silencer = $silent ? '> /dev/null 2>&1' : '';
+
+
+
+# Ensure that the repository exists
+die unless -e "$git_repo/.git";
+$ENV{'GIT_DIR'} = "$git_repo/.git";
+
+
+
+my $git_dir = "$git_repo/.git";
+my $sizefile = "$git_repo/.oldreposize";
+
+# Determine current repository size
+my $reposize = `du -s $git_dir` or die;
+$reposize = (split ' ', $reposize)[0];
+
+# Read old repository size
+my $oldreposize;
+if (open FILE, '<', $sizefile) {
+ $oldreposize = <FILE>;
+ close FILE;
+}
+if (! defined $oldreposize) {
+ $oldreposize = 0;
+}
+
+my $maxreposize = 10 * $oldreposize;
+if ($reposize > $maxreposize) {
+
+ print "Formaline: Optimising git repository (slow only the first time)...\n";
+
+ # Collect garbage
+ print "Executing: $git_cmd gc\n" unless $silent;
+ system "$git_cmd gc $silencer";
+ if ($?) {
+ die "Could not compact repository";
+ }
+
+ # Determine new repository size
+ my $newreposize = `du -s $git_dir` or die;
+ $newreposize = (split ' ', $newreposize)[0];
+
+ # Write new repository size
+ open (FILE, "> $sizefile") or die;
+ print FILE "$newreposize\n" or die;
+ close FILE or die;
+}
diff --git a/src/util/git-init-master-repo.pl b/src/util/git-init-master-repo.pl
new file mode 100755
index 0000000..ef5d5e5
--- /dev/null
+++ b/src/util/git-init-master-repo.pl
@@ -0,0 +1,71 @@
+#! /usr/bin/perl -w
+
+# Initialise the master repository
+
+# 2010-01-29 Erik Schnetter <schnetter@cct.lsu.edu>
+
+use strict;
+
+
+
+$#ARGV == 1 or die;
+my ($git_cmd, $git_master_repo) = @ARGV;
+
+my $silent = $ENV{'SILENT'};
+$silent = 'yes' if ! defined $silent;
+$silent = $silent !~ /^no$/i;
+my $silencer = $silent ? '> /dev/null 2>&1' : '';
+
+
+
+# If the repository exists already, do nothing
+if (-e "$git_master_repo/.git") {
+ exit;
+}
+
+
+
+print "Formaline: Creating git master repository...\n";
+
+# Create the directory for the repository
+mkdir $git_master_repo;
+$ENV{'GIT_DIR'} = $git_master_repo;
+
+# Create the repository
+print "Executing: $git_cmd init-db\n" unless $silent;
+system "$git_cmd init-db $silencer";
+if ($?) {
+ die "Formaline: WARNING: Error while initialising master git repository";
+}
+
+
+
+# Add a README
+open README, "> $git_master_repo/README" or die;
+my $today = `date`;
+print README "\
+This directory $git_master_repo
+
+is not empty -- it contains a git repository with the Cactus source
+trees of all previous builds, starting on $today.
+
+You can use the command \"git branch\" to list all configurations that
+are stored in this repository. The history of each branch is the
+sequence in which the configurations were built. The most recent
+build is stored in the branch head, as usual. In order to check out a
+certain branch into a directory <name>, issue the following commands:
+ cd <somewhere_else>
+ mkdir <name>
+ cd <name>
+ git init
+ git pull $git_master_repo <branch>
+
+You can also use the command \"git tag -l\" to list all builds that
+are stored in this repository. This keeps the source tree for each
+build directly accessible. In order to check out a certain tag into a
+directory <name>, issue the following commands:
+ cd <somewhere_else>
+ git clone -o <name> $git_master_repo
+ git checkout <tag>"
+ or die;
+close README or die;
diff --git a/src/util/git-init-repo.pl b/src/util/git-init-repo.pl
new file mode 100755
index 0000000..07a6f43
--- /dev/null
+++ b/src/util/git-init-repo.pl
@@ -0,0 +1,71 @@
+#! /usr/bin/perl -w
+
+# Initialise a repository
+
+# 2010-01-29 Erik Schnetter <schnetter@cct.lsu.edu>
+
+use strict;
+
+
+
+$#ARGV == 1 or die;
+my ($git_cmd, $git_repo) = @ARGV;
+
+my $silent = $ENV{'SILENT'};
+$silent = 'yes' if ! defined $silent;
+$silent = $silent !~ /^no$/i;
+my $silencer = $silent ? '> /dev/null 2>&1' : '';
+
+
+
+# If the repository exists already, do nothing
+if (-e "$git_repo/.git") {
+ exit;
+}
+
+
+
+print "Formaline: Creating git repository...\n";
+
+# Create the directory for the repository
+mkdir $git_repo;
+$ENV{'GIT_DIR'} = "$git_repo/.git";
+
+# Create the repository
+print "Executing: $git_cmd init-db\n" unless $silent;
+system "$git_cmd init-db $silencer";
+if ($?) {
+ die "Formaline: WARNING: Error while initialising git repository";
+}
+
+
+
+# Add a README
+open README, "> $git_repo/README" or die;
+my $today = `date`;
+print README "\
+This directory $git_repo
+
+is not empty -- it contains a git repository with the Cactus source
+trees of all previous builds, starting on $today.
+
+You can use the command \"git branch\" to list all configurations that
+are stored in this repository. The history of each branch is the
+sequence in which the configuration was built. The most recent
+build is stored in the branch head, as usual. In order to check out a
+certain branch into a directory <name>, issue the following commands:
+ cd <somewhere_else>
+ mkdir <name>
+ cd <name>
+ git init
+ git pull $git_repo <branch>
+
+You can also use the command \"git tag -l\" to list all builds that
+are stored in this repository. This keeps the source tree for each
+build directly accessible. In order to check out a certain tag into a
+directory <name>, issue the following commands:
+ cd <somewhere_else>
+ git clone -o <name> $git_repo
+ git checkout <tag>"
+ or die;
+close README or die;
diff --git a/src/util/git-lock.pl b/src/util/git-lock.pl
index 0eb7922..c05a31a 100755
--- a/src/util/git-lock.pl
+++ b/src/util/git-lock.pl
@@ -29,7 +29,7 @@ my $lockdir = "$git_dir/GITLOCK";
-my $waittime = 1;
+my $waittime = 0.01;
my $maxwaittime = 10;
while (! (mkdir $lockdir)) {
# Wait some time
@@ -38,6 +38,7 @@ while (! (mkdir $lockdir)) {
system "sleep $waittime";
# Back off exponentially
$waittime *= 2;
+ $waittime = 1 if $waittime>1 && $waittime<2;
$waittime = $maxwaittime if $waittime > $maxwaittime;
}
diff --git a/src/util/git-push-everything.pl b/src/util/git-push-everything.pl
new file mode 100755
index 0000000..faebdf7
--- /dev/null
+++ b/src/util/git-push-everything.pl
@@ -0,0 +1,74 @@
+#! /usr/bin/perl -w
+
+# Push everything to the master repository
+
+# 2010-01-29 Erik Schnetter <schnetter@cct.lsu.edu>
+
+use strict;
+
+
+
+$#ARGV == 2 or die;
+my ($git_cmd, $git_repo, $git_master_repo) = @ARGV;
+
+# Central Cactus repository
+my $git_central_repo = $ENV{'CACTUS_CENTRAL_GIT_REPO'};
+
+# Path where the git-*.pl commands are installed
+my $bindir = $ENV{'SCRATCH_BUILD'} . '/formaline-bin';
+
+my $silent = $ENV{'SILENT'};
+$silent = 'yes' if ! defined $silent;
+$silent = $silent !~ /^no$/i;
+my $silencer = $silent ? '> /dev/null 2>&1' : '';
+
+
+
+# Ensure that the repositories exist
+die unless -e "$git_repo/.git";
+$ENV{'GIT_DIR'} = "$git_repo/.git";
+die unless -e "$git_master_repo/.git";
+
+
+
+print "Formaline: Pushing source tree to master git repository...\n";
+
+print "Executing: $git_cmd push -v -f --all $git_master_repo\n" unless $silent;
+system "$git_cmd push -v -f --all $git_master_repo $silencer";
+if ($?) {
+ die "Could not push branches";
+}
+
+print "Executing: $git_cmd push -v -f --tags $git_master_repo\n" unless $silent;
+system "$git_cmd push -v -f --tags $git_master_repo $silencer";
+if ($?) {
+ die "Could not push tags";
+}
+
+print "Executing: $bindir/git-gc-repo.pl '$git_cmd' $git_master_repo\n"
+ unless $silent;
+system "$bindir/git-gc-repo.pl '$git_cmd' $git_master_repo $silencer";
+if ($?) {
+ die "Could not collect garbage";
+}
+
+
+
+if (defined $git_central_repo) {
+ $ENV{'GIT_DIR'} = "$git_master_repo/.git";
+
+ print "Formaline: Pushing to central repository $git_central_repo...\n";
+
+ print "Executing: $git_cmd push -v -f --all $git_central_repo\n"
+ unless $silent;
+ system "$git_cmd push -v -f --all $git_central_repo $silencer";
+ if ($?) {
+ die "Could not push branches";
+ }
+
+ print "$git_cmd push -v -f --tags $git_central_repo\n" unless $silent;
+ system "$git_cmd push -v -f --tags $git_central_repo $silencer";
+ if ($?) {
+ die "Could not push tags";
+ }
+}
diff --git a/src/util/git-rm-thorn.pl b/src/util/git-rm-thorn.pl
new file mode 100755
index 0000000..9d5342b
--- /dev/null
+++ b/src/util/git-rm-thorn.pl
@@ -0,0 +1,40 @@
+#! /usr/bin/perl -w
+
+# Remote a Cactus thorn from the repository index, if and wherever it
+# exists
+
+# 2010-01-29 Erik Schnetter <schnetter@cct.lsu.edu>
+
+use strict;
+
+
+
+$#ARGV >= 3 or die;
+my ($git_cmd, $git_repo, $git_root, $thorn, @files) = @ARGV;
+
+my $silent = $ENV{'SILENT'};
+$silent = 'yes' if ! defined $silent;
+$silent = $silent !~ /^no$/i;
+my $silencer = $silent ? '> /dev/null 2>&1' : '';
+
+
+
+# Ensure that the repository exists
+die unless -e "$git_repo/.git";
+$ENV{'GIT_DIR'} = "$git_repo/.git";
+
+
+
+# Remove the files one by one because we want to ignore errors, but
+# git aborts after the first error
+for my $file (@files) {
+
+ print "Executing: $git_cmd rm --cached -r $file 2> /dev/null\n"
+ unless $silent;
+ system "$git_cmd rm --cached -r $file > /dev/null 2>&1";
+ # Ignore errors
+ #if ($?) {
+ # die "Could not remove thorn $thorn from git repository";
+ #}
+
+}
diff --git a/src/util/makeblob.pl b/src/util/makeblob.pl
index 8eaed08..14fd49c 100755
--- a/src/util/makeblob.pl
+++ b/src/util/makeblob.pl
@@ -3,7 +3,7 @@
use strict;
my $items_per_line = 16;
-my $items_per_file = 1024 * 1024;
+my $items_per_file = 128 * 1024;
$#ARGV == 1 or die;