2006-08-12 01:41:10 +02:00
|
|
|
declare -r dotSTR=".................."
|
|
|
|
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
#----------------------------#
|
2006-04-29 16:44:29 +02:00
|
|
|
validate_config() { # Are the config values sane (within reason)
|
2006-04-06 21:35:22 +02:00
|
|
|
#----------------------------#
|
|
|
|
: <<inline_doc
|
2022-03-30 17:45:35 +02:00
|
|
|
Validates the configuration parameters.
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
input vars: none
|
|
|
|
externals: color constants
|
|
|
|
modifies: none
|
|
|
|
returns: nothing
|
2006-04-29 16:44:29 +02:00
|
|
|
on error: write text to console and dies
|
2006-04-06 21:35:22 +02:00
|
|
|
on success: write text to console and returns
|
|
|
|
inline_doc
|
|
|
|
|
2007-05-30 21:50:10 +02:00
|
|
|
# Common settings by Config.in sections and books family
|
2022-03-30 17:45:35 +02:00
|
|
|
local -r BOOK_common="COMMIT BOOK CUSTOM_TOOLS"
|
2007-05-30 21:50:10 +02:00
|
|
|
local -r GENERAL_common="LUSER LGROUP LHOME BUILDDIR CLEAN GETPKG SRC_ARCHIVE \
|
2010-03-12 04:32:25 +01:00
|
|
|
SERVER RETRYSRCDOWNLOAD RETRYDOWNLOADCNT DOWNLOADTIMEOUT \
|
2012-02-10 23:35:59 +01:00
|
|
|
RUNMAKE"
|
2022-06-15 15:09:49 +02:00
|
|
|
local -r BUILD_chroot="TEST STRIP"
|
2007-06-03 11:06:13 +02:00
|
|
|
local -r BUILD_common="FSTAB CONFIG TIMEZONE PAGE LANG INSTALL_LOG"
|
2019-04-24 18:16:20 +02:00
|
|
|
local -r ADVANCED_chroot="COMPARE RUN_ICA ITERATIONS OPTIMIZE"
|
2007-05-30 21:50:10 +02:00
|
|
|
local -r ADVANCED_common="REPORT REBUILD_MAKEFILE"
|
|
|
|
|
|
|
|
# BOOK Settings by book
|
2016-05-28 12:34:51 +02:00
|
|
|
local -r LFS_book="$BOOK_common INITSYS BLFS_TOOL"
|
2007-05-30 21:50:10 +02:00
|
|
|
|
|
|
|
# Build Settings by book
|
2023-08-30 20:20:59 +02:00
|
|
|
local -r LFS_build="$BUILD_chroot NCURSES5 $BUILD_common PKGMNGT FULL_LOCALE WRAP_INSTALL"
|
2007-05-30 21:50:10 +02:00
|
|
|
|
2022-03-01 21:09:30 +01:00
|
|
|
# System Settings by book
|
2019-03-09 09:11:37 +01:00
|
|
|
local -r LFS_system="HOSTNAME INTERFACE IP_ADDR GATEWAY PREFIX BROADCAST DOMAIN DNS1 DNS2 FONT KEYMAP LOCAL LOG_LEVEL"
|
2017-04-09 12:29:32 +02:00
|
|
|
|
2007-05-30 21:50:10 +02:00
|
|
|
# Full list of books settings
|
2021-08-28 19:53:16 +02:00
|
|
|
local -r lfs_PARAM_LIST="$LFS_book $GENERAL_common $LFS_build $LFS_system $ADVANCED_chroot N_PARALLEL REALSBU SAVE_CH5 $ADVANCED_common"
|
2013-11-16 23:35:25 +01:00
|
|
|
# local -r blfs_PARAM_LIST="BRANCH_ID BLFS_ROOT BLFS_XML TRACKING_DIR"
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2013-11-16 23:35:25 +01:00
|
|
|
# Additional variables
|
|
|
|
local -r blfs_tool_PARAM_LIST="\
|
2022-04-01 10:26:17 +02:00
|
|
|
BLFS_COMMIT BLFS_ROOT BLFS_XML TRACKING_DIR \
|
2016-11-24 17:52:03 +01:00
|
|
|
DEP_LIBXML DEP_LIBXSLT DEP_DBXML DEP_LYNX DEP_SUDO DEP_WGET \
|
2021-04-30 21:39:34 +02:00
|
|
|
DEP_GIT DEP_GPM"
|
2006-10-16 20:17:01 +02:00
|
|
|
local -r custom_tool_PARAM_LIST="TRACKING_DIR"
|
2006-08-29 20:18:06 +02:00
|
|
|
|
2007-05-30 21:50:10 +02:00
|
|
|
# Internal variables
|
2006-04-06 21:35:22 +02:00
|
|
|
local -r ERROR_MSG_pt1='The variable \"${L_arrow}${config_param}${R_arrow}\" value ${L_arrow}${BOLD}${!config_param}${R_arrow} is invalid,'
|
2006-08-29 20:18:06 +02:00
|
|
|
local -r ERROR_MSG_pt2='rerun make and fix your configuration settings${OFF}'
|
2006-08-12 01:41:10 +02:00
|
|
|
local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
|
2006-04-06 21:35:22 +02:00
|
|
|
|
2006-12-15 11:53:10 +01:00
|
|
|
local PARAM_LIST=
|
2006-04-06 21:35:22 +02:00
|
|
|
local config_param
|
|
|
|
local validation_str
|
2006-04-29 16:44:29 +02:00
|
|
|
local save_param
|
2006-04-06 21:35:22 +02:00
|
|
|
|
|
|
|
write_error_and_die() {
|
|
|
|
echo -e "\n${DD_BORDER}"
|
|
|
|
echo -e "`eval echo ${ERROR_MSG_pt1}`" >&2
|
|
|
|
echo -e "`eval echo ${ERROR_MSG_pt2}`" >&2
|
|
|
|
echo -e "${DD_BORDER}\n"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2017-03-19 15:54:28 +01:00
|
|
|
# This function is only used when testing package management files.
|
|
|
|
write_pkg_and_die() {
|
|
|
|
echo -e "\n${DD_BORDER}"
|
|
|
|
echo "Package management is requested but" >&2
|
|
|
|
echo -e $* >&2
|
|
|
|
echo -e "${DD_BORDER}\n"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2006-04-29 16:44:29 +02:00
|
|
|
validate_file() {
|
|
|
|
# For parameters ending with a '+' failure causes a warning message only
|
|
|
|
echo -n "`eval echo $PARAM_VALS`"
|
|
|
|
while test $# -gt 0 ; do
|
|
|
|
case $1 in
|
|
|
|
# Failures caused program exit
|
|
|
|
"-z") [[ -z "${!config_param}" ]] && echo "${tab_}<-- NO file name given" && write_error_and_die ;;
|
|
|
|
"-e") [[ ! -e "${!config_param}" ]] && echo "${tab_}<-- file does not exist" && write_error_and_die ;;
|
|
|
|
"-s") [[ ! -s "${!config_param}" ]] && echo "${tab_}<-- file has zero bytes" && write_error_and_die ;;
|
|
|
|
"-r") [[ ! -r "${!config_param}" ]] && echo "${tab_}<-- no read permission " && write_error_and_die ;;
|
|
|
|
"-w") [[ ! -w "${!config_param}" ]] && echo "${tab_}<-- no write permission" && write_error_and_die ;;
|
|
|
|
"-x") [[ ! -x "${!config_param}" ]] && echo "${tab_}<-- file cannot be executed" && write_error_and_die ;;
|
|
|
|
# Warning messages only
|
|
|
|
"-z+") [[ -z "${!config_param}" ]] && echo && return ;;
|
|
|
|
esac
|
|
|
|
shift 1
|
|
|
|
done
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
validate_dir() {
|
|
|
|
# For parameters ending with a '+' failure causes a warning message only
|
|
|
|
echo -n "`eval echo $PARAM_VALS`"
|
|
|
|
while test $# -gt 0 ; do
|
|
|
|
case $1 in
|
|
|
|
"-z") [[ -z "${!config_param}" ]] && echo "${tab_}NO directory name given" && write_error_and_die ;;
|
|
|
|
"-d") [[ ! -d "${!config_param}" ]] && echo "${tab_}This is NOT a directory" && write_error_and_die ;;
|
|
|
|
"-w") if [[ ! -w "${!config_param}" ]]; then
|
|
|
|
echo "${nl_}${DD_BORDER}"
|
|
|
|
echo "${tab_}${RED}You do not have ${L_arrow}write${R_arrow}${RED} access to the directory${OFF}"
|
|
|
|
echo "${tab_}${BOLD}${!config_param}${OFF}"
|
|
|
|
echo "${DD_BORDER}${nl_}"
|
|
|
|
exit 1
|
|
|
|
fi ;;
|
|
|
|
# Warnings only
|
|
|
|
"-w+") if [[ ! -w "${!config_param}" ]]; then
|
|
|
|
echo "${nl_}${DD_BORDER}"
|
|
|
|
echo "${tab_}WARNING-- You do not have ${L_arrow}write${R_arrow} access to the directory${OFF}"
|
|
|
|
echo "${tab_} -- ${BOLD}${!config_param}${OFF}"
|
|
|
|
echo "${DD_BORDER}"
|
|
|
|
fi ;;
|
|
|
|
"-z+") [[ -z "${!config_param}" ]] && echo "${tab_}<-- NO directory name given" && return
|
|
|
|
esac
|
|
|
|
shift 1
|
|
|
|
done
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
2006-04-06 21:35:22 +02:00
|
|
|
set +e
|
2022-03-30 17:45:35 +02:00
|
|
|
for config_param in $lfs_PARAM_LIST; do
|
2006-04-29 16:44:29 +02:00
|
|
|
case $config_param in
|
2006-08-29 20:16:27 +02:00
|
|
|
# Envvars that depend on other settings to be displayed
|
2010-03-12 04:32:25 +01:00
|
|
|
COMPARE) [[ ! "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
|
|
|
RUN_ICA) [[ "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
|
|
|
ITERATIONS) [[ "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
|
|
|
TARGET32) [[ -n "${TARGET32}" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
|
|
|
MIPS_LEVEL) [[ "${ARCH}" = "mips" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
|
|
|
SERVER) [[ "$GETPKG" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
|
|
|
RETRYSRCDOWNLOAD) [[ "$GETPKG" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
|
|
|
RETRYDOWNLOADCNT) [[ "$GETPKG" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
|
|
|
DOWNLOADTIMEOUT) [[ "$GETPKG" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
2021-08-28 19:53:16 +02:00
|
|
|
N_PARALLEL) [[ "$OPTIMIZE" -gt "0" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
2018-01-14 11:26:43 +01:00
|
|
|
REALSBU) [[ "$OPTIMIZE" = "2" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
2006-08-29 20:16:27 +02:00
|
|
|
|
|
|
|
# Envars that requires some validation
|
|
|
|
LUSER) echo -e "`eval echo $PARAM_VALS`"
|
|
|
|
[[ "${!config_param}" = "**EDIT ME**" ]] && write_error_and_die
|
|
|
|
;;
|
|
|
|
LGROUP) echo -e "`eval echo $PARAM_VALS`"
|
|
|
|
[[ "${!config_param}" = "**EDIT ME**" ]] && write_error_and_die
|
|
|
|
;;
|
|
|
|
# BOOK validation. Very ugly, need be fixed
|
2006-08-29 20:18:06 +02:00
|
|
|
BOOK) if [[ "${WORKING_COPY}" = "y" ]] ; then
|
2006-04-29 16:44:29 +02:00
|
|
|
validate_dir -z -d
|
|
|
|
else
|
2006-08-29 20:16:27 +02:00
|
|
|
echo -e "`eval echo $PARAM_VALS`"
|
2007-05-26 23:16:18 +02:00
|
|
|
fi
|
|
|
|
;;
|
2006-08-29 20:16:27 +02:00
|
|
|
# Validate directories, testable states:
|
|
|
|
# fatal -z -d -w,
|
|
|
|
# warning -z+ -w+
|
2006-08-16 19:42:54 +02:00
|
|
|
SRC_ARCHIVE) [[ "$GETPKG" = "y" ]] && validate_dir -z+ -d -w+ ;;
|
2006-08-29 20:16:27 +02:00
|
|
|
# The build directory/partition MUST exist and be writable by the user
|
2018-02-03 17:37:32 +01:00
|
|
|
BUILDDIR) validate_dir -z -d
|
2006-10-24 04:49:37 +02:00
|
|
|
[[ "xx x/x" =~ x${!config_param}x ]] && write_error_and_die ;;
|
2007-04-13 22:40:38 +02:00
|
|
|
LHOME) validate_dir -z -d ;;
|
2006-04-29 16:44:29 +02:00
|
|
|
|
2006-08-29 20:16:27 +02:00
|
|
|
# Validate files, testable states:
|
|
|
|
# fatal -z -e -s -w -x -r,
|
|
|
|
# warning -z+
|
2006-04-29 16:44:29 +02:00
|
|
|
FSTAB) validate_file -z+ -e -s ;;
|
|
|
|
CONFIG) validate_file -z+ -e -s ;;
|
|
|
|
BOOT_CONFIG) [[ "${METHOD}" = "boot" ]] && validate_file -z -e -s ;;
|
|
|
|
|
2007-06-03 12:27:05 +02:00
|
|
|
# Treatment of LANG parameter
|
|
|
|
LANG ) # See it the locale value has been set
|
2006-04-29 16:44:29 +02:00
|
|
|
echo -n "`eval echo $PARAM_VALS`"
|
|
|
|
[[ -z "${!config_param}" ]] &&
|
|
|
|
echo " -- Variable $config_param cannot be empty!" &&
|
|
|
|
write_error_and_die
|
|
|
|
echo
|
|
|
|
;;
|
2006-08-14 22:19:15 +02:00
|
|
|
|
2017-04-09 12:29:32 +02:00
|
|
|
# Treatment of HOSTNAME
|
|
|
|
HOSTNAME) echo -e "`eval echo $PARAM_VALS`"
|
|
|
|
[[ "${!config_param}" = "**EDIT ME**" ]] && write_error_and_die
|
|
|
|
;;
|
|
|
|
|
2017-03-19 15:54:28 +01:00
|
|
|
# Case of PKGMNGT: two files, packageManager.xml and packInstall.sh
|
2017-03-25 22:00:16 +01:00
|
|
|
# must exist in $PKGMNGTDIR if PKGMNGT='y':
|
2017-03-19 15:54:28 +01:00
|
|
|
PKGMNGT) echo -e "`eval echo $PARAM_VALS`"
|
2017-03-25 22:00:16 +01:00
|
|
|
if [ "$PKGMNGT" = y ]; then
|
|
|
|
if [ ! -e "$PKGMNGTDIR/packageManager.xml" ]; then
|
|
|
|
write_pkg_and_die $PKGMNGTDIR/packageManager.xml does not exist
|
|
|
|
fi
|
|
|
|
if [ ! -e "$PKGMNGTDIR/packInstall.sh" ]; then
|
|
|
|
write_pkg_and_die $PKGMNGTDIR/packInstall.sh does not exist
|
|
|
|
fi
|
|
|
|
if [ ! -s "$PKGMNGTDIR/packageManager.xml" ]; then
|
|
|
|
write_pkg_and_die $PKGMNGTDIR/packageManager.xml has zero size
|
|
|
|
fi
|
|
|
|
if [ ! -s "$PKGMNGTDIR/packInstall.sh" ]; then
|
|
|
|
write_pkg_and_die $PKGMNGTDIR/packInstall.sh has zero size
|
|
|
|
fi
|
|
|
|
if [ ! -r "$PKGMNGTDIR/packageManager.xml" ]; then
|
|
|
|
write_pkg_and_die $PKGMNGTDIR/packageManager.xml is not readable
|
|
|
|
fi
|
|
|
|
if [ ! -r "$PKGMNGTDIR/packInstall.sh" ]; then
|
|
|
|
write_pkg_and_die $PKGMNGTDIR/packInstall.sh is not readable
|
|
|
|
fi
|
2017-03-19 15:54:28 +01:00
|
|
|
fi
|
|
|
|
;;
|
2022-03-30 17:45:35 +02:00
|
|
|
# Display non-validated envars found in lfs_PARAM_LIST
|
2007-05-30 21:50:10 +02:00
|
|
|
* ) echo -e "`eval echo $PARAM_VALS`" ;;
|
|
|
|
|
2006-04-29 16:44:29 +02:00
|
|
|
esac
|
|
|
|
done
|
2006-08-29 20:18:06 +02:00
|
|
|
|
|
|
|
if [[ "${BLFS_TOOL}" = "y" ]] ; then
|
|
|
|
echo "${nl_} ${BLUE}blfs-tool settings${OFF}"
|
|
|
|
for config_param in ${blfs_tool_PARAM_LIST}; do
|
|
|
|
echo -e "`eval echo $PARAM_VALS`"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2006-10-16 20:17:01 +02:00
|
|
|
if [[ "${CUSTOM_TOOLS}" = "y" ]] && [[ "${BLFS_TOOL}" = "n" ]] ; then
|
|
|
|
for config_param in ${custom_tool_PARAM_LIST}; do
|
|
|
|
echo -e "`eval echo $PARAM_VALS`"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2006-04-06 21:35:22 +02:00
|
|
|
set -e
|
2006-05-02 19:38:25 +02:00
|
|
|
echo "${nl_}***${BOLD}${GREEN} ${PARAM_GROUP%%_*T} config parameters look good${OFF} ***${nl_}"
|
2006-04-06 21:35:22 +02:00
|
|
|
}
|