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 | |
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
-rw-r--r-- | src/make.code.deps | 2 | ||||
-rw-r--r-- | src/make.configuration.deps | 5 | ||||
-rwxr-xr-x | src/util/git-gc-repo.pl | 2 | ||||
-rwxr-xr-x | src/util/git-get-localdir.pl | 55 | ||||
-rwxr-xr-x | src/util/git-init-local-repo.pl | 77 | ||||
-rwxr-xr-x | src/util/git-init-master-repo.pl | 2 | ||||
-rwxr-xr-x | src/util/git-init-repo.pl | 2 | ||||
-rwxr-xr-x | src/util/git-push-everything.pl | 26 |
8 files changed, 164 insertions, 7 deletions
diff --git a/src/make.code.deps b/src/make.code.deps index d9b30a1..a697586 100644 --- a/src/make.code.deps +++ b/src/make.code.deps @@ -9,7 +9,7 @@ FORMALINE_BIN_DIR = $(SCRATCH_BUILD)/Formaline/bin FORMALINE_TAR_FILES = gethostname.pl makeblob.pl makemetablob.pl -FORMALINE_GIT_FILES = git-add-thorn.pl git-commit-everything.pl git-gc-repo.pl git-init-master-repo.pl git-init-repo.pl git-lock.pl git-push-everything.pl git-rm-unused-thorns.pl git-rm-thorn.pl +FORMALINE_GIT_FILES = git-add-thorn.pl git-commit-everything.pl git-gc-repo.pl git-get-localdir.pl git-init-local-repo.pl git-init-master-repo.pl git-init-repo.pl git-lock.pl git-push-everything.pl git-rm-unused-thorns.pl git-rm-thorn.pl $(CCTK_TARGET): $(FORMALINE_TAR_FILES:%=$(FORMALINE_BIN_DIR)/%) $(FORMALINE_GIT_FILES:%=$(FORMALINE_BIN_DIR)/%) diff --git a/src/make.configuration.deps b/src/make.configuration.deps index ba81ac3..4ccfd1f 100644 --- a/src/make.configuration.deps +++ b/src/make.configuration.deps @@ -318,10 +318,11 @@ CONFIG-ID-FILE = $(TOP)/CONFIG-ID git-push-everything: git-commit-everything $(BUILD-ID-FILE) { \ '$(GIT-BIN)/git-init-master-repo.pl' '$(GIT)' '$(GIT-MASTER-REPO)' && \ + eval "$$('$(GIT-BIN)/git-get-localdir.pl' '$(GIT)')" && \ if [ -e "$(CCTK_HOME)/cactus.config" ]; then \ - . "$(CCTK_HOME)/cactus.config"; \ + source "$(CCTK_HOME)/cactus.config"; \ fi && \ - export CACTUS_CENTRAL_GIT_REPO && \ + export CACTUS_LOCAL_GIT_REPO CACTUS_CENTRAL_GIT_REPO && \ '$(GIT-BIN)/git-push-everything.pl' '$(GIT)' '$(GIT-REPO)' '$(GIT-MASTER-REPO)'; \ } || echo "Formaline: WARNING: Error while pushing to master repository" diff --git a/src/util/git-gc-repo.pl b/src/util/git-gc-repo.pl index d232cde..6b602d1 100755 --- a/src/util/git-gc-repo.pl +++ b/src/util/git-gc-repo.pl @@ -1,7 +1,7 @@ #! /usr/bin/perl -w # Collect garbage in the repository if it grown in size by more than a -# factor of 10. +# factor of two. # 2010-01-29 Erik Schnetter <schnetter@cct.lsu.edu> 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"; diff --git a/src/util/git-init-local-repo.pl b/src/util/git-init-local-repo.pl new file mode 100755 index 0000000..d9b7db9 --- /dev/null +++ b/src/util/git-init-local-repo.pl @@ -0,0 +1,77 @@ +#! /usr/bin/perl -w + +# Initialise the local repository + +# 2011-11-13 Erik Schnetter <eschnetter@perimeterinstitute.ca> + +use strict; + + + +$#ARGV == 1 or die; +my ($git_cmd, $git_local_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_local_repo/.git") { + exit; +} + + + +print "Formaline: Creating git local repository...\n"; + +# Create the directory for the repository +mkdir $git_local_repo; +$ENV{'GIT_DIR'} = "$git_local_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 local git repository\nCommand was\n $git_cmd init-db"; +} +print "Executing: $git_cmd config receive.denyCurrentBranch false\n" unless $silent; +system "$git_cmd config receive.denyCurrentBranch false $silencer"; +if ($?) { + die "Formaline: Error while configuring local git repository\nCommand was\n $git_cmd config receive.denyCurrentBranch false"; +} + + + +# Add a README +open README, "> $git_local_repo/README" or die; +my $today = `date`; +chomp $today; +print README "\ +This directory $git_local_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_local_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_local_repo + git checkout <tag> +" + or die; +close README or die; diff --git a/src/util/git-init-master-repo.pl b/src/util/git-init-master-repo.pl index 8330a1e..ef31159 100755 --- a/src/util/git-init-master-repo.pl +++ b/src/util/git-init-master-repo.pl @@ -48,9 +48,9 @@ if ($?) { # Add a README open README, "> $git_master_repo/README" or die; my $today = `date`; +chomp $today; 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. diff --git a/src/util/git-init-repo.pl b/src/util/git-init-repo.pl index a4d5d74..ab7d571 100755 --- a/src/util/git-init-repo.pl +++ b/src/util/git-init-repo.pl @@ -48,9 +48,9 @@ if ($?) { # Add a README open README, "> $git_repo/README" or die; my $today = `date`; +chomp $today; 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. diff --git a/src/util/git-push-everything.pl b/src/util/git-push-everything.pl index 10ad4dc..fb3782d 100755 --- a/src/util/git-push-everything.pl +++ b/src/util/git-push-everything.pl @@ -11,7 +11,8 @@ use strict; $#ARGV == 2 or die; my ($git_cmd, $git_repo, $git_master_repo) = @ARGV; -# Central Cactus repository +# Local and central Cactus repositories +my $git_local_repo = $ENV{'CACTUS_LOCAL_GIT_REPO'}; my $git_central_repo = $ENV{'CACTUS_CENTRAL_GIT_REPO'}; # Path where the git-*.pl commands are installed @@ -60,6 +61,29 @@ if ($?) { +if (defined $git_local_repo) { + $ENV{'GIT_DIR'} = "$git_master_repo/.git"; + + print "Formaline: Pushing to local repository $git_local_repo...\n"; + + print "Executing: $git_cmd push -v -f --all '$git_local_repo'\n" + unless $silent; + system "$git_cmd push -v -f --all '$git_local_repo' $silencer"; + if ($?) { + die "Could not push branches\nCommand was\n $git_cmd push -v -f --all '$git_local_repo'"; + } + + print "$git_cmd push -v -f --tags '$git_local_repo'\n" unless $silent; + system "$git_cmd push -v -f --tags '$git_local_repo' $silencer"; + if ($?) { + die "Could not push tags\nCommand was\n $git_cmd push -v -f --tags '$git_local_repo'"; + } + + system "${bindir}/git-gc-repo.pl '$git_cmd' '$git_local_repo'"; +} + + + if (defined $git_central_repo) { $ENV{'GIT_DIR'} = "$git_master_repo/.git"; |