source: common/func_validate_configs.sh@ a6b81cd

experimental
Last change on this file since a6b81cd was 4fcc4d4, checked in by George Boudreau <georgeb@…>, 19 years ago

common/func_validate_configs.sh, ADDED ppc64 as a valid architecture

  • Property mode set to 100644
File size: 5.3 KB
RevLine 
[3bbf6d5]1
[c0aeabe]2# $Id$
[3bbf6d5]3
[22670f4]4#----------------------------#
5validate_config() { # Are the config values sane (within reason)
6#----------------------------#
7: <<inline_doc
[3bbf6d5]8 Validates the configuration parameters. The global var PROGNAME selects the
[22670f4]9 parameter list.
[3bbf6d5]10
[1b9148c]11 input vars: $1 0/1 0=quiet, 1=verbose output
[22670f4]12 externals: color constants
13 PROGNAME (lfs,clfs,hlfs,blfs)
14 modifies: none
15 returns: nothing
16 on error: write text to console and dies
17 on success: write text to console and returns
18inline_doc
19
[fdd1aa3e]20 local -r lfs_PARAM_LIST="VIMLANG"
[dbf2c71]21 local -r blfs_PARAM_LIST="TEST DEPEND"
[3f858ca]22 local -r hlfs_PARAM_LIST="MODEL GRSECURITY_HOST"
[afd0232]23 local -r clfs_PARAM_LIST="ARCH METHOD VIMLANG"
[fdd1aa3e]24 local -r global_PARAM_LIST="BUILDDIR HPKG RUNMAKE TEST STRIP PAGE TIMEZONE"
[22670f4]25
26 local -r ERROR_MSG='The variable \"${L_arrow}${config_param}${R_arrow}\" value ${L_arrow}${BOLD}${!config_param}${R_arrow} is invalid, ${nl_}check the config file ${BOLD}${GREEN}\<$PROGNAME.conf\>${OFF}'
27 local -r PARAM_VALS='${config_param}: ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
28
29 local PARAM_LIST=
30
31 local config_param
32 local validation_str
[3bbf6d5]33
[22670f4]34 write_error_and_die() {
35 echo -e "\n${DD_BORDER}"
36 echo -e "`eval echo ${ERROR_MSG}`" >&2
37 echo -e "${DD_BORDER}\n"
38 exit 1
39 }
40
41 set +e
42 for PARAM_GROUP in global_PARAM_LIST ${PROGNAME}_PARAM_LIST; do
43 for config_param in ${!PARAM_GROUP}; do
44 # This is a tricky little piece of code.. executes a cmd string.
45 [[ $1 = "1" ]] && echo -e "`eval echo $PARAM_VALS`"
46 case $config_param in
47 BUILDDIR) # We cannot have an <empty> or </> root mount point
48 if [[ "xx x/x" =~ "x${!config_param}x" ]]; then
49 write_error_and_die
50 fi
51 continue ;;
52 TIMEZONE) continue;;
53 MKFILE) continue;;
54 HPKG) validation_str="x0x x1x" ;;
55 RUNMAKE) validation_str="x0x x1x" ;;
[12a5707]56 TEST) validation_str="x0x x1x x2x x3x" ;;
[22670f4]57 STRIP) validation_str="x0x x1x" ;;
58 VIMLANG) validation_str="x0x x1x" ;;
59 DEPEND) validation_str="x0x x1x x2x" ;;
60 MODEL) validation_str="xglibcx xuclibcx" ;;
61 PAGE) validation_str="xletterx xA4x" ;;
[4fcc4d4]62 ARCH) validation_str="xx86x xx86_64x xx86_64-64x xsparcx xsparcv8x xsparc64x xsparc64-64x xmipsx xmips64x xmips64-64x xppcx xppc64x xalphax" ;;
[22670f4]63 GRSECURITY_HOST) validation_str="x0x x1x" ;;
[afd0232]64 METHOD) validation_str="xchrootx xbootx";;
[22670f4]65 *)
66 echo "WHAT PARAMETER IS THIS.. <<${config_param}>>"
67 exit
68 ;;
69 esac
70 #
71 # This is the 'regexp' test available in bash-3.0..
72 # using it as a poor man's test for substring
73 if [[ ! "${validation_str}" =~ "x${!config_param}x" ]] ; then
74 # parameter value entered is no good
75 write_error_and_die
76 fi
77 done # for loop
78
[fdd1aa3e]79
[dbf2c71]80 # No further tests needed on globals
[22670f4]81 if [[ "$PARAM_GROUP" = "global_PARAM_LIST" ]]; then
[dbf2c71]82
83 for config_param in LC_ALL LANG; do
84 [[ $1 = "1" ]] && echo "`eval echo $PARAM_VALS`"
85 [[ -z "${!config_param}" ]] && continue
86 # See it the locale values exist on this machine
87 [[ "`locale -a | grep -c ${!config_param}`" > 0 ]] && continue
88
89 # If you make it this far then there is a problem
90 write_error_and_die
91 done
[fdd1aa3e]92
[dbf2c71]93 for config_param in KEYMAP; do
94 [[ $1 = "1" ]] && echo "`eval echo $PARAM_VALS`"
[d540567]95 [[ "${!config_param}" = "none" ]] && continue
96 [[ -e "/usr/share/kbd/keymaps/${!config_param}" ]] && [[ -s "/usr/share/kbd/keymaps/${!config_param}" ]] && continue
[dbf2c71]97
98 # If you make it this far then there is a problem
99 write_error_and_die
100 done
[fdd1aa3e]101
102 # Check out the global param SRC_ARCHIVE
[dbf2c71]103 config_param=SRC_ARCHIVE
104 [[ $1 = "1" ]] && echo -n "`eval echo $PARAM_VALS`"
105 if [ ! -z ${SRC_ARCHIVE} ]; then
106 if [ ! -d ${SRC_ARCHIVE} ]; then
107 echo " -- is NOT a directory"
108 write_error_and_die
109 fi
110 if [ ! -w ${SRC_ARCHIVE} ]; then
111 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"
112 fi
113 fi
114 echo "${nl_} ${BOLD}${GREEN}global parameters are valid${OFF}${nl_}"
[22670f4]115 continue
116 fi
[3bbf6d5]117
[22670f4]118
[6eef5ef]119 for config_param in FSTAB BOOK CONFIG; do
[22670f4]120 [[ $1 = "1" ]] && echo "`eval echo $PARAM_VALS`"
121 if [[ $config_param = BOOK ]]; then
122 [[ ! "${WC}" = 1 ]] && continue
123 fi
124 [[ -z "${!config_param}" ]] && continue
125 [[ -e "${!config_param}" ]] && [[ -s "${!config_param}" ]] && continue
[3bbf6d5]126
[22670f4]127 # If you make it this far then there is a problem
128 write_error_and_die
129 done
[6eef5ef]130
131 [[ "$PROGNAME" = "clfs" ]] &&
132 for config_param in BOOT_CONFIG; do
133 if [[ "${METHOD}" = "boot" ]]; then
134 [[ $1 = "1" ]] && echo "`eval echo $PARAM_VALS`"
135 # There must be a config file when the build method is 'boot'
136 [[ -e "${!config_param}" ]] && [[ -s "${!config_param}" ]] && continue
137 # If you make it this far then there is a problem
138 write_error_and_die
139 fi
140 done
141 echo " ${BOLD}${GREEN}${PARAM_GROUP%%_*T} specific parameters are valid${OFF}"
[22670f4]142 done
[6eef5ef]143
[22670f4]144 set -e
145 echo "$tab_***${BOLD}${GREEN}Config parameters look good${OFF}***"
146}
Note: See TracBrowser for help on using the repository browser.