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 |
|
---|
53 | ${BOLD} -D --directory DIR${OFF}
|
---|
54 | use DIR directory for building ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])${OFF}; all files jhalfs produces
|
---|
55 | will be in the directory DIR/jhalfs.
|
---|
56 |
|
---|
57 | ${BOLD} -G, --get-packages${OFF}
|
---|
58 | download the packages and patches. This assumes that the server declared
|
---|
59 | in the configuration file has the proper packages and patches for the
|
---|
60 | book version being processed.
|
---|
61 |
|
---|
62 | ${BOLD} -T, --testsuites N ${OFF}
|
---|
63 | Run test suites [0-3]
|
---|
64 | 0 = none
|
---|
65 | 1 = only chapter06 Glibc, GCC and Binutils testsuites
|
---|
66 | 2 = all chapter06 testsuites (in BLFS, alias to 1)
|
---|
67 | 3 = all chapter05 and chapter06 testsuites
|
---|
68 | In BLFS, 2 and 3 are aliases to 1
|
---|
69 | In CLFS, 3 is an alias to 2
|
---|
70 |
|
---|
71 | ${BOLD} -W, --working-copy DIR${OFF}
|
---|
72 | use the local working copy placed in DIR as the $(echo $PROGNAME | tr [a-z] [A-Z]) book
|
---|
73 | -EOF-
|
---|
74 |
|
---|
75 | [[ ${PROGNAME} != "blfs" ]] &&
|
---|
76 | cat <<- -EOF-
|
---|
77 |
|
---|
78 | ${BOLD} -C, --comparasion TYPE${OFF}
|
---|
79 | do iterative comparison analysis. That will take several time due that
|
---|
80 | the final system packages wil be rebuilded the times defined in the
|
---|
81 | ITERATIONS config option.
|
---|
82 | Analisys types allowed are:
|
---|
83 | ICA = do the ICA analysis designed by Greg Schafer
|
---|
84 | farce = do the farce analysis designed by Ken Moffat
|
---|
85 | both = perfom both ICA and farce analysis
|
---|
86 |
|
---|
87 | ${BOLD} -F, --fstab FILE${OFF}
|
---|
88 | use FILE as the /etc/fstab file for the ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])${OFF} system. If not specified,
|
---|
89 | a default /etc/fstab file with dummy values is created.
|
---|
90 |
|
---|
91 | ${BOLD} -K, --kernel-config FILE${OFF}
|
---|
92 | use the kernel configuration file specified in FILE to build the kernel.
|
---|
93 | if the file is not found, or if not specified, the kernel build is skipped.
|
---|
94 |
|
---|
95 | ${BOLD} -M, --run-make${OFF}
|
---|
96 | run make on the generated Makefile
|
---|
97 |
|
---|
98 | ${BOLD} -R --rebuild${OFF}
|
---|
99 | clean the build directory before to perfom any other task. The directory
|
---|
100 | is cleaned only if it was populated by a previous jhalfs run.
|
---|
101 | -EOF-
|
---|
102 |
|
---|
103 | [[ ${PROGNAME} = "clfs" ]] &&
|
---|
104 | cat <<- -EOF-
|
---|
105 |
|
---|
106 | ${BOLD} -A, --arch ARCH ${OFF}
|
---|
107 | Select the TARGET architecture, valid selections are:
|
---|
108 | 32bit builds
|
---|
109 | x86, i486, i586, ppc, mips, mipsel, sparc
|
---|
110 | 64bit builds
|
---|
111 | x86_64-64, mips64-64, mipsel64-64, sparc64-64, alpha
|
---|
112 | 64bit multi-lib
|
---|
113 | x86_64, mips64, mipsel64, sparc64, ppc64
|
---|
114 |
|
---|
115 | ${BOLD} --boot-config FILE ${OFF}
|
---|
116 | The configuration file for the bootstrap kernel if method=boot
|
---|
117 |
|
---|
118 | ${BOLD} --method BUILDMETHOD ${OFF}
|
---|
119 | Select the build method, chroot or boot
|
---|
120 | -EOF-
|
---|
121 |
|
---|
122 | [[ ${PROGNAME} = "hlfs" ]] &&
|
---|
123 | cat <<- -EOF-
|
---|
124 |
|
---|
125 | ${BOLD} --model STYLE ${OFF}
|
---|
126 | Select the library model for the HLFS system
|
---|
127 | Valid choices are: glibc or uclibc
|
---|
128 | -EOF-
|
---|
129 |
|
---|
130 | [[ ${PROGNAME} = "blfs" ]] &&
|
---|
131 | cat <<- -EOF-
|
---|
132 |
|
---|
133 | ${BOLD} --dependencies 0/1/2${OFF}
|
---|
134 | add dependencies of type TYPE to the build tree.
|
---|
135 | If not set, both required and recommended are used.
|
---|
136 |
|
---|
137 | Possible values are:
|
---|
138 | 0 - required only required dependecies are used
|
---|
139 | 1 - recommended both required a recommended dependencies are used
|
---|
140 | 2 - optional all dependencies are used
|
---|
141 | -EOF-
|
---|
142 |
|
---|
143 | cat <<- -EOF-
|
---|
144 | ${DD_BORDER}
|
---|
145 | -EOF-
|
---|
146 | exit
|
---|
147 | }
|
---|
148 |
|
---|
149 | version="
|
---|
150 | ${BOLD} \"jhalfs\"${OFF} builder tool (development) \$Rev$
|
---|
151 | \$Date$
|
---|
152 |
|
---|
153 | ${BOLD} \"${PROGNAME}\"${OFF} script module
|
---|
154 |
|
---|
155 | Written by George Boudreau,
|
---|
156 | Manuel Canales Esparcia,
|
---|
157 | Jeremy Huntwork
|
---|
158 |
|
---|
159 | This program is published under the ${BOLD}Gnu General Public License, Version 2.${OFF}
|
---|
160 | "
|
---|
161 |
|
---|
162 |
|
---|
163 | no_empty_builddir() {
|
---|
164 | 'clear'
|
---|
165 | cat <<- -EOF-
|
---|
166 | ${DD_BORDER}
|
---|
167 |
|
---|
168 | ${tab_}${tab_}${BOLD}${RED}W A R N I N G${OFF}
|
---|
169 | Looks like the \$BUILDDIR directory contains subdirectories
|
---|
170 | from a previous HLFS build.
|
---|
171 |
|
---|
172 | Please format the partition mounted on \$BUILDDIR or set
|
---|
173 | a different build directory before running jhalfs.
|
---|
174 | ${OFF}
|
---|
175 | ${DD_BORDER}
|
---|
176 | -EOF-
|
---|
177 | exit
|
---|
178 | }
|
---|
179 |
|
---|
180 |
|
---|
181 | help="${nl_}Try '$0 --help' for more information."
|
---|
182 |
|
---|
183 |
|
---|
184 | exit_missing_arg="\
|
---|
185 | echo \"Option '\$1' requires an argument\" >&2
|
---|
186 | echo \"\$help\" >&2
|
---|
187 | exit 1"
|
---|
188 |
|
---|
189 | no_dl_client="\
|
---|
190 | echo \"Could not find a way to download the ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])${OFF} sources.\" >&2
|
---|
191 | echo \"Attempting to continue.\" >&2"
|
---|
192 |
|
---|
193 | HEADER="# This file is automatically generated by jhalfs
|
---|
194 | # DO NOT EDIT THIS FILE MANUALLY
|
---|
195 | #
|
---|
196 | # Generated on `date \"+%F %X %Z\"`"
|
---|
197 |
|
---|
198 |
|
---|
199 |
|
---|
200 |
|
---|
201 |
|
---|
202 | #----------------------------------#
|
---|
203 | wrt_target() { # Create target and initialize log file
|
---|
204 | #----------------------------------#
|
---|
205 | local i=$1
|
---|
206 | local PREV=$2
|
---|
207 | (
|
---|
208 | cat << EOF
|
---|
209 |
|
---|
210 | $i: $PREV
|
---|
211 | @\$(call echo_message, Building)
|
---|
212 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >logs/$this_script
|
---|
213 | EOF
|
---|
214 | ) >> $MKFILE.tmp
|
---|
215 | }
|
---|
216 |
|
---|
217 |
|
---|
218 | #----------------------------------#
|
---|
219 | wrt_unpack() { # Unpack and set 'ROOT' var
|
---|
220 | #----------------------------------#
|
---|
221 | local FILE=$1
|
---|
222 | (
|
---|
223 | cat << EOF
|
---|
224 | @\$(call unpack,$FILE)
|
---|
225 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
226 | echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
|
---|
227 | chown -R lfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
---|
228 | EOF
|
---|
229 | ) >> $MKFILE.tmp
|
---|
230 | }
|
---|
231 |
|
---|
232 |
|
---|
233 | #----------------------------------#
|
---|
234 | wrt_unpack2() { #
|
---|
235 | #----------------------------------#
|
---|
236 | local FILE=$1
|
---|
237 | (
|
---|
238 | cat << EOF
|
---|
239 | @\$(call unpack2,$FILE)
|
---|
240 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
241 | echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
|
---|
242 | EOF
|
---|
243 | ) >> $MKFILE.tmp
|
---|
244 | }
|
---|
245 |
|
---|
246 |
|
---|
247 | #=============================#
|
---|
248 | wrt_unpack3() { #
|
---|
249 | #=============================#
|
---|
250 | local FILE=$1
|
---|
251 | (
|
---|
252 | cat << EOF
|
---|
253 | @\$(call unpack3,$FILE)
|
---|
254 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
255 | echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
|
---|
256 | EOF
|
---|
257 | ) >> $MKFILE.tmp
|
---|
258 | }
|
---|
259 |
|
---|
260 |
|
---|
261 |
|
---|
262 | #----------------------------------#
|
---|
263 | wrt_target_vars() { # Target vars for hlfs (cross-build method)
|
---|
264 | #----------------------------------#
|
---|
265 | (
|
---|
266 | cat << EOF
|
---|
267 | @echo "export target=$(uname -m)-${TARGET}" >> envars && \\
|
---|
268 | echo "export ldso=/lib/${LOADER}" >> envars
|
---|
269 | EOF
|
---|
270 | ) >> $MKFILE.tmp
|
---|
271 |
|
---|
272 | }
|
---|
273 |
|
---|
274 |
|
---|
275 | #----------------------------------#
|
---|
276 | wrt_run_as_su() { # Execute script inside time { }, footer to log file
|
---|
277 | #----------------------------------#
|
---|
278 | local this_script=$1
|
---|
279 | local file=$2
|
---|
280 | (
|
---|
281 | cat << EOF
|
---|
282 | @( time { su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
---|
283 | echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/$this_script
|
---|
284 | EOF
|
---|
285 | ) >> $MKFILE.tmp
|
---|
286 | }
|
---|
287 |
|
---|
288 |
|
---|
289 | #----------------------------------#
|
---|
290 | wrt_run_as_root() { # Some scripts must be run as root..
|
---|
291 | #----------------------------------#
|
---|
292 | local this_script=$1
|
---|
293 | local file=$2
|
---|
294 | (
|
---|
295 | cat << EOF
|
---|
296 | @( time { export LFS=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
---|
297 | echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/$this_script
|
---|
298 | EOF
|
---|
299 | ) >> $MKFILE.tmp
|
---|
300 | }
|
---|
301 |
|
---|
302 |
|
---|
303 | #=============================#
|
---|
304 | wrt_run_as_root2() { #
|
---|
305 | #=============================#
|
---|
306 | local this_script=$1
|
---|
307 | local file=$2
|
---|
308 | (
|
---|
309 | cat << EOF
|
---|
310 | @( time { source envars && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
---|
311 | echo -e "\nKB: \`du -skx --exclude=jhalfs \`\n" >>logs/$this_script
|
---|
312 | EOF
|
---|
313 | ) >> $MKFILE.tmp
|
---|
314 | }
|
---|
315 |
|
---|
316 |
|
---|
317 |
|
---|
318 | #----------------------------------#
|
---|
319 | wrt_run_as_chroot1() { #
|
---|
320 | #----------------------------------#
|
---|
321 | local this_script=$1
|
---|
322 | local file=$2
|
---|
323 | (
|
---|
324 | cat << EOF
|
---|
325 | @( time { \$(CHROOT1) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' ; } ) 2>>logs/$this_script && \\
|
---|
326 | echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/${this_script}
|
---|
327 | EOF
|
---|
328 | ) >> $MKFILE.tmp
|
---|
329 | }
|
---|
330 |
|
---|
331 |
|
---|
332 | #----------------------------------#
|
---|
333 | wrt_run_as_chroot2() { #
|
---|
334 | #----------------------------------#
|
---|
335 | local this_script=$1
|
---|
336 | local file=$2
|
---|
337 | (
|
---|
338 | cat << EOF
|
---|
339 | @( time { \$(CHROOT2) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' ; } ) 2>>logs/$this_script && \\
|
---|
340 | echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/${this_script}
|
---|
341 | EOF
|
---|
342 | ) >> $MKFILE.tmp
|
---|
343 | }
|
---|
344 |
|
---|
345 |
|
---|
346 | #----------------------------------#
|
---|
347 | wrt_copy_fstab() { #
|
---|
348 | #----------------------------------#
|
---|
349 | local i=$1
|
---|
350 | (
|
---|
351 | cat << EOF
|
---|
352 | @cp -v $FSTAB \$(MOUNT_PT)/etc/fstab >>logs/$i 2>&1
|
---|
353 | EOF
|
---|
354 | ) >> $MKFILE.tmp
|
---|
355 | }
|
---|
356 |
|
---|
357 | #----------------------------------#
|
---|
358 | wrt_copy_fstab2() { #
|
---|
359 | #----------------------------------#
|
---|
360 | local i=$1
|
---|
361 | (
|
---|
362 | cat << EOF
|
---|
363 | @cp -v /sources/fstab /etc/fstab >>logs/$i 2>&1
|
---|
364 | EOF
|
---|
365 | ) >> $MKFILE.tmp
|
---|
366 | }
|
---|
367 |
|
---|
368 |
|
---|
369 | #----------------------------------#
|
---|
370 | wrt_remove_build_dirs() { #
|
---|
371 | #----------------------------------#
|
---|
372 | local name=$1
|
---|
373 | (
|
---|
374 | cat << EOF
|
---|
375 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
376 | rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
|
---|
377 | if [ -e \$(MOUNT_PT)\$(SRC)/$name-build ]; then \\
|
---|
378 | rm -r \$(MOUNT_PT)\$(SRC)/$name-build; \\
|
---|
379 | fi;
|
---|
380 | EOF
|
---|
381 | ) >> $MKFILE.tmp
|
---|
382 | }
|
---|
383 |
|
---|
384 |
|
---|
385 | #----------------------------------#
|
---|
386 | wrt_remove_build_dirs2() { #
|
---|
387 | #----------------------------------#
|
---|
388 | local name=$1
|
---|
389 | (
|
---|
390 | cat << EOF
|
---|
391 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
392 | rm -r \$(SRC)/\$\$ROOT && \\
|
---|
393 | if [ -e \$(SRC)/$name-build ]; then \\
|
---|
394 | rm -r \$(SRC)/$name-build; \\
|
---|
395 | fi;
|
---|
396 | EOF
|
---|
397 | ) >> $MKFILE.tmp
|
---|
398 | }
|
---|
399 |
|
---|
400 |
|
---|
401 | #----------------------------------#
|
---|
402 | wrt_report() { #
|
---|
403 | #----------------------------------#
|
---|
404 | (
|
---|
405 | cat << EOF
|
---|
406 |
|
---|
407 | create-sbu_du-report: $PREV
|
---|
408 | @\$(call echo_message, Building)
|
---|
409 | @./create-sbu_du-report.sh logs $VERSION
|
---|
410 | @\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report)
|
---|
411 | @touch \$@
|
---|
412 | EOF
|
---|
413 | ) >> $MKFILE.tmp
|
---|
414 |
|
---|
415 | chapter789="$chapter789 create-sbu_du-report"
|
---|
416 | }
|
---|
417 |
|
---|
418 |
|
---|
419 | #----------------------------#
|
---|
420 | run_make() {
|
---|
421 | #----------------------------#
|
---|
422 | # Test if make must be run.
|
---|
423 | if [ "$RUNMAKE" = "1" ] ; then
|
---|
424 | # Test to make sure we're running the build as root
|
---|
425 | if [ "$UID" != "0" ] ; then
|
---|
426 | echo "You must be logged in as root to successfully build the system."
|
---|
427 | exit 1
|
---|
428 | fi
|
---|
429 | # Build the system
|
---|
430 | if [ -e $MKFILE ] ; then
|
---|
431 | echo -ne "Building the system...\n"
|
---|
432 | cd $JHALFSDIR && make
|
---|
433 | echo -ne "done\n"
|
---|
434 | fi
|
---|
435 | fi
|
---|
436 | }
|
---|
437 |
|
---|
438 |
|
---|
439 | #----------------------------#
|
---|
440 | clean_builddir() {
|
---|
441 | #----------------------------#
|
---|
442 | # Test if the clean must be done.
|
---|
443 | if [ "$CLEAN" = "1" ] ; then
|
---|
444 | # Test to make sure we're running the clean as root
|
---|
445 | if [ "$UID" != "0" ] ; then
|
---|
446 | echo "You must be logged in as root to clean the build directory."
|
---|
447 | exit 1
|
---|
448 | fi
|
---|
449 | # Test to make sure that the build directory was populated by jhalfs
|
---|
450 | if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
|
---|
451 | echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
|
---|
452 | exit 1
|
---|
453 | else
|
---|
454 | # Clean the build directory
|
---|
455 | echo -ne "Cleaning $BUILDDIR...\n"
|
---|
456 | rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,cross-tools,usr,var}
|
---|
457 | echo -ne "Cleaning $JHALFSDIR...\n"
|
---|
458 | rm -rf $JHALFSDIR/{0*,1*,envars,sources-dir,*commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
|
---|
459 | echo -ne "Cleaning remainig extracted sources in $BUILDDIR/sources...\n"
|
---|
460 | rm -rf `find $BUILDDIR/sources/* -maxdepth 0 -type d`
|
---|
461 | echo -ne "done\n"
|
---|
462 | fi
|
---|
463 | fi
|
---|
464 | }
|
---|
465 |
|
---|
466 | #----------------------------#
|
---|
467 | get_book() {
|
---|
468 | #----------------------------#
|
---|
469 | cd $JHALFSDIR
|
---|
470 |
|
---|
471 | if [ -z $WC ] ; then
|
---|
472 | # Check for Subversion instead of just letting the script hit 'svn' and fail.
|
---|
473 | test `type -p svn` || eval "echo \"This feature requires Subversion.\"
|
---|
474 | exit 1"
|
---|
475 | echo -n "Downloading the $PROGNAME document, $LFSVRS version... "
|
---|
476 |
|
---|
477 | case $PROGNAME in
|
---|
478 | lfs) svn_root="LFS" ;;
|
---|
479 | hlfs) svn_root="HLFS" ;;
|
---|
480 | clfs) svn_root="cross-lfs" ;;
|
---|
481 | blfs) svn_root="BLFS" ;;
|
---|
482 | *) echo "BOOK not defined in function <get_book>"
|
---|
483 | exit 1 ;;
|
---|
484 | esac
|
---|
485 | # Grab a fresh book if it's missing, otherwise, update it from the
|
---|
486 | # repo. If we've already extracted the commands, move on to getting the
|
---|
487 | # sources.
|
---|
488 | if [ -d ${PROGNAME}-$LFSVRS ] ; then
|
---|
489 | cd ${PROGNAME}-$LFSVRS
|
---|
490 | if LC_ALL=C svn up | grep -q At && test -d $JHALFSDIR/${PROGNAME}-commands && \
|
---|
491 | test -f $JHALFSDIR/packages ; then
|
---|
492 | echo -ne "done\n"
|
---|
493 | # Set the canonical book version
|
---|
494 | cd $JHALFSDIR
|
---|
495 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
496 | get_sources
|
---|
497 | else
|
---|
498 | echo -ne "done\n"
|
---|
499 | # Set the canonical book version
|
---|
500 | cd $JHALFSDIR
|
---|
501 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
502 | extract_commands
|
---|
503 | fi
|
---|
504 | else
|
---|
505 | case $LFSVRS in
|
---|
506 | development)
|
---|
507 | svn co $SVN/${svn_root}/trunk/BOOK ${PROGNAME}-$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 | extract_commands() { #
|
---|
526 | #----------------------------#
|
---|
527 |
|
---|
528 | # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
|
---|
529 | test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
|
---|
530 | exit 1"
|
---|
531 |
|
---|
532 | cd $JHALFSDIR
|
---|
533 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
534 |
|
---|
535 | # Start clean
|
---|
536 | if [ -d ${PROGNAME}-commands ]; then
|
---|
537 | rm -rf ${PROGNAME}-commands
|
---|
538 | mkdir -v ${PROGNAME}-commands
|
---|
539 | fi
|
---|
540 | echo -n "Extracting commands for"
|
---|
541 |
|
---|
542 | # Dump the commands in shell script form from the HLFS book.
|
---|
543 | case ${PROGNAME} in
|
---|
544 | clfs)
|
---|
545 | echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
|
---|
546 | xsltproc --nonet \
|
---|
547 | --xinclude \
|
---|
548 | --stringparam method $METHOD \
|
---|
549 | --stringparam testsuite $TEST \
|
---|
550 | --stringparam vim-lang $VIMLANG \
|
---|
551 | --stringparam timezone $TIMEZONE \
|
---|
552 | --stringparam page $PAGE \
|
---|
553 | --stringparam lang $LANG \
|
---|
554 | --stringparam keymap $KEYMAP \
|
---|
555 | -o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
|
---|
556 | ;;
|
---|
557 | hlfs)
|
---|
558 | echo -n " ${L_arrow}${BOLD}$MODEL${R_arrow} HLFS libc implementation"
|
---|
559 | xsltproc --nonet \
|
---|
560 | --xinclude \
|
---|
561 | --stringparam model $MODEL \
|
---|
562 | --stringparam testsuite $TEST \
|
---|
563 | --stringparam timezone $TIMEZONE \
|
---|
564 | --stringparam page $PAGE \
|
---|
565 | --stringparam lang $LANG \
|
---|
566 | --stringparam lc_all $LC_ALL \
|
---|
567 | --stringparam keymap $KEYMAP \
|
---|
568 | --stringparam grsecurity_host $GRSECURITY_HOST \
|
---|
569 | -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
570 | ;;
|
---|
571 | lfs)
|
---|
572 | echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build"
|
---|
573 | xsltproc --nonet \
|
---|
574 | --xinclude \
|
---|
575 | --stringparam testsuite $TEST \
|
---|
576 | --stringparam vim-lang $VIMLANG \
|
---|
577 | --stringparam timezone $TIMEZONE \
|
---|
578 | --stringparam page $PAGE \
|
---|
579 | --stringparam lang $LANG \
|
---|
580 | -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
581 | ;;
|
---|
582 | blfs)
|
---|
583 | echo -n " ${L_arrow}${BOLD}BLFS${R_arrow} build"
|
---|
584 | xsltproc --nonet \
|
---|
585 | --xinclude \
|
---|
586 | --stringparam testsuite $TEST \
|
---|
587 | --stringparam server $SERVER \
|
---|
588 | -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
589 | ;;
|
---|
590 | *) exit 1 ;;
|
---|
591 | esac
|
---|
592 |
|
---|
593 | echo " ...OK"
|
---|
594 |
|
---|
595 | # Make the scripts executable.
|
---|
596 | chmod -R +x $JHALFSDIR/${PROGNAME}-commands
|
---|
597 |
|
---|
598 | # Create the packages file. We need it for proper Makefile creation
|
---|
599 | rm -f packages
|
---|
600 | case "${PROGNAME}" in
|
---|
601 | clfs)
|
---|
602 | echo -n "Creating <${PROGNAME}> specific packages file"
|
---|
603 | grep "\-version " $BOOK/packages.ent | sed -e 's@<!ENTITY @@' \
|
---|
604 | -e 's@">@"@' \
|
---|
605 | -e '/generic/d' > packages
|
---|
606 | echo " ...OK"
|
---|
607 | ;;
|
---|
608 |
|
---|
609 | hlfs)
|
---|
610 | echo -n "Creating <${PROGNAME}> specific packages file"
|
---|
611 | grep "\-version" $BOOK/general.ent | sed -e 's@<!ENTITY @@' \
|
---|
612 | -e 's@">@"@' \
|
---|
613 | -e '/generic/d' >> packages
|
---|
614 | echo " ...OK"
|
---|
615 | ;;
|
---|
616 |
|
---|
617 | lfs)
|
---|
618 | echo -n "Creating <${PROGNAME}> specific packages file"
|
---|
619 | grep "\-version" $BOOK/general.ent | sed -e 's@<!ENTITY @@' \
|
---|
620 | -e 's@">@"@' \
|
---|
621 | -e '/generic/d' >> packages
|
---|
622 | echo " ...OK"
|
---|
623 | ;;
|
---|
624 | esac
|
---|
625 |
|
---|
626 | # Done. Moving on...
|
---|
627 | get_sources
|
---|
628 | }
|
---|
629 |
|
---|
630 |
|
---|
631 | #----------------------------#
|
---|
632 | get_sources() { # Download file, write name to MISSING_FILES.DMP if an error
|
---|
633 | #----------------------------#
|
---|
634 | local saveIFS=$IFS
|
---|
635 | local IFS line URL1 URL2 FILE MD5 NOMD5
|
---|
636 |
|
---|
637 | # Test if the packages must be downloaded
|
---|
638 | if [ "$GETPKG" = "1" ] ; then
|
---|
639 |
|
---|
640 | [[ ! -d $BUILDDIR/sources ]] && mkdir $BUILDDIR/sources
|
---|
641 | cd $BUILDDIR/sources
|
---|
642 | [[ -f MD5SUMS ]] && rm MD5SUMS
|
---|
643 | [[ -f MD5SUMS-$VERSION ]] && rm MD5SUMS-$VERSION
|
---|
644 | [[ -f MISSING_FILES.DMP ]] && rm MISSING_FILES.DMP
|
---|
645 | [[ -f urls.lst ]] && rm urls.lst
|
---|
646 |
|
---|
647 | # Download a fresh MD5SUMS file
|
---|
648 | wget $SERVER/pub/lfs/conglomeration/MD5SUMS
|
---|
649 |
|
---|
650 | # Generate URLs file
|
---|
651 | create_urls
|
---|
652 |
|
---|
653 | IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
|
---|
654 | for line in `cat urls.lst`; do
|
---|
655 | IFS=$saveIFS # Restore the system defaults
|
---|
656 |
|
---|
657 | # Skip some packages if they aren't needed
|
---|
658 | case $line in
|
---|
659 | */tcl* | */expect* | */dejagnu* | */tree* | */gcc-testsuite* )
|
---|
660 | [[ "$TEST" = "0" ]] && continue
|
---|
661 | ;;
|
---|
662 | */vim-*-lang* )
|
---|
663 | [[ "$VIMLANG" = "0" ]] && continue
|
---|
664 | ;;
|
---|
665 | esac
|
---|
666 |
|
---|
667 | URL1=`echo $line | cut -d" " -f1` # Upstream URL
|
---|
668 | URL2=`echo $line | cut -d" " -f2` # Fallback URL
|
---|
669 | FILE=`basename $URL2` # File name
|
---|
670 |
|
---|
671 | # If the file exists in the archive copy it to the $BUILDDIR/sources dir
|
---|
672 | # MD5SUM is assumed to be correct from previous download
|
---|
673 | if [ ! -z ${SRC_ARCHIVE} ] &&
|
---|
674 | [ -d ${SRC_ARCHIVE} ] &&
|
---|
675 | [ -f ${SRC_ARCHIVE}/$FILE ]; then
|
---|
676 | cp ${SRC_ARCHIVE}/$FILE .
|
---|
677 | echo "$FILE: -- copied from $SRC_ARCHIVE" && continue
|
---|
678 | fi
|
---|
679 |
|
---|
680 | # Find the md5 sum for this package.
|
---|
681 | set +e
|
---|
682 | MD5=`grep " $FILE" MD5SUMS`
|
---|
683 | if [ $? -ne 0 ]; then
|
---|
684 | set -e
|
---|
685 | echo "${RED}$FILE not found in MD5SUMS${OFF}"
|
---|
686 | echo "$FILE not found in MD5SUMS" >> MISSING_FILES.DMP
|
---|
687 | NOMD5=1
|
---|
688 | fi
|
---|
689 | set -e
|
---|
690 |
|
---|
691 | if [ ! -f $FILE ] ; then
|
---|
692 | wget $URL1 || wget $URL2 || \
|
---|
693 | echo "${RED}$FILE not found on the servers${OFF}"
|
---|
694 | echo "$FILE not found on the servers" >> MISSING_FILES.DMP
|
---|
695 | elif [[ "$NOMD5" != "1" ]] && ! echo "$MD5" | md5sum -c - ; then
|
---|
696 | wget -N $URL1 || wget -N $URL2 || \
|
---|
697 | echo "${RED}$FILE not found on the servers${OFF}"
|
---|
698 | echo "$FILE not found on the servers" >> MISSING_FILES.DMP
|
---|
699 | fi
|
---|
700 |
|
---|
701 | if [[ "$NOMD5" != "1" ]] && ! echo "$MD5" | md5sum -c - ; then
|
---|
702 | echo "${RED}$FILE not match MD5SUMS value${OFF}"
|
---|
703 | echo "$FILE not match MD5SUMS value" >> MISSING_FILES.DMP
|
---|
704 | fi
|
---|
705 | echo `grep "$MD5" MD5SUMS` >> MD5SUMS-$VERSION
|
---|
706 |
|
---|
707 | # Copy the freshly downloaded file
|
---|
708 | # to the source archive.
|
---|
709 | if [ ! -z ${SRC_ARCHIVE} ] &&
|
---|
710 | [ -d ${SRC_ARCHIVE} ] &&
|
---|
711 | [ -w ${SRC_ARCHIVE} ] &&
|
---|
712 | [ ! -f ${SRC_ARCHIVE}/$FILE ] ; then
|
---|
713 | echo "Store file:<$FILE> in package archive"
|
---|
714 | cp -v $FILE ${SRC_ARCHIVE}
|
---|
715 | fi
|
---|
716 |
|
---|
717 | done
|
---|
718 |
|
---|
719 | if [[ -s MISSING_FILES.DMP ]]; then
|
---|
720 | echo -e "\n\n${tab_}${RED} One or more files were not retrieved or have a bad MD5SUMS chechsum.\n${tab_} Check ${L_arrow}$BUILDDIR/sources/MISSING_FILES.DMP${R_arrow} for names ${OFF}\n\n"
|
---|
721 | fi
|
---|
722 |
|
---|
723 | fi
|
---|
724 | }
|
---|
725 |
|
---|
726 |
|
---|
727 | #----------------------------#
|
---|
728 | create_urls() { #
|
---|
729 | #----------------------------#
|
---|
730 | cd $JHALFSDIR
|
---|
731 |
|
---|
732 | case ${PROGNAME} in
|
---|
733 | clfs)
|
---|
734 | echo -n "Creating CLFS <${ARCH}> specific URLs file"
|
---|
735 | xsltproc --nonet --xinclude \
|
---|
736 | --stringparam server $SERVER \
|
---|
737 | -o $BUILDDIR/sources/urls.lst urls.xsl \
|
---|
738 | $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
|
---|
739 | echo " ...OK"
|
---|
740 | ;;
|
---|
741 | hlfs)
|
---|
742 | echo -n "Creating HLFS <${MODEL}> specific URLs file"
|
---|
743 | xsltproc --nonet --xinclude \
|
---|
744 | --stringparam server $SERVER \
|
---|
745 | --stringparam model $MODEL \
|
---|
746 | -o $BUILDDIR/sources/urls.lst urls.xsl \
|
---|
747 | $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
|
---|
748 | echo " ...OK"
|
---|
749 | ;;
|
---|
750 | lfs)
|
---|
751 | echo -n "Creating LFS specific URLs file"
|
---|
752 | xsltproc --nonet --xinclude \
|
---|
753 | --stringparam server $SERVER \
|
---|
754 | -o ../sources/urls.lst urls.xsl \
|
---|
755 | $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
|
---|
756 | echo " ...OK"
|
---|
757 | ;;
|
---|
758 | esac
|
---|
759 |
|
---|
760 | cd $BUILDDIR/sources
|
---|
761 | }
|
---|