[877cc6a] | 1 | # $Id$
|
---|
| 2 |
|
---|
[c14e4b3] | 3 | declare -r dotSTR=".................."
|
---|
| 4 |
|
---|
[877cc6a] | 5 |
|
---|
| 6 | #----------------------------#
|
---|
[45f82718] | 7 | validate_config() { # Are the config values sane (within reason)
|
---|
[877cc6a] | 8 | #----------------------------#
|
---|
| 9 | : <<inline_doc
|
---|
| 10 | Validates the configuration parameters. The global var PROGNAME selects the
|
---|
| 11 | parameter list.
|
---|
| 12 |
|
---|
| 13 | input vars: none
|
---|
| 14 | externals: color constants
|
---|
[350625a] | 15 | PROGNAME (lfs,hlfs,clfs,clfs2,clfs3,blfs)
|
---|
[877cc6a] | 16 | modifies: none
|
---|
| 17 | returns: nothing
|
---|
[45f82718] | 18 | on error: write text to console and dies
|
---|
[877cc6a] | 19 | on success: write text to console and returns
|
---|
| 20 | inline_doc
|
---|
| 21 |
|
---|
[350625a] | 22 | # Common settings by Config.in sections and books family
|
---|
| 23 | local -r BOOK_common="BOOK CUSTOM_TOOLS"
|
---|
| 24 | local -r BOOK_clfsX="ARCH TARGET"
|
---|
| 25 | local -r GENERAL_common="LUSER LGROUP LHOME BUILDDIR CLEAN GETPKG SRC_ARCHIVE \
|
---|
[de63126] | 26 | SERVER RETRYSRCDOWNLOAD RETRYDOWNLOADCNT DOWNLOADTIMEOUT \
|
---|
[3158dfa] | 27 | RUNMAKE"
|
---|
[350625a] | 28 | local -r BUILD_chroot="TEST BOMB_TEST STRIP"
|
---|
[f546320] | 29 | local -r BUILD_common="FSTAB CONFIG TIMEZONE PAGE LANG INSTALL_LOG"
|
---|
[350625a] | 30 | local -r ADVANCED_chroot="COMPARE RUN_ICA RUN_FARCE ITERATIONS OPTIMIZE"
|
---|
| 31 | local -r ADVANCED_common="REPORT REBUILD_MAKEFILE"
|
---|
| 32 |
|
---|
| 33 | # BOOK Settings by book
|
---|
[7bd0866] | 34 | local -r LFS_book="$BOOK_common INITSYS BLFS_TOOL"
|
---|
[6d5844c] | 35 | #local -r HLFS_added="SET_SSP SET_ASLR SET_PAX SET_HARDENED_TMP SET_WARNINGS \
|
---|
| 36 | # SET_MISC SET_BLOWFISH"
|
---|
| 37 | local -r HLFS_added=""
|
---|
[d035526] | 38 | local -r HLFS_book="$BOOK_common BLFS_TOOL MODEL KERNEL GRSECURITY_HOST $HLFS_added"
|
---|
[350625a] | 39 | local -r CLFS_book="$BOOK_common BLFS_TOOL METHOD $BOOK_clfsX TARGET32 BOOT_CONFIG"
|
---|
| 40 | local -r CLFS2_book="$BOOK_common BLFS_TOOL $BOOK_clfsX"
|
---|
| 41 | local -r CLFS3_book="$BOOK_common $BOOK_clfsX PLATFORM MIPS_LEVEL"
|
---|
| 42 |
|
---|
| 43 | # Build Settings by book
|
---|
[df42c7c] | 44 | local -r LFS_build="$BUILD_chroot VIMLANG $BUILD_common PKGMNGT FULL_LOCALE WRAP_INSTALL"
|
---|
[05760bc] | 45 | local -r HLFS_build="$BUILD_chroot $BUILD_common"
|
---|
[f546320] | 46 | local -r CLFS_build="$BUILD_chroot VIMLANG $BUILD_common"
|
---|
| 47 | local -r CLFS2_build="STRIP VIMLANG $BUILD_common"
|
---|
| 48 | local -r CLFS3_build=" $BUILD_common"
|
---|
[350625a] | 49 |
|
---|
[77fa8ba] | 50 | # System Settings by book (only LFS for now)
|
---|
| 51 | local -r LFS_system="HOSTNAME INTERFACE IP_ADDR GATEWAY PREFIX BROADCAST DOMAIN DNS1 DNS2 FONT CONSOLE_MAP UNICODE KEYMAP"
|
---|
| 52 |
|
---|
[350625a] | 53 | # Full list of books settings
|
---|
[77fa8ba] | 54 | local -r lfs_PARAM_LIST="$LFS_book $GENERAL_common $LFS_build $LFS_system $ADVANCED_chroot $ADVANCED_common"
|
---|
[350625a] | 55 | local -r hlfs_PARAM_LIST="$HLFS_book $GENERAL_common $HLFS_build $ADVANCED_chroot $ADVANCED_common"
|
---|
| 56 | local -r clfs_PARAM_LIST="$CLFS_book $GENERAL_common $CLFS_build $ADVANCED_chroot $ADVANCED_common"
|
---|
| 57 | local -r clfs2_PARAM_LIST="$CLFS2_book $GENERAL_common $CLFS2_build $ADVANCED_common"
|
---|
| 58 | local -r clfs3_PARAM_LIST="$CLFS3_book $GENERAL_common $CLFS3_build $ADVANCED_common"
|
---|
[854854e] | 59 | # local -r blfs_PARAM_LIST="BRANCH_ID BLFS_ROOT BLFS_XML TRACKING_DIR"
|
---|
[877cc6a] | 60 |
|
---|
[854854e] | 61 | # Additional variables
|
---|
| 62 | local -r blfs_tool_PARAM_LIST="\
|
---|
| 63 | BLFS_TREE BLFS_BRANCH_ID BLFS_ROOT BLFS_XML TRACKING_DIR \
|
---|
[e042e91] | 64 | DEP_LIBXML DEP_LIBXSLT DEP_DBXML DEP_LYNX DEP_SUDO DEP_WGET \
|
---|
[854854e] | 65 | DEP_SVN DEP_GPM DEP_OPENSSL DEP_PYTHON"
|
---|
[53f291f] | 66 | local -r custom_tool_PARAM_LIST="TRACKING_DIR"
|
---|
[4965fa8] | 67 |
|
---|
[350625a] | 68 | # Internal variables
|
---|
[877cc6a] | 69 | local -r ERROR_MSG_pt1='The variable \"${L_arrow}${config_param}${R_arrow}\" value ${L_arrow}${BOLD}${!config_param}${R_arrow} is invalid,'
|
---|
[4965fa8] | 70 | local -r ERROR_MSG_pt2='rerun make and fix your configuration settings${OFF}'
|
---|
[c14e4b3] | 71 | local -r PARAM_VALS='${config_param}${dotSTR:${#config_param}} ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
|
---|
[877cc6a] | 72 |
|
---|
[3e7ceed] | 73 | local PARAM_LIST=
|
---|
[877cc6a] | 74 | local config_param
|
---|
| 75 | local validation_str
|
---|
[45f82718] | 76 | local save_param
|
---|
[877cc6a] | 77 |
|
---|
| 78 | write_error_and_die() {
|
---|
| 79 | echo -e "\n${DD_BORDER}"
|
---|
| 80 | echo -e "`eval echo ${ERROR_MSG_pt1}`" >&2
|
---|
| 81 | echo -e "`eval echo ${ERROR_MSG_pt2}`" >&2
|
---|
| 82 | echo -e "${DD_BORDER}\n"
|
---|
| 83 | exit 1
|
---|
| 84 | }
|
---|
| 85 |
|
---|
[14bcaee] | 86 | # This function is only used when testing package management files.
|
---|
| 87 | write_pkg_and_die() {
|
---|
| 88 | echo -e "\n${DD_BORDER}"
|
---|
| 89 | echo "Package management is requested but" >&2
|
---|
| 90 | echo -e $* >&2
|
---|
| 91 | echo -e "${DD_BORDER}\n"
|
---|
| 92 | exit 1
|
---|
| 93 | }
|
---|
| 94 |
|
---|
[45f82718] | 95 | validate_file() {
|
---|
| 96 | # For parameters ending with a '+' failure causes a warning message only
|
---|
| 97 | echo -n "`eval echo $PARAM_VALS`"
|
---|
| 98 | while test $# -gt 0 ; do
|
---|
| 99 | case $1 in
|
---|
| 100 | # Failures caused program exit
|
---|
| 101 | "-z") [[ -z "${!config_param}" ]] && echo "${tab_}<-- NO file name given" && write_error_and_die ;;
|
---|
| 102 | "-e") [[ ! -e "${!config_param}" ]] && echo "${tab_}<-- file does not exist" && write_error_and_die ;;
|
---|
| 103 | "-s") [[ ! -s "${!config_param}" ]] && echo "${tab_}<-- file has zero bytes" && write_error_and_die ;;
|
---|
| 104 | "-r") [[ ! -r "${!config_param}" ]] && echo "${tab_}<-- no read permission " && write_error_and_die ;;
|
---|
| 105 | "-w") [[ ! -w "${!config_param}" ]] && echo "${tab_}<-- no write permission" && write_error_and_die ;;
|
---|
| 106 | "-x") [[ ! -x "${!config_param}" ]] && echo "${tab_}<-- file cannot be executed" && write_error_and_die ;;
|
---|
| 107 | # Warning messages only
|
---|
| 108 | "-z+") [[ -z "${!config_param}" ]] && echo && return ;;
|
---|
| 109 | esac
|
---|
| 110 | shift 1
|
---|
| 111 | done
|
---|
| 112 | echo
|
---|
| 113 | }
|
---|
| 114 |
|
---|
| 115 | validate_dir() {
|
---|
| 116 | # For parameters ending with a '+' failure causes a warning message only
|
---|
| 117 | echo -n "`eval echo $PARAM_VALS`"
|
---|
| 118 | while test $# -gt 0 ; do
|
---|
| 119 | case $1 in
|
---|
| 120 | "-z") [[ -z "${!config_param}" ]] && echo "${tab_}NO directory name given" && write_error_and_die ;;
|
---|
| 121 | "-d") [[ ! -d "${!config_param}" ]] && echo "${tab_}This is NOT a directory" && write_error_and_die ;;
|
---|
| 122 | "-w") if [[ ! -w "${!config_param}" ]]; then
|
---|
| 123 | echo "${nl_}${DD_BORDER}"
|
---|
| 124 | echo "${tab_}${RED}You do not have ${L_arrow}write${R_arrow}${RED} access to the directory${OFF}"
|
---|
| 125 | echo "${tab_}${BOLD}${!config_param}${OFF}"
|
---|
| 126 | echo "${DD_BORDER}${nl_}"
|
---|
| 127 | exit 1
|
---|
| 128 | fi ;;
|
---|
| 129 | # Warnings only
|
---|
| 130 | "-w+") if [[ ! -w "${!config_param}" ]]; then
|
---|
| 131 | echo "${nl_}${DD_BORDER}"
|
---|
| 132 | echo "${tab_}WARNING-- You do not have ${L_arrow}write${R_arrow} access to the directory${OFF}"
|
---|
| 133 | echo "${tab_} -- ${BOLD}${!config_param}${OFF}"
|
---|
| 134 | echo "${DD_BORDER}"
|
---|
| 135 | fi ;;
|
---|
| 136 | "-z+") [[ -z "${!config_param}" ]] && echo "${tab_}<-- NO directory name given" && return
|
---|
| 137 | esac
|
---|
| 138 | shift 1
|
---|
| 139 | done
|
---|
| 140 | echo
|
---|
| 141 | }
|
---|
| 142 |
|
---|
[877cc6a] | 143 | set +e
|
---|
[45f82718] | 144 | PARAM_GROUP=${PROGNAME}_PARAM_LIST
|
---|
| 145 | for config_param in ${!PARAM_GROUP}; do
|
---|
| 146 | case $config_param in
|
---|
[4da2512] | 147 | # Envvars that depend on other settings to be displayed
|
---|
[de63126] | 148 | COMPARE) [[ ! "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
---|
| 149 | RUN_ICA) [[ "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
---|
| 150 | RUN_FARCE) [[ "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
---|
| 151 | ITERATIONS) [[ "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
---|
| 152 | BOMB_TEST) [[ ! "$TEST" = "0" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
---|
| 153 | TARGET32) [[ -n "${TARGET32}" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
---|
| 154 | MIPS_LEVEL) [[ "${ARCH}" = "mips" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
---|
| 155 | SERVER) [[ "$GETPKG" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
---|
| 156 | RETRYSRCDOWNLOAD) [[ "$GETPKG" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
---|
| 157 | RETRYDOWNLOADCNT) [[ "$GETPKG" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
---|
| 158 | DOWNLOADTIMEOUT) [[ "$GETPKG" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
|
---|
[4da2512] | 159 |
|
---|
| 160 | # Envars that requires some validation
|
---|
| 161 | LUSER) echo -e "`eval echo $PARAM_VALS`"
|
---|
| 162 | [[ "${!config_param}" = "**EDIT ME**" ]] && write_error_and_die
|
---|
| 163 | ;;
|
---|
| 164 | LGROUP) echo -e "`eval echo $PARAM_VALS`"
|
---|
| 165 | [[ "${!config_param}" = "**EDIT ME**" ]] && write_error_and_die
|
---|
| 166 | ;;
|
---|
| 167 | # BOOK validation. Very ugly, need be fixed
|
---|
[4965fa8] | 168 | BOOK) if [[ "${WORKING_COPY}" = "y" ]] ; then
|
---|
[45f82718] | 169 | validate_dir -z -d
|
---|
| 170 | else
|
---|
[4da2512] | 171 | echo -e "`eval echo $PARAM_VALS`"
|
---|
[0210014] | 172 | fi
|
---|
| 173 | ;;
|
---|
[4da2512] | 174 | # Validate directories, testable states:
|
---|
| 175 | # fatal -z -d -w,
|
---|
| 176 | # warning -z+ -w+
|
---|
[401f81e] | 177 | SRC_ARCHIVE) [[ "$GETPKG" = "y" ]] && validate_dir -z+ -d -w+ ;;
|
---|
[4da2512] | 178 | # The build directory/partition MUST exist and be writable by the user
|
---|
| 179 | BUILDDIR) validate_dir -z -d -w
|
---|
[a96109a] | 180 | [[ "xx x/x" =~ x${!config_param}x ]] && write_error_and_die ;;
|
---|
[962793a] | 181 | LHOME) validate_dir -z -d ;;
|
---|
[45f82718] | 182 |
|
---|
[4da2512] | 183 | # Validate files, testable states:
|
---|
| 184 | # fatal -z -e -s -w -x -r,
|
---|
| 185 | # warning -z+
|
---|
[45f82718] | 186 | FSTAB) validate_file -z+ -e -s ;;
|
---|
| 187 | CONFIG) validate_file -z+ -e -s ;;
|
---|
| 188 | BOOT_CONFIG) [[ "${METHOD}" = "boot" ]] && validate_file -z -e -s ;;
|
---|
| 189 |
|
---|
[5c575e1] | 190 | # Treatment of LANG parameter
|
---|
| 191 | LANG ) # See it the locale value has been set
|
---|
[45f82718] | 192 | echo -n "`eval echo $PARAM_VALS`"
|
---|
| 193 | [[ -z "${!config_param}" ]] &&
|
---|
| 194 | echo " -- Variable $config_param cannot be empty!" &&
|
---|
| 195 | write_error_and_die
|
---|
| 196 | echo
|
---|
| 197 | ;;
|
---|
[c59f9a0] | 198 |
|
---|
[77fa8ba] | 199 | # Treatment of HOSTNAME
|
---|
| 200 | HOSTNAME) echo -e "`eval echo $PARAM_VALS`"
|
---|
| 201 | [[ "${!config_param}" = "**EDIT ME**" ]] && write_error_and_die
|
---|
| 202 | ;;
|
---|
| 203 |
|
---|
[14bcaee] | 204 | # Case of PKGMNGT: two files, packageManager.xml and packInstall.sh
|
---|
| 205 | # must exist in $PKGMNGTDIR:
|
---|
| 206 | PKGMNGT) echo -e "`eval echo $PARAM_VALS`"
|
---|
| 207 | if [ ! -e "$PKGMNGTDIR/packageManager.xml" ]; then
|
---|
| 208 | write_pkg_and_die $PKGMNGTDIR/packageManager.xml does not exist
|
---|
| 209 | fi
|
---|
| 210 | if [ ! -e "$PKGMNGTDIR/packInstall.sh" ]; then
|
---|
| 211 | write_pkg_and_die $PKGMNGTDIR/packInstall.sh does not exist
|
---|
| 212 | fi
|
---|
| 213 | if [ ! -s "$PKGMNGTDIR/packageManager.xml" ]; then
|
---|
| 214 | write_pkg_and_die $PKGMNGTDIR/packageManager.xml has zero size
|
---|
| 215 | fi
|
---|
| 216 | if [ ! -s "$PKGMNGTDIR/packInstall.sh" ]; then
|
---|
| 217 | write_pkg_and_die $PKGMNGTDIR/packInstall.sh has zero size
|
---|
| 218 | fi
|
---|
| 219 | if [ ! -r "$PKGMNGTDIR/packageManager.xml" ]; then
|
---|
| 220 | write_pkg_and_die $PKGMNGTDIR/packageManager.xml is not readable
|
---|
| 221 | fi
|
---|
| 222 | if [ ! -r "$PKGMNGTDIR/packInstall.sh" ]; then
|
---|
| 223 | write_pkg_and_die $PKGMNGTDIR/packInstall.sh is not readable
|
---|
| 224 | fi
|
---|
| 225 | ;;
|
---|
[350625a] | 226 | # Display non-validated envars found in ${PROGNAME}_PARAM_LIST
|
---|
| 227 | * ) echo -e "`eval echo $PARAM_VALS`" ;;
|
---|
| 228 |
|
---|
[45f82718] | 229 | esac
|
---|
| 230 | done
|
---|
[4965fa8] | 231 |
|
---|
| 232 | if [[ "${BLFS_TOOL}" = "y" ]] ; then
|
---|
| 233 | echo "${nl_} ${BLUE}blfs-tool settings${OFF}"
|
---|
| 234 | for config_param in ${blfs_tool_PARAM_LIST}; do
|
---|
| 235 | echo -e "`eval echo $PARAM_VALS`"
|
---|
| 236 | done
|
---|
| 237 | fi
|
---|
| 238 |
|
---|
[53f291f] | 239 | if [[ "${CUSTOM_TOOLS}" = "y" ]] && [[ "${BLFS_TOOL}" = "n" ]] ; then
|
---|
| 240 | for config_param in ${custom_tool_PARAM_LIST}; do
|
---|
| 241 | echo -e "`eval echo $PARAM_VALS`"
|
---|
| 242 | done
|
---|
| 243 | fi
|
---|
| 244 |
|
---|
[877cc6a] | 245 | set -e
|
---|
[21f0a91] | 246 | echo "${nl_}***${BOLD}${GREEN} ${PARAM_GROUP%%_*T} config parameters look good${OFF} ***${nl_}"
|
---|
[877cc6a] | 247 | }
|
---|