Generate and apply config
Allows for faster configuration in known environments Signed-off-by: Robert Baldyga <robert.baldyga@intel.com> Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
committed by
Michal Mielewczyk
parent
e1055fe262
commit
13c51041ff
50
configure
vendored
50
configure
vendored
@@ -3,23 +3,51 @@
|
||||
# Copyright(c) 2012-2019 Intel Corporation
|
||||
# SPDX-License-Identifier: BSD-3-Clause-Clear
|
||||
#
|
||||
which dirname 2>&1 > /dev/null || { echo >&2 "Eror: missing 'dirname' utility"; exit 1; }
|
||||
which realpath 2>&1 > /dev/null || { echo >&2 "Eror: missing 'realpath' utility"; exit 1; }
|
||||
|
||||
check_util() {
|
||||
which $1 2>&1 > /dev/null || { echo >&2 "Error: missing '$1' utility"; exit 1; }
|
||||
}
|
||||
|
||||
check_util dirname
|
||||
check_util realpath
|
||||
check_util basename
|
||||
check_util awk
|
||||
|
||||
SCRIPTPATH=`dirname $0`
|
||||
SCRIPTPATH=`realpath $SCRIPTPATH`
|
||||
|
||||
CONFIG_FILES=`ls $SCRIPTPATH/configure.d/*.conf | sort`
|
||||
FILES_COUNT=`echo $CONFIG_FILES | wc -w`
|
||||
|
||||
rm -f $SCRIPTPATH/modules/generated_defines.h
|
||||
generate_config() {
|
||||
rm -f config.out
|
||||
progress=0
|
||||
for file in $CONFIG_FILES; do
|
||||
progress=$((progress+1))
|
||||
echo -ne "Generating configuration: $progress/$FILES_COUNT\033[0K\r"
|
||||
CONF="$(/bin/bash $file "check")"
|
||||
echo "$(basename $file) $CONF" >> config.out
|
||||
done
|
||||
echo ""
|
||||
}
|
||||
|
||||
files_count=`echo $CONFIG_FILES | wc -w`
|
||||
progress=0
|
||||
generate_header() {
|
||||
rm -f $SCRIPTPATH/modules/generated_defines.h
|
||||
progress=0
|
||||
for file in $CONFIG_FILES; do
|
||||
progress=$((progress+1))
|
||||
echo -ne "Configuring OpenCAS: $progress/$FILES_COUNT\033[0K\r"
|
||||
CONF=$(cat config.out | awk -v file=$(basename $file) '{ if ($1 == file) print $2 }')
|
||||
/bin/bash $file "apply" "$CONF"
|
||||
done
|
||||
echo ""
|
||||
}
|
||||
|
||||
for file in $CONFIG_FILES; do
|
||||
progress=$((progress+1))
|
||||
echo -ne "Configuring OpenCAS: $progress/$files_count\033[0K\r"
|
||||
/bin/bash $file
|
||||
done
|
||||
echo -ne " \033[0K\r"
|
||||
if [ -z "$1" ]; then
|
||||
generate_config
|
||||
CONFIG_FILE="config.out"
|
||||
else
|
||||
CONFIG_FILE="$1"
|
||||
fi
|
||||
|
||||
generate_header
|
||||
|
||||
Reference in New Issue
Block a user