- Timestamp:
- 04/29/2006 02:44:29 PM (18 years ago)
- Branches:
- 1.0, 2.3, 2.3.x, 2.4, ablfs, ablfs-more, legacy, new_features, trunk
- Children:
- 0ad851d
- Parents:
- c7c5a53
- Location:
- common
- Files:
-
- 1 added
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
common/common-functions
rc7c5a53 r45f82718 76 76 [[ ${PROGNAME} != "blfs" ]] && 77 77 cat <<- -EOF- 78 79 ${BOLD} -C, --comparasion TYPE${OFF} 80 do iterative comparison analysis. That will take several time due that 81 the final system packages wil be rebuilded the times defined in the 82 ITERATIONS config option. 83 Analisys types allowed are: 84 ICA = do the ICA analisys designed by Greg Schafer 85 farce = do the farce analisys designed by Ken Moffat 86 both = perfom both ICA and farce analisys 78 87 79 88 ${BOLD} -F, --fstab FILE${OFF} -
common/config
rc7c5a53 r45f82718 63 63 KEYMAP=none 64 64 65 #=== Variables needed by ICA (Not implemented yet :-/)=== 66 #--- Run ICA testing 0/1 0(no)/1(yes) 65 #=== Variables needed by iterative comparison analysis === 66 #--- Should some iterative comparison analysis by made? 0(no)/1(yes) 67 COMPARE=0 68 69 #--- The number of final stage builds to create and compare, min. 2, max. 5 70 ITERATIONS=3 71 72 #--- Run ICA testing 0(no)/1(yes) 67 73 RUN_ICA=0 68 74 69 #--- The number of final stage builds to create and compare 70 ITERATIONS= 71 72 #--- ICA report log directory 73 ICALOGDIR=$JHALFSDIR/logs/ICA 75 #--- Run farce testing 0(no)/1(yes) 76 RUN_FARCE=0 74 77 75 78 #==== INTERNAL VARIABLES ==== … … 79 82 JHALFSDIR=$BUILDDIR/jhalfs 80 83 LOGDIR=$JHALFSDIR/logs 84 85 #--- ICA report log directory 86 ICALOGDIR=$LOGDIR/ICA 87 88 #--- farce report log directory 89 FARCELOGDIR=$LOGDIR/farce -
common/func_validate_configs.sh
rc7c5a53 r45f82718 1 1 # $Id$ 2 2 3 validate_target() { 4 3 #----------------------------# 4 validate_target() { # 5 #----------------------------# 5 6 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 7 local -r ERROR_MSG_pt2=' check the config file ${BOLD}${GREEN}\<$(echo $PROGNAME | tr [a-z] [A-Z])/config\> or \<common/config\>${OFF}' … … 68 69 69 70 #----------------------------# 70 validate_config() {# Are the config values sane (within reason)71 validate_config() { # Are the config values sane (within reason) 71 72 #----------------------------# 72 73 : <<inline_doc … … 79 80 modifies: none 80 81 returns: nothing 81 on error: 82 on error: write text to console and dies 82 83 on success: write text to console and returns 83 84 inline_doc … … 85 86 # First internal variables, then the ones that change the book's flavour, and lastly system configuration variables 86 87 local -r blfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG DEPEND TEST" 87 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"88 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"89 local -r lfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG RUNMAKE TEST REPORT STRIP FSTAB CONFIG VIMLANG PAGE TIMEZONE LANG"88 local -r hlfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG RUNMAKE MODEL GRSECURITY_HOST TEST REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB CONFIG KEYMAP PAGE TIMEZONE LANG LC_ALL" 89 local -r clfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG RUNMAKE METHOD ARCH TARGET TEST REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB BOOT_CONFIG CONFIG KEYMAP VIMLANG PAGE TIMEZONE LANG" 90 local -r lfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG RUNMAKE TEST REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB CONFIG VIMLANG PAGE TIMEZONE LANG" 90 91 91 92 local -r ERROR_MSG_pt1='The variable \"${L_arrow}${config_param}${R_arrow}\" value ${L_arrow}${BOLD}${!config_param}${R_arrow} is invalid,' … … 94 95 95 96 local PARAM_LIST= 96 97 97 local config_param 98 98 local validation_str 99 local save_param 99 100 100 101 write_error_and_die() { … … 106 107 } 107 108 108 validate_ str() {109 validate_against_str() { 109 110 # This is the 'regexp' test available in bash-3.0.. 110 111 # using it as a poor man's test for substring 111 112 echo -e "`eval echo $PARAM_VALS`" 112 if [[ ! "$ {validation_str}" =~ "x${!config_param}x" ]] ; then113 if [[ ! "$1" =~ "x${!config_param}x" ]] ; then 113 114 # parameter value entered is no good 114 115 write_error_and_die … … 116 117 } 117 118 119 validate_file() { 120 # For parameters ending with a '+' failure causes a warning message only 121 echo -n "`eval echo $PARAM_VALS`" 122 while test $# -gt 0 ; do 123 case $1 in 124 # Failures caused program exit 125 "-z") [[ -z "${!config_param}" ]] && echo "${tab_}<-- NO file name given" && write_error_and_die ;; 126 "-e") [[ ! -e "${!config_param}" ]] && echo "${tab_}<-- file does not exist" && write_error_and_die ;; 127 "-s") [[ ! -s "${!config_param}" ]] && echo "${tab_}<-- file has zero bytes" && write_error_and_die ;; 128 "-r") [[ ! -r "${!config_param}" ]] && echo "${tab_}<-- no read permission " && write_error_and_die ;; 129 "-w") [[ ! -w "${!config_param}" ]] && echo "${tab_}<-- no write permission" && write_error_and_die ;; 130 "-x") [[ ! -x "${!config_param}" ]] && echo "${tab_}<-- file cannot be executed" && write_error_and_die ;; 131 # Warning messages only 132 "-z+") [[ -z "${!config_param}" ]] && echo && return ;; 133 esac 134 shift 1 135 done 136 echo 137 } 138 139 validate_dir() { 140 # For parameters ending with a '+' failure causes a warning message only 141 echo -n "`eval echo $PARAM_VALS`" 142 while test $# -gt 0 ; do 143 case $1 in 144 "-z") [[ -z "${!config_param}" ]] && echo "${tab_}NO directory name given" && write_error_and_die ;; 145 "-d") [[ ! -d "${!config_param}" ]] && echo "${tab_}This is NOT a directory" && write_error_and_die ;; 146 "-w") if [[ ! -w "${!config_param}" ]]; then 147 echo "${nl_}${DD_BORDER}" 148 echo "${tab_}${RED}You do not have ${L_arrow}write${R_arrow}${RED} access to the directory${OFF}" 149 echo "${tab_}${BOLD}${!config_param}${OFF}" 150 echo "${DD_BORDER}${nl_}" 151 exit 1 152 fi ;; 153 # Warnings only 154 "-w+") if [[ ! -w "${!config_param}" ]]; then 155 echo "${nl_}${DD_BORDER}" 156 echo "${tab_}WARNING-- You do not have ${L_arrow}write${R_arrow} access to the directory${OFF}" 157 echo "${tab_} -- ${BOLD}${!config_param}${OFF}" 158 echo "${DD_BORDER}" 159 fi ;; 160 "-z+") [[ -z "${!config_param}" ]] && echo "${tab_}<-- NO directory name given" && return 161 esac 162 shift 1 163 done 164 echo 165 } 166 118 167 set +e 119 for PARAM_GROUP in ${PROGNAME}_PARAM_LIST; do 120 for config_param in ${!PARAM_GROUP}; do 121 # This is a tricky little piece of code.. executes a cmd string. 122 case $config_param in 123 BUILDDIR) # We cannot have an <empty> or </> root mount point 124 echo -e "`eval echo $PARAM_VALS`" 125 if [[ "xx x/x" =~ "x${!config_param}x" ]]; then 126 write_error_and_die 127 fi 128 continue ;; 129 TIMEZONE) continue;; 130 MKFILE) continue;; 131 HPKG) validation_str="x0x x1x"; validate_str; continue ;; 132 RUNMAKE) validation_str="x0x x1x"; validate_str; continue ;; 133 TEST) validation_str="x0x x1x x2x x3x"; validate_str; continue ;; 134 REPORT) validation_str="x0x x1x"; validate_str; 135 if [[ "${!config_param}" = "1" ]]; then 136 if [[ `type -p bc` ]]; then 137 continue 138 else 139 echo -e " ${BOLD}The bc binary was not found${OFF}" 140 echo -e " The SBU and disk usage report creation will be skiped" 141 REPORT=0 142 continue 143 fi 144 fi ;; 145 STRIP) validation_str="x0x x1x"; validate_str; continue ;; 146 VIMLANG) validation_str="x0x x1x"; validate_str; continue ;; 147 DEPEND) validation_str="x0x x1x x2x"; validate_str; continue ;; 148 MODEL) validation_str="xglibcx xuclibcx"; validate_str; continue ;; 149 PAGE) validation_str="xletterx xA4x"; validate_str; continue ;; 150 GRSECURITY_HOST) validation_str="x0x x1x"; validate_str; continue ;; 151 METHOD) validation_str="xchrootx xbootx"; validate_str; continue ;; 152 ARCH) validation_str="xx86x xx86_64x xx86_64-64x xsparcx xsparc64x xsparc64-64x xmipsx xmips64x xmips64-64x xppcx xppc64x xalphax"; validate_str; continue ;; 153 TARGET) validate_target; continue ;; 154 esac 155 156 157 if [[ "${config_param}" = "LC_ALL" ]]; then 158 echo "`eval echo $PARAM_VALS`" 159 [[ -z "${!config_param}" ]] && echo -e "\nVariable LC_ALL cannot be empty!" && write_error_and_die 160 # See it the locale values exist on this machine 161 if [[ "`locale -a | grep -c ${!config_param}`" > 0 ]]; then 162 continue 163 else # If you make it this far then there is a problem 164 write_error_and_die 165 fi 166 fi 167 168 if [[ "${config_param}" = "LANG" ]]; then 169 echo "`eval echo $PARAM_VALS`" 170 [[ -z "${!config_param}" ]] && echo -e "\nVariable LANG cannot be empty!" && write_error_and_die 171 # See if the locale values exist on this machine 172 if [[ "`locale -a | grep -c ${!config_param}`" > 0 ]]; then 173 continue 174 else # If you make it this far then there is a problem 175 write_error_and_die 176 fi 177 fi 178 179 180 if [[ "${config_param}" = "KEYMAP" ]]; then 181 echo "`eval echo $PARAM_VALS`" 182 [[ "${!config_param}" = "none" ]] && continue 183 if [[ -e "/usr/share/kbd/keymaps/${!config_param}" ]] && 184 [[ -s "/usr/share/kbd/keymaps/${!config_param}" ]]; then 185 continue 186 else 187 write_error_and_die 188 fi 189 fi 190 191 if [[ "${config_param}" = "SRC_ARCHIVE" ]]; then 192 echo -n "`eval echo $PARAM_VALS`" 193 if [ ! -z ${SRC_ARCHIVE} ]; then 194 if [ ! -d ${SRC_ARCHIVE} ]; then 195 echo " -- is NOT a directory" 196 write_error_and_die 197 fi 198 if [ ! -w ${SRC_ARCHIVE} ]; then 199 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" 200 fi 201 fi 202 echo 203 continue 204 fi 205 206 if [[ "${config_param}" = "FSTAB" ]]; then 207 echo "`eval echo $PARAM_VALS`" 208 [[ -z "${!config_param}" ]] && continue 209 if [[ -e "${!config_param}" ]] && 210 [[ -s "${!config_param}" ]]; then 211 continue 212 else 213 write_error_and_die 214 fi 215 fi 216 217 if [[ "${config_param}" = "BOOK" ]]; then 218 echo "`eval echo $PARAM_VALS`" 219 [[ ! "${WC}" = 1 ]] && continue 220 [[ -z "${!config_param}" ]] && continue 221 if [[ -e "${!config_param}" ]] && 222 [[ -s "${!config_param}" ]]; then 223 continue 224 else 225 write_error_and_die 226 fi 227 fi 228 229 if [[ "${config_param}" = "CONFIG" ]]; then 230 echo "`eval echo $PARAM_VALS`" 231 [[ -z "${!config_param}" ]] && continue 232 if [[ -e "${!config_param}" ]] && 233 [[ -s "${!config_param}" ]]; then 234 continue 235 else 236 write_error_and_die 237 fi 238 fi 239 240 if [[ "${config_param}" = "BOOT_CONFIG" ]]; then 241 if [[ "${METHOD}" = "boot" ]]; then 242 echo "`eval echo $PARAM_VALS`" 243 # There must be a config file when the build method is 'boot' 244 [[ -e "${!config_param}" ]] && [[ -s "${!config_param}" ]] && continue 245 # If you make it this far then there is a problem 246 write_error_and_die 247 fi 248 fi 249 done 168 PARAM_GROUP=${PROGNAME}_PARAM_LIST 169 for config_param in ${!PARAM_GROUP}; do 170 # This is a tricky little piece of code.. executes a cmd string. 171 case $config_param in 172 BUILDDIR) # We cannot have an <empty> or </> root mount point 173 echo -e "`eval echo $PARAM_VALS`" 174 [[ "xx x/x" =~ "x${!config_param}x" ]] && 175 write_error_and_die 176 ;; 177 TIMEZONE) ;; 178 179 # Validate general parameters.. 180 HPKG) validate_against_str "x0x x1x" ;; 181 RUNMAKE) validate_against_str "x0x x1x" ;; 182 REPORT) validate_against_str "x0x x1x" 183 if [[ "${!config_param}" = "1" ]]; then 184 if [[ `type -p bc` ]]; then 185 continue 186 else 187 echo -e " ${BOLD}The bc binary was not found${OFF}" 188 echo -e " The SBU and disk usage report creation will be skiped" 189 REPORT=0 190 continue 191 fi 192 fi ;; 193 COMPARE) if [[ ! "$COMPARE" = "1" ]]; then 194 validate_against_str "x0x x1x" 195 else 196 if [[ ! "${RUN_ICA}" = "1" ]] && [[ ! "${RUN_FARCE}" = "1" ]]; then 197 echo "${nl_}${DD_BORDER}" 198 echo "You have elected to analyse your build but have failed to select a tool." >&2 199 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 200 echo "${DD_BORDER}${nl_}" 201 exit 1 202 fi 203 fi ;; 204 RUN_ICA) [[ "$COMPARE" = "1" ]] && validate_against_str "x0x x1x" ;; 205 RUN_FARCE) [[ "$COMPARE" = "1" ]] && validate_against_str "x0x x1x" ;; 206 ITERATIONS) [[ "$COMPARE" = "1" ]] && validate_against_str "x2x x3x x4x x5x" ;; 207 TEST) validate_against_str "x0x x1x x2x x3x" ;; 208 STRIP) validate_against_str "x0x x1x" ;; 209 VIMLANG) validate_against_str "x0x x1x" ;; 210 DEPEND) validate_against_str "x0x x1x x2x" ;; 211 MODEL) validate_against_str "xglibcx xuclibcx" ;; 212 PAGE) validate_against_str "xletterx xA4x" ;; 213 METHOD) validate_against_str "xchrootx xbootx" ;; 214 ARCH) validate_against_str "xx86x xx86_64x xx86_64-64x xsparcx xsparc64x xsparc64-64x xmipsx xmips64x xmips64-64x xppcx xppc64x xalphax" ;; 215 TARGET) validate_target ;; 216 GRSECURITY_HOST) validate_against_str "x0x x1x" ;; 217 218 # BOOK validation. Very ugly, need be fixed 219 BOOK) if [[ "${WC}" = "1" ]] ; then 220 validate_dir -z -d 221 else 222 validate_against_str "x${PROGNAME}-developmentx xlfs-udev_updatex" 223 fi 224 ;; 225 226 # Validate directories, testable states: 227 # fatal -z -d -w, 228 # warning -z+ -w+ 229 SRC_ARCHIVE) validate_dir -z+ -d -w+ ;; 230 231 # Validate files, testable states: 232 # fatal -z -e -s -w -x -r, 233 # warning -z+ 234 FSTAB) validate_file -z+ -e -s ;; 235 CONFIG) validate_file -z+ -e -s ;; 236 BOOT_CONFIG) [[ "${METHOD}" = "boot" ]] && validate_file -z -e -s ;; 237 238 # Treatment of 'special' parameters 239 LANG | \ 240 LC_ALL) # See it the locale values exist on this machine 241 echo -n "`eval echo $PARAM_VALS`" 242 [[ -z "${!config_param}" ]] && 243 echo " -- Variable $config_param cannot be empty!" && 244 write_error_and_die 245 [[ ! "`locale -a | grep -c ${!config_param}`" > 0 ]] && 246 write_error_and_die 247 echo 248 ;; 249 KEYMAP) echo "`eval echo $PARAM_VALS`" 250 save_param=${KEYMAP} 251 [[ ! "${!config_param}" = "none" ]] && 252 KEYMAP="/usr/share/kbd/keymaps/${KEYMAP}" && 253 validate_file -z -e -s 254 KEYMAP=${save_param} 255 ;; 256 esac 250 257 done 251 252 258 set -e 253 259 echo "$tab_***${BOLD}${GREEN} ${PARAM_GROUP%%_*T} config parameters look good${OFF} ***"
Note:
See TracChangeset
for help on using the changeset viewer.