[c0aeabe] | 1 | # $Id$
|
---|
[3bbf6d5] | 2 |
|
---|
[3c61617] | 3 | validate_target() {
|
---|
| 4 |
|
---|
| 5 | local -r ERROR_MSG_pt1='The variable \"${L_arrow}TARGET${R_arrow}\" value ${L_arrow}${BOLD}${TARGET}${R_arrow} is invalid for the ${L_arrow}${BOLD}${ARCH}${R_arrow} architecture'
|
---|
| 6 | local -r ERROR_MSG_pt2=' check the config file ${BOLD}${GREEN}\<$(echo $PROGNAME | tr [a-z] [A-Z])/config\> or \<common/config\>${OFF}'
|
---|
| 7 |
|
---|
| 8 | local -r PARAM_VALS='TARGET: ${L_arrow}${BOLD}${TARGET}${OFF}${R_arrow}'
|
---|
| 9 | local -r PARAM_VALS2='TARGET32: ${L_arrow}${BOLD}${TARGET32}${OFF}${R_arrow}'
|
---|
| 10 |
|
---|
| 11 | write_error_and_die() {
|
---|
| 12 | echo -e "\n${DD_BORDER}"
|
---|
| 13 | echo -e "`eval echo ${ERROR_MSG_pt1}`" >&2
|
---|
| 14 | echo -e "`eval echo ${ERROR_MSG_pt2}`" >&2
|
---|
| 15 | echo -e "${DD_BORDER}\n"
|
---|
| 16 | exit 1
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | if [[ ! "${TARGET32}" = "" ]]; then
|
---|
| 20 | [[ $verbose = "1" ]] && echo -e "`eval echo $PARAM_VALS2`"
|
---|
| 21 | fi
|
---|
| 22 | [[ $verbose = "1" ]] && echo -e "`eval echo $PARAM_VALS`"
|
---|
| 23 |
|
---|
| 24 | case "${ARCH}" in
|
---|
| 25 | "x86") [[ "${TARGET}" = "i486-pc-linux-gnu" ]] && return
|
---|
| 26 | [[ "${TARGET}" = "i586-pc-linux-gnu" ]] && return
|
---|
| 27 | [[ "${TARGET}" = "i686-pc-linux-gnu" ]] && return
|
---|
| 28 | write_error_and_die
|
---|
| 29 | ;;
|
---|
| 30 | "ppc") [[ "${TARGET}" = "powerpc-unknown-linux-gnu" ]] && return
|
---|
| 31 | write_error_and_die
|
---|
| 32 | ;;
|
---|
| 33 | "mips") [[ "${TARGET}" = "mipsel-unknown-linux-gnu" ]] && return
|
---|
| 34 | [[ "${TARGET}" = "mips-unknown-linux-gnu" ]] && return
|
---|
| 35 | write_error_and_die
|
---|
| 36 | ;;
|
---|
| 37 | "sparc") [[ "${TARGET}" = "sparcv9-unknown-linux-gnu" ]] && return
|
---|
| 38 | write_error_and_die
|
---|
| 39 | ;;
|
---|
| 40 | "sparcv8") [[ "${TARGET}" = "sparc-unknown-linux-gnu" ]] && return
|
---|
| 41 | write_error_and_die
|
---|
| 42 | ;;
|
---|
| 43 | "x86_64-64") [[ "${TARGET}" = "x86_64-unknown-linux-gnu" ]] && return
|
---|
| 44 | write_error_and_die
|
---|
| 45 | ;;
|
---|
| 46 | "mips64-64") [[ "${TARGET}" = "mipsel-unknown-linux-gnu" ]] && return
|
---|
| 47 | [[ "${TARGET}" = "mips-unknown-linux-gnu" ]] && return
|
---|
| 48 | write_error_and_die
|
---|
| 49 | ;;
|
---|
| 50 | "sparc64-64") [[ "${TARGET}" = "sparc64-unknown-linux-gnu" ]] && return
|
---|
| 51 | write_error_and_die
|
---|
| 52 | ;;
|
---|
| 53 | "alpha") [[ "${TARGET}" = "alpha-unknown-linux-gnu" ]] && return
|
---|
| 54 | write_error_and_die
|
---|
| 55 | ;;
|
---|
| 56 | "x86_64") [[ "${TARGET}" = "x86_64-unknown-linux-gnu" ]] &&
|
---|
| 57 | [[ "${TARGET32}" = "i686-pc-linux-gnu" ]] && return
|
---|
| 58 | write_error_and_die
|
---|
| 59 | ;;
|
---|
| 60 | "mips64") [[ "${TARGET}" = "mipsel-unknown-linux-gnu" ]] &&
|
---|
| 61 | [[ "${TARGET32}" = "mipsel-unknown-linux-gnu" ]] && return
|
---|
[ffd482f] | 62 |
|
---|
[3c61617] | 63 | [[ "${TARGET}" = "mips-unknown-linux-gnu" ]] &&
|
---|
| 64 | [[ "${TARGET32}" = "mips-unknown-linux-gnu" ]] && return
|
---|
| 65 | write_error_and_die
|
---|
| 66 | ;;
|
---|
[ffd482f] | 67 | "sparc64") [[ "${TARGET}" = "sparc64-unknown-linux-gnu" ]] &&
|
---|
[3c61617] | 68 | [[ "${TARGET32}" = "sparcv9-unknown-linux-gnu" ]] && return
|
---|
| 69 | write_error_and_die
|
---|
| 70 | ;;
|
---|
| 71 | "ppc64") [[ "${TARGET}" = "powerpc64-unknown-linux-gnu" ]] &&
|
---|
[ffd482f] | 72 | [[ "${TARGET32}" = "powerpc-unknown-linux-gnu" ]] && return
|
---|
[3c61617] | 73 | write_error_and_die
|
---|
| 74 | ;;
|
---|
| 75 | *) write_error_and_die
|
---|
[ffd482f] | 76 | ;;
|
---|
[3c61617] | 77 | esac
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 |
|
---|
[22670f4] | 81 | #----------------------------#
|
---|
| 82 | validate_config() { # Are the config values sane (within reason)
|
---|
| 83 | #----------------------------#
|
---|
| 84 | : <<inline_doc
|
---|
[3bbf6d5] | 85 | Validates the configuration parameters. The global var PROGNAME selects the
|
---|
[22670f4] | 86 | parameter list.
|
---|
[3bbf6d5] | 87 |
|
---|
[1b9148c] | 88 | input vars: $1 0/1 0=quiet, 1=verbose output
|
---|
[22670f4] | 89 | externals: color constants
|
---|
| 90 | PROGNAME (lfs,clfs,hlfs,blfs)
|
---|
| 91 | modifies: none
|
---|
| 92 | returns: nothing
|
---|
| 93 | on error: write text to console and dies
|
---|
| 94 | on success: write text to console and returns
|
---|
| 95 | inline_doc
|
---|
| 96 |
|
---|
[51a0bb1] | 97 | # First internal variables, then the ones that change the book's flavour, and lastly system configuration variables
|
---|
| 98 | local -r blfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG DEPEND TEST"
|
---|
[c16896d] | 99 | local -r hlfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG RUNMAKE MODEL GRSECURITY_HOST TEST STRIP FSTAB CONFIG KEYMAP PAGE TIMEZONE LANG LC_ALL"
|
---|
[51a0bb1] | 100 | local -r clfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG RUNMAKE METHOD ARCH TARGET TEST STRIP FSTAB BOOT_CONFIG CONFIG KEYMAP VIMLANG PAGE TIMEZONE LANG"
|
---|
[c16896d] | 101 | local -r lfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG RUNMAKE TEST STRIP FSTAB CONFIG VIMLANG PAGE TIMEZONE LANG"
|
---|
[22670f4] | 102 |
|
---|
[3c61617] | 103 | local -r ERROR_MSG_pt1='The variable \"${L_arrow}${config_param}${R_arrow}\" value ${L_arrow}${BOLD}${!config_param}${R_arrow} is invalid,'
|
---|
| 104 | local -r ERROR_MSG_pt2=' check the config file ${BOLD}${GREEN}\<$(echo $PROGNAME | tr [a-z] [A-Z])/config\> or \<common/config\>${OFF}'
|
---|
[22670f4] | 105 | local -r PARAM_VALS='${config_param}: ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
|
---|
| 106 |
|
---|
| 107 | local PARAM_LIST=
|
---|
| 108 |
|
---|
| 109 | local config_param
|
---|
| 110 | local validation_str
|
---|
[cc82e37] | 111 | local verbose=$1
|
---|
[ffd482f] | 112 |
|
---|
[22670f4] | 113 | write_error_and_die() {
|
---|
| 114 | echo -e "\n${DD_BORDER}"
|
---|
[3c61617] | 115 | echo -e "`eval echo ${ERROR_MSG_pt1}`" >&2
|
---|
| 116 | echo -e "`eval echo ${ERROR_MSG_pt2}`" >&2
|
---|
[22670f4] | 117 | echo -e "${DD_BORDER}\n"
|
---|
| 118 | exit 1
|
---|
| 119 | }
|
---|
| 120 |
|
---|
[cc82e37] | 121 | validate_str() {
|
---|
| 122 | # This is the 'regexp' test available in bash-3.0..
|
---|
| 123 | # using it as a poor man's test for substring
|
---|
| 124 | [[ $verbose = "1" ]] && echo -e "`eval echo $PARAM_VALS`"
|
---|
| 125 | if [[ ! "${validation_str}" =~ "x${!config_param}x" ]] ; then
|
---|
| 126 | # parameter value entered is no good
|
---|
| 127 | write_error_and_die
|
---|
| 128 | fi
|
---|
| 129 | }
|
---|
[ffd482f] | 130 |
|
---|
[22670f4] | 131 | set +e
|
---|
[cc82e37] | 132 | for PARAM_GROUP in ${PROGNAME}_PARAM_LIST; do
|
---|
[22670f4] | 133 | for config_param in ${!PARAM_GROUP}; do
|
---|
| 134 | # This is a tricky little piece of code.. executes a cmd string.
|
---|
| 135 | case $config_param in
|
---|
| 136 | BUILDDIR) # We cannot have an <empty> or </> root mount point
|
---|
[cc82e37] | 137 | [[ $verbose = "1" ]] && echo -e "`eval echo $PARAM_VALS`"
|
---|
[22670f4] | 138 | if [[ "xx x/x" =~ "x${!config_param}x" ]]; then
|
---|
| 139 | write_error_and_die
|
---|
| 140 | fi
|
---|
| 141 | continue ;;
|
---|
| 142 | TIMEZONE) continue;;
|
---|
[cc82e37] | 143 | MKFILE) continue;;
|
---|
| 144 | HPKG) validation_str="x0x x1x"; validate_str; continue ;;
|
---|
| 145 | RUNMAKE) validation_str="x0x x1x"; validate_str; continue ;;
|
---|
| 146 | TEST) validation_str="x0x x1x x2x x3x"; validate_str; continue ;;
|
---|
| 147 | STRIP) validation_str="x0x x1x"; validate_str; continue ;;
|
---|
| 148 | VIMLANG) validation_str="x0x x1x"; validate_str; continue ;;
|
---|
| 149 | DEPEND) validation_str="x0x x1x x2x"; validate_str; continue ;;
|
---|
| 150 | MODEL) validation_str="xglibcx xuclibcx"; validate_str; continue ;;
|
---|
| 151 | PAGE) validation_str="xletterx xA4x"; validate_str; continue ;;
|
---|
| 152 | GRSECURITY_HOST) validation_str="x0x x1x"; validate_str; continue ;;
|
---|
| 153 | METHOD) validation_str="xchrootx xbootx"; validate_str; continue ;;
|
---|
| 154 | ARCH) validation_str="xx86x xx86_64x xx86_64-64x xsparcx xsparcv8x xsparc64x xsparc64-64x xmipsx xmips64x xmips64-64x xppcx xppc64x xalphax"; validate_str; continue ;;
|
---|
[3c61617] | 155 | TARGET) validate_target; continue ;;
|
---|
[22670f4] | 156 | esac
|
---|
| 157 |
|
---|
[fdd1aa3e] | 158 |
|
---|
[cc82e37] | 159 | if [[ "${config_param}" = "LC_ALL" ]]; then
|
---|
| 160 | [[ $1 = "1" ]] && echo "`eval echo $PARAM_VALS`"
|
---|
| 161 | [[ -z "${!config_param}" ]] && continue
|
---|
| 162 | # See it the locale values exist on this machine
|
---|
| 163 | if [[ "`locale -a | grep -c ${!config_param}`" > 0 ]]; then
|
---|
| 164 | continue
|
---|
| 165 | else # If you make it this far then there is a problem
|
---|
| 166 | write_error_and_die
|
---|
| 167 | fi
|
---|
| 168 | fi
|
---|
[dbf2c71] | 169 |
|
---|
[cc82e37] | 170 | if [[ "${config_param}" = "LANG" ]]; then
|
---|
| 171 | [[ $verbose = "1" ]] && echo "`eval echo $PARAM_VALS`"
|
---|
| 172 | [[ -z "${!config_param}" ]] && continue
|
---|
[dbf2c71] | 173 | # See it the locale values exist on this machine
|
---|
[cc82e37] | 174 | if [[ "`locale -a | grep -c ${!config_param}`" > 0 ]]; then
|
---|
| 175 | continue
|
---|
| 176 | else # If you make it this far then there is a problem
|
---|
| 177 | write_error_and_die
|
---|
| 178 | fi
|
---|
[ffd482f] | 179 | fi
|
---|
[cc82e37] | 180 |
|
---|
| 181 |
|
---|
| 182 | if [[ "${config_param}" = "KEYMAP" ]]; then
|
---|
| 183 | [[ $verbose = "1" ]] && echo "`eval echo $PARAM_VALS`"
|
---|
| 184 | [[ "${!config_param}" = "none" ]] && continue
|
---|
[ffd482f] | 185 | if [[ -e "/usr/share/kbd/keymaps/${!config_param}" ]] &&
|
---|
[cc82e37] | 186 | [[ -s "/usr/share/kbd/keymaps/${!config_param}" ]]; then
|
---|
| 187 | continue
|
---|
| 188 | else
|
---|
| 189 | write_error_and_die
|
---|
| 190 | fi
|
---|
| 191 | fi
|
---|
| 192 |
|
---|
| 193 | if [[ "${config_param}" = "SRC_ARCHIVE" ]]; then
|
---|
| 194 | [[ $verbose = "1" ]] && echo -n "`eval echo $PARAM_VALS`"
|
---|
| 195 | if [ ! -z ${SRC_ARCHIVE} ]; then
|
---|
| 196 | if [ ! -d ${SRC_ARCHIVE} ]; then
|
---|
| 197 | echo " -- is NOT a directory"
|
---|
| 198 | write_error_and_die
|
---|
| 199 | fi
|
---|
| 200 | if [ ! -w ${SRC_ARCHIVE} ]; then
|
---|
| 201 | echo -n "${nl_} [${BOLD}${YELLOW}WARN$OFF] You do not have <write> access to this directory, ${nl_}${tab_}downloaded files can not be saved in this archive"
|
---|
| 202 | fi
|
---|
[dbf2c71] | 203 | fi
|
---|
[cc82e37] | 204 | echo
|
---|
| 205 | continue
|
---|
[dbf2c71] | 206 | fi
|
---|
[3bbf6d5] | 207 |
|
---|
[cc82e37] | 208 | if [[ "${config_param}" = "FSTAB" ]]; then
|
---|
| 209 | [[ $verbose = "1" ]] && echo "`eval echo $PARAM_VALS`"
|
---|
| 210 | [[ -z "${!config_param}" ]] && continue
|
---|
| 211 | if [[ -e "${!config_param}" ]] &&
|
---|
| 212 | [[ -s "${!config_param}" ]]; then
|
---|
| 213 | continue
|
---|
| 214 | else
|
---|
| 215 | write_error_and_die
|
---|
| 216 | fi
|
---|
| 217 | fi
|
---|
[22670f4] | 218 |
|
---|
[cc82e37] | 219 | if [[ "${config_param}" = "BOOK" ]]; then
|
---|
| 220 | [[ $verbose = "1" ]] && echo "`eval echo $PARAM_VALS`"
|
---|
[22670f4] | 221 | [[ ! "${WC}" = 1 ]] && continue
|
---|
[cc82e37] | 222 | [[ -z "${!config_param}" ]] && continue
|
---|
[ffd482f] | 223 | if [[ -e "${!config_param}" ]] &&
|
---|
| 224 | [[ -s "${!config_param}" ]]; then
|
---|
[cc82e37] | 225 | continue
|
---|
| 226 | else
|
---|
| 227 | write_error_and_die
|
---|
| 228 | fi
|
---|
[22670f4] | 229 | fi
|
---|
[cc82e37] | 230 |
|
---|
| 231 | if [[ "${config_param}" = "CONFIG" ]]; then
|
---|
| 232 | [[ $verbose = "1" ]] && echo "`eval echo $PARAM_VALS`"
|
---|
| 233 | [[ -z "${!config_param}" ]] && continue
|
---|
[ffd482f] | 234 | if [[ -e "${!config_param}" ]] &&
|
---|
[cc82e37] | 235 | [[ -s "${!config_param}" ]]; then
|
---|
| 236 | continue
|
---|
| 237 | else
|
---|
| 238 | write_error_and_die
|
---|
| 239 | fi
|
---|
[6eef5ef] | 240 | fi
|
---|
[cc82e37] | 241 |
|
---|
| 242 | if [[ "${config_param}" = "BOOT_CONFIG" ]]; then
|
---|
| 243 | if [[ "${METHOD}" = "boot" ]]; then
|
---|
| 244 | [[ $verbose = "1" ]] && echo "`eval echo $PARAM_VALS`"
|
---|
| 245 | # There must be a config file when the build method is 'boot'
|
---|
| 246 | [[ -e "${!config_param}" ]] && [[ -s "${!config_param}" ]] && continue
|
---|
| 247 | # If you make it this far then there is a problem
|
---|
| 248 | write_error_and_die
|
---|
| 249 | fi
|
---|
| 250 | fi
|
---|
[51a0bb1] | 251 | done
|
---|
[22670f4] | 252 | done
|
---|
[6eef5ef] | 253 |
|
---|
[22670f4] | 254 | set -e
|
---|
[cc82e37] | 255 | echo "$tab_***${BOLD}${GREEN} ${PARAM_GROUP%%_*T} config parameters look good${OFF} ***"
|
---|
[22670f4] | 256 | }
|
---|