1 | # $Id$
|
---|
2 |
|
---|
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
|
---|
62 |
|
---|
63 | [[ "${TARGET}" = "mips-unknown-linux-gnu" ]] &&
|
---|
64 | [[ "${TARGET32}" = "mips-unknown-linux-gnu" ]] && return
|
---|
65 | write_error_and_die
|
---|
66 | ;;
|
---|
67 | "sparc64") [[ "${TARGET}" = "sparc64-unknown-linux-gnu" ]] &&
|
---|
68 | [[ "${TARGET32}" = "sparcv9-unknown-linux-gnu" ]] && return
|
---|
69 | write_error_and_die
|
---|
70 | ;;
|
---|
71 | "ppc64") [[ "${TARGET}" = "powerpc64-unknown-linux-gnu" ]] &&
|
---|
72 | [[ "${TARGET32}" = "powerpc-unknown-linux-gnu" ]] && return
|
---|
73 | write_error_and_die
|
---|
74 | ;;
|
---|
75 | *) write_error_and_die
|
---|
76 | esac
|
---|
77 | }
|
---|
78 |
|
---|
79 |
|
---|
80 | #----------------------------#
|
---|
81 | validate_config() { # Are the config values sane (within reason)
|
---|
82 | #----------------------------#
|
---|
83 | : <<inline_doc
|
---|
84 | Validates the configuration parameters. The global var PROGNAME selects the
|
---|
85 | parameter list.
|
---|
86 |
|
---|
87 | input vars: $1 0/1 0=quiet, 1=verbose output
|
---|
88 | externals: color constants
|
---|
89 | PROGNAME (lfs,clfs,hlfs,blfs)
|
---|
90 | modifies: none
|
---|
91 | returns: nothing
|
---|
92 | on error: write text to console and dies
|
---|
93 | on success: write text to console and returns
|
---|
94 | inline_doc
|
---|
95 |
|
---|
96 | local -r blfs_PARAM_LIST="BUILDDIR SRC_ARCHIVE TEST LANG DEPEND"
|
---|
97 | local -r hlfs_PARAM_LIST="BUILDDIR SRC_ARCHIVE TEST HPKG RUNMAKE STRIP PAGE TIMEZONE LC_ALL LANG KEYMAP FSTAB CONFIG MODEL GRSECURITY_HOST"
|
---|
98 | local -r clfs_PARAM_LIST="BUILDDIR SRC_ARCHIVE TEST HPKG RUNMAKE STRIP PAGE TIMEZONE LANG VIMLANG KEYMAP ARCH TARGET FSTAB CONFIG BOOT_CONFIG METHOD"
|
---|
99 | local -r lfs_PARAM_LIST="BUILDDIR SRC_ARCHIVE TEST HPKG RUNMAKE STRIP PAGE TIMEZONE LANG VIMLANG FSTAB CONFIG"
|
---|
100 |
|
---|
101 | local -r ERROR_MSG_pt1='The variable \"${L_arrow}${config_param}${R_arrow}\" value ${L_arrow}${BOLD}${!config_param}${R_arrow} is invalid,'
|
---|
102 | local -r ERROR_MSG_pt2=' check the config file ${BOLD}${GREEN}\<$(echo $PROGNAME | tr [a-z] [A-Z])/config\> or \<common/config\>${OFF}'
|
---|
103 | local -r PARAM_VALS='${config_param}: ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
|
---|
104 |
|
---|
105 | local PARAM_LIST=
|
---|
106 |
|
---|
107 | local config_param
|
---|
108 | local validation_str
|
---|
109 | local verbose=$1
|
---|
110 |
|
---|
111 | write_error_and_die() {
|
---|
112 | echo -e "\n${DD_BORDER}"
|
---|
113 | echo -e "`eval echo ${ERROR_MSG_pt1}`" >&2
|
---|
114 | echo -e "`eval echo ${ERROR_MSG_pt2}`" >&2
|
---|
115 | echo -e "${DD_BORDER}\n"
|
---|
116 | exit 1
|
---|
117 | }
|
---|
118 |
|
---|
119 | validate_str() {
|
---|
120 | # This is the 'regexp' test available in bash-3.0..
|
---|
121 | # using it as a poor man's test for substring
|
---|
122 | [[ $verbose = "1" ]] && echo -e "`eval echo $PARAM_VALS`"
|
---|
123 | if [[ ! "${validation_str}" =~ "x${!config_param}x" ]] ; then
|
---|
124 | # parameter value entered is no good
|
---|
125 | write_error_and_die
|
---|
126 | fi
|
---|
127 | }
|
---|
128 |
|
---|
129 | set +e
|
---|
130 | for PARAM_GROUP in ${PROGNAME}_PARAM_LIST; do
|
---|
131 | for config_param in ${!PARAM_GROUP}; do
|
---|
132 | # This is a tricky little piece of code.. executes a cmd string.
|
---|
133 | case $config_param in
|
---|
134 | BUILDDIR) # We cannot have an <empty> or </> root mount point
|
---|
135 | [[ $verbose = "1" ]] && echo -e "`eval echo $PARAM_VALS`"
|
---|
136 | if [[ "xx x/x" =~ "x${!config_param}x" ]]; then
|
---|
137 | write_error_and_die
|
---|
138 | fi
|
---|
139 | continue ;;
|
---|
140 | TIMEZONE) continue;;
|
---|
141 | MKFILE) continue;;
|
---|
142 | HPKG) validation_str="x0x x1x"; validate_str; continue ;;
|
---|
143 | RUNMAKE) validation_str="x0x x1x"; validate_str; continue ;;
|
---|
144 | TEST) validation_str="x0x x1x x2x x3x"; validate_str; continue ;;
|
---|
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 xsparcv8x 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 | [[ $1 = "1" ]] && echo "`eval echo $PARAM_VALS`"
|
---|
159 | [[ -z "${!config_param}" ]] && continue
|
---|
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 | [[ $verbose = "1" ]] && echo "`eval echo $PARAM_VALS`"
|
---|
170 | [[ -z "${!config_param}" ]] && continue
|
---|
171 | # See it 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 | [[ $verbose = "1" ]] && 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 | [[ $verbose = "1" ]] && 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 | [[ $verbose = "1" ]] && 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 | [[ $verbose = "1" ]] && 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 | [[ $verbose = "1" ]] && 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 | [[ $verbose = "1" ]] && 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
|
---|
250 | done
|
---|
251 |
|
---|
252 | set -e
|
---|
253 | echo "$tab_***${BOLD}${GREEN} ${PARAM_GROUP%%_*T} config parameters look good${OFF} ***"
|
---|
254 | }
|
---|