Changeset 392e11c3 for common


Ignore:
Timestamp:
08/26/2006 05:35:57 PM (18 years ago)
Author:
Manuel Canales Esparcia <manuel@…>
Branches:
experimental
Children:
2b0f8a5
Parents:
0818ea6
Message:

func_validate_config.sh clean-up.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • common/func_validate_configs.sh

    r0818ea6 r392e11c3  
    22
    33declare -r dotSTR=".................."
    4 
    5 #----------------------------#
    6 validate_target() {          #
    7 #----------------------------#
    8   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'
    9   local -r ERROR_MSG_pt2='  check the config file ${BOLD}${GREEN}\<$(echo $PROGNAME | tr [a-z] [A-Z])/config\> or \<common/config\>${OFF}'
    10 
    11   local -r PARAM_VALS='TARGET${dotSTR:6} ${L_arrow}${BOLD}${TARGET}${OFF}${R_arrow}'
    12   local -r PARAM_VALS2='TARGET32${dotSTR:8} ${L_arrow}${BOLD}${TARGET32}${OFF}${R_arrow}'
    13 
    14   write_error_and_die() {
    15     echo -e "\n${DD_BORDER}"
    16     echo -e "`eval echo ${ERROR_MSG_pt1}`" >&2
    17     echo -e "`eval echo ${ERROR_MSG_pt2}`" >&2
    18     echo -e "${DD_BORDER}\n"
    19     exit 1
    20   }
    21 
    22  if [[ ! "${TARGET32}" = "" ]]; then
    23     echo -e "`eval echo $PARAM_VALS2`"
    24  fi
    25  echo -e "`eval echo $PARAM_VALS`"
    26 
    27  case "${ARCH}" in
    28    "x86")        [[ "${TARGET}" = "i486-pc-linux-gnu" ]] && return
    29                  [[ "${TARGET}" = "i586-pc-linux-gnu" ]] && return
    30                  [[ "${TARGET}" = "i686-pc-linux-gnu" ]] && return
    31     ;;
    32    "ppc")        [[ "${TARGET}" = "powerpc-unknown-linux-gnu" ]] && return
    33     ;;
    34    "mips")       [[ "${TARGET}" = "mipsel-unknown-linux-gnu" ]] && return
    35                  [[ "${TARGET}" = "mips-unknown-linux-gnu"   ]] && return
    36     ;;
    37    "sparc")      [[ "${TARGET}" = "sparcv9-unknown-linux-gnu" ]] && return
    38     ;;
    39    "x86_64-64")  [[ "${TARGET}" = "x86_64-unknown-linux-gnu" ]] && return
    40     ;;
    41    "mips64-64")  [[ "${TARGET}" = "mips64el-unknown-linux-gnu" ]] && return
    42                  [[ "${TARGET}" = "mips64-unknown-linux-gnu"   ]] && return
    43     ;;
    44    "sparc64-64") [[ "${TARGET}" = "sparc64-unknown-linux-gnu" ]] && return
    45     ;;
    46    "alpha")      [[ "${TARGET}" = "alpha-unknown-linux-gnu" ]] && return
    47     ;;
    48    "x86_64")     [[ "${TARGET}"   = "x86_64-unknown-linux-gnu" ]] &&
    49                  [[ "${TARGET32}" = "i686-pc-linux-gnu" ]] && return
    50     ;;
    51    "mips64")     [[ "${TARGET}"   = "mips64el-unknown-linux-gnu" ]] &&
    52                  [[ "${TARGET32}" = "mipsel-unknown-linux-gnu" ]] && return
    53 
    54                  [[ "${TARGET}"   = "mips64-unknown-linux-gnu" ]] &&
    55                  [[ "${TARGET32}" = "mips-unknown-linux-gnu" ]] && return
    56     ;;
    57    "sparc64")    [[ "${TARGET}"   = "sparc64-unknown-linux-gnu" ]] &&
    58                  [[ "${TARGET32}" = "sparc-unknown-linux-gnu" ]] && return
    59     ;;
    60    "ppc64")      [[ "${TARGET}"   = "powerpc64-unknown-linux-gnu" ]] &&
    61                  [[ "${TARGET32}" = "powerpc-unknown-linux-gnu"   ]] && return
    62     ;;
    63    "arm")        [[ "${TARGET}"   = "arm-unknown-linux-gnu" ]] && return
    64     ;;
    65    *)  write_error_and_die
    66    ;;
    67  esac
    68 
    69    # If you end up here then there was an error SO...
    70    write_error_and_die
    71 }
    724
    735
     
    8921
    9022  # First internal variables, then the ones that change the book's flavour, and lastly system configuration variables
    91   local -r  hlfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE MODEL GRSECURITY_HOST TEST BOMB_TEST OPTIMIZE REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB             CONFIG GETKERNEL KEYMAP         PAGE TIMEZONE LANG LC_ALL LUSER LGROUP"
    92   local -r  clfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE METHOD  ARCH  TARGET TEST BOMB_TEST OPTIMIZE REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB BOOT_CONFIG CONFIG GETKERNEL KEYMAP VIMLANG PAGE TIMEZONE LANG        LUSER LGROUP"
    93   local -r clfs2_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE         ARCH  TARGET                 OPTIMIZE REPORT                                      STRIP FSTAB             CONFIG GETKERNEL KEYMAP VIMLANG PAGE TIMEZONE LANG        LUSER LGROUP"
    94   local -r   lfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE                       TEST BOMB_TEST OPTIMIZE REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB             CONFIG GETKERNEL        VIMLANG PAGE TIMEZONE LANG        LUSER LGROUP"
     23  local -r  hlfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE MODEL  GRSECURITY_HOST      TEST BOMB_TEST OPTIMIZE REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB             CONFIG GETKERNEL KEYMAP         PAGE TIMEZONE LANG LC_ALL LUSER LGROUP"
     24  local -r  clfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE METHOD ARCH TARGET TARGET32 TEST BOMB_TEST OPTIMIZE REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB BOOT_CONFIG CONFIG GETKERNEL KEYMAP VIMLANG PAGE TIMEZONE LANG        LUSER LGROUP"
     25  local -r clfs2_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE        ARCH TARGET                         OPTIMIZE REPORT                                      STRIP FSTAB             CONFIG GETKERNEL KEYMAP VIMLANG PAGE TIMEZONE LANG        LUSER LGROUP"
     26  local -r   lfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE                             TEST BOMB_TEST OPTIMIZE REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB             CONFIG GETKERNEL        VIMLANG PAGE TIMEZONE LANG        LUSER LGROUP"
    9527  local -r  blfs_PARAM_LIST="BRANCH_ID BLFS_ROOT BLFS_XML TRACKING_DIR"
    9628
     
    11042    echo -e "${DD_BORDER}\n"
    11143    exit 1
    112   }
    113 
    114   validate_against_str() {
    115      # This is the 'regexp' test available in bash-3.0..
    116      # using it as a poor man's test for substring
    117      echo -e "`eval echo $PARAM_VALS`"
    118      if [[ ! "$1" =~ "x${!config_param}x" ]] ; then
    119        # parameter value entered is no good
    120        write_error_and_die
    121      fi
    12244  }
    12345
     
    17395  PARAM_GROUP=${PROGNAME}_PARAM_LIST
    17496  for config_param in ${!PARAM_GROUP}; do
    175     # This is a tricky little piece of code.. executes a cmd string.
    17697    case $config_param in
    177       TIMEZONE)   echo -e "`eval echo $PARAM_VALS`" ;;
     98      # Allways display this, if found in ${PROGNAME}_PARAM_LIST
     99      GETPKG          | \
     100      RUNMAKE         | \
     101      TEST            | \
     102      OPTIMIZE        | \
     103      STRIP           | \
     104      VIMLANG         | \
     105      MODEL           | \
     106      METHOD          | \
     107      ARCH            | \
     108      TARGET          | \
     109      GRSECURITY_HOST | \
     110      TIMEZONE        | \
     111      PAGE)   echo -e "`eval echo $PARAM_VALS`" ;;
    178112
    179       # Validate general parameters..
    180       GETPKG)     validate_against_str "xnx xyx" ;;
     113      # Envvars that depend on other settings to be displayed
    181114      GETKERNEL ) if [[ -z "$CONFIG" ]] && [[ -z "$BOOT_CONFIG" ]] ; then
    182                     [[ "$GETPKG" = "y" ]] && validate_against_str "xnx xyx"
     115                    [[ "$GETPKG" = "y" ]] && echo -e "`eval echo $PARAM_VALS`"
    183116                  fi ;;
    184       RUNMAKE)    validate_against_str "xnx xyx" ;;
    185       REPORT)     validate_against_str "xnx xyx"
     117      COMPARE)    [[ ! "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
     118      RUN_ICA)    [[ "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
     119      RUN_FARCE)  [[ "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
     120      ITERATIONS) [[ "$COMPARE" = "y" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
     121      BOMB_TEST)  [[ ! "$TEST" = "0" ]] && echo -e "`eval echo $PARAM_VALS`" ;;
     122      TARGET32)   [[ -n "${TARGET32}" ]] &&  echo -e "`eval echo $PARAM_VALS`" ;;
     123
     124      # Envars that requires some validation
     125      LUSER)      echo -e "`eval echo $PARAM_VALS`"
     126                  [[ "${!config_param}" = "**EDIT ME**" ]] && write_error_and_die
     127                  ;;
     128      LGROUP)     echo -e "`eval echo $PARAM_VALS`"
     129                  [[ "${!config_param}" = "**EDIT ME**" ]] && write_error_and_die
     130                  ;;
     131      REPORT)     echo -e "`eval echo $PARAM_VALS`"
    186132                  if [[ "${!config_param}" = "y" ]]; then
    187133                    if [[ `type -p bc` ]]; then
     
    194140                    fi
    195141                  fi ;;
    196       COMPARE)    if [[ ! "$COMPARE" = "y" ]]; then
    197                     validate_against_str "xnx xyx"
    198                   else
    199                     if [[ ! "${RUN_ICA}" = "y" ]] && [[ ! "${RUN_FARCE}" = "y" ]]; then
    200                        echo  "${nl_}${DD_BORDER}"
    201                        echo  "You have elected to analyse your build but have failed to select a tool." >&2
    202                        echo  "Edit /common/config and set ${L_arrow}${BOLD}RUN_ICA${R_arrow} and/or ${L_arrow}${BOLD}RUN_FARCE${R_arrow} to the required values" >&2
    203                        echo  "${DD_BORDER}${nl_}"
    204                        exit 1
    205                     fi
    206                   fi ;;
    207       RUN_ICA)    [[ "$COMPARE" = "y" ]] && validate_against_str "xnx xyx" ;;
    208       RUN_FARCE)  [[ "$COMPARE" = "y" ]] && validate_against_str "xnx xyx" ;;
    209       ITERATIONS) [[ "$COMPARE" = "y" ]] && validate_against_str "x2x x3x x4x x5x" ;;
    210       TEST)       validate_against_str "x0x x1x x2x x3x" ;;
    211       BOMB_TEST)  [[ ! "$TEST" = "0" ]] && validate_against_str "xnx xyx" ;;
    212       OPTIMIZE)   validate_against_str "x0x x1x x2x" ;;
    213       STRIP)      validate_against_str "xnx xyx" ;;
    214       VIMLANG)    validate_against_str "xnx xyx" ;;
    215       MODEL)      validate_against_str "xglibcx xuclibcx" ;;
    216       PAGE)       validate_against_str "xletterx xA4x" ;;
    217       METHOD)     validate_against_str "xchrootx xbootx" ;;
    218       ARCH)       validate_against_str "xx86x xx86_64x xx86_64-64x xsparcx xsparc64x xsparc64-64x xmipsx xmips64x xmips64-64x xppcx xppc64x xalphax xarmx" ;;
    219       TARGET)     validate_target ;;
    220       LUSER)      echo -e "`eval echo $PARAM_VALS`"
    221                   [[ "${!config_param}" = "**EDIT ME**" ]] && write_error_and_die
    222                   ;;
    223       LGROUP)     echo -e "`eval echo $PARAM_VALS`"
    224                   [[ "${!config_param}" = "**EDIT ME**" ]] && write_error_and_die
    225                   ;;
    226       GRSECURITY_HOST)  validate_against_str "xnx xyx" ;;
    227142
    228       # BOOK validation. Very ugly, need be fixed
     143        # BOOK validation. Very ugly, need be fixed
    229144      BOOK)        if [[ "${WC}" = "1" ]] ; then
    230145                     validate_dir -z -d
    231146                   else
    232                      validate_against_str "x${PROGNAME}-${LFSVRS}x"
     147                     echo -e "`eval echo $PARAM_VALS`"
    233148                   fi ;;
    234149
    235       # Validate directories, testable states:
    236       #  fatal   -z -d -w,
    237       #  warning -z+   -w+
     150        # Validate directories, testable states:
     151        #  fatal   -z -d -w,
     152        #  warning -z+   -w+
    238153      SRC_ARCHIVE) [[ "$GETPKG" = "y" ]] && validate_dir -z+ -d -w+ ;;
    239       BUILDDIR)   # The build directory/partition MUST exist and be writable by the user
    240                   validate_dir -z -d -w
    241                   [[ "xx x/x" =~ "x${!config_param}x" ]] &&
    242                        write_error_and_die
    243                   ;;
     154        # The build directory/partition MUST exist and be writable by the user
     155      BUILDDIR)   validate_dir -z -d -w
     156                  [[ "xx x/x" =~ "x${!config_param}x" ]] && write_error_and_die ;;
    244157
    245       # Validate files, testable states:
    246       #  fatal   -z -e -s -w -x -r,
    247       #  warning -z+
     158        # Validate files, testable states:
     159        #  fatal   -z -e -s -w -x -r,
     160        #  warning -z+
    248161      FSTAB)       validate_file -z+ -e -s ;;
    249162      CONFIG)      validate_file -z+ -e -s ;;
    250163      BOOT_CONFIG) [[ "${METHOD}" = "boot" ]] && validate_file -z -e -s ;;
    251164
    252       # Treatment of 'special' parameters
     165        # Treatment of 'special' parameters
    253166      LANG | \
    254167      LC_ALL)  # See it the locale values exist on this machine
     
    267180               ;;
    268181
    269       # BLFS params. No validation is required/allowed, IMHO
     182      # BLFS params.
    270183      BRANCH_ID | BLFS_ROOT | BLFS_XML )  echo "`eval echo $PARAM_VALS`" ;;
    271184      TRACKING_DIR ) validate_dir -z -d -w ;;
Note: See TracChangeset for help on using the changeset viewer.