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 | echo -e "`eval echo $PARAM_VALS2`"
|
---|
21 | fi
|
---|
22 | 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 | ;;
|
---|
77 | esac
|
---|
78 | }
|
---|
79 |
|
---|
80 |
|
---|
81 | #----------------------------#
|
---|
82 | validate_config() { # Are the config values sane (within reason)
|
---|
83 | #----------------------------#
|
---|
84 | : <<inline_doc
|
---|
85 | Validates the configuration parameters. The global var PROGNAME selects the
|
---|
86 | parameter list.
|
---|
87 |
|
---|
88 | input vars: none
|
---|
89 | externals: color constants
|
---|
90 | PROGNAME (lfs,clfs,hlfs,blfs)
|
---|
91 | modifies: none
|
---|
92 | returns: nothing
|
---|
93 | on error: write text to console and dies
|
---|
94 | on success: write text to console and returns
|
---|
95 | inline_doc
|
---|
96 |
|
---|
97 | # First internal variables, then the ones that change the book's flavour, and lastly system configuration variables
|
---|
98 | local -r blfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG DEPEND TEST"
|
---|
99 | local -r hlfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG RUNMAKE MODEL GRSECURITY_HOST TEST STRIP FSTAB CONFIG KEYMAP PAGE TIMEZONE LANG LC_ALL"
|
---|
100 | local -r clfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG RUNMAKE METHOD ARCH TARGET TEST STRIP FSTAB BOOT_CONFIG CONFIG KEYMAP VIMLANG PAGE TIMEZONE LANG"
|
---|
101 | local -r lfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE HPKG RUNMAKE TEST STRIP FSTAB CONFIG VIMLANG PAGE TIMEZONE LANG"
|
---|
102 |
|
---|
103 | local -r ERROR_MSG_pt1='The variable \"${L_arrow}${config_param}${R_arrow}\" value ${L_arrow}${BOLD}${!config_param}${R_arrow} is invalid,'
|
---|
104 | local -r ERROR_MSG_pt2=' check the config file ${BOLD}${GREEN}\<$(echo $PROGNAME | tr [a-z] [A-Z])/config\> or \<common/config\>${OFF}'
|
---|
105 | local -r PARAM_VALS='${config_param}: ${L_arrow}${BOLD}${!config_param}${OFF}${R_arrow}'
|
---|
106 |
|
---|
107 | local PARAM_LIST=
|
---|
108 |
|
---|
109 | local config_param
|
---|
110 | local validation_str
|
---|
111 |
|
---|
112 | write_error_and_die() {
|
---|
113 | echo -e "\n${DD_BORDER}"
|
---|
114 | echo -e "`eval echo ${ERROR_MSG_pt1}`" >&2
|
---|
115 | echo -e "`eval echo ${ERROR_MSG_pt2}`" >&2
|
---|
116 | echo -e "${DD_BORDER}\n"
|
---|
117 | exit 1
|
---|
118 | }
|
---|
119 |
|
---|
120 | validate_str() {
|
---|
121 | # This is the 'regexp' test available in bash-3.0..
|
---|
122 | # using it as a poor man's test for substring
|
---|
123 | echo -e "`eval echo $PARAM_VALS`"
|
---|
124 | if [[ ! "${validation_str}" =~ "x${!config_param}x" ]] ; then
|
---|
125 | # parameter value entered is no good
|
---|
126 | write_error_and_die
|
---|
127 | fi
|
---|
128 | }
|
---|
129 |
|
---|
130 | set +e
|
---|
131 | for PARAM_GROUP in ${PROGNAME}_PARAM_LIST; do
|
---|
132 | for config_param in ${!PARAM_GROUP}; do
|
---|
133 | # This is a tricky little piece of code.. executes a cmd string.
|
---|
134 | case $config_param in
|
---|
135 | BUILDDIR) # We cannot have an <empty> or </> root mount point
|
---|
136 | echo -e "`eval echo $PARAM_VALS`"
|
---|
137 | if [[ "xx x/x" =~ "x${!config_param}x" ]]; then
|
---|
138 | write_error_and_die
|
---|
139 | fi
|
---|
140 | continue ;;
|
---|
141 | TIMEZONE) continue;;
|
---|
142 | MKFILE) continue;;
|
---|
143 | HPKG) validation_str="x0x x1x"; validate_str; continue ;;
|
---|
144 | RUNMAKE) validation_str="x0x x1x"; validate_str; continue ;;
|
---|
145 | TEST) validation_str="x0x x1x x2x x3x"; validate_str; continue ;;
|
---|
146 | STRIP) validation_str="x0x x1x"; validate_str; continue ;;
|
---|
147 | VIMLANG) validation_str="x0x x1x"; validate_str; continue ;;
|
---|
148 | DEPEND) validation_str="x0x x1x x2x"; validate_str; continue ;;
|
---|
149 | MODEL) validation_str="xglibcx xuclibcx"; validate_str; continue ;;
|
---|
150 | PAGE) validation_str="xletterx xA4x"; validate_str; continue ;;
|
---|
151 | GRSECURITY_HOST) validation_str="x0x x1x"; validate_str; continue ;;
|
---|
152 | METHOD) validation_str="xchrootx xbootx"; validate_str; continue ;;
|
---|
153 | ARCH) validation_str="xx86x xx86_64x xx86_64-64x xsparcx xsparcv8x xsparc64x xsparc64-64x xmipsx xmips64x xmips64-64x xppcx xppc64x xalphax"; validate_str; continue ;;
|
---|
154 | TARGET) validate_target; continue ;;
|
---|
155 | esac
|
---|
156 |
|
---|
157 |
|
---|
158 | if [[ "${config_param}" = "LC_ALL" ]]; then
|
---|
159 | echo "`eval echo $PARAM_VALS`"
|
---|
160 | [[ -z "${!config_param}" ]] && continue
|
---|
161 | # See it the locale values exist on this machine
|
---|
162 | if [[ "`locale -a | grep -c ${!config_param}`" > 0 ]]; then
|
---|
163 | continue
|
---|
164 | else # If you make it this far then there is a problem
|
---|
165 | write_error_and_die
|
---|
166 | fi
|
---|
167 | fi
|
---|
168 |
|
---|
169 | if [[ "${config_param}" = "LANG" ]]; then
|
---|
170 | echo "`eval echo $PARAM_VALS`"
|
---|
171 | [[ -z "${!config_param}" ]] && continue
|
---|
172 | # See it the locale values exist on this machine
|
---|
173 | if [[ "`locale -a | grep -c ${!config_param}`" > 0 ]]; then
|
---|
174 | continue
|
---|
175 | else # If you make it this far then there is a problem
|
---|
176 | write_error_and_die
|
---|
177 | fi
|
---|
178 | fi
|
---|
179 |
|
---|
180 |
|
---|
181 | if [[ "${config_param}" = "KEYMAP" ]]; then
|
---|
182 | echo "`eval echo $PARAM_VALS`"
|
---|
183 | [[ "${!config_param}" = "none" ]] && continue
|
---|
184 | if [[ -e "/usr/share/kbd/keymaps/${!config_param}" ]] &&
|
---|
185 | [[ -s "/usr/share/kbd/keymaps/${!config_param}" ]]; then
|
---|
186 | continue
|
---|
187 | else
|
---|
188 | write_error_and_die
|
---|
189 | fi
|
---|
190 | fi
|
---|
191 |
|
---|
192 | if [[ "${config_param}" = "SRC_ARCHIVE" ]]; then
|
---|
193 | echo -n "`eval echo $PARAM_VALS`"
|
---|
194 | if [ ! -z ${SRC_ARCHIVE} ]; then
|
---|
195 | if [ ! -d ${SRC_ARCHIVE} ]; then
|
---|
196 | echo " -- is NOT a directory"
|
---|
197 | write_error_and_die
|
---|
198 | fi
|
---|
199 | if [ ! -w ${SRC_ARCHIVE} ]; then
|
---|
200 | 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"
|
---|
201 | fi
|
---|
202 | fi
|
---|
203 | echo
|
---|
204 | continue
|
---|
205 | fi
|
---|
206 |
|
---|
207 | if [[ "${config_param}" = "FSTAB" ]]; then
|
---|
208 | echo "`eval echo $PARAM_VALS`"
|
---|
209 | [[ -z "${!config_param}" ]] && continue
|
---|
210 | if [[ -e "${!config_param}" ]] &&
|
---|
211 | [[ -s "${!config_param}" ]]; then
|
---|
212 | continue
|
---|
213 | else
|
---|
214 | write_error_and_die
|
---|
215 | fi
|
---|
216 | fi
|
---|
217 |
|
---|
218 | if [[ "${config_param}" = "BOOK" ]]; then
|
---|
219 | echo "`eval echo $PARAM_VALS`"
|
---|
220 | [[ ! "${WC}" = 1 ]] && continue
|
---|
221 | [[ -z "${!config_param}" ]] && continue
|
---|
222 | if [[ -e "${!config_param}" ]] &&
|
---|
223 | [[ -s "${!config_param}" ]]; then
|
---|
224 | continue
|
---|
225 | else
|
---|
226 | write_error_and_die
|
---|
227 | fi
|
---|
228 | fi
|
---|
229 |
|
---|
230 | if [[ "${config_param}" = "CONFIG" ]]; then
|
---|
231 | echo "`eval echo $PARAM_VALS`"
|
---|
232 | [[ -z "${!config_param}" ]] && continue
|
---|
233 | if [[ -e "${!config_param}" ]] &&
|
---|
234 | [[ -s "${!config_param}" ]]; then
|
---|
235 | continue
|
---|
236 | else
|
---|
237 | write_error_and_die
|
---|
238 | fi
|
---|
239 | fi
|
---|
240 |
|
---|
241 | if [[ "${config_param}" = "BOOT_CONFIG" ]]; then
|
---|
242 | if [[ "${METHOD}" = "boot" ]]; then
|
---|
243 | echo "`eval echo $PARAM_VALS`"
|
---|
244 | # There must be a config file when the build method is 'boot'
|
---|
245 | [[ -e "${!config_param}" ]] && [[ -s "${!config_param}" ]] && continue
|
---|
246 | # If you make it this far then there is a problem
|
---|
247 | write_error_and_die
|
---|
248 | fi
|
---|
249 | fi
|
---|
250 | done
|
---|
251 | done
|
---|
252 |
|
---|
253 | set -e
|
---|
254 | echo "$tab_***${BOLD}${GREEN} ${PARAM_GROUP%%_*T} config parameters look good${OFF} ***"
|
---|
255 | }
|
---|