From 98d4ed5ebf8385be986b4cc01977d3807a70c699 Mon Sep 17 00:00:00 2001 From: Michael McCune Date: Wed, 28 May 2014 16:13:28 -0400 Subject: [PATCH] Adding options to control DIB repo branch * Added the -m option * Added detection of variable DIB_REPO_BRANCH * Added tag 0.1.17 as default branch of DIB repo * Added exit error if both DIB_REPO_BRANCH and -m are specified Implements: blueprint dib-repo-branch-option Change-Id: I44f0689f7844085c39b5560c65024b68c3424ad8 --- diskimage-create/README.rst | 6 ++++++ diskimage-create/diskimage-create.sh | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/diskimage-create/README.rst b/diskimage-create/README.rst index 29f8f2a2..9c3342d5 100644 --- a/diskimage-create/README.rst +++ b/diskimage-create/README.rst @@ -65,3 +65,9 @@ For developers: .. sourcecode:: bash sudo SIM_REPO_PATH="$(pwd)/sahara-image-elements" DIB_REPO_PATH="$(pwd)/diskimage-builder" bash sahara-image-elements/diskimage-create/diskimage-create.sh + +3. If you want to specify the diskimage-builder repository branch, or tag, that is used during the diskimage-create script there are two methods. The '-m' option of diskimage-create.sh will always use the 'master' branch of diskimage-builder. Alternatively exporting 'DIB_REPO_BRANCH' will allow the use of an arbitrary branch or tag. By default diskimage-create will use a known good tag from the upstream repository. + +.. sourcecode:: bash + + sudo DIB_REPO_BRANCH="custom-branch" bash sahara-image-elements/diskimage-create/diskimage-create.sh diff --git a/diskimage-create/diskimage-create.sh b/diskimage-create/diskimage-create.sh index d59d2da4..5b8cbb42 100755 --- a/diskimage-create/diskimage-create.sh +++ b/diskimage-create/diskimage-create.sh @@ -9,7 +9,10 @@ unset DIB_IMAGE_SIZE # DEBUG_MODE is set by the -d flag, debug is enabled if the value is "true" DEBUG_MODE="false" -while getopts "p:i:v:d" opt; do +# The default tag to use for the DIB repo +DEFAULT_DIB_REPO_BRANCH="0.1.17" + +while getopts "p:i:v:d:m" opt; do case $opt in p) PLUGIN=$OPTARG @@ -23,6 +26,14 @@ while getopts "p:i:v:d" opt; do d) DEBUG_MODE="true" ;; + m) + if [ -n "$DIB_REPO_BRANCH" ]; then + echo "Error: DIB_REPO_BRANCH set and -m requested, please choose one." + exit 3 + else + DIB_REPO_BRANCH="master" + fi + ;; *) echo echo "Usage: $(basename $0)" @@ -30,10 +41,12 @@ while getopts "p:i:v:d" opt; do echo " [-i ubuntu|fedora|centos]" echo " [-v 1|2|plain]" echo " [-d]" + echo " [-m]" echo " '-p' is plugin version (default: vanilla)" echo " '-i' is image type (default: all supported by plugin)" echo " '-v' is hadoop version (default: all supported by plugin)" echo " '-d' enable debug mode, root account will have password 'hadoop'" + echo " '-m' set the diskimage-builder repo to the master branch (default: $DEFAULT_DIB_REPO_BRANCH)" echo echo "You shouldn't specify hadoop version and image type for spark plugin" echo "You shouldn't specify image type for hdp plugin" @@ -46,6 +59,10 @@ while getopts "p:i:v:d" opt; do esac done +if [ -z $DIB_REPO_BRANCH ]; then + DIB_REPO_BRANCH=$DEFAULT_DIB_REPO_BRANCH +fi + if [ -e /etc/os-release ]; then platform=$(head -1 /etc/os-release) else @@ -117,6 +134,7 @@ export DIB_IMAGE_CACHE=$TEMP/.cache-image-create if [ -z $DIB_REPO_PATH ]; then git clone https://git.openstack.org/openstack/diskimage-builder DIB_REPO_PATH="$(pwd)/diskimage-builder" + git --git-dir=$DIB_REPO_PATH/.git --work-tree=$DIB_REPO_PATH checkout $DIB_REPO_BRANCH fi export PATH=$PATH:$DIB_REPO_PATH/bin