From a76751fec25df86cc25985ec4fedf1571460c27d Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 27 Aug 2009 12:05:56 -0500 Subject: [PATCH 1/2] change factor.sh update to fetch and pull in separate steps so certain platforms that exclusive-lock running scripts won't ruin the repo when factor.sh changes in the future --- build-support/factor.sh | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/build-support/factor.sh b/build-support/factor.sh index b179811bda..1bddb935ab 100755 --- a/build-support/factor.sh +++ b/build-support/factor.sh @@ -14,6 +14,7 @@ WORD= NO_UI= GIT_PROTOCOL=${GIT_PROTOCOL:="git"} GIT_URL=${GIT_URL:=$GIT_PROTOCOL"://factorcode.org/git/factor.git"} +SCRIPT_ARGS="$*" test_program_installed() { if ! [[ -n `type -p $1` ]] ; then @@ -353,9 +354,40 @@ git_clone() { invoke_git clone $GIT_URL } -git_pull_factorcode() { - echo "Updating the git repository from factorcode.org..." - invoke_git pull $GIT_URL master +update_script_name() { + echo `dirname $0`/_update.sh +} + +update_script() { + echo "Updating and restarting the factor.sh script..." + + update_script=`update_script_name` + + echo "#!/bin/sh" >"$update_script" + echo "git pull \"$GIT_URL\" master" >>"$update_script" + echo "if [[ \$? -eq 0 ]]; then exec \"$0\" $SCRIPT_ARGS; else echo \"git pull failed\"; exit 2; fi" \ + >>"$update_script" + echo "exit 0" >>"$update_script" + + chmod 755 "$update_script" + exec "$update_script" +} + +update_script_changed() { + invoke_git diff --stat `invoke_git merge-base HEAD FETCH_HEAD` FETCH_HEAD | grep 'build-support.factor\.sh' >/dev/null +} + +git_fetch_factorcode() { + echo "Fetching the git repository from factorcode.org..." + + rm -f `update_script_name` + invoke_git fetch "$GIT_URL" master + + if update_script_changed; then + update_script + else + invoke_git pull "$GIT_URL" master + fi } cd_factor() { @@ -475,7 +507,7 @@ install() { update() { get_config_info - git_pull_factorcode + git_fetch_factorcode backup_factor make_clean make_factor From 54772c9de1c094fd2c32d2f749664f2d4283f449 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Thu, 27 Aug 2009 12:15:52 -0500 Subject: [PATCH 2/2] better factor.sh output after git fetch whether script is restarted or not --- build-support/factor.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-support/factor.sh b/build-support/factor.sh index 1bddb935ab..4943d3e5c0 100755 --- a/build-support/factor.sh +++ b/build-support/factor.sh @@ -359,8 +359,6 @@ update_script_name() { } update_script() { - echo "Updating and restarting the factor.sh script..." - update_script=`update_script_name` echo "#!/bin/sh" >"$update_script" @@ -384,8 +382,10 @@ git_fetch_factorcode() { invoke_git fetch "$GIT_URL" master if update_script_changed; then + echo "Updating and restarting the factor.sh script..." update_script else + echo "Updating the working tree..." invoke_git pull "$GIT_URL" master fi }