xci: Move sourcing of configuration files to the install-lib.sh 83/55083/3
authorMarkos Chandras <mchandras@suse.de>
Fri, 6 Apr 2018 19:28:10 +0000 (20:28 +0100)
committerMarkos Chandras <mchandras@suse.de>
Fri, 18 May 2018 10:20:52 +0000 (11:20 +0100)
The install-lib.sh assumes that certain configuration files have been
loaded before it's sourced. However, this doesn't work well when other
scripts are using install-lib.sh directly since they also need to load
the same configuration files. As such, lets source all these
configuration files from the install-lib.sh file directly. We also
rename this file to 'xci-lib.sh' since it's not just about installation
helpers anymore.

Change-Id: I35e1e804db06b2bb512e4991e5fdf21a72ffaadb
Signed-off-by: Markos Chandras <mchandras@suse.de>
xci/files/xci-lib.sh [moved from xci/files/install-lib.sh with 93% similarity]
xci/xci-deploy.sh

similarity index 93%
rename from xci/files/install-lib.sh
rename to xci/files/xci-lib.sh
index af86be4..bdb6451 100644 (file)
@@ -7,9 +7,21 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 
-# NOTE(hwoarang): Most parts of this this file were taken from the
-# bifrost repository (scripts/install-deps.sh). This script contains all
-# the necessary distro specific code to install ansible and it's dependencies.
+function bootstrap_xci_env() {
+    # Declare our virtualenv
+    export XCI_VENV=${XCI_PATH}/venv/
+
+    # source user vars
+    source $XCI_PATH/xci/config/user-vars
+    # source pinned versions
+    source $XCI_PATH/xci/config/pinned-versions
+    # source flavor configuration
+    source "$XCI_PATH/xci/config/${XCI_FLAVOR}-vars"
+    # source installer configuration
+    source "$XCI_PATH/xci/installer/${INSTALLER_TYPE}/env" &>/dev/null || true
+    # source xci configuration
+    source $XCI_PATH/xci/config/env-vars
+}
 
 function install_ansible() {
     set -eu
index a04fb21..6f7490b 100755 (executable)
@@ -81,20 +81,8 @@ fi
 #-------------------------------------------------------------------------------
 # find where are we
 export XCI_PATH="$(git rev-parse --show-toplevel)"
-# Declare our virtualenv
-export XCI_VENV=${XCI_PATH}/venv/
-# source user vars
-source $XCI_PATH/xci/config/user-vars
-# source pinned versions
-source $XCI_PATH/xci/config/pinned-versions
-# source flavor configuration
-source "$XCI_PATH/xci/config/${XCI_FLAVOR}-vars"
-# source installer configuration
-source "$XCI_PATH/xci/installer/${INSTALLER_TYPE}/env" &>/dev/null || true
-# source xci configuration
-source $XCI_PATH/xci/config/env-vars
 # source helpers library
-source ${XCI_PATH}/xci/files/install-lib.sh
+source ${XCI_PATH}/xci/files/xci-lib.sh
 
 # Make sure we pass XCI_PATH everywhere
 export XCI_ANSIBLE_PARAMS+=" -e xci_path=${XCI_PATH}"
@@ -114,17 +102,18 @@ for local_user_var in ${user_local_dev_vars[@]}; do
 done
 unset user_local_dev_vars local_user_var
 
-# register our handler
-trap exit_trap ERR
-
-# We are using sudo so we need to make sure that env_reset is not present
-sudo sed -i "s/^Defaults.*env_reset/#&/" /etc/sudoers
-
 #
 # Bootstrap environment for XCI Deployment
 #
 echo "Info: Preparing host environment for the XCI deployment"
 echo "-------------------------------------------------------------------------"
+bootstrap_xci_env
+
+# register our handler
+trap exit_trap ERR
+
+# We are using sudo so we need to make sure that env_reset is not present
+sudo sed -i "s/^Defaults.*env_reset/#&/" /etc/sudoers
 
 #-------------------------------------------------------------------------------
 # Clean up environment