1 | #!/bin/bash
|
---|
2 |
|
---|
3 | # $Id$
|
---|
4 |
|
---|
5 | set +e
|
---|
6 |
|
---|
7 | # VT100 colors
|
---|
8 | declare -r BLACK=$'\e[1;30m'
|
---|
9 | declare -r DK_GRAY=$'\e[0;30m'
|
---|
10 |
|
---|
11 | declare -r RED=$'\e[31m'
|
---|
12 | declare -r GREEN=$'\e[32m'
|
---|
13 | declare -r YELLOW=$'\e[33m'
|
---|
14 | declare -r BLUE=$'\e[34m'
|
---|
15 | declare -r MAGENTA=$'\e[35m'
|
---|
16 | declare -r CYAN=$'\e[36m'
|
---|
17 | declare -r WHITE=$'\e[37m'
|
---|
18 |
|
---|
19 | declare -r OFF=$'\e[0m'
|
---|
20 | declare -r BOLD=$'\e[1m'
|
---|
21 | declare -r REVERSE=$'\e[7m'
|
---|
22 | declare -r HIDDEN=$'\e[8m'
|
---|
23 |
|
---|
24 | declare -r tab_=$'\t'
|
---|
25 | declare -r nl_=$'\n'
|
---|
26 |
|
---|
27 | declare -r DD_BORDER="${BOLD}${WHITE}==============================================================================${OFF}"
|
---|
28 | declare -r SD_BORDER="${BOLD}${WHITE}------------------------------------------------------------------------------${OFF}"
|
---|
29 | declare -r STAR_BORDER="${BOLD}${WHITE}******************************************************************************${OFF}"
|
---|
30 |
|
---|
31 | # bold yellow > < pair
|
---|
32 | declare -r R_arrow=$'\e[1;33m>\e[0m'
|
---|
33 | declare -r L_arrow=$'\e[1;33m<\e[0m'
|
---|
34 |
|
---|
35 |
|
---|
36 | usage() {
|
---|
37 | cat <<- -EOF-
|
---|
38 | ${DD_BORDER}
|
---|
39 | ${BOLD}
|
---|
40 | Usage: $0 ${BOLD}[OPTION]
|
---|
41 |
|
---|
42 | Options:
|
---|
43 | ${BOLD} -h, --help${OFF}
|
---|
44 | print this help, then exit
|
---|
45 |
|
---|
46 | ${BOLD} -V, --version${OFF}
|
---|
47 | print version information, then exit
|
---|
48 |
|
---|
49 | ${BOLD} -B, --book VER${OFF}
|
---|
50 | checkout VER version of the book. Supported versions at this time are:
|
---|
51 | dev* | trunk | SVN aliases for Development {C,H,B}LFS
|
---|
52 | udev* aliases for the LFS udev_update branch
|
---|
53 |
|
---|
54 | ${BOLD} -D --directory DIR${OFF}
|
---|
55 | use DIR directory for building ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])${OFF}; all files jhalfs-X produces
|
---|
56 | will be in the directory DIR/jhalfs.
|
---|
57 |
|
---|
58 | ${BOLD} -G, --get-packages${OFF}
|
---|
59 | download the packages and patches. This assumes that the server declared
|
---|
60 | in the configuration file has the proper packages and patches for the
|
---|
61 | book version being processed.
|
---|
62 |
|
---|
63 | ${BOLD} -T, --testsuites N ${OFF}
|
---|
64 | Run test suites [0-3]
|
---|
65 | 0 = none
|
---|
66 | 1 = only chapter06 Glibc, GCC and Binutils testsuites
|
---|
67 | 2 = all chapter06 testsuites (in BLFS, alias to 1)
|
---|
68 | 3 = all chapter05 and chapter06 testsuites
|
---|
69 | In BLFS, 2 and 3 are aliases to 1
|
---|
70 | In CLFS, 3 is an alias to 2
|
---|
71 |
|
---|
72 | ${BOLD} -W, --working-copy DIR${OFF}
|
---|
73 | use the local working copy placed in DIR as the $(echo $PROGNAME | tr [a-z] [A-Z]) book
|
---|
74 | -EOF-
|
---|
75 |
|
---|
76 | [[ ${PROGNAME} != "blfs" ]] &&
|
---|
77 | cat <<- -EOF-
|
---|
78 |
|
---|
79 | ${BOLD} --do-ICA${OFF}
|
---|
80 | do the Iterative Comparison Analysis. That will take several time.
|
---|
81 |
|
---|
82 | ${BOLD} -F, --fstab FILE${OFF}
|
---|
83 | use FILE as the /etc/fstab file for the ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])${OFF} system. If not specified,
|
---|
84 | a default /etc/fstab file with dummy values is created.
|
---|
85 |
|
---|
86 | ${BOLD} -K, --kernel-config FILE${OFF}
|
---|
87 | use the kernel configuration file specified in FILE to build the kernel.
|
---|
88 | if the file is not found, or if not specified, the kernel build is skipped.
|
---|
89 |
|
---|
90 | ${BOLD} -M, --run-make${OFF}
|
---|
91 | run make on the generated Makefile
|
---|
92 |
|
---|
93 | ${BOLD} -R --rebuild${OFF}
|
---|
94 | clean the build directory before to perfom any other task. The directory
|
---|
95 | is cleaned only if it was populated by a previous jhalfs-X run.
|
---|
96 | -EOF-
|
---|
97 |
|
---|
98 | [[ ${PROGNAME} = "clfs" ]] &&
|
---|
99 | cat <<- -EOF-
|
---|
100 |
|
---|
101 | ${BOLD} -A, --arch ARCH ${OFF}
|
---|
102 | Select the TARGET architecture, valid selections are:
|
---|
103 | 32bit builds
|
---|
104 | x86, i486, i586, ppc, mips, mipsel, sparc, sparcv8
|
---|
105 | 64bit builds
|
---|
106 | x86_64-64, mips64-64, mipsel64-64, sparc64-64, alpha
|
---|
107 | 64bit multi-lib
|
---|
108 | x86_64, mips64, mipsel64, sparc64, ppc64
|
---|
109 |
|
---|
110 | ${BOLD} --boot_config FILE ${OFF}
|
---|
111 | The configuration file for the bootstrap kernel if method=boot
|
---|
112 |
|
---|
113 | ${BOLD} --method BUILDMETHOD ${OFF}
|
---|
114 | Select the build method, chroot or boot
|
---|
115 | -EOF-
|
---|
116 |
|
---|
117 | [[ ${PROGNAME} = "hlfs" ]] &&
|
---|
118 | cat <<- -EOF-
|
---|
119 |
|
---|
120 | ${BOLD} --model STYLE ${OFF}
|
---|
121 | Select the library model for the HLFS system
|
---|
122 | Valid choices are: glibc or uclibc
|
---|
123 | -EOF-
|
---|
124 |
|
---|
125 | [[ ${PROGNAME} = "blfs" ]] &&
|
---|
126 | cat <<- -EOF-
|
---|
127 |
|
---|
128 | ${BOLD} --dependencies 0/1/2${OFF}
|
---|
129 | add dependencies of type TYPE to the build tree.
|
---|
130 | If not set, both required and recommended are used.
|
---|
131 |
|
---|
132 | Possible values are:
|
---|
133 | 0 - required only required dependecies are used
|
---|
134 | 1 - recommended both required a recommended dependencies are used
|
---|
135 | 2 - optional all dependencies are used
|
---|
136 | -EOF-
|
---|
137 |
|
---|
138 | cat <<- -EOF-
|
---|
139 | ${DD_BORDER}
|
---|
140 | -EOF-
|
---|
141 | exit
|
---|
142 | }
|
---|
143 |
|
---|
144 | version="
|
---|
145 | ${BOLD} \"jhalfs-X\"${OFF} builder tool (development) \$Rev$
|
---|
146 | \$Date$
|
---|
147 |
|
---|
148 | ${BOLD} \"${PROGNAME}\"${OFF} script module
|
---|
149 |
|
---|
150 | Written by George Boudreau,
|
---|
151 | Manuel Canales Esparcia,
|
---|
152 | Jeremy Huntwork
|
---|
153 |
|
---|
154 | This program is published under the ${BOLD}Gnu General Public License, Version 2.${OFF}
|
---|
155 | "
|
---|
156 |
|
---|
157 |
|
---|
158 | no_empty_builddir() {
|
---|
159 | 'clear'
|
---|
160 | cat <<- -EOF-
|
---|
161 | ${DD_BORDER}
|
---|
162 |
|
---|
163 | ${tab_}${tab_}${BOLD}${RED}W A R N I N G${OFF}
|
---|
164 | Looks like the \$BUILDDIR directory contains subdirectories
|
---|
165 | from a previous HLFS build.
|
---|
166 |
|
---|
167 | Please format the partition mounted on \$BUILDDIR or set
|
---|
168 | a different build directory before running jhalfs-X.
|
---|
169 | ${OFF}
|
---|
170 | ${DD_BORDER}
|
---|
171 | -EOF-
|
---|
172 | exit
|
---|
173 | }
|
---|
174 |
|
---|
175 |
|
---|
176 | help="${nl_}Try '$0 --help' for more information."
|
---|
177 |
|
---|
178 |
|
---|
179 | exit_missing_arg="\
|
---|
180 | echo \"Option '\$1' requires an argument\" >&2
|
---|
181 | echo \"\$help\" >&2
|
---|
182 | exit 1"
|
---|
183 |
|
---|
184 | no_dl_client="\
|
---|
185 | echo \"Could not find a way to download the ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])${OFF} sources.\" >&2
|
---|
186 | echo \"Attempting to continue.\" >&2"
|
---|
187 |
|
---|
188 | HEADER="# This file is automatically generated by jhalfs-X
|
---|
189 | # DO NOT EDIT THIS FILE MANUALLY
|
---|
190 | #
|
---|
191 | # Generated on `date \"+%F %X %Z\"`"
|
---|
192 |
|
---|
193 |
|
---|
194 |
|
---|
195 |
|
---|
196 |
|
---|
197 | #----------------------------------#
|
---|
198 | wrt_target() { #
|
---|
199 | #----------------------------------#
|
---|
200 | local i=$1
|
---|
201 | local PREV=$2
|
---|
202 | (
|
---|
203 | cat << EOF
|
---|
204 |
|
---|
205 | $i: $PREV
|
---|
206 | @\$(call echo_message, Building)
|
---|
207 | EOF
|
---|
208 | ) >> $MKFILE.tmp
|
---|
209 | }
|
---|
210 |
|
---|
211 |
|
---|
212 | #----------------------------------#
|
---|
213 | wrt_unpack() { # Unpack and set 'ROOT' var
|
---|
214 | #----------------------------------#
|
---|
215 | local FILE=$1
|
---|
216 | (
|
---|
217 | cat << EOF
|
---|
218 | @\$(call unpack,$FILE)
|
---|
219 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
220 | echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
|
---|
221 | chown -R lfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
|
---|
222 | EOF
|
---|
223 | ) >> $MKFILE.tmp
|
---|
224 | }
|
---|
225 |
|
---|
226 |
|
---|
227 | #----------------------------------#
|
---|
228 | wrt_unpack2() { #
|
---|
229 | #----------------------------------#
|
---|
230 | local FILE=$1
|
---|
231 | (
|
---|
232 | cat << EOF
|
---|
233 | @\$(call unpack2,$FILE)
|
---|
234 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
235 | echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
|
---|
236 | EOF
|
---|
237 | ) >> $MKFILE.tmp
|
---|
238 | }
|
---|
239 |
|
---|
240 |
|
---|
241 | #=============================#
|
---|
242 | wrt_unpack3() { #
|
---|
243 | #=============================#
|
---|
244 | local FILE=$1
|
---|
245 | (
|
---|
246 | cat << EOF
|
---|
247 | @\$(call unpack3,$FILE)
|
---|
248 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
249 | echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
|
---|
250 | EOF
|
---|
251 | ) >> $MKFILE.tmp
|
---|
252 | }
|
---|
253 |
|
---|
254 |
|
---|
255 |
|
---|
256 | #----------------------------------#
|
---|
257 | wrt_target_vars() { # Target vars for hlfs (cross-build method)
|
---|
258 | #----------------------------------#
|
---|
259 | (
|
---|
260 | cat << EOF
|
---|
261 | @echo "export target=$(uname -m)-${TARGET}" >> envars && \\
|
---|
262 | echo "export ldso=/lib/${LOADER}" >> envars
|
---|
263 | EOF
|
---|
264 | ) >> $MKFILE.tmp
|
---|
265 |
|
---|
266 | }
|
---|
267 |
|
---|
268 |
|
---|
269 | #----------------------------------#
|
---|
270 | wrt_run_as_su() { # header to log file, execute script, footer to log file
|
---|
271 | #----------------------------------#
|
---|
272 | local this_script=$1
|
---|
273 | local file=$2
|
---|
274 | (
|
---|
275 | cat << EOF
|
---|
276 | @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$this_script && \\
|
---|
277 | su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 && \\
|
---|
278 | echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$this_script
|
---|
279 | EOF
|
---|
280 | ) >> $MKFILE.tmp
|
---|
281 | }
|
---|
282 |
|
---|
283 |
|
---|
284 | #----------------------------------#
|
---|
285 | wrt_run_as_root() { #
|
---|
286 | #----------------------------------#
|
---|
287 | local this_script=$1
|
---|
288 | local file=$2
|
---|
289 | (
|
---|
290 | cat << EOF
|
---|
291 | @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$this_script && \\
|
---|
292 | export LFS=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 && \\
|
---|
293 | echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$this_script
|
---|
294 | EOF
|
---|
295 | ) >> $MKFILE.tmp
|
---|
296 | }
|
---|
297 |
|
---|
298 |
|
---|
299 | #=============================#
|
---|
300 | wrt_run_as_root2() { # Some scripts must be run as root..
|
---|
301 | #=============================#
|
---|
302 | local this_script=$1
|
---|
303 | local file=$2
|
---|
304 | (
|
---|
305 | cat << EOF
|
---|
306 | @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \`\n" >logs/$this_script && \\
|
---|
307 | source envars && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 && \\
|
---|
308 | echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \`\n" >>logs/$this_script
|
---|
309 | EOF
|
---|
310 | ) >> $MKFILE.tmp
|
---|
311 | }
|
---|
312 |
|
---|
313 |
|
---|
314 | #----------------------------------#
|
---|
315 | wrt_remove_build_dirs() { #
|
---|
316 | #----------------------------------#
|
---|
317 | local name=$1
|
---|
318 | (
|
---|
319 | cat << EOF
|
---|
320 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
321 | rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
|
---|
322 | if [ -e \$(MOUNT_PT)\$(SRC)/$name-build ]; then \\
|
---|
323 | rm -r \$(MOUNT_PT)\$(SRC)/$name-build; \\
|
---|
324 | fi;
|
---|
325 | EOF
|
---|
326 | ) >> $MKFILE.tmp
|
---|
327 | }
|
---|
328 |
|
---|
329 |
|
---|
330 | #----------------------------------#
|
---|
331 | wrt_remove_build_dirs2() { #
|
---|
332 | #----------------------------------#
|
---|
333 | local name=$1
|
---|
334 | (
|
---|
335 | cat << EOF
|
---|
336 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
337 | rm -r \$(SRC)/\$\$ROOT && \\
|
---|
338 | if [ -e \$(SRC)/$name-build ]; then \\
|
---|
339 | rm -r \$(SRC)/$name-build; \\
|
---|
340 | fi;
|
---|
341 | EOF
|
---|
342 | ) >> $MKFILE.tmp
|
---|
343 | }
|
---|
344 |
|
---|
345 |
|
---|
346 |
|
---|
347 | #----------------------------------#
|
---|
348 | wrt_run_as_chroot1() { #
|
---|
349 | #----------------------------------#
|
---|
350 | local this_script=$1
|
---|
351 | local file=$2
|
---|
352 | (
|
---|
353 | cat << EOF
|
---|
354 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/${this_script} && \\
|
---|
355 | \$(CHROOT1) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' && \\
|
---|
356 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/${this_script}
|
---|
357 | EOF
|
---|
358 | ) >> $MKFILE.tmp
|
---|
359 | }
|
---|
360 |
|
---|
361 |
|
---|
362 | #----------------------------------#
|
---|
363 | wrt_run_as_chroot2() { #
|
---|
364 | #----------------------------------#
|
---|
365 | local this_script=$1
|
---|
366 | local file=$2
|
---|
367 | (
|
---|
368 | cat << EOF
|
---|
369 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/${this_script} && \\
|
---|
370 | \$(CHROOT2) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' && \\
|
---|
371 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/${this_script}
|
---|
372 | EOF
|
---|
373 | ) >> $MKFILE.tmp
|
---|
374 | }
|
---|
375 |
|
---|
376 |
|
---|
377 | #----------------------------------#
|
---|
378 | wrt_copy_fstab() { #
|
---|
379 | #----------------------------------#
|
---|
380 | local i=$1
|
---|
381 | (
|
---|
382 | cat << EOF
|
---|
383 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >logs/$i && \\
|
---|
384 | cp -v $FSTAB \$(MOUNT_PT)/etc/fstab >>logs/$i 2>&1 && \\
|
---|
385 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(MOUNT_PT)\`\n" >>logs/$i
|
---|
386 | EOF
|
---|
387 | ) >> $MKFILE.tmp
|
---|
388 | }
|
---|
389 |
|
---|
390 | #----------------------------------#
|
---|
391 | wrt_copy_fstab2() { #
|
---|
392 | #----------------------------------#
|
---|
393 | local i=$1
|
---|
394 | (
|
---|
395 | cat << EOF
|
---|
396 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \`\n" >logs/$i && \\
|
---|
397 | cp -v /sources/fstab /etc/fstab >>logs/$i 2>&1 && \\
|
---|
398 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \`\n" >>logs/$i
|
---|
399 | EOF
|
---|
400 | ) >> $MKFILE.tmp
|
---|
401 | }
|
---|
402 |
|
---|
403 |
|
---|
404 | #----------------------------------#
|
---|
405 | wrt_export_pkgdir() { #
|
---|
406 | #----------------------------------#
|
---|
407 | (
|
---|
408 | cat << EOF
|
---|
409 | @echo "export PKGDIR=\$(SRC)/binutils-build" > envars
|
---|
410 | EOF
|
---|
411 | ) >> $MKFILE.tmp
|
---|
412 | }
|
---|
413 |
|
---|
414 |
|
---|
415 | #----------------------------#
|
---|
416 | run_make() {
|
---|
417 | #----------------------------#
|
---|
418 | # Test if make must be run.
|
---|
419 | if [ "$RUNMAKE" = "1" ] ; then
|
---|
420 | # Test to make sure we're running the build as root
|
---|
421 | if [ "$UID" != "0" ] ; then
|
---|
422 | echo "You must be logged in as root to successfully build the system."
|
---|
423 | exit 1
|
---|
424 | fi
|
---|
425 | # Build the system
|
---|
426 | if [ -e $MKFILE ] ; then
|
---|
427 | echo -ne "Building the system...\n"
|
---|
428 | cd $JHALFSDIR && make -f ${PROGNAME}-Makefile
|
---|
429 | echo -ne "done\n"
|
---|
430 | fi
|
---|
431 | fi
|
---|
432 | }
|
---|
433 |
|
---|
434 |
|
---|
435 | #----------------------------#
|
---|
436 | clean_builddir() {
|
---|
437 | #----------------------------#
|
---|
438 | # Test if the clean must be done.
|
---|
439 | if [ "$CLEAN" = "1" ] ; then
|
---|
440 | # Test to make sure we're running the clean as root
|
---|
441 | if [ "$UID" != "0" ] ; then
|
---|
442 | echo "You must be logged in as root to clean the build directory."
|
---|
443 | exit 1
|
---|
444 | fi
|
---|
445 | # Test to make sure that the build directory was populated by jhalfs
|
---|
446 | if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
|
---|
447 | echo "Looks like $BUILDDIR was not populated by a previous jhalfs-X run."
|
---|
448 | exit 1
|
---|
449 | else
|
---|
450 | # Clean the build directory
|
---|
451 | echo -ne "Cleaning $BUILDDIR...\n"
|
---|
452 | rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,cross-tools,usr,var}
|
---|
453 | echo -ne "Cleaning $JHALFSDIR...\n"
|
---|
454 | rm -rf $JHALFSDIR/{0*,1*,envars,sources-dir,*commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
|
---|
455 | echo -ne "Cleaning remainig extracted sources in $BUILDDIR/sources...\n"
|
---|
456 | rm -rf `find $BUILDDIR/sources/* -maxdepth 0 -type d`
|
---|
457 | echo -ne "done\n"
|
---|
458 | fi
|
---|
459 | fi
|
---|
460 | }
|
---|
461 |
|
---|
462 | #----------------------------#
|
---|
463 | get_book() {
|
---|
464 | #----------------------------#
|
---|
465 | cd $JHALFSDIR
|
---|
466 |
|
---|
467 | if [ -z $WC ] ; then
|
---|
468 | # Check for Subversion instead of just letting the script hit 'svn' and fail.
|
---|
469 | test `type -p svn` || eval "echo \"This feature requires Subversion.\"
|
---|
470 | exit 1"
|
---|
471 | echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
|
---|
472 |
|
---|
473 | case $PROGNAME in
|
---|
474 | lfs) svn_root="LFS" ;;
|
---|
475 | hlfs) svn_root="HLFS" ;;
|
---|
476 | clfs) svn_root="cross-lfs" ;;
|
---|
477 | blfs) svn_root="BLFS" ;;
|
---|
478 | *) echo "BOOK not defined in function <get_book>"
|
---|
479 | exit 1 ;;
|
---|
480 | esac
|
---|
481 | # Grab a fresh book if it's missing, otherwise, update it from the
|
---|
482 | # repo. If we've already extracted the commands, move on to getting the
|
---|
483 | # sources.
|
---|
484 | if [ -d ${PROGNAME}-$LFSVRS ] ; then
|
---|
485 | cd ${PROGNAME}-$LFSVRS
|
---|
486 | if LC_ALL=C svn up | grep -q At && test -d $JHALFSDIR/commands && \
|
---|
487 | test -f $JHALFSDIR/packages && test -f $JHALFSDIR/patches ; then
|
---|
488 | echo -ne "done\n"
|
---|
489 | # Set the canonical book version
|
---|
490 | cd $JHALFSDIR
|
---|
491 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
492 | get_sources
|
---|
493 | else
|
---|
494 | echo -ne "done\n"
|
---|
495 | # Set the canonical book version
|
---|
496 | cd $JHALFSDIR
|
---|
497 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
498 | extract_commands
|
---|
499 | fi
|
---|
500 | else
|
---|
501 | case $LFSVRS in
|
---|
502 | development)
|
---|
503 | svn co $SVN/${svn_root}/trunk/BOOK ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
|
---|
504 | alphabetical)
|
---|
505 | svn co $SVN/${svn_root}/branches/$LFSVRS/BOOK ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
|
---|
506 | udev_update)
|
---|
507 | svn co $SVN/LFS/branches/$LFSVRS/BOOK lfs-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
|
---|
508 | esac
|
---|
509 | echo -ne "done\n"
|
---|
510 | # Set the canonical book version
|
---|
511 | cd $JHALFSDIR
|
---|
512 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
513 | extract_commands
|
---|
514 | fi
|
---|
515 | else
|
---|
516 | echo -ne "Using $BOOK as book's sources ...\n"
|
---|
517 | # Set the canonical book version
|
---|
518 | cd $JHALFSDIR
|
---|
519 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
520 | extract_commands
|
---|
521 | fi
|
---|
522 | }
|
---|
523 |
|
---|
524 |
|
---|
525 | #----------------------------#
|
---|
526 | build_patches_file() { # Supply a suitably formated list of patches.
|
---|
527 | #----------------------------#
|
---|
528 | local saveIFS=$IFS
|
---|
529 | local IFS
|
---|
530 |
|
---|
531 | rm -f patches
|
---|
532 |
|
---|
533 | LOC_add_patches_entry() {
|
---|
534 | for f in `grep "/$1-" patcheslist_.wget`; do
|
---|
535 | basename $f | sed "s|${2}|\&${1}-version;|" >> patches
|
---|
536 | done
|
---|
537 | }
|
---|
538 |
|
---|
539 | case ${PROGNAME} in
|
---|
540 | hlfs)
|
---|
541 | echo -n "Creating the HLFS ${L_arrow}${BOLD}$MODEL${R_arrow} specific patches file"
|
---|
542 | xsltproc --nonet \
|
---|
543 | --xinclude \
|
---|
544 | --stringparam model $MODEL \
|
---|
545 | -o patcheslist_.wget \
|
---|
546 | patcheslist.xsl \
|
---|
547 | $BOOK/chapter04/patches.xml
|
---|
548 | #> /dev/null 2>&1
|
---|
549 |
|
---|
550 | # .... U G L Y .... what to do with the grsecurity patch to the kernel..
|
---|
551 | for f in `grep "/grsecurity-" patcheslist_.wget`; do
|
---|
552 | basename $f >> patches
|
---|
553 | done
|
---|
554 | ;;
|
---|
555 |
|
---|
556 | clfs) # Pull out a list of arch specific patches
|
---|
557 | echo -n "Creating CLFS ${L_arrow}${BOLD}$ARCH${R_arrow} specific patches file"
|
---|
558 | xsltproc -xinclude \
|
---|
559 | -o patcheslist_.wget \
|
---|
560 | patcheslist.xsl \
|
---|
561 | $BOOK/materials/${ARCH}-chapter.xml
|
---|
562 | ;;
|
---|
563 | *) return
|
---|
564 | esac
|
---|
565 |
|
---|
566 |
|
---|
567 | IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
|
---|
568 | for f in `cat packages`; do
|
---|
569 | IFS=$saveIFS # Restore the system defaults
|
---|
570 | LOC_add_patches_entry \
|
---|
571 | `echo $f | sed -e 's/-version//' \
|
---|
572 | -e 's/-file.*//' \
|
---|
573 | -e 's/"//g' \
|
---|
574 | -e 's/uclibc/uClibc/'`
|
---|
575 | done
|
---|
576 |
|
---|
577 | rm -f patcheslist_.wget
|
---|
578 |
|
---|
579 | echo " ...OK"
|
---|
580 | }
|
---|
581 |
|
---|
582 |
|
---|
583 | #----------------------------#
|
---|
584 | extract_commands() { #
|
---|
585 | #----------------------------#
|
---|
586 | local saveIFS=$IFS
|
---|
587 |
|
---|
588 | # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
|
---|
589 | test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
|
---|
590 | exit 1"
|
---|
591 |
|
---|
592 | cd $JHALFSDIR
|
---|
593 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
594 |
|
---|
595 | # Start clean
|
---|
596 | if [ -d commands ]; then
|
---|
597 | rm -rf commands
|
---|
598 | mkdir -v commands
|
---|
599 | fi
|
---|
600 | echo -n "Extracting commands for"
|
---|
601 |
|
---|
602 | # Dump the commands in shell script form from the HLFS book.
|
---|
603 | case ${PROGNAME} in
|
---|
604 | clfs)
|
---|
605 | echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
|
---|
606 | xsltproc --nonet \
|
---|
607 | --xinclude \
|
---|
608 | --stringparam method $METHOD \
|
---|
609 | --stringparam testsuite $TEST \
|
---|
610 | --stringparam vim-lang $VIMLANG \
|
---|
611 | --stringparam timezone $TIMEZONE \
|
---|
612 | --stringparam page $PAGE \
|
---|
613 | --stringparam lang $LANG \
|
---|
614 | --stringparam keymap $KEYMAP \
|
---|
615 | -o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
|
---|
616 | ;;
|
---|
617 | hlfs)
|
---|
618 | echo -n " ${L_arrow}${BOLD}$MODEL${R_arrow} HLFS libc implementation"
|
---|
619 | xsltproc --nonet \
|
---|
620 | --xinclude \
|
---|
621 | --stringparam model $MODEL \
|
---|
622 | --stringparam testsuite $TEST \
|
---|
623 | --stringparam timezone $TIMEZONE \
|
---|
624 | --stringparam page $PAGE \
|
---|
625 | --stringparam lang $LANG \
|
---|
626 | --stringparam lc_all $LC_ALL \
|
---|
627 | --stringparam keymap $KEYMAP \
|
---|
628 | --stringparam grsecurity_host $GRSECURITY_HOST \
|
---|
629 | -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
630 | ;;
|
---|
631 | lfs)
|
---|
632 | echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build"
|
---|
633 | xsltproc --nonet \
|
---|
634 | --xinclude \
|
---|
635 | --stringparam testsuite $TEST \
|
---|
636 | --stringparam vim-lang $VIMLANG \
|
---|
637 | --stringparam timezone $TIMEZONE \
|
---|
638 | --stringparam page $PAGE \
|
---|
639 | --stringparam lang $LANG \
|
---|
640 | -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
641 | ;;
|
---|
642 | blfs)
|
---|
643 | echo -n " ${L_arrow}${BOLD}BLFS${R_arrow} build"
|
---|
644 | xsltproc --nonet \
|
---|
645 | --xinclude \
|
---|
646 | --stringparam testsuite $TEST \
|
---|
647 | --stringparam server $SERVER \
|
---|
648 | -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
649 | ;;
|
---|
650 | *) exit 1
|
---|
651 | esac
|
---|
652 |
|
---|
653 | echo " ...OK"
|
---|
654 |
|
---|
655 | # Make the scripts executable.
|
---|
656 | chmod -R +x $JHALFSDIR/${PROGNAME}-commands
|
---|
657 |
|
---|
658 | # Grab the patches and package names.
|
---|
659 | for i in patches packages ; do
|
---|
660 | rm -f $i
|
---|
661 | done
|
---|
662 | #
|
---|
663 | case "${PROGNAME}" in
|
---|
664 | clfs)
|
---|
665 | ################################
|
---|
666 | # A LOCAL function
|
---|
667 | # xx_.wget contains arch specific files but in URL format
|
---|
668 | # Build a file with only arch specific files.. small ugly..
|
---|
669 | LOC_add_packages_entry() {
|
---|
670 | local fileMATCH aFILE
|
---|
671 |
|
---|
672 | # Deal with a non-standard format
|
---|
673 | if [[ "$1" = "clfs-bootscripts" ]]; then
|
---|
674 | set -- "bootscripts-cross-lfs" $2
|
---|
675 | fi
|
---|
676 | fileMATCH="/$1"
|
---|
677 |
|
---|
678 | # format.. Filename-Version or FilenameVersion
|
---|
679 | for aFILE in `grep ${fileMATCH}-*[[:digit:]] packageslist_.wget`; do
|
---|
680 | # Block vim-x.x-lang file, will add it later based on config flag
|
---|
681 | if [[ ! "${aFILE}" =~ "vim-$2-lang" ]]; then
|
---|
682 | echo "$1-version \"$2\"" >> packages
|
---|
683 | fi
|
---|
684 | done
|
---|
685 | }
|
---|
686 | #################################
|
---|
687 |
|
---|
688 | # We only want a list arch specific files..
|
---|
689 | # Unfortunately this script produces URL's which must be converted to a std format
|
---|
690 | echo -n "Creating CLFS ${L_arrow}${BOLD}${ARCH}${R_arrow} specific packages file"
|
---|
691 | xsltproc -xinclude \
|
---|
692 | -o packageslist_.wget \
|
---|
693 | packageslist.xsl \
|
---|
694 | $BOOK/materials/${ARCH}-chapter.xml
|
---|
695 |
|
---|
696 | # This has the correct format but contains packages from every book
|
---|
697 | grep "\-version " $BOOK/packages.ent | sed -e 's@<!ENTITY @@' \
|
---|
698 | -e 's@">@"@' \
|
---|
699 | -e '/generic/d' > packages.tmp
|
---|
700 | # This variable is necessary to make sure the `cat $JHALFSDIR/packages`
|
---|
701 | # separates each iteration by lines.
|
---|
702 | # Modify the 'internal field separator' to break on 'LF' only
|
---|
703 | IFS=$'\x0A'
|
---|
704 | for f in `cat packages.tmp`; do
|
---|
705 | IFS=$saveIFS # Restore the system defaults
|
---|
706 | LOC_add_packages_entry \
|
---|
707 | `echo $f | sed -e 's/-version//' \
|
---|
708 | -e 's/-file.*//' \
|
---|
709 | -e 's/"//g'`
|
---|
710 | done
|
---|
711 |
|
---|
712 | rm -f packageslist_.wget packages.tmp
|
---|
713 |
|
---|
714 | echo " ...OK"
|
---|
715 | ;;
|
---|
716 |
|
---|
717 | hlfs)
|
---|
718 | echo -n "Creating <${PROGNAME}> specific packages file"
|
---|
719 | grep "\-version" $BOOK/general.ent | sed -e 's@<!ENTITY @@' \
|
---|
720 | -e 's@">@"@' \
|
---|
721 | -e '/generic/d' >> packages
|
---|
722 | echo " ...OK"
|
---|
723 | ;;
|
---|
724 |
|
---|
725 | lfs)
|
---|
726 | echo -n "Creating <${PROGNAME}> specific packages file"
|
---|
727 | grep "\-version" $BOOK/general.ent | sed -e 's@<!ENTITY @@' \
|
---|
728 | -e 's@">@"@' \
|
---|
729 | -e '/generic/d' >> packages
|
---|
730 | echo `grep "glibc" packages | sed 's@glibc@glibc-libidn@'` >> packages
|
---|
731 | echo `grep "udev-config-file" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@'` >> packages
|
---|
732 | echo " ...OK"
|
---|
733 | ;;
|
---|
734 | esac
|
---|
735 |
|
---|
736 | # Download the vim-lang package if it must be installed
|
---|
737 | if [ "$VIMLANG" = "1" ] && [ ! "$PROGNAME" = "hlfs" ] ; then
|
---|
738 | echo `grep "vim" packages | sed 's@vim@&-lang@'` >> packages
|
---|
739 | fi
|
---|
740 |
|
---|
741 | # Create the patches file
|
---|
742 | case "${PROGNAME}" in
|
---|
743 | hlfs)
|
---|
744 | build_patches_file ;;
|
---|
745 | clfs )
|
---|
746 | build_patches_file ;;
|
---|
747 | lfs)
|
---|
748 | grep "^<\!ENTITY" $BOOK/patches.ent | sed -e 's/.* "//' -e 's/">//' >> patches
|
---|
749 | ;;
|
---|
750 | blfs) ;;
|
---|
751 | *) exit 1
|
---|
752 | esac
|
---|
753 |
|
---|
754 | # Done. Moving on...
|
---|
755 | get_sources
|
---|
756 | }
|
---|
757 |
|
---|
758 |
|
---|
759 | #----------------------------#
|
---|
760 | download() { # Download file, write name to MISSING_FILES.DMP if an error
|
---|
761 | #----------------------------#
|
---|
762 | cd $BUILDDIR/sources
|
---|
763 |
|
---|
764 | # Hackish fix for the bash-doc, glibc-{linuxthreads,libidn}
|
---|
765 | # that don't conform to norms in the URL scheme.
|
---|
766 | DIR=`echo $1 | sed 's@-doc@@;s@-linuxthreads@@;s@-libidn@@;s@-testsuite@@'`
|
---|
767 |
|
---|
768 | # If the file exists in the archive copy it to the $BUILDDIR/sources dir
|
---|
769 | # MD5SUM is assumed to be correct from previous download
|
---|
770 | if [ ! -z ${SRC_ARCHIVE} ] &&
|
---|
771 | [ -d ${SRC_ARCHIVE} ] &&
|
---|
772 | [ -f ${SRC_ARCHIVE}/$2 ]; then
|
---|
773 | cp ${SRC_ARCHIVE}/$2 .
|
---|
774 | echo "$2: -- ok"
|
---|
775 | return
|
---|
776 | fi
|
---|
777 |
|
---|
778 | # Find the md5 sum for this package.
|
---|
779 | if [ $2 != MD5SUMS ] ; then
|
---|
780 | set +e
|
---|
781 | MD5=`grep " $2" MD5SUMS`
|
---|
782 | if [ $? -ne 0 ]; then
|
---|
783 | set -e
|
---|
784 | echo "${RED}$2 not found in MD5SUMS${OFF}"
|
---|
785 | echo "$2 not found in MD5SUMS" >> MISSING_FILES.DMP
|
---|
786 | return
|
---|
787 | fi
|
---|
788 | set -e
|
---|
789 | fi
|
---|
790 |
|
---|
791 | if [ ! -f $2 ] ; then
|
---|
792 | case $DL in
|
---|
793 | wgetFTP ) wget --passive $FTP/$DIR/$2 ;;
|
---|
794 | wget ) wget $HTTP/$DIR/$2 ;;
|
---|
795 | curl ) `curl -# $FTP/$DIR/$2 -o $2` ;;
|
---|
796 | * ) echo "$DL not supported at this time." ;;
|
---|
797 | esac
|
---|
798 | elif ! echo "$MD5" | md5sum -c - >/dev/null 2>/dev/null ; then
|
---|
799 | case $DL in
|
---|
800 | wgetFTP ) wget --passive -c $FTP/$DIR/$2 ;;
|
---|
801 | wget ) wget -c $HTTP/$DIR/$2 ;;
|
---|
802 | curl ) `curl -# -C - $FTP/$DIR/$2 -o $2` ;;
|
---|
803 | * ) echo "$DL not supported at this time." ;;
|
---|
804 | esac
|
---|
805 | fi
|
---|
806 |
|
---|
807 | if [ $2 != MD5SUMS ] && ! echo "$MD5" | md5sum -c - ; then
|
---|
808 | exit 1
|
---|
809 | fi
|
---|
810 | if [ $2 != MD5SUMS ] ; then
|
---|
811 | echo `grep "$MD5" MD5SUMS` >> MD5SUMS-$VERSION
|
---|
812 | fi
|
---|
813 |
|
---|
814 | # If we make it this far we should copy the freshly downloaded file
|
---|
815 | # to the source archive.
|
---|
816 | if [ ! -z ${SRC_ARCHIVE} ] &&
|
---|
817 | [ -d ${SRC_ARCHIVE} ] &&
|
---|
818 | [ -w ${SRC_ARCHIVE} ] &&
|
---|
819 | [ $2 != MD5SUMS ]; then
|
---|
820 | echo "Store file:<$2> in package archive"
|
---|
821 | cp -v $2 ${SRC_ARCHIVE}
|
---|
822 | fi
|
---|
823 |
|
---|
824 | }
|
---|
825 |
|
---|
826 |
|
---|
827 | #----------------------------#
|
---|
828 | get_sources() {
|
---|
829 | #----------------------------#
|
---|
830 |
|
---|
831 | # Test if the packages must be downloaded
|
---|
832 | if [ "$HPKG" = "1" ] ; then
|
---|
833 |
|
---|
834 | # This variable is necessary to make sure the `cat $JHALFSDIR/packages`
|
---|
835 | # separates each iteration by lines.
|
---|
836 | # Modify the 'internal field separator' to break on 'LF' only
|
---|
837 | IFS=$'\x0A'
|
---|
838 |
|
---|
839 | if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi
|
---|
840 | cd $BUILDDIR/sources
|
---|
841 | if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi
|
---|
842 | if [ -f MD5SUMS-$VERSION ] ; then rm MD5SUMS-$VERSION ; fi
|
---|
843 | if [ -f MISSING_FILES.DMP ] ; then rm MISSING_FILES.DMP ; fi
|
---|
844 |
|
---|
845 | download "" MD5SUMS
|
---|
846 |
|
---|
847 | # Iterate through each package and grab it, along with any patches it needs.
|
---|
848 | for i in `cat $JHALFSDIR/packages` ; do
|
---|
849 | PKG=`echo $i | sed -e 's/-version.*//' -e 's/-file.*//'`
|
---|
850 |
|
---|
851 | # There are some entities that aren't valid packages.
|
---|
852 | if [ "$PKG" = "expect-lib" -o "$PKG" = "linux-dl" ] ; then continue ; fi
|
---|
853 |
|
---|
854 | VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
|
---|
855 | case $PKG in
|
---|
856 | tcl) FILE="$PKG$VRS-src.tar.bz2" ;;
|
---|
857 | vim-lang) PKG="vim"
|
---|
858 | FILE="vim-$VRS-lang.tar.bz2" ;;
|
---|
859 | udev-config) PKG="udev"
|
---|
860 | FILE="$VRS" ;;
|
---|
861 | *) FILE="$PKG-$VRS.tar.bz2" ;;
|
---|
862 | esac
|
---|
863 | download $PKG $FILE
|
---|
864 |
|
---|
865 | # Download any associated patches
|
---|
866 | for patch in `grep "&$PKG-version" $JHALFSDIR/patches` ; do
|
---|
867 | PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'`
|
---|
868 | download $PKG $PATCH
|
---|
869 | done
|
---|
870 | done
|
---|
871 | if [[ -s $BUILDDIR/sources/MISSING_FILES.DMP ]]; then
|
---|
872 | echo -e "\n\n${tab_}${RED} One or more files were not retrieved.\n${tab_} Check ${L_arrow}$BUILDDIR/sources/MISSING_FILES.DMP${R_arrow} for names ${OFF}\n\n"
|
---|
873 | fi
|
---|
874 | fi
|
---|
875 | }
|
---|
876 |
|
---|