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}==============================================================================${OFF}"
|
---|
28 | declare -r SD_BORDER="${BOLD}------------------------------------------------------------------------------${OFF}"
|
---|
29 | declare -r STAR_BORDER="${BOLD}******************************************************************************${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 | ${RED}IMPORTANT:${OFF} Only supported command line switches are listed here.
|
---|
43 | For more fine-grained setups you must edit the relevant
|
---|
44 | configuration files placed under ${BOLD}common/${OFF} and ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])/${OFF}
|
---|
45 |
|
---|
46 | Options:
|
---|
47 | ${BOLD} -h, --help${OFF}
|
---|
48 | print this help, then exit
|
---|
49 |
|
---|
50 | ${BOLD} -V, --version${OFF}
|
---|
51 | print version information, then exit
|
---|
52 |
|
---|
53 | ${BOLD} -B, --book VER${OFF}
|
---|
54 | use VER version of the book as the system to build.
|
---|
55 | Supported versions are: dev*, trunk, SVN
|
---|
56 | These are aliases for the Development version of {C,H}LFS
|
---|
57 |
|
---|
58 | ${BOLD} -D --directory DIR${OFF}
|
---|
59 | use DIR directory for building ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])${OFF}; all files jhalfs produces
|
---|
60 | will be in the directory DIR/jhalfs.
|
---|
61 | The current setting for BUILDDIR is "$BUILDDIR"
|
---|
62 |
|
---|
63 | ${BOLD} -G, --get-packages${OFF}
|
---|
64 | download the packages and patches. This assumes that the server declared
|
---|
65 | in the configuration file has the proper packages and patches for the
|
---|
66 | book version being processed.
|
---|
67 |
|
---|
68 | ${BOLD} -O, --optimize${OFF}
|
---|
69 | Optimize [0-2]
|
---|
70 | 0 = no optimization
|
---|
71 | 1 = optimize final system only
|
---|
72 | 2 = optimize both temporary tools and final system
|
---|
73 | Edit common/opt_config{,.d/*} and common/opt_override as desired.
|
---|
74 |
|
---|
75 | ${BOLD} -T, --testsuites N ${OFF}
|
---|
76 | Run test suites [0-3]
|
---|
77 | 0 = none
|
---|
78 | 1 = only final system Glibc, GCC and Binutils testsuites
|
---|
79 | 2 = all final system testsuites
|
---|
80 | 3 = all temporary tools and final system testsuites
|
---|
81 | In CLFS, 3 is an alias to 2
|
---|
82 |
|
---|
83 | ${BOLD} -W, --working-copy DIR${OFF}
|
---|
84 | use the local working copy placed in DIR as the $(echo $PROGNAME | tr [a-z] [A-Z]) book
|
---|
85 |
|
---|
86 | ${BOLD} -C, --comparasion TYPE${OFF}
|
---|
87 | do iterative comparison analysis. This extends the total build time
|
---|
88 | considerably because the entire final system will rebuild itself
|
---|
89 | the number of times specified by ITERATIONS in common/config.
|
---|
90 | Types allowed are:
|
---|
91 | ICA = do ICA as designed by Greg Schafer
|
---|
92 | farce = do the farce analysis designed by Ken Moffat
|
---|
93 | both = perfom both ICA and farce analysis
|
---|
94 |
|
---|
95 | ${BOLD} -F, --fstab FILE${OFF}
|
---|
96 | use FILE as the /etc/fstab file for the ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])${OFF} system. If not specified,
|
---|
97 | a default /etc/fstab file with dummy values is created.
|
---|
98 |
|
---|
99 | ${BOLD} -K, --kernel-config FILE${OFF}
|
---|
100 | use the kernel configuration file specified in FILE to build the kernel.
|
---|
101 | if the file is not found, or if not specified, the kernel build is skipped.
|
---|
102 |
|
---|
103 | ${BOLD} -M, --run-make${OFF}
|
---|
104 | run make on the generated Makefile
|
---|
105 |
|
---|
106 | ${BOLD} -R --rebuild${OFF}
|
---|
107 | clean the build directory before perfoming any other task. The directory
|
---|
108 | is cleaned only if it was populated by a previous jhalfs run.
|
---|
109 | -EOF-
|
---|
110 |
|
---|
111 | [[ ${PROGNAME} = "clfs" ]] &&
|
---|
112 | cat <<- -EOF-
|
---|
113 |
|
---|
114 | ${BOLD} -A, --arch ARCH ${OFF}
|
---|
115 | Select the TARGET architecture, valid selections are:
|
---|
116 | 32bit builds
|
---|
117 | x86, i486, i586, ppc, mips, mipsel, sparc
|
---|
118 | 64bit builds
|
---|
119 | x86_64-64, mips64-64, mipsel64-64, sparc64-64, alpha
|
---|
120 | 64bit multi-lib
|
---|
121 | x86_64, mips64, mipsel64, sparc64, ppc64
|
---|
122 |
|
---|
123 | ${BOLD} --boot-config FILE ${OFF}
|
---|
124 | The configuration file for the bootstrap kernel if method=boot
|
---|
125 |
|
---|
126 | ${BOLD} --method BUILDMETHOD ${OFF}
|
---|
127 | Select the build method, chroot or boot
|
---|
128 | -EOF-
|
---|
129 |
|
---|
130 | [[ ${PROGNAME} = "hlfs" ]] &&
|
---|
131 | cat <<- -EOF-
|
---|
132 |
|
---|
133 | ${BOLD} --model STYLE ${OFF}
|
---|
134 | Select the library model for the HLFS system
|
---|
135 | Valid choices are: glibc or uclibc
|
---|
136 | -EOF-
|
---|
137 |
|
---|
138 | cat <<- -EOF-
|
---|
139 | ${DD_BORDER}
|
---|
140 | -EOF-
|
---|
141 | exit
|
---|
142 | }
|
---|
143 |
|
---|
144 | version="
|
---|
145 | ${BOLD} \"jhalfs\"${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.
|
---|
169 | ${OFF}
|
---|
170 | ${DD_BORDER}
|
---|
171 | -EOF-
|
---|
172 | exit
|
---|
173 | }
|
---|
174 |
|
---|
175 |
|
---|
176 | help="${nl_}Try '$0 --help' for more information."
|
---|
177 |
|
---|
178 | exit_missing_arg="\
|
---|
179 | echo \"Option '\$1' requires an argument\" >&2
|
---|
180 | echo \"\$help\" >&2
|
---|
181 | exit 1"
|
---|
182 |
|
---|
183 | HEADER="# This file is automatically generated by jhalfs
|
---|
184 | # DO NOT EDIT THIS FILE MANUALLY
|
---|
185 | #
|
---|
186 | # Generated on `date \"+%F %X %Z\"`"
|
---|
187 |
|
---|
188 |
|
---|
189 |
|
---|
190 | #----------------------------------#
|
---|
191 | wrt_target() { # Create target and initialize log file
|
---|
192 | #----------------------------------#
|
---|
193 | local i=$1
|
---|
194 | local PREV=$2
|
---|
195 | case $i in
|
---|
196 | iteration* ) local LOGFILE=$this_script.log ;;
|
---|
197 | * ) local LOGFILE=$this_script ;;
|
---|
198 | esac
|
---|
199 | (
|
---|
200 | cat << EOF
|
---|
201 |
|
---|
202 | $i: $PREV
|
---|
203 | @\$(call echo_message, Building)
|
---|
204 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >logs/$LOGFILE
|
---|
205 | EOF
|
---|
206 | ) >> $MKFILE.tmp
|
---|
207 | }
|
---|
208 |
|
---|
209 |
|
---|
210 | #----------------------------------#
|
---|
211 | wrt_unpack() { # Unpack and set 'ROOT' var
|
---|
212 | #----------------------------------#
|
---|
213 | local FILE=$1
|
---|
214 | local file=$2
|
---|
215 | (
|
---|
216 | cat << EOF
|
---|
217 | @\$(call unpack,$FILE)
|
---|
218 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
219 | echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
|
---|
220 | chown -R lfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
---|
221 | EOF
|
---|
222 | ) >> $MKFILE.tmp
|
---|
223 | }
|
---|
224 |
|
---|
225 |
|
---|
226 | #----------------------------------#
|
---|
227 | wrt_unpack2() { #
|
---|
228 | #----------------------------------#
|
---|
229 | local FILE=$1
|
---|
230 | (
|
---|
231 | cat << EOF
|
---|
232 | @\$(call unpack2,$FILE)
|
---|
233 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
234 | echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
|
---|
235 | EOF
|
---|
236 | ) >> $MKFILE.tmp
|
---|
237 | }
|
---|
238 |
|
---|
239 |
|
---|
240 | #----------------------------------#
|
---|
241 | wrt_unpack3() { #
|
---|
242 | #----------------------------------#
|
---|
243 | local FILE=$1
|
---|
244 | (
|
---|
245 | cat << EOF
|
---|
246 | @\$(call unpack3,$FILE)
|
---|
247 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
248 | echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars
|
---|
249 | EOF
|
---|
250 | ) >> $MKFILE.tmp
|
---|
251 | }
|
---|
252 |
|
---|
253 |
|
---|
254 | #----------------------------------#
|
---|
255 | wrt_target_vars() { # Target vars for hlfs (cross-build method)
|
---|
256 | #----------------------------------#
|
---|
257 | (
|
---|
258 | cat << EOF
|
---|
259 | @echo "export target=$(uname -m)-${TARGET}" >> envars && \\
|
---|
260 | echo "export ldso=/lib/${LOADER}" >> envars
|
---|
261 | EOF
|
---|
262 | ) >> $MKFILE.tmp
|
---|
263 |
|
---|
264 | }
|
---|
265 |
|
---|
266 |
|
---|
267 | #----------------------------------#
|
---|
268 | wrt_run_as_su() { # Execute script inside time { }, footer to log file
|
---|
269 | #----------------------------------#
|
---|
270 | local this_script=$1
|
---|
271 | local file=$2
|
---|
272 | (
|
---|
273 | cat << EOF
|
---|
274 | @( time { su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
---|
275 | echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/$this_script
|
---|
276 | EOF
|
---|
277 | ) >> $MKFILE.tmp
|
---|
278 | }
|
---|
279 |
|
---|
280 |
|
---|
281 | #----------------------------------#
|
---|
282 | wrt_run_as_root() { # Some scripts must be run as root..
|
---|
283 | #----------------------------------#
|
---|
284 | local this_script=$1
|
---|
285 | local file=$2
|
---|
286 | (
|
---|
287 | cat << EOF
|
---|
288 | @( time { export LFS=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
---|
289 | echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/$this_script
|
---|
290 | EOF
|
---|
291 | ) >> $MKFILE.tmp
|
---|
292 | }
|
---|
293 |
|
---|
294 |
|
---|
295 | #----------------------------------#
|
---|
296 | wrt_run_as_root2() { #
|
---|
297 | #----------------------------------#
|
---|
298 | local this_script=$1
|
---|
299 | local file=$2
|
---|
300 | (
|
---|
301 | cat << EOF
|
---|
302 | @( time { source envars && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
---|
303 | echo -e "\nKB: \`du -skx --exclude=jhalfs \`\n" >>logs/$this_script
|
---|
304 | EOF
|
---|
305 | ) >> $MKFILE.tmp
|
---|
306 | }
|
---|
307 |
|
---|
308 |
|
---|
309 |
|
---|
310 | #----------------------------------#
|
---|
311 | wrt_run_as_chroot1() { #
|
---|
312 | #----------------------------------#
|
---|
313 | local this_script=$1
|
---|
314 | local file=$2
|
---|
315 | (
|
---|
316 | cat << EOF
|
---|
317 | @( time { \$(CHROOT1) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' ; } ) 2>>logs/$this_script && \\
|
---|
318 | echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/${this_script}
|
---|
319 | EOF
|
---|
320 | ) >> $MKFILE.tmp
|
---|
321 | }
|
---|
322 |
|
---|
323 |
|
---|
324 | #----------------------------------#
|
---|
325 | wrt_run_as_chroot2() { #
|
---|
326 | #----------------------------------#
|
---|
327 | local this_script=$1
|
---|
328 | local file=$2
|
---|
329 | (
|
---|
330 | cat << EOF
|
---|
331 | @( time { \$(CHROOT2) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' ; } ) 2>>logs/$this_script && \\
|
---|
332 | echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/${this_script}
|
---|
333 | EOF
|
---|
334 | ) >> $MKFILE.tmp
|
---|
335 | }
|
---|
336 |
|
---|
337 |
|
---|
338 | #----------------------------------#
|
---|
339 | wrt_copy_fstab() { #
|
---|
340 | #----------------------------------#
|
---|
341 | local i=$1
|
---|
342 | (
|
---|
343 | cat << EOF
|
---|
344 | @cp -v $FSTAB \$(MOUNT_PT)/etc/fstab >>logs/$i 2>&1
|
---|
345 | EOF
|
---|
346 | ) >> $MKFILE.tmp
|
---|
347 | }
|
---|
348 |
|
---|
349 | #----------------------------------#
|
---|
350 | wrt_copy_fstab2() { #
|
---|
351 | #----------------------------------#
|
---|
352 | local i=$1
|
---|
353 | (
|
---|
354 | cat << EOF
|
---|
355 | @cp -v /sources/fstab /etc/fstab >>logs/$i 2>&1
|
---|
356 | EOF
|
---|
357 | ) >> $MKFILE.tmp
|
---|
358 | }
|
---|
359 |
|
---|
360 |
|
---|
361 | #----------------------------------#
|
---|
362 | wrt_remove_build_dirs() { #
|
---|
363 | #----------------------------------#
|
---|
364 | local name=$1
|
---|
365 | (
|
---|
366 | cat << EOF
|
---|
367 | @if [ -f /tmp/unpacked ] ; then \\
|
---|
368 | ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
369 | if [ "x" != "x\$\$ROOT" ] ; then rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT; fi; \\
|
---|
370 | fi;
|
---|
371 | @if [ -e \$(MOUNT_PT)\$(SRC)/$name-build ]; then \\
|
---|
372 | rm -r \$(MOUNT_PT)\$(SRC)/$name-build; \\
|
---|
373 | fi;
|
---|
374 | EOF
|
---|
375 | ) >> $MKFILE.tmp
|
---|
376 | }
|
---|
377 |
|
---|
378 |
|
---|
379 | #----------------------------------#
|
---|
380 | wrt_remove_build_dirs2() { #
|
---|
381 | #----------------------------------#
|
---|
382 | local name=$1
|
---|
383 | (
|
---|
384 | cat << EOF
|
---|
385 | @if [ -f /tmp/unpacked ] ; then \\
|
---|
386 | ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
387 | if [ "x" != "x\$\$ROOT" ] ; then rm -r \$(SRC)/\$\$ROOT; fi; \\
|
---|
388 | fi;
|
---|
389 | @if [ -e \$(SRC)/$name-build ]; then \\
|
---|
390 | rm -r \$(SRC)/$name-build; \\
|
---|
391 | fi;
|
---|
392 | EOF
|
---|
393 | ) >> $MKFILE.tmp
|
---|
394 | }
|
---|
395 |
|
---|
396 |
|
---|
397 | #----------------------------------#
|
---|
398 | wrt_report() { #
|
---|
399 | #----------------------------------#
|
---|
400 | (
|
---|
401 | cat << EOF
|
---|
402 |
|
---|
403 | create-sbu_du-report: $PREV
|
---|
404 | @\$(call echo_message, Building)
|
---|
405 | @./create-sbu_du-report.sh logs $VERSION
|
---|
406 | @\$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report)
|
---|
407 | @touch \$@
|
---|
408 | EOF
|
---|
409 | ) >> $MKFILE.tmp
|
---|
410 |
|
---|
411 | chapter789="$chapter789 create-sbu_du-report"
|
---|
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
|
---|
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 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 | *) echo "BOOK not defined in function <get_book>"
|
---|
478 | exit 1 ;;
|
---|
479 | esac
|
---|
480 | # Grab a fresh book if it's missing, otherwise, update it from the
|
---|
481 | # repo. If we've already extracted the commands, move on to getting the
|
---|
482 | # sources.
|
---|
483 | if [ -d ${PROGNAME}-$LFSVRS ] ; then
|
---|
484 | cd ${PROGNAME}-$LFSVRS
|
---|
485 | if LC_ALL=C svn up | grep -q At && test -d $JHALFSDIR/${PROGNAME}-commands && \
|
---|
486 | test -f $JHALFSDIR/packages ; then
|
---|
487 | echo -ne "done\n"
|
---|
488 | # Set the canonical book version
|
---|
489 | cd $JHALFSDIR
|
---|
490 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
491 | get_sources
|
---|
492 | else
|
---|
493 | echo -ne "done\n"
|
---|
494 | # Set the canonical book version
|
---|
495 | cd $JHALFSDIR
|
---|
496 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
497 | extract_commands
|
---|
498 | fi
|
---|
499 | else
|
---|
500 | case $LFSVRS in
|
---|
501 | development)
|
---|
502 | svn co $SVN/${svn_root}/trunk/BOOK ${PROGNAME}-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
|
---|
503 | esac
|
---|
504 | echo -ne "done\n"
|
---|
505 | # Set the canonical book version
|
---|
506 | cd $JHALFSDIR
|
---|
507 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
508 | extract_commands
|
---|
509 | fi
|
---|
510 | else
|
---|
511 | echo -ne "Using $BOOK as book's sources ...\n"
|
---|
512 | # Set the canonical book version
|
---|
513 | cd $JHALFSDIR
|
---|
514 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
515 | extract_commands
|
---|
516 | fi
|
---|
517 | }
|
---|
518 |
|
---|
519 | #----------------------------#
|
---|
520 | extract_commands() { #
|
---|
521 | #----------------------------#
|
---|
522 |
|
---|
523 | # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
|
---|
524 | test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
|
---|
525 | exit 1"
|
---|
526 |
|
---|
527 | cd $JHALFSDIR
|
---|
528 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
529 |
|
---|
530 | # Start clean
|
---|
531 | if [ -d ${PROGNAME}-commands ]; then
|
---|
532 | rm -rf ${PROGNAME}-commands
|
---|
533 | mkdir -v ${PROGNAME}-commands
|
---|
534 | fi
|
---|
535 | echo -n "Extracting commands for"
|
---|
536 |
|
---|
537 | # Dump the commands in shell script form from the HLFS book.
|
---|
538 | case ${PROGNAME} in
|
---|
539 | clfs)
|
---|
540 | echo -n " ${L_arrow}${BOLD}$ARCH${R_arrow} target architecture"
|
---|
541 | xsltproc --nonet \
|
---|
542 | --xinclude \
|
---|
543 | --stringparam method $METHOD \
|
---|
544 | --stringparam testsuite $TEST \
|
---|
545 | --stringparam vim-lang $VIMLANG \
|
---|
546 | --stringparam timezone $TIMEZONE \
|
---|
547 | --stringparam page $PAGE \
|
---|
548 | --stringparam lang $LANG \
|
---|
549 | --stringparam keymap $KEYMAP \
|
---|
550 | -o ./${PROGNAME}-commands/ $XSL $BOOK/$ARCH-index.xml >>$LOGDIR/$LOG 2>&1
|
---|
551 | ;;
|
---|
552 | hlfs)
|
---|
553 | echo -n " ${L_arrow}${BOLD}$MODEL${R_arrow} HLFS libc implementation"
|
---|
554 | xsltproc --nonet \
|
---|
555 | --xinclude \
|
---|
556 | --stringparam model $MODEL \
|
---|
557 | --stringparam testsuite $TEST \
|
---|
558 | --stringparam timezone $TIMEZONE \
|
---|
559 | --stringparam page $PAGE \
|
---|
560 | --stringparam lang $LANG \
|
---|
561 | --stringparam lc_all $LC_ALL \
|
---|
562 | --stringparam keymap $KEYMAP \
|
---|
563 | --stringparam grsecurity_host $GRSECURITY_HOST \
|
---|
564 | -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
565 | ;;
|
---|
566 | lfs)
|
---|
567 | echo -n " ${L_arrow}${BOLD}LFS${R_arrow} build"
|
---|
568 | xsltproc --nonet \
|
---|
569 | --xinclude \
|
---|
570 | --stringparam testsuite $TEST \
|
---|
571 | --stringparam vim-lang $VIMLANG \
|
---|
572 | --stringparam timezone $TIMEZONE \
|
---|
573 | --stringparam page $PAGE \
|
---|
574 | --stringparam lang $LANG \
|
---|
575 | -o ./${PROGNAME}-commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
576 | ;;
|
---|
577 | *) exit 1 ;;
|
---|
578 | esac
|
---|
579 |
|
---|
580 | echo " ...OK"
|
---|
581 |
|
---|
582 | # Make the scripts executable.
|
---|
583 | chmod -R +x $JHALFSDIR/${PROGNAME}-commands
|
---|
584 |
|
---|
585 | # Create the packages file. We need it for proper Makefile creation
|
---|
586 | rm -f packages
|
---|
587 | echo -n "Creating <${PROGNAME}> specific packages file"
|
---|
588 | grep "\-version " $BOOK/packages.ent | sed -e 's@<!ENTITY @@' \
|
---|
589 | -e 's@">@"@' > packages
|
---|
590 | echo " ...OK"
|
---|
591 |
|
---|
592 | # Done. Moving on...
|
---|
593 | get_sources
|
---|
594 | }
|
---|
595 |
|
---|
596 | #----------------------------#
|
---|
597 | get_sources() { # Download file, write name to MISSING_FILES.DMP if an error
|
---|
598 | #----------------------------#
|
---|
599 | local saveIFS=$IFS
|
---|
600 | local IFS line URL1 URL2 FILE BOOKMD5 MD5 HAVEMD5 fromARCHIVE
|
---|
601 |
|
---|
602 | # Test if the packages must be downloaded
|
---|
603 | [ ! "$GETPKG" = "1" ] && return
|
---|
604 |
|
---|
605 | gs_wrt_message(){
|
---|
606 | echo "${RED}$1${OFF}"
|
---|
607 | echo "$1" >> MISSING_FILES.DMP
|
---|
608 | }
|
---|
609 | # Housekeeping
|
---|
610 | [[ ! -d $BUILDDIR/sources ]] && mkdir $BUILDDIR/sources
|
---|
611 | cd $BUILDDIR/sources
|
---|
612 | [[ -f MD5SUMS ]] && rm MD5SUMS
|
---|
613 | [[ -f MISSING_FILES.DMP ]] && rm MISSING_FILES.DMP
|
---|
614 | [[ -f urls.lst ]] && rm urls.lst
|
---|
615 |
|
---|
616 | # Generate URLs file
|
---|
617 | create_urls
|
---|
618 |
|
---|
619 | IFS=$'\x0A' # Modify the 'internal field separator' to break on 'LF' only
|
---|
620 | for line in `cat urls.lst`; do
|
---|
621 | IFS=$saveIFS # Restore the system defaults
|
---|
622 |
|
---|
623 | # Skip some packages if they aren't needed
|
---|
624 | case $line in
|
---|
625 | */tcl* | */expect* | */dejagnu* | */tree* | */gcc-testsuite* )
|
---|
626 | [[ "$TEST" = "0" ]] && continue
|
---|
627 | ;;
|
---|
628 | */vim-*-lang* )
|
---|
629 | [[ "$VIMLANG" = "0" ]] && continue
|
---|
630 | ;;
|
---|
631 | *linux/linux-* )
|
---|
632 | [[ -z "$CONFIG" ]] && [[ -z "$BOOT_CONFIG" ]] && \
|
---|
633 | [[ "$GETKERNEL" = "0" ]] && continue
|
---|
634 | ;;
|
---|
635 | esac
|
---|
636 |
|
---|
637 | # Locations
|
---|
638 | URL1=`echo $line | cut -d" " -f2` # Preferred URL
|
---|
639 | URL2=`echo $line | cut -d" " -f1` # Fallback Upstream URL
|
---|
640 | FILE=`basename $URL1` # File name
|
---|
641 | BOOKMD5=`echo $line | cut -d" " -f3` # MD5 book value
|
---|
642 |
|
---|
643 | # Validation pair
|
---|
644 | MD5="$BOOKMD5 $FILE"
|
---|
645 | HAVEMD5=1
|
---|
646 |
|
---|
647 | set -e
|
---|
648 | # If the file exists in the archive copy it to the
|
---|
649 | # $BUILDDIR/sources dir. MD5SUM will be validated later.
|
---|
650 | if [ ! -z ${SRC_ARCHIVE} ] &&
|
---|
651 | [ -d ${SRC_ARCHIVE} ] &&
|
---|
652 | [ -f ${SRC_ARCHIVE}/$FILE ]; then
|
---|
653 | cp ${SRC_ARCHIVE}/$FILE .
|
---|
654 | echo "$FILE: -- copied from $SRC_ARCHIVE"
|
---|
655 | fromARCHIVE=1
|
---|
656 | else
|
---|
657 | echo "${BOLD}${YELLOW}$FILE: not found in ${SRC_ARCHIVE}${OFF}"
|
---|
658 | fromARCHIVE=0
|
---|
659 | # If the file does not exist yet in /sources download a fresh one
|
---|
660 | if [ ! -f $FILE ] ; then
|
---|
661 | if ! wget $URL1 && ! wget $URL2 ; then
|
---|
662 | gs_wrt_message "$FILE not found in the SRC_ARCHIVE or on any server..SKIPPING"
|
---|
663 | continue
|
---|
664 | fi
|
---|
665 | fi
|
---|
666 | fi
|
---|
667 |
|
---|
668 | # IF the md5sum does not match the existing files
|
---|
669 | if ! echo "$MD5" | md5sum -c - >/dev/null ; then
|
---|
670 | [[ $fromARCHIVE = "1" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match SRC_ARCHIVE copy${OFF}"
|
---|
671 | [[ $fromARCHIVE = "0" ]] && echo "${BOLD}${YELLOW}MD5SUM did not match REMOTE copy${OFF}"
|
---|
672 | # Remove the old file and download a new one
|
---|
673 | rm -fv $FILE
|
---|
674 | # Force storage in SRC_ARCHIVE
|
---|
675 | fromARCHIVE=0;
|
---|
676 | # Try to retrieve again the file. Servers in reverse order.
|
---|
677 | if ! wget $URL2 && ! wget $URL1 ; then
|
---|
678 | gs_wrt_message "$FILE not found on the servers.. SKIPPING"
|
---|
679 | continue
|
---|
680 | fi
|
---|
681 | fi
|
---|
682 |
|
---|
683 | # Validate the MD5SUM one last time
|
---|
684 | if ! echo "$MD5" | md5sum -c - >/dev/null ; then
|
---|
685 | gs_wrt_message "$FILE does not match MD5SUMS value"
|
---|
686 | # Force generation of MD5SUM
|
---|
687 | HAVEMD5=0
|
---|
688 | fi
|
---|
689 |
|
---|
690 | # Generate a fresh MD5SUM for this file
|
---|
691 | if [[ "$HAVEMD5" = "0" ]] ; then
|
---|
692 | echo "${BOLD}${YELLOW}Generating a new MD5SUM for ${OFF}$FILE"
|
---|
693 | echo "NEW MD5SUM: $(md5sum $FILE)" >> MISSING_FILES.DMP
|
---|
694 | fi
|
---|
695 |
|
---|
696 | # Good or bad we write the original md5sum to a file
|
---|
697 | echo "$MD5" >> MD5SUMS
|
---|
698 |
|
---|
699 | # Copy the freshly downloaded file
|
---|
700 | # to the source archive.
|
---|
701 | if [ ! -z ${SRC_ARCHIVE} ] &&
|
---|
702 | [ -d ${SRC_ARCHIVE} ] &&
|
---|
703 | [ -w ${SRC_ARCHIVE} ] &&
|
---|
704 | [ "$fromARCHIVE" = "0" ] ; then
|
---|
705 | echo "Storing file:<$FILE> in the package archive"
|
---|
706 | cp -f $FILE ${SRC_ARCHIVE}
|
---|
707 | fi
|
---|
708 |
|
---|
709 | done
|
---|
710 |
|
---|
711 | if [[ -s MISSING_FILES.DMP ]]; then
|
---|
712 | 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"
|
---|
713 | # Do not allow the automatic exection of the Makefile.
|
---|
714 | echo "${tab_}${BOLD}${RED}*** ${YELLOW}Automatic execution of the generated makefile has been inhibited. ${RED}***${OFF}${nl_}"
|
---|
715 | RUNMAKE=0
|
---|
716 | fi
|
---|
717 | }
|
---|
718 |
|
---|
719 |
|
---|
720 | #----------------------------#
|
---|
721 | create_urls() { #
|
---|
722 | #----------------------------#
|
---|
723 | cd $JHALFSDIR
|
---|
724 |
|
---|
725 | case ${PROGNAME} in
|
---|
726 | clfs)
|
---|
727 | echo -n "Creating CLFS <${ARCH}> specific URLs file"
|
---|
728 | xsltproc --nonet --xinclude \
|
---|
729 | --stringparam server $SERVER \
|
---|
730 | -o $BUILDDIR/sources/urls.lst urls.xsl \
|
---|
731 | $BOOK/materials/$ARCH-chapter.xml >>$LOGDIR/$LOG 2>&1
|
---|
732 | echo " ...OK"
|
---|
733 | ;;
|
---|
734 | hlfs)
|
---|
735 | echo -n "Creating HLFS <${MODEL}> specific URLs file"
|
---|
736 | xsltproc --nonet --xinclude \
|
---|
737 | --stringparam server $SERVER \
|
---|
738 | --stringparam model $MODEL \
|
---|
739 | -o $BUILDDIR/sources/urls.lst urls.xsl \
|
---|
740 | $BOOK/chapter04/chapter04.xml >>$LOGDIR/$LOG 2>&1
|
---|
741 | echo " ...OK"
|
---|
742 | ;;
|
---|
743 | lfs)
|
---|
744 | echo -n "Creating LFS specific URLs file"
|
---|
745 | xsltproc --nonet --xinclude \
|
---|
746 | --stringparam server $SERVER \
|
---|
747 | -o ../sources/urls.lst urls.xsl \
|
---|
748 | $BOOK/chapter03/chapter03.xml >>$LOGDIR/$LOG 2>&1
|
---|
749 | echo " ...OK"
|
---|
750 | ;;
|
---|
751 | esac
|
---|
752 |
|
---|
753 | cd $BUILDDIR/sources
|
---|
754 | }
|
---|