From ae28c0fa4271dcd745495a663158aa6a2773ae88 Mon Sep 17 00:00:00 2001 From: iberezovskiy Date: Mon, 16 Dec 2013 16:59:25 +0400 Subject: [PATCH] Add possibility to use local repositories * add parameters 'DIB_REPO_PATH' and 'SIM_REPO_PATH' for specifying pathes * script tries to use local repository 'savanna-image-elements' as default Change-Id: I46f3b5573e68e5dfaf5fd98b86eedc90fa108073 --- diskimage-create/README.rst | 18 ++++++++++++--- diskimage-create/diskimage-create.sh | 33 ++++++++++++++++++++++------ 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/diskimage-create/README.rst b/diskimage-create/README.rst index 78eaebb5..c98dae25 100644 --- a/diskimage-create/README.rst +++ b/diskimage-create/README.rst @@ -7,14 +7,26 @@ NOTE: You should use Ubuntu or Fedora host OS for building images, CentOS as a h For users: -1. Use your environment (export / setenv) to alter the scripts behavior. Environment variables the script accepts are DIB_HADOOP_VERSION, JAVA_DOWNLOAD_URL, OOZIE_DOWNLOAD_URL, HIVE_VERSION, ubuntu_image_name, fedora_image_name. +1. Use your environment (export / setenv) to alter the scripts behavior. Environment variables the script accepts are 'DIB_HADOOP_VERSION', 'JAVA_DOWNLOAD_URL', 'OOZIE_DOWNLOAD_URL', 'HIVE_VERSION', 'ubuntu_image_name', 'fedora_image_name'. -2. If you want to use your local mirrors, you should specify http urls for Fedora and Ubuntu mirrors using parameters 'FEDORA_MIRROR' and 'UBUNTU_MIRROR' like this: +2. For creating images just clone this repository and run script. .. sourcecode:: bash - sudo USE_MIRRORS=true FEDORA_MIRROR="url_for_fedora_mirror" UBUNTU_MIRROR="url_for_ubuntu_mirror" bash diskimage-create.sh + sudo bash savanna-image-elements/diskimage-create/diskimage-create.sh + +3. If you want to use your local mirrors, you should specify http urls for Fedora and Ubuntu mirrors using parameters 'FEDORA_MIRROR' and 'UBUNTU_MIRROR' like this: + +.. sourcecode:: bash + + sudo USE_MIRRORS=true FEDORA_MIRROR="url_for_fedora_mirror" UBUNTU_MIRROR="url_for_ubuntu_mirror" bash savanna-image-elements/diskimage-create/diskimage-create.sh For developers: 1. If you want to add your element to this repository, you should edit this script in your commit (you should export variables for your element and add name of element to variables 'element_sequence'). + +2. If you want to test your Patch Set to savanna-image-elements or diskimage-builder, you can specify 'SIM_REPO_PATH' or 'DIB_REPO_PATH' (this parameters should be a full path to repositories) and run this script like this: + +.. sourcecode:: bash + + sudo SIM_REPO_PATH="$(pwd)/savanna-image-elements" DIB_REPO_PATH="$(pwd)/diskimage-builder" bash savanna-image-elements/diskimage-create/diskimage-create.sh diff --git a/diskimage-create/diskimage-create.sh b/diskimage-create/diskimage-create.sh index e9b11dd9..c8f99f88 100755 --- a/diskimage-create/diskimage-create.sh +++ b/diskimage-create/diskimage-create.sh @@ -31,24 +31,43 @@ else fi fi +base_dir="$(dirname $(readlink -e $0))" + TEMP=$(mktemp -d diskimage-create.XXXXXX) pushd $TEMP export DIB_IMAGE_CACHE=$TEMP/.cache-image-create -# Cloning repostiroies +# Working with repositories +# disk-image-builder repo -git clone https://git.openstack.org/openstack/diskimage-builder -git clone https://git.openstack.org/openstack/savanna-image-elements +if [ -z $DIB_REPO_PATH ]; then + git clone https://git.openstack.org/openstack/diskimage-builder + DIB_REPO_PATH="$(pwd)/diskimage-builder" +fi -pushd diskimage-builder +export PATH=$PATH:$DIB_REPO_PATH/bin + +pushd $DIB_REPO_PATH export DIB_COMMIT_ID=`git rev-parse HEAD` popd -export PATH=$PATH:$PWD/diskimage-builder/bin -export ELEMENTS_PATH=$PWD/diskimage-builder/elements:$PWD/savanna-image-elements/elements +export ELEMENTS_PATH="$DIB_REPO_PATH/elements" -pushd savanna-image-elements +# savanna-image-elements repo + +if [ -z $SIM_REPO_PATH ]; then + SIM_REPO_PATH="$(dirname $base_dir)" + if [ $(basename $SIM_REPO_PATH) != "savanna-image-elements" ]; then + echo "Can't find Savanna-image-elements repository. Cloning it." + git clone https://git.openstack.org/openstack/savanna-image-elements + SIM_REPO_PATH="$(pwd)/savanna-image-elements" + fi +fi + +ELEMENTS_PATH=$ELEMENTS_PATH:$SIM_REPO_PATH/elements + +pushd $SIM_REPO_PATH export SAVANNA_ELEMENTS_COMMIT_ID=`git rev-parse HEAD` popd