Extract common functions into a separate file
This is the start of an effort to organize devstack's code
to better document the requirements for configuring the individual
components.
Change-Id: I3476b76b9d1f9ee63687fb9898a98729118cbd84
diff --git a/tools/build_tempest.sh b/tools/build_tempest.sh
index aa44766..230e8f9 100755
--- a/tools/build_tempest.sh
+++ b/tools/build_tempest.sh
@@ -26,7 +26,10 @@
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
-TOP_DIR=`cd $TOOLS_DIR/..; pwd`
+TOP_DIR=$(cd $TOOLS_DIR/..; pwd)
+
+# Import common functions
+. $TOP_DIR/functions
# Abort if localrc is not set
if [ ! -e $TOP_DIR/localrc ]; then
@@ -43,42 +46,8 @@
TEMPEST_DIR=$DEST/tempest
-DIST_NAME=${DIST_NAME:-oneiric}
-
-# git clone only if directory doesn't exist already. Since ``DEST`` might not
-# be owned by the installation user, we create the directory and change the
-# ownership to the proper user.
-function git_clone {
-
- GIT_REMOTE=$1
- GIT_DEST=$2
- GIT_BRANCH=$3
-
- # do a full clone only if the directory doesn't exist
- if [ ! -d $GIT_DEST ]; then
- git clone $GIT_REMOTE $GIT_DEST
- cd $2
- # This checkout syntax works for both branches and tags
- git checkout $GIT_BRANCH
- elif [[ "$RECLONE" == "yes" ]]; then
- # if it does exist then simulate what clone does if asked to RECLONE
- cd $GIT_DEST
- # set the url to pull from and fetch
- git remote set-url origin $GIT_REMOTE
- git fetch origin
- # remove the existing ignored files (like pyc) as they cause breakage
- # (due to the py files having older timestamps than our pyc, so python
- # thinks the pyc files are correct using them)
- find $GIT_DEST -name '*.pyc' -delete
- git checkout -f origin/$GIT_BRANCH
- # a local branch might not exist
- git branch -D $GIT_BRANCH || true
- git checkout -b $GIT_BRANCH
- fi
-}
-
# Install tests and prerequisites
-sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install --use-mirrors `cat $TOP_DIR/files/pips/tempest`
+pip_install `cat $TOP_DIR/files/pips/tempest`
git_clone $TEMPEST_REPO $TEMPEST_DIR $TEMPEST_BRANCH