aboutsummaryrefslogtreecommitdiff
path: root/src/util/git-add-thorn.pl
diff options
context:
space:
mode:
authorschnetter <schnetter@83718e91-0e4f-0410-abf4-91180603181f>2010-02-06 17:24:06 +0000
committerschnetter <schnetter@83718e91-0e4f-0410-abf4-91180603181f>2010-02-06 17:24:06 +0000
commit1f053de3b2531ccad7f4e96e18892435705996c2 (patch)
treee4604175591382e231485e7d7bce8245b497ee56 /src/util/git-add-thorn.pl
parentd602467129df8ca1bd67edbb6fe96a534f06064f (diff)
Git stuff:
Replace shell commands in Makefile with explicit perl scripts. Handle symbolic links to arrangements or thorns explicitly, so that newer versions of git work fine. git-svn-id: http://svn.cactuscode.org/arrangements/CactusUtils/Formaline/trunk@181 83718e91-0e4f-0410-abf4-91180603181f
Diffstat (limited to 'src/util/git-add-thorn.pl')
-rwxr-xr-xsrc/util/git-add-thorn.pl59
1 files changed, 59 insertions, 0 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;