<commit_before># $Id$

validate_target() {

  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'
  local -r ERROR_MSG_pt2='  check the config file ${BOLD}${GREEN}\<$(echo $PROGNAME | tr [a-z] [A-Z])/config\> or \<common/config\>${OFF}'

  local -r PARAM_VALS='TARGET: ${L_arrow}${BOLD}${TARGET}${OFF}${R_arrow}'
  local -r PARAM_VALS2='TARGET32: ${L_arrow}${BOLD}${TARGET32}${OFF}${R_arrow}'

  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
  }

 if [[ ! "${TARGET32}" = "" ]]; then
    echo -e "`eval echo $PARAM_VALS2`"
 fi
 echo -e "`eval echo $PARAM_VALS`"

 case "${ARCH}" in
   "x86")        [[ "${TARGET}" = "i486-pc-linux-gnu" ]] && return
                 [[ "${TARGET}" = "i586-pc-linux-gnu" ]] && return
                 [[ "${TARGET}" = "i686-pc-linux-gnu" ]] && return
    ;;
   "ppc")        [[ "${TARGET}" = "powerpc-unknown-linux-gnu" ]] && return
    ;;
   "mips")       [[ "${TARGET}" = "mipsel-unknown-linux-gnu" ]] && return
                 [[ "${TARGET}" = "mips-unknown-linux-gnu"   ]] && return
    ;;
   "sparc")      [[ "${TARGET}" = "sparcv9-unknown-linux-gnu" ]] && return
    ;;
   "x86_64-64")  [[ "${TARGET}" = "x86_64-unknown-linux-gnu" ]] && return
    ;;
   "mips64-64")  [[ "${TARGET}" = "mipsel-unknown-linux-gnu" ]] && return
                 [[ "${TARGET}" = "mips-unknown-linux-gnu"   ]] && return
    ;;
   "sparc64-64") [[ "${TARGET}" = "sparc64-unknown-linux-gnu" ]] && return
    ;;
   "alpha")      [[ "${TARGET}" = "alpha-unknown-linux-gnu" ]] && return
    ;;
   "x86_64")     [[ "${TARGET}"   = "x86_64-unknown-linux-gnu" ]] &&
                 [[ "${TARGET32}" = "i686-pc-linux-gnu" ]] && return
    ;;
   "mips64")     [[ "${TARGET}"   = "mipsel-unknown-linux-gnu" ]] &&
                 [[ "${TARGET32}" = "mipsel-unknown-linux-gnu" ]] && return

                 [[ "${TARGET}"   = "mips-unknown-linux-gnu" ]] &&
                 [[ "${TARGET32}" = "mips-unknown-linux-gnu" ]] && return
    ;;
   "sparc64")    [[ "${TARGET}"   = "sparc64-unknown-linux-gnu" ]] &&
                 [[ "${TARGET32}" = "sparcv9-unknown-linux-gnu" ]] && return
    ;;
   "ppc64")      [[ "${TARGET}"   = "powerpc64-unknown-linux-gnu" ]] &&
                 [[ "${TARGET32}" = "powerpc-unknown-linux-gnu"   ]] && return
    ;;
   *)  write_error_and_die
   ;;
 esac

   # If you end up here then there was an error SO...
   write_error_and_die
}


#----------------------------#
validate_config()    {       # Are the config values sane (within reason)
#----------------------------#
: <<inline_doc
      Validates the configuration parameters. The global var PROGNAME selects the
    parameter list.

    input vars: none
    externals:  color constants
                PROGNAME (lfs,clfs,hlfs,blfs)
    modifies:   none
    returns:    nothing
    on error:	write text to console and dies
    on success: write text to console and returns
inline_doc

  # First internal variables, then the ones that change the book's flavour, and lastly system configuration variables
  local -r blfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG         DEPEND                TEST"
  local -r hlfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG RUNMAKE MODEL GRSECURITY_HOST TEST REPORT STRIP FSTAB             CONFIG KEYMAP         PAGE TIMEZONE LANG LC_ALL"
  local -r clfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG RUNMAKE METHOD  ARCH  TARGET  TEST REPORT STRIP FSTAB BOOT_CONFIG CONFIG KEYMAP VIMLANG PAGE TIMEZONE LANG"
  local -r  lfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG RUNMAKE                       TEST REPORT STRIP FSTAB             CONFIG        VIMLANG PAGE TIMEZONE LANG"

  local -r ERROR_MSG_pt1='The variable \"${L_arrow}${config_param}${R_arrow}\" value ${L_arrow}${BOLD}${!config_param}${R_arrow} is invalid,'
  local -r ERROR_MSG_pt2=' check the config file ${BOLD}${GREEN}\<$(echo $PROGNAME | tr [a-z] [A-Z])/config\> or \<common/config\>${OFF}'
  local -r PARAM_VALS='${config_param}: ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'

  local    PARAM_LIST=

  local config_param
  local validation_str

  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
  }

  validate_str() {
     # This is the 'regexp' test available in bash-3.0..
     # using it as a poor man's test for substring
     echo -e "`eval echo $PARAM_VALS`"
     if [[ ! "${validation_str}" =~ "x${!config_param}x" ]] ; then
       # parameter value entered is no good
       write_error_and_die
     fi
  }

  set +e
  for PARAM_GROUP in ${PROGNAME}_PARAM_LIST; do
    for config_param in ${!PARAM_GROUP}; do
      # This is a tricky little piece of code.. executes a cmd string.
      case $config_param in
        BUILDDIR) # We cannot have an <empty> or </> root mount point
            echo -e "`eval echo $PARAM_VALS`"
            if [[ "xx x/x" =~ "x${!config_param}x" ]]; then
              write_error_and_die
            fi
            continue  ;;
        TIMEZONE)  continue;;
        MKFILE)    continue;;
        HPKG)      validation_str="x0x x1x";          validate_str; continue ;;
        RUNMAKE)   validation_str="x0x x1x";          validate_str; continue ;;
        TEST)      validation_str="x0x x1x x2x x3x";  validate_str; continue ;;
        REPORT)    validation_str="x0x x1x";          validate_str;
            if [[ "${!config_param}" = "1" ]] && [[ `type -p bc` ]]; then
              continue
            else
              echo -e "  ${BOLD}The bc binary was not found${OFF}"
              echo -e "  The SBU and disk usage report creation will be skiped"
              REPORT=0
              continue
            fi ;;
        STRIP)     validation_str="x0x x1x";          validate_str; continue ;;
        VIMLANG)   validation_str="x0x x1x";          validate_str; continue ;;
        DEPEND)    validation_str="x0x x1x x2x";      validate_str; continue ;;<commit_msg>Fixing a test.<commit_after># $Id$

validate_target() {

  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'
  local -r ERROR_MSG_pt2='  check the config file ${BOLD}${GREEN}\<$(echo $PROGNAME | tr [a-z] [A-Z])/config\> or \<common/config\>${OFF}'

  local -r PARAM_VALS='TARGET: ${L_arrow}${BOLD}${TARGET}${OFF}${R_arrow}'
  local -r PARAM_VALS2='TARGET32: ${L_arrow}${BOLD}${TARGET32}${OFF}${R_arrow}'

  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
  }

 if [[ ! "${TARGET32}" = "" ]]; then
    echo -e "`eval echo $PARAM_VALS2`"
 fi
 echo -e "`eval echo $PARAM_VALS`"

 case "${ARCH}" in
   "x86")        [[ "${TARGET}" = "i486-pc-linux-gnu" ]] && return
                 [[ "${TARGET}" = "i586-pc-linux-gnu" ]] && return
                 [[ "${TARGET}" = "i686-pc-linux-gnu" ]] && return
    ;;
   "ppc")        [[ "${TARGET}" = "powerpc-unknown-linux-gnu" ]] && return
    ;;
   "mips")       [[ "${TARGET}" = "mipsel-unknown-linux-gnu" ]] && return
                 [[ "${TARGET}" = "mips-unknown-linux-gnu"   ]] && return
    ;;
   "sparc")      [[ "${TARGET}" = "sparcv9-unknown-linux-gnu" ]] && return
    ;;
   "x86_64-64")  [[ "${TARGET}" = "x86_64-unknown-linux-gnu" ]] && return
    ;;
   "mips64-64")  [[ "${TARGET}" = "mipsel-unknown-linux-gnu" ]] && return
                 [[ "${TARGET}" = "mips-unknown-linux-gnu"   ]] && return
    ;;
   "sparc64-64") [[ "${TARGET}" = "sparc64-unknown-linux-gnu" ]] && return
    ;;
   "alpha")      [[ "${TARGET}" = "alpha-unknown-linux-gnu" ]] && return
    ;;
   "x86_64")     [[ "${TARGET}"   = "x86_64-unknown-linux-gnu" ]] &&
                 [[ "${TARGET32}" = "i686-pc-linux-gnu" ]] && return
    ;;
   "mips64")     [[ "${TARGET}"   = "mipsel-unknown-linux-gnu" ]] &&
                 [[ "${TARGET32}" = "mipsel-unknown-linux-gnu" ]] && return

                 [[ "${TARGET}"   = "mips-unknown-linux-gnu" ]] &&
                 [[ "${TARGET32}" = "mips-unknown-linux-gnu" ]] && return
    ;;
   "sparc64")    [[ "${TARGET}"   = "sparc64-unknown-linux-gnu" ]] &&
                 [[ "${TARGET32}" = "sparcv9-unknown-linux-gnu" ]] && return
    ;;
   "ppc64")      [[ "${TARGET}"   = "powerpc64-unknown-linux-gnu" ]] &&
                 [[ "${TARGET32}" = "powerpc-unknown-linux-gnu"   ]] && return
    ;;
   *)  write_error_and_die
   ;;
 esac

   # If you end up here then there was an error SO...
   write_error_and_die
}


#----------------------------#
validate_config()    {       # Are the config values sane (within reason)
#----------------------------#
: <<inline_doc
      Validates the configuration parameters. The global var PROGNAME selects the
    parameter list.

    input vars: none
    externals:  color constants
                PROGNAME (lfs,clfs,hlfs,blfs)
    modifies:   none
    returns:    nothing
    on error:	write text to console and dies
    on success: write text to console and returns
inline_doc

  # First internal variables, then the ones that change the book's flavour, and lastly system configuration variables
  local -r blfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG         DEPEND                TEST"
  local -r hlfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG RUNMAKE MODEL GRSECURITY_HOST TEST REPORT STRIP FSTAB             CONFIG KEYMAP         PAGE TIMEZONE LANG LC_ALL"
  local -r clfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG RUNMAKE METHOD  ARCH  TARGET  TEST REPORT STRIP FSTAB BOOT_CONFIG CONFIG KEYMAP VIMLANG PAGE TIMEZONE LANG"
  local -r  lfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG RUNMAKE                       TEST REPORT STRIP FSTAB             CONFIG        VIMLANG PAGE TIMEZONE LANG"

  local -r ERROR_MSG_pt1='The variable \"${L_arrow}${config_param}${R_arrow}\" value ${L_arrow}${BOLD}${!config_param}${R_arrow} is invalid,'
  local -r ERROR_MSG_pt2=' check the config file ${BOLD}${GREEN}\<$(echo $PROGNAME | tr [a-z] [A-Z])/config\> or \<common/config\>${OFF}'
  local -r PARAM_VALS='${config_param}: ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'

  local    PARAM_LIST=

  local config_param
  local validation_str

  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
  }

  validate_str() {
     # This is the 'regexp' test available in bash-3.0..
     # using it as a poor man's test for substring
     echo -e "`eval echo $PARAM_VALS`"
     if [[ ! "${validation_str}" =~ "x${!config_param}x" ]] ; then
       # parameter value entered is no good
       write_error_and_die
     fi
  }

  set +e
  for PARAM_GROUP in ${PROGNAME}_PARAM_LIST; do
    for config_param in ${!PARAM_GROUP}; do
      # This is a tricky little piece of code.. executes a cmd string.
      case $config_param in
        BUILDDIR) # We cannot have an <empty> or </> root mount point
            echo -e "`eval echo $PARAM_VALS`"
            if [[ "xx x/x" =~ "x${!config_param}x" ]]; then
              write_error_and_die
            fi
            continue  ;;
        TIMEZONE)  continue;;
        MKFILE)    continue;;
        HPKG)      validation_str="x0x x1x";          validate_str; continue ;;
        RUNMAKE)   validation_str="x0x x1x";          validate_str; continue ;;
        TEST)      validation_str="x0x x1x x2x x3x";  validate_str; continue ;;
        REPORT)    validation_str="x0x x1x";          validate_str;
            if [[ "${!config_param}" = "1" ]]; then
              if [[ `type -p bc` ]]; then
                continue
              else
                echo -e "  ${BOLD}The bc binary was not found${OFF}"
                echo -e "  The SBU and disk usage report creation will be skiped"
                REPORT=0
                continue
              fi
            fi ;;
        STRIP)     validation_str="x0x x1x";          validate_str; continue ;;
        VIMLANG)   validation_str="x0x x1x";          validate_str; continue ;;
        DEPEND)    validation_str="x0x x1x x2x";      validate_str; continue ;;
{'fraction_non_alphanumeric': 0.1679743795036029, 'fraction_numerical': 0.017133706965572457, 'mean_word_length': 2.365032327586207, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7635822', 'n_tokens_mistral': 4461, 'n_tokens_neox': 4233, 'n_words': 1017}