install.sh: fix handling of env var config overrides (#845)

overriding config values through environment variables wasn't working
because the script call was resetting them before
they were saved

also, the external config file was getting sourced twice
This commit is contained in:
Adel Kara Slimane
2023-11-14 09:40:22 +01:00
committed by GitHub
parent c3fc434ff9
commit ae773456f6

View File

@ -1,5 +1,11 @@
#!/bin/bash
# Stop the script at any ecountered error
set -e
# save current environment before losing it to the script call
declare -p -x > current_env
# If current run is not using 'script' for logging, do it
if [ -z "$SCRIPT" ]; then
export SCRIPT=1
@ -11,8 +17,7 @@ if [ -z "$SCRIPT" ]; then
exit $exit_status
fi
# Stop the script at any ecountered error
set -e
###################### Definition of helper variables and functions
_where=`pwd`
srcdir="$_where"
@ -42,7 +47,10 @@ plain() {
echo -e "$1" >&2
}
declare -p -x > current_env
####################################################################
################### Config sourcing
source customization.cfg
if [ -e "$_EXT_CONFIG_PATH" ]; then
@ -54,6 +62,8 @@ fi
source linux-tkg-config/prepare
####################################################################
_distro_prompt() {
echo "Which linux distribution are you running ?"
echo "if it's not on the list, chose the closest one to it: Fedora/Suse for RPM, Ubuntu/Debian for DEB"
@ -89,12 +99,6 @@ if [ "$1" != "install" ] && [ "$1" != "config" ] && [ "$1" != "uninstall-help" ]
exit 0
fi
# Load external configuration file if present. Available variable values will overwrite customization.cfg ones.
if [ -e "$_EXT_CONFIG_PATH" ]; then
msg2 "External configuration file $_EXT_CONFIG_PATH will be used and will override customization.cfg values."
source "$_EXT_CONFIG_PATH"
fi
if [ "$1" = "install" ] || [ "$1" = "config" ]; then
if [ -z "$_distro" ] && [ "$1" = "install" ]; then