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