diff options
author | eschnett <eschnett@83718e91-0e4f-0410-abf4-91180603181f> | 2011-11-14 15:06:17 +0000 |
---|---|---|
committer | eschnett <eschnett@83718e91-0e4f-0410-abf4-91180603181f> | 2011-11-14 15:06:17 +0000 |
commit | b379fef2660ff2add91076f7c74e3f29e0fa9b1a (patch) | |
tree | faff89db1427493c286620761d6f0b3ff9b5b9d8 /src/util/git-get-localdir.pl | |
parent | 6345342a5de31761b11e1c880f6ec72a97d70c1b (diff) |
Support a "local repository" that collects all machine-local repositories
Support a "local git repository" that collects all machine-local git
repositories. This is stored in sourcebasedir, which is taken from
Simfactory's MDB.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusUtils/Formaline/trunk@214 83718e91-0e4f-0410-abf4-91180603181f
Diffstat (limited to 'src/util/git-get-localdir.pl')
-rwxr-xr-x | src/util/git-get-localdir.pl | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/util/git-get-localdir.pl b/src/util/git-get-localdir.pl new file mode 100755 index 0000000..97e9872 --- /dev/null +++ b/src/util/git-get-localdir.pl @@ -0,0 +1,55 @@ +#! /usr/bin/perl -w + +# Determine the local git repository directory + +# 2011-11-13 Erik Schnetter <eschnetter@perimeterinstitute.ca> + +use strict; + + + +$#ARGV == 0 or die; +my ($git_cmd) = @ARGV; + +my $CCTK_HOME = $ENV{'CCTK_HOME'}; + +# 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' : ''; + + + +# Obtain local machine name +my $machine = `cd ${CCTK_HOME} && ${CCTK_HOME}/bin/sim whoami`; +chomp $machine; +$machine =~ s{Current machine:\s*(.*)}{$1}; +exit 0 if $machine eq ''; + +# Obtain sourcebasedir +my @mdb=`cd ${CCTK_HOME} && ${CCTK_HOME}/bin/sim print-mdb "${machine}"`; +@mdb = grep m{^\s*sourcebasedir\s*=}, @mdb; +exit 1 if @mdb != 1; +my $sourcebasedir = $mdb[0]; +$sourcebasedir =~ s{^[^=]*=\s*(.*)}{$1}; +chomp $sourcebasedir; +exit 0 if $sourcebasedir eq ''; + +# Replace variables +if ($ENV{'USER'}) { + my $USER = $ENV{'USER'}; + $sourcebasedir =~ s{\@USER\@}{${USER}}g; +} + +# Define local git repo name +my $git_local_repo = "${sourcebasedir}/CactusSourceJar.git"; + +# Create local git repo if it does not exist +# (Don't print anything to stdout) +system "${bindir}/git-init-local-repo.pl '$git_cmd' '$git_local_repo' >&2"; + +# Output git repo name +print "CACTUS_LOCAL_GIT_REPO='${git_local_repo}'\n"; |