From 153f76f440b01e2c57376103965ee261b651a9e2 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Mon, 7 Apr 2014 22:28:04 +0100 Subject: [PATCH] Assure proper versioning with external Salt repositories. In case Salt is getting installed using a repository which is not SaltStack's Salt repository, add the latest as a remote and fetch tags from there for proper versioning. --- bootstrap-salt.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/bootstrap-salt.sh b/bootstrap-salt.sh index 7c0987f..321e471 100755 --- a/bootstrap-salt.sh +++ b/bootstrap-salt.sh @@ -237,6 +237,7 @@ EOT _KEEP_TEMP_FILES=${BS_KEEP_TEMP_FILES:-$BS_FALSE} _TEMP_CONFIG_DIR="null" _SALTSTACK_REPO_URL="git://github.com/saltstack/salt.git" +_SALT_REPO_URL=${_SALTSTACK_REPO_URL} _TEMP_KEYS_DIR="null" _INSTALL_MASTER=$BS_FALSE _INSTALL_SYNDIC=$BS_FALSE @@ -283,7 +284,7 @@ do exit 1 fi ;; - g ) _SALTSTACK_REPO_URL=$OPTARG ;; + g ) _SALT_REPO_URL=$OPTARG ;; k ) _TEMP_KEYS_DIR="$OPTARG" # If the configuration directory does not exist, error out if [ ! -d "$_TEMP_KEYS_DIR" ]; then @@ -1019,6 +1020,15 @@ __git_clone_and_checkout() { git fetch || return 1 # Tags are needed because of salt's versioning, also fetch that git fetch --tags || return 1 + + # If we have the SaltStack remote set as upstream, we also need to fetch the tags from there + if [ "x$(git remote -v | grep $_SALTSTACK_REPO_URL)" != "x" ]; then + git fetch --tags upstream + else + git remote add upstream $_SALTSTACK_REPO_URL + git fetch --tags upstream + fi + git reset --hard $GIT_REV || return 1 # Just calling `git reset --hard $GIT_REV` on a branch name that has @@ -1031,9 +1041,17 @@ __git_clone_and_checkout() { git pull --rebase || return 1 fi else - git clone $_SALTSTACK_REPO_URL || return 1 + git clone $_SALT_REPO_URL || return 1 cd $SALT_GIT_CHECKOUT_DIR + + if [ $_SALT_REPO_URL != $_SALTSTACK_REPO_URL ]; then + # We need to add the saltstack repository as a remote and fetch tags for proper versioning + git remote add upstream $_SALTSTACK_REPO_URL + git fetch --tags upstream + fi + git checkout $GIT_REV || return 1 + fi return 0 }