1 | #!/bin/sh
|
---|
2 |
|
---|
3 | #
|
---|
4 | # Load the configuration file
|
---|
5 | #
|
---|
6 | source jhalfs.conf
|
---|
7 |
|
---|
8 |
|
---|
9 | version="
|
---|
10 | jhalfs development \$Date$
|
---|
11 |
|
---|
12 | Written by Jeremy Huntwork and Manuel Canales Esparcia.
|
---|
13 |
|
---|
14 | This program is published under the \
|
---|
15 | Gnu General Public License, Version 2.
|
---|
16 | "
|
---|
17 |
|
---|
18 | usage="\
|
---|
19 | Usage: $0 [OPTION]
|
---|
20 |
|
---|
21 | Options:
|
---|
22 | -h, --help print this help, then exit
|
---|
23 |
|
---|
24 | -V, --version print version number, then exit
|
---|
25 |
|
---|
26 | -d --directory DIR use DIR directory for building LFS; all files
|
---|
27 | jhalfs produces will be in the directory
|
---|
28 | DIR/jhalfs. Default is \"/mnt/lfs\".
|
---|
29 |
|
---|
30 | --rebuild clean the build directory before to perfom
|
---|
31 | any other task. The directory is cleaned
|
---|
32 | only if it was populated by a previous
|
---|
33 | jhalfs run.
|
---|
34 |
|
---|
35 | -P, --get-packages download the packages and patches. This
|
---|
36 | assumes that the server declared in the
|
---|
37 | jhalfs.conf file has the proper packages
|
---|
38 | and patches for the book version being
|
---|
39 | processed.
|
---|
40 |
|
---|
41 | -D, --download-client CLIENT use CLIENT as the program for retrieving
|
---|
42 | packages (for use in conjunction with -P)
|
---|
43 |
|
---|
44 | -W, --working-copy DIR use the local working copy placed in DIR
|
---|
45 | as the LFS book
|
---|
46 |
|
---|
47 | -L, --LFS-version VER checkout VER version of the LFS book.
|
---|
48 | Supported versions at this time are:
|
---|
49 |
|
---|
50 | dev* | trunk | SVN aliases for Development LFS
|
---|
51 | alpha* aliases for the alphabetical branch
|
---|
52 | udev* aliases for the udev_update branch
|
---|
53 |
|
---|
54 | For stable 6.1.1 book, please use jhalfs-0.2.
|
---|
55 |
|
---|
56 | -T, --testsuites add support to run the optional testsuites
|
---|
57 |
|
---|
58 | --no-toolchain-test don't run the toolchain testsuites. This
|
---|
59 | also disables the build of TCL, Expect
|
---|
60 | and DejaGNU
|
---|
61 |
|
---|
62 | --no-strip don't run the strip command on both the
|
---|
63 | temporary system and the final system
|
---|
64 |
|
---|
65 | --timezone TIMEZONE set TIMEZONE as the local timezone. If not
|
---|
66 | specified, \"Europe/London\" will be used.
|
---|
67 |
|
---|
68 | --page_size PAGE set PAGE as the default page size (letter
|
---|
69 | or A4). This setting is required to
|
---|
70 | build Groff. If not specified, \"letter\"
|
---|
71 | will be used.
|
---|
72 |
|
---|
73 | --fstab FILE use FILE as the /etc/fstab file for the
|
---|
74 | LFS system. If not specified, a default
|
---|
75 | /etc/fstab file with dummy values is
|
---|
76 | created.
|
---|
77 |
|
---|
78 | --no-vim-lang don't install the optional vim-lang package
|
---|
79 |
|
---|
80 | -C, --kernel-config FILE use the kernel configuration file specified
|
---|
81 | in FILE to build the kernel. If the file is
|
---|
82 | not found, or if not specified, the kernel
|
---|
83 | build is skipped.
|
---|
84 |
|
---|
85 | -M, --run-make run make on the generated Makefile
|
---|
86 |
|
---|
87 | "
|
---|
88 |
|
---|
89 | help="\
|
---|
90 | Try '$0 --help' for more information."
|
---|
91 |
|
---|
92 | no_empty_builddir="\
|
---|
93 | echo \"\" >&2
|
---|
94 | echo \" W A R N I N G\" >&2
|
---|
95 | echo \"\" >&2
|
---|
96 | echo \"Looks like the \$BUILDDIR directory contains subdirectories\" >&2
|
---|
97 | echo \"from a previous LFS build.\" >&2
|
---|
98 | echo \"\" >&2
|
---|
99 | echo \"Please format the partition mounted on \$BUILDDIR or set\" >&2
|
---|
100 | echo \"a different build directory before running jhalfs.\" >&2
|
---|
101 | echo \"\" >&2
|
---|
102 | exit 1"
|
---|
103 |
|
---|
104 | exit_missing_arg="\
|
---|
105 | echo \"Option '\$1' requires an argument\" >&2
|
---|
106 | echo \"\$help\" >&2
|
---|
107 | exit 1"
|
---|
108 |
|
---|
109 | no_dl_client="\
|
---|
110 | echo \"Could not find a way to download the LFS sources.\" >&2
|
---|
111 | echo \"Attempting to continue.\" >&2"
|
---|
112 |
|
---|
113 | HEADER="# This file is automatically generated by jhalfs
|
---|
114 | # DO NOT EDIT THIS FILE MANUALLY
|
---|
115 | #
|
---|
116 | # Generated on `date \"+%F %X %Z\"`"
|
---|
117 |
|
---|
118 |
|
---|
119 | ###################################
|
---|
120 | ### FUNCTIONS ###
|
---|
121 | ###################################
|
---|
122 |
|
---|
123 |
|
---|
124 | #----------------------------#
|
---|
125 | clean_builddir() {
|
---|
126 | #----------------------------#
|
---|
127 | # Test if the clean must be done.
|
---|
128 | if [ "$CLEAN" = "1" ] ; then
|
---|
129 | # Test to make sure we're running the clean as root
|
---|
130 | if [ "$UID" != "0" ] ; then
|
---|
131 | echo "You must be logged in as root to clean the build directory."
|
---|
132 | exit 1
|
---|
133 | fi
|
---|
134 | # Test to make sure that the build directory was populated by jhalfs
|
---|
135 | if [ ! -d $JHALFSDIR ] || [ ! -d $BUILDDIR/sources ] ; then
|
---|
136 | echo "Looks like $BUILDDIR was not populated by a previous jhalfs run."
|
---|
137 | exit 1
|
---|
138 | else
|
---|
139 | # Clean the build directory
|
---|
140 | echo -ne "Cleaning $BUILDDIR...\n"
|
---|
141 | rm -rf $BUILDDIR/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,tools,usr,var}
|
---|
142 | echo -ne "Cleaning $JHALFSDIR...\n"
|
---|
143 | rm -rf $JHALFSDIR/{0*,1*,envars,sources-dir,commands,logs,Makefile,dump-lfs-scripts.xsl,functions,packages,patches}
|
---|
144 | echo -ne "Cleaning remainig extracted sources in $BUILDDIR/sources...\n"
|
---|
145 | rm -rf `find $BUILDDIR/sources/* -maxdepth 0 -type d`
|
---|
146 | echo -ne "done\n"
|
---|
147 | fi
|
---|
148 | fi
|
---|
149 | }
|
---|
150 |
|
---|
151 | #----------------------------#
|
---|
152 | get_book() {
|
---|
153 | #----------------------------#
|
---|
154 | cd $JHALFSDIR
|
---|
155 |
|
---|
156 | if [ -z $WC ] ; then
|
---|
157 | # Check for Subversion instead of just letting the script hit 'svn' and fail.
|
---|
158 | test `type -p svn` || eval "echo \"This feature requires Subversion.\"
|
---|
159 | exit 1"
|
---|
160 | echo -n "Downloading the LFS Book, version $LFSVRS... "
|
---|
161 |
|
---|
162 | # Grab a fresh LFS book if it's missing, otherwise, update it from the
|
---|
163 | # repo. If we've already extracted the commands, move on to getting the
|
---|
164 | # sources.
|
---|
165 | if [ -d lfs-$LFSVRS ] ; then
|
---|
166 | cd lfs-$LFSVRS
|
---|
167 | if LC_ALL=C svn up | grep -q At && test -d $JHALFSDIR/commands && \
|
---|
168 | test -f $JHALFSDIR/packages && test -f $JHALFSDIR/patches ; then
|
---|
169 | echo -ne "done\n"
|
---|
170 | # Set the canonical book version
|
---|
171 | cd $JHALFSDIR
|
---|
172 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
173 | get_sources
|
---|
174 | else
|
---|
175 | echo -ne "done\n"
|
---|
176 | # Set the canonical book version
|
---|
177 | cd $JHALFSDIR
|
---|
178 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
179 | extract_commands
|
---|
180 | fi
|
---|
181 | else
|
---|
182 | case $LFSVRS in
|
---|
183 | development)
|
---|
184 | svn co $SVN/LFS/trunk/BOOK lfs-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
|
---|
185 | alphabetical)
|
---|
186 | svn co $SVN/LFS/branches/$LFSVRS/BOOK lfs-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
|
---|
187 | udev_update)
|
---|
188 | svn co $SVN/LFS/branches/$LFSVRS/BOOK lfs-$LFSVRS >>$LOGDIR/$LOG 2>&1 ;;
|
---|
189 | esac
|
---|
190 | echo -ne "done\n"
|
---|
191 | # Set the canonical book version
|
---|
192 | cd $JHALFSDIR
|
---|
193 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
194 | extract_commands
|
---|
195 | fi
|
---|
196 | else
|
---|
197 | echo -ne "Using $BOOK as book's sources ...\n"
|
---|
198 | # Set the canonical book version
|
---|
199 | cd $JHALFSDIR
|
---|
200 | VERSION=`grep "ENTITY version " $BOOK/general.ent | sed 's@<!ENTITY version "@@;s@">@@'`
|
---|
201 | extract_commands
|
---|
202 | fi
|
---|
203 | }
|
---|
204 |
|
---|
205 | #----------------------------#
|
---|
206 | extract_commands() {
|
---|
207 | #----------------------------#
|
---|
208 | # Check for libxslt instead of just letting the script hit 'xsltproc' and fail.
|
---|
209 | test `type -p xsltproc` || eval "echo \"This feature requires libxslt.\"
|
---|
210 | exit 1"
|
---|
211 | cd $JHALFSDIR
|
---|
212 |
|
---|
213 | # Start clean
|
---|
214 | if [ -d commands ] ; then rm -rf commands ; fi && mkdir commands
|
---|
215 | echo -n "Extracting commands... "
|
---|
216 |
|
---|
217 | # Dump the commands in shell script form from the LFS book.
|
---|
218 | xsltproc --nonet --xinclude --stringparam testsuite $TEST \
|
---|
219 | --stringparam toolchaintest $TOOLCHAINTEST --stringparam vim-lang $VIMLANG \
|
---|
220 | -o ./commands/ $XSL $BOOK/index.xml >>$LOGDIR/$LOG 2>&1
|
---|
221 |
|
---|
222 | # Make the scripts executable.
|
---|
223 | chmod -R +x $JHALFSDIR/commands
|
---|
224 |
|
---|
225 | # Grab the patches and package names.
|
---|
226 | cd $JHALFSDIR
|
---|
227 | for i in patches packages ; do rm -f $i ; done
|
---|
228 | grep "\-version" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@' \
|
---|
229 | -e '/generic/d' >> packages
|
---|
230 | # Download the vim-lang package if it must be installed
|
---|
231 | if [ "$VIMLANG" = "1" ] ; then
|
---|
232 | echo `grep "vim" packages | sed 's@vim@&-lang@'` >> packages
|
---|
233 | fi
|
---|
234 | echo `grep "udev-config-file" $BOOK/general.ent | sed -e 's@<!ENTITY @@' -e 's@">@"@'` >> packages
|
---|
235 | echo `grep "glibc" packages | sed 's@glibc@glibc-libidn@'` >> packages
|
---|
236 | grep "^<\!ENTITY" $BOOK/patches.ent | sed -e 's/.* "//' -e 's/">//' >> patches
|
---|
237 | # Done. Moving on...
|
---|
238 | echo -ne "done\n"
|
---|
239 | get_sources
|
---|
240 | }
|
---|
241 |
|
---|
242 | #----------------------------#
|
---|
243 | download() {
|
---|
244 | #----------------------------#
|
---|
245 | cd $BUILDDIR/sources
|
---|
246 |
|
---|
247 | # Hackish fix for the bash-doc, glibc-{linuxthreads,libidn} that don't
|
---|
248 | # conform to norms in the URL scheme.
|
---|
249 | DIR=`echo $1 | sed 's@-doc@@;s@-libidn@@'`
|
---|
250 |
|
---|
251 | # Find the md5 sum for this package.
|
---|
252 | if [ $2 != MD5SUMS ] ; then MD5=`grep " $2$" MD5SUMS` ; fi
|
---|
253 |
|
---|
254 | if [ ! -f $2 ] ; then
|
---|
255 | case $DL in
|
---|
256 | wget )
|
---|
257 | wget --passive $FTP/$DIR/$2
|
---|
258 | ;;
|
---|
259 | curl )
|
---|
260 | `curl -# $FTP/$DIR/$2 -o $2`
|
---|
261 | ;;
|
---|
262 | * )
|
---|
263 | echo "$DL not supported at this time."
|
---|
264 | ;;
|
---|
265 | esac
|
---|
266 | elif ! echo "$MD5" | md5sum -c - >/dev/null 2>/dev/null ; then
|
---|
267 | case $DL in
|
---|
268 | wget )
|
---|
269 | wget --passive -c $FTP/$DIR/$2
|
---|
270 | ;;
|
---|
271 | curl )
|
---|
272 | `curl -# -C - $FTP/$DIR/$2 -o $2`
|
---|
273 | ;;
|
---|
274 | * )
|
---|
275 | echo "$DL not supported at this time."
|
---|
276 | ;;
|
---|
277 | esac
|
---|
278 | fi
|
---|
279 | if [ $2 != MD5SUMS ] && ! echo "$MD5" | md5sum -c - ; then
|
---|
280 | exit 1
|
---|
281 | fi
|
---|
282 | if [ $2 != MD5SUMS ] ; then
|
---|
283 | echo `grep "$MD5" MD5SUMS` >> MD5SUMS-$VERSION
|
---|
284 | fi
|
---|
285 | }
|
---|
286 |
|
---|
287 | #----------------------------#
|
---|
288 | get_sources() {
|
---|
289 | #----------------------------#
|
---|
290 |
|
---|
291 | # Test if the packages must be downloaded
|
---|
292 | if [ "$HPKG" = "1" ] ; then
|
---|
293 |
|
---|
294 | # This variable is necessary to make sure the `cat $JHALFSDIR/packages`
|
---|
295 | # separates each iteration by lines. It is necessary to have the second
|
---|
296 | # ' on the next line.
|
---|
297 | IFS='
|
---|
298 | '
|
---|
299 |
|
---|
300 | if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi
|
---|
301 | cd $BUILDDIR/sources
|
---|
302 | if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi
|
---|
303 | if [ -f MD5SUMS-$VERSION ] ; then rm MD5SUMS-$VERSION ; fi
|
---|
304 |
|
---|
305 | download "" MD5SUMS
|
---|
306 |
|
---|
307 | # Iterate through each package and grab it, along with any patches it needs.
|
---|
308 | for i in `cat $JHALFSDIR/packages` ; do
|
---|
309 | PKG=`echo $i | sed -e 's/-version.*//' -e 's/-file.*//'`
|
---|
310 |
|
---|
311 | # There are some entities that aren't valid packages.
|
---|
312 | if [ "$PKG" = "expect-lib" -o "$PKG" = "linux-dl" ] ; then continue ; fi
|
---|
313 |
|
---|
314 | VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
|
---|
315 | case $PKG in
|
---|
316 | tcl)
|
---|
317 | FILE="$PKG$VRS-src.tar.bz2"
|
---|
318 | ;;
|
---|
319 | vim-lang)
|
---|
320 | PKG="vim"
|
---|
321 | FILE="vim-$VRS-lang.tar.bz2"
|
---|
322 | ;;
|
---|
323 | udev-config)
|
---|
324 | PKG="udev"
|
---|
325 | FILE="$VRS"
|
---|
326 | ;;
|
---|
327 | *)
|
---|
328 | FILE="$PKG-$VRS.tar.bz2"
|
---|
329 | ;;
|
---|
330 | esac
|
---|
331 | download $PKG $FILE
|
---|
332 |
|
---|
333 | # Download any associated patches
|
---|
334 | for patch in `grep "&$PKG-version" $JHALFSDIR/patches` ; do
|
---|
335 | PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'`
|
---|
336 | download $PKG $PATCH
|
---|
337 | done
|
---|
338 | done
|
---|
339 | fi
|
---|
340 | }
|
---|
341 |
|
---|
342 | #-----------------------------------------------#
|
---|
343 | _IS_() # Function to test build scripts names
|
---|
344 | #-----------------------------------------------#
|
---|
345 | {
|
---|
346 | # Returns substr $2 or null str
|
---|
347 | # Must use string testing
|
---|
348 | case $1 in
|
---|
349 | *$2*) echo "$2" ;;
|
---|
350 | *) echo "" ;;
|
---|
351 | esac
|
---|
352 | }
|
---|
353 |
|
---|
354 | #----------------------------#
|
---|
355 | chapter4_Makefiles() {
|
---|
356 | #----------------------------#
|
---|
357 |
|
---|
358 | # If /home/lfs is already present in the host, we asume that the
|
---|
359 | # lfs user and group are also presents in the host, and a backup
|
---|
360 | # of their bash init files is made.
|
---|
361 | (
|
---|
362 | cat << EOF
|
---|
363 | 020-creatingtoolsdir:
|
---|
364 | @\$(call echo_message, Building)
|
---|
365 | @mkdir -v \$(LFS)/tools && \\
|
---|
366 | rm -fv /tools && \\
|
---|
367 | ln -sv \$(LFS)/tools / && \\
|
---|
368 | touch \$@
|
---|
369 |
|
---|
370 | 021-addinguser: 020-creatingtoolsdir
|
---|
371 | @\$(call echo_message, Building)
|
---|
372 | @if [ ! -d /home/lfs ]; then \\
|
---|
373 | groupadd lfs; \\
|
---|
374 | useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\
|
---|
375 | else \\
|
---|
376 | touch user-lfs-exist; \\
|
---|
377 | fi;
|
---|
378 | @chown lfs \$(LFS)/tools && \\
|
---|
379 | chown lfs \$(LFS)/sources && \\
|
---|
380 | touch \$@
|
---|
381 |
|
---|
382 | 022-settingenvironment: 021-addinguser
|
---|
383 | @\$(call echo_message, Building)
|
---|
384 | @if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\
|
---|
385 | mv -v /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\
|
---|
386 | fi;
|
---|
387 | @if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\
|
---|
388 | mv -v /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\
|
---|
389 | fi;
|
---|
390 | @echo "set +h" > /home/lfs/.bashrc && \\
|
---|
391 | echo "umask 022" >> /home/lfs/.bashrc && \\
|
---|
392 | echo "LFS=/mnt/lfs" >> /home/lfs/.bashrc && \\
|
---|
393 | echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
|
---|
394 | echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
|
---|
395 | echo "export LFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
|
---|
396 | echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc && \\
|
---|
397 | chown lfs:lfs /home/lfs/.bashrc && \\
|
---|
398 | touch envars && \\
|
---|
399 | touch \$@
|
---|
400 | EOF
|
---|
401 | ) >> $MKFILE.tmp
|
---|
402 | }
|
---|
403 |
|
---|
404 | #----------------------------#
|
---|
405 | chapter5_Makefiles() {
|
---|
406 | #----------------------------#
|
---|
407 | for file in chapter05/* ; do
|
---|
408 | # Keep the script file name
|
---|
409 | i=`basename $file`
|
---|
410 |
|
---|
411 | # If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
|
---|
412 | if [ "$TOOLCHAINTEST" = "0" ]; then
|
---|
413 | if [[ `_IS_ $i tcl` ]] || [[ `_IS_ $i expect` ]] || [[ `_IS_ $i dejagnu` ]] ; then
|
---|
414 | continue
|
---|
415 | fi
|
---|
416 | fi
|
---|
417 |
|
---|
418 | # Test if the stripping phase must be skipped
|
---|
419 | if [ "$STRIP" = "0" ] && [[ `_IS_ $i stripping` ]] ; then
|
---|
420 | continue
|
---|
421 | fi
|
---|
422 |
|
---|
423 | # First append each name of the script files to a list (this will become
|
---|
424 | # the names of the targets in the Makefile
|
---|
425 | chapter5="$chapter5 $i"
|
---|
426 |
|
---|
427 | # Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc
|
---|
428 | # and binutils in chapter 5)
|
---|
429 | name=`echo $i | sed -e 's@[0-9]\{3\}-@@' -e 's@-pass[0-9]\{1\}@@'`
|
---|
430 |
|
---|
431 | # Set the dependency for the first target.
|
---|
432 | if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
|
---|
433 |
|
---|
434 | # Drop in the name of the target on a new line, and the previous target
|
---|
435 | # as a dependency. Also call the echo_message function.
|
---|
436 | (
|
---|
437 | cat << EOF
|
---|
438 |
|
---|
439 | $i: $PREV
|
---|
440 | @\$(call echo_message, Building)
|
---|
441 | EOF
|
---|
442 | ) >> $MKFILE.tmp
|
---|
443 |
|
---|
444 | # Find the version of the command files, if it corresponds with the building of
|
---|
445 | # a specific package
|
---|
446 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
447 |
|
---|
448 | # If $vrs isn't empty, we've got a package...
|
---|
449 | if [ "$vrs" != "" ] ; then
|
---|
450 | if [ "$name" = "tcl" ] ; then
|
---|
451 | FILE="$name$vrs-src.tar"
|
---|
452 | else
|
---|
453 | FILE="$name-$vrs.tar"
|
---|
454 | fi
|
---|
455 |
|
---|
456 | # Insert instructions for unpacking the package and to set
|
---|
457 | # the PKGDIR variable.
|
---|
458 | (
|
---|
459 | cat << EOF
|
---|
460 | @\$(call unpack,$FILE)
|
---|
461 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
462 | chown -R lfs \$(LFS)\$(SRC)/\$\$ROOT && \\
|
---|
463 | echo "PKGDIR=\$(LFS)\$(SRC)/\$\$ROOT" > envars && \\
|
---|
464 | echo "export PKGDIR" >> envars
|
---|
465 | EOF
|
---|
466 | ) >> $MKFILE.tmp
|
---|
467 |
|
---|
468 | fi
|
---|
469 |
|
---|
470 | # Insert date and disk usage at the top of the log file, the script run
|
---|
471 | # and date and disk usage again at the bottom of the log file.
|
---|
472 | (
|
---|
473 | cat << EOF
|
---|
474 | @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
---|
475 | su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/commands/$file" >>logs/$i 2>&1 && \\
|
---|
476 | echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
---|
477 | EOF
|
---|
478 | ) >> $MKFILE.tmp
|
---|
479 |
|
---|
480 | # Remove the build directory(ies) except if the package build fails
|
---|
481 | # (so we can review config.cache, config.log, etc.)
|
---|
482 | # For Binutils the sources must be retained for some time.
|
---|
483 | if [ "$vrs" != "" ] ; then
|
---|
484 | (
|
---|
485 | cat << EOF
|
---|
486 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
487 | rm -r \$(LFS)\$(SRC)/\$\$ROOT && \\
|
---|
488 | if [ -e \$(LFS)\$(SRC)/$name-build ]; then \\
|
---|
489 | rm -r \$(LFS)\$(SRC)/$name-build; \\
|
---|
490 | fi;
|
---|
491 | EOF
|
---|
492 | ) >> $MKFILE.tmp
|
---|
493 | fi
|
---|
494 |
|
---|
495 | # Include a touch of the target name so make can check
|
---|
496 | # if it's already been made.
|
---|
497 | (
|
---|
498 | cat << EOF
|
---|
499 | @touch \$@
|
---|
500 | EOF
|
---|
501 | ) >> $MKFILE.tmp
|
---|
502 |
|
---|
503 | # Keep the script file name for Makefile dependencies.
|
---|
504 | PREV=$i
|
---|
505 | done # end for file in chapter05/*
|
---|
506 | }
|
---|
507 |
|
---|
508 | #----------------------------#
|
---|
509 | chapter6_Makefiles() {
|
---|
510 | #----------------------------#
|
---|
511 | for file in chapter06/* ; do
|
---|
512 | # Keep the script file name
|
---|
513 | i=`basename $file`
|
---|
514 |
|
---|
515 | # We'll run the chroot commands differently than the others, so skip them in the
|
---|
516 | # dependencies and target creation.
|
---|
517 | if [[ `_IS_ $i chroot` ]] ; then
|
---|
518 | continue
|
---|
519 | fi
|
---|
520 |
|
---|
521 | # Test if the stripping phase must be skipped
|
---|
522 | if [ "$STRIP" = "0" ] && [[ `_IS_ $i stripping` ]] ; then
|
---|
523 | continue
|
---|
524 | fi
|
---|
525 |
|
---|
526 | # First append each name of the script files to a list (this will become
|
---|
527 | # the names of the targets in the Makefile
|
---|
528 | chapter6="$chapter6 $i"
|
---|
529 |
|
---|
530 | # Grab the name of the target
|
---|
531 | name=`echo $i | sed -e 's@[0-9]\{3\}-@@'`
|
---|
532 |
|
---|
533 | # Drop in the name of the target on a new line, and the previous target
|
---|
534 | # as a dependency. Also call the echo_message function.
|
---|
535 | (
|
---|
536 | cat << EOF
|
---|
537 |
|
---|
538 | $i: $PREV
|
---|
539 | @\$(call echo_message, Building)
|
---|
540 | EOF
|
---|
541 | ) >> $MKFILE.tmp
|
---|
542 |
|
---|
543 | # Find the version of the command files, if it corresponds with the building of
|
---|
544 | # a specific package
|
---|
545 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
546 |
|
---|
547 | # If $vrs isn't empty, we've got a package...
|
---|
548 | # Insert instructions for unpacking the package and changing directories
|
---|
549 | if [ "$vrs" != "" ] ; then
|
---|
550 | FILE="$name-$vrs.tar.*"
|
---|
551 | (
|
---|
552 | cat << EOF
|
---|
553 | @\$(call unpack2,$FILE)
|
---|
554 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
555 | echo "PKGDIR=\$(SRC)/\$\$ROOT" > envars && \\
|
---|
556 | echo "export PKGDIR" >> envars
|
---|
557 | EOF
|
---|
558 | ) >> $MKFILE.tmp
|
---|
559 | fi
|
---|
560 |
|
---|
561 | # For Glibc we need to set TIMEZONE envar.
|
---|
562 | if [[ `_IS_ $i glibc` ]] ; then
|
---|
563 | (
|
---|
564 | cat << EOF
|
---|
565 | @echo "TIMEZONE=\$(TIMEZONE)" >> envars && \\
|
---|
566 | echo "export TIMEZONE" >> envars
|
---|
567 | EOF
|
---|
568 | ) >> $MKFILE.tmp
|
---|
569 |
|
---|
570 | # For Groff we need to set PAGE envar.
|
---|
571 | elif [[ `_IS_ $i groff` ]] ; then
|
---|
572 | (
|
---|
573 | cat << EOF
|
---|
574 | @echo "PAGE=\$(PAGE)" >> envars && \\
|
---|
575 | echo "export PAGE" >> envars
|
---|
576 | EOF
|
---|
577 | ) >> $MKFILE.tmp
|
---|
578 | fi
|
---|
579 |
|
---|
580 | # In the mount of kernel filesystems we need to set LFS
|
---|
581 | # and not to use chroot.
|
---|
582 | if [[ `_IS_ $i kernfs` ]] ; then
|
---|
583 | (
|
---|
584 | cat << EOF
|
---|
585 | @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
---|
586 | export LFS=\$(LFS) && commands/$file >>logs/$i 2>&1 && \\
|
---|
587 | echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
---|
588 | EOF
|
---|
589 | ) >> $MKFILE.tmp
|
---|
590 |
|
---|
591 | # The rest of Chapter06
|
---|
592 | else
|
---|
593 | (
|
---|
594 | cat << EOF
|
---|
595 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
---|
596 | \$(CHROOT1) 'cd /jhalfs && source envars && /jhalfs/commands/$file >>/jhalfs/logs/$i 2>&1' && \\
|
---|
597 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
---|
598 | EOF
|
---|
599 | ) >> $MKFILE.tmp
|
---|
600 | fi
|
---|
601 |
|
---|
602 | # Remove the build directory(ies) except if the package build fails.
|
---|
603 | if [ "$vrs" != "" ] ; then
|
---|
604 | (
|
---|
605 | cat << EOF
|
---|
606 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
607 | rm -r \$(LFS)\$(SRC)/\$\$ROOT && \\
|
---|
608 | if [ -e \$(LFS)\$(SRC)/$name-build ]; then \\
|
---|
609 | rm -r \$(LFS)\$(SRC)/$name-build; \\
|
---|
610 | fi;
|
---|
611 | EOF
|
---|
612 | ) >> $MKFILE.tmp
|
---|
613 | fi
|
---|
614 |
|
---|
615 | # Include a touch of the target name so make can check
|
---|
616 | # if it's already been made.
|
---|
617 | (
|
---|
618 | cat << EOF
|
---|
619 | @touch \$@
|
---|
620 | EOF
|
---|
621 | ) >> $MKFILE.tmp
|
---|
622 |
|
---|
623 | # Keep the script file name for Makefile dependencies.
|
---|
624 | PREV=$i
|
---|
625 | done # end for file in chapter06/*
|
---|
626 | }
|
---|
627 |
|
---|
628 | #----------------------------#
|
---|
629 | chapter789_Makefiles() {
|
---|
630 | #----------------------------#
|
---|
631 | for file in chapter0{7,8,9}/* ; do
|
---|
632 | # Keep the script file name
|
---|
633 | i=`basename $file`
|
---|
634 |
|
---|
635 | # Grub must be configured manually.
|
---|
636 | # The filesystems can't be unmounted via Makefile and the user
|
---|
637 | # should enter the chroot environment to create the root
|
---|
638 | # password, edit several files and setup Grub.
|
---|
639 | if [[ `_IS_ $i grub` ]] || [[ `_IS_ $i reboot` ]] ; then
|
---|
640 | continue
|
---|
641 | fi
|
---|
642 |
|
---|
643 | # If no .config file is supplied, the kernel build is skipped
|
---|
644 | if [ -z $CONFIG ] && [[ `_IS_ $i kernel` ]] ; then
|
---|
645 | continue
|
---|
646 | fi
|
---|
647 |
|
---|
648 | # First append each name of the script files to a list (this will become
|
---|
649 | # the names of the targets in the Makefile
|
---|
650 | chapter789="$chapter789 $i"
|
---|
651 |
|
---|
652 | # Drop in the name of the target on a new line, and the previous target
|
---|
653 | # as a dependency. Also call the echo_message function.
|
---|
654 | (
|
---|
655 | cat << EOF
|
---|
656 |
|
---|
657 | $i: $PREV
|
---|
658 | @\$(call echo_message, Building)
|
---|
659 | EOF
|
---|
660 | ) >> $MKFILE.tmp
|
---|
661 |
|
---|
662 | # Find the bootscripts and kernel package names
|
---|
663 | if [[ `_IS_ $i bootscripts` ]] || [[ `_IS_ $i kernel` ]] ; then
|
---|
664 | if [[ `_IS_ $i bootscripts` ]] ; then
|
---|
665 | vrs=`grep "^lfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
666 | FILE="lfs-bootscripts-$vrs.tar.*"
|
---|
667 | elif [[ `_IS_ $i kernel` ]] ; then
|
---|
668 | vrs=`grep "^linux-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
669 | FILE="linux-$vrs.tar.*"
|
---|
670 | fi
|
---|
671 | (
|
---|
672 | cat << EOF
|
---|
673 | @\$(call unpack2,$FILE)
|
---|
674 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
675 | echo "PKGDIR=\$(SRC)/\$\$ROOT" > envars && \\
|
---|
676 | echo "export PKGDIR" >> envars
|
---|
677 | EOF
|
---|
678 | ) >> $MKFILE.tmp
|
---|
679 | fi
|
---|
680 |
|
---|
681 | # Put in place the kernel .config file
|
---|
682 | if [[ `_IS_ $i kernel` ]] ; then
|
---|
683 | (
|
---|
684 | cat << EOF
|
---|
685 | @cp $CONFIG \$(LFS)/sources/kernel-config
|
---|
686 | EOF
|
---|
687 | ) >> $MKFILE.tmp
|
---|
688 | fi
|
---|
689 |
|
---|
690 | # Check if we have a real /etc/fstab file
|
---|
691 | if [[ `_IS_ $i fstab` ]] && [[ -n "$FSTAB" ]] ; then
|
---|
692 | (
|
---|
693 | cat << EOF
|
---|
694 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
---|
695 | cp -v $FSTAB \$(LFS)/etc/fstab >>logs/$i 2>&1 && \\
|
---|
696 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
---|
697 | EOF
|
---|
698 | ) >> $MKFILE.tmp
|
---|
699 | else
|
---|
700 | # Initialize the log and run the script
|
---|
701 | (
|
---|
702 | cat << EOF
|
---|
703 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
---|
704 | \$(CHROOT2) 'cd /jhalfs && source envars && /jhalfs/commands/$file >>/jhalfs/logs/$i 2>&1' && \\
|
---|
705 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
---|
706 | EOF
|
---|
707 | ) >> $MKFILE.tmp
|
---|
708 | fi
|
---|
709 |
|
---|
710 | # Remove the build directory except if the package build fails.
|
---|
711 | if [[ `_IS_ $i bootscripts` ]] || [[ `_IS_ $i kernel` ]] ; then
|
---|
712 | (
|
---|
713 | cat << EOF
|
---|
714 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
715 | rm -r \$(LFS)\$(SRC)/\$\$ROOT
|
---|
716 | EOF
|
---|
717 | ) >> $MKFILE.tmp
|
---|
718 | fi
|
---|
719 |
|
---|
720 | # Include a touch of the target name so make can check
|
---|
721 | # if it's already been made.
|
---|
722 | (
|
---|
723 | cat << EOF
|
---|
724 | @touch \$@
|
---|
725 | EOF
|
---|
726 | ) >> $MKFILE.tmp
|
---|
727 |
|
---|
728 | # Keep the script file name for Makefile dependencies.
|
---|
729 | PREV=$i
|
---|
730 | done # for file in chapter0{7,8,9}/*
|
---|
731 | }
|
---|
732 |
|
---|
733 |
|
---|
734 | #----------------------------#
|
---|
735 | build_Makefile() {
|
---|
736 | #----------------------------#
|
---|
737 | echo -n "Creating Makefile... "
|
---|
738 | cd $JHALFSDIR/commands
|
---|
739 |
|
---|
740 | # Start with a clean Makefile.tmp file
|
---|
741 | >$MKFILE.tmp
|
---|
742 |
|
---|
743 | chapter4_Makefiles
|
---|
744 | chapter5_Makefiles
|
---|
745 | chapter6_Makefiles
|
---|
746 | chapter789_Makefiles
|
---|
747 |
|
---|
748 |
|
---|
749 | # Add a header, some variables and include the function file
|
---|
750 | # to the top of the real Makefile.
|
---|
751 | (
|
---|
752 | cat << EOF
|
---|
753 | $HEADER
|
---|
754 |
|
---|
755 | SRC= /sources
|
---|
756 | LFS= $BUILDDIR
|
---|
757 | PAGE= $PAGE
|
---|
758 | TIMEZONE= $TIMEZONE
|
---|
759 |
|
---|
760 | include functions
|
---|
761 |
|
---|
762 | EOF
|
---|
763 | ) > $MKFILE
|
---|
764 |
|
---|
765 |
|
---|
766 | # Add chroot commands
|
---|
767 | i=1
|
---|
768 | for file in chapter06/*chroot* ; do
|
---|
769 | chroot=`cat $file | sed -e '/#!\/bin\/sh/d' -e 's@ \\\@ @g' | tr -d '\n' | sed \
|
---|
770 | -e 's/ */ /g' -e 's|\\$|&&|g' -e 's|exit||g' -e 's|$| -c|' \
|
---|
771 | -e 's|"$$LFS"|$(LFS)|' -e 's|set -e||'`
|
---|
772 | echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
---|
773 | i=`expr $i + 1`
|
---|
774 | done
|
---|
775 |
|
---|
776 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
777 | # as a dependency.
|
---|
778 | (
|
---|
779 | cat << EOF
|
---|
780 | all: chapter4 chapter5 chapter6 chapter789
|
---|
781 | @\$(call echo_finished,$VERSION)
|
---|
782 |
|
---|
783 | chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
|
---|
784 |
|
---|
785 | chapter5: chapter4 $chapter5 restore-lfs-env
|
---|
786 |
|
---|
787 | chapter6: chapter5 $chapter6
|
---|
788 |
|
---|
789 | chapter789: chapter6 $chapter789
|
---|
790 |
|
---|
791 | clean-all: clean
|
---|
792 | rm -rf ./{commands,logs,Makefile,dump-lfs-scripts.xsl,functions,packages,patches}
|
---|
793 |
|
---|
794 | clean: clean-chapter789 clean-chapter6 clean-chapter5 clean-chapter4
|
---|
795 |
|
---|
796 | clean-chapter4:
|
---|
797 | -if [ ! -f user-lfs-exist ]; then \\
|
---|
798 | userdel lfs; \\
|
---|
799 | rm -rf /home/lfs; \\
|
---|
800 | fi;
|
---|
801 | rm -rf \$(LFS)/tools
|
---|
802 | rm -f /tools
|
---|
803 | rm -f envars user-lfs-exist
|
---|
804 | rm -f 02* logs/02*.log
|
---|
805 |
|
---|
806 | clean-chapter5:
|
---|
807 | rm -rf \$(LFS)/tools/*
|
---|
808 | rm -f $chapter5 restore-lfs-env sources-dir
|
---|
809 | cd logs && rm -f $chapter5 && cd ..
|
---|
810 |
|
---|
811 | clean-chapter6:
|
---|
812 | -umount \$(LFS)/sys
|
---|
813 | -umount \$(LFS)/proc
|
---|
814 | -umount \$(LFS)/dev/shm
|
---|
815 | -umount \$(LFS)/dev/pts
|
---|
816 | -umount \$(LFS)/dev
|
---|
817 | rm -rf \$(LFS)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
|
---|
818 | rm -f $chapter6
|
---|
819 | cd logs && rm -f $chapter6 && cd ..
|
---|
820 |
|
---|
821 | clean-chapter789:
|
---|
822 | rm -f $chapter789
|
---|
823 | cd logs && rm -f $chapter789 && cd ..
|
---|
824 |
|
---|
825 | restore-lfs-env:
|
---|
826 | @\$(call echo_message, Building)
|
---|
827 | @if [ -f /home/lfs/.bashrc.XXX ]; then \\
|
---|
828 | mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
|
---|
829 | fi;
|
---|
830 | @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
|
---|
831 | mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
|
---|
832 | fi;
|
---|
833 | @chown lfs:lfs /home/lfs/.bash* && \\
|
---|
834 | touch \$@
|
---|
835 |
|
---|
836 | EOF
|
---|
837 | ) >> $MKFILE
|
---|
838 |
|
---|
839 | # Bring over the items from the Makefile.tmp
|
---|
840 | cat $MKFILE.tmp >> $MKFILE
|
---|
841 | rm $MKFILE.tmp
|
---|
842 | echo -ne "done\n"
|
---|
843 | }
|
---|
844 |
|
---|
845 | #----------------------------#
|
---|
846 | run_make() {
|
---|
847 | #----------------------------#
|
---|
848 | # Test if make must be run.
|
---|
849 | if [ "$RUNMAKE" = "1" ] ; then
|
---|
850 | # Test to make sure we're running the build as root
|
---|
851 | if [ "$UID" != "0" ] ; then
|
---|
852 | echo "You must be logged in as root to successfully build LFS."
|
---|
853 | exit 1
|
---|
854 | fi
|
---|
855 | # Build the system
|
---|
856 | if [ -e $MKFILE ] ; then
|
---|
857 | echo -ne "Building the LFS system...\n"
|
---|
858 | cd $JHALFSDIR && make
|
---|
859 | echo -ne "done\n"
|
---|
860 | fi
|
---|
861 | fi
|
---|
862 | }
|
---|
863 |
|
---|
864 |
|
---|
865 |
|
---|
866 | ###################################
|
---|
867 | ### MAIN ###
|
---|
868 | ###################################
|
---|
869 |
|
---|
870 | # Evaluate any command line switches
|
---|
871 |
|
---|
872 | while test $# -gt 0 ; do
|
---|
873 | case $1 in
|
---|
874 | --version | -V )
|
---|
875 | echo "$version"
|
---|
876 | exit 0
|
---|
877 | ;;
|
---|
878 |
|
---|
879 | --help | -h )
|
---|
880 | echo "$usage"
|
---|
881 | exit 0
|
---|
882 | ;;
|
---|
883 |
|
---|
884 | --LFS-version | -L )
|
---|
885 | test $# = 1 && eval "$exit_missing_arg"
|
---|
886 | shift
|
---|
887 | case $1 in
|
---|
888 | dev* | SVN | trunk )
|
---|
889 | LFSVRS=development
|
---|
890 | ;;
|
---|
891 |
|
---|
892 | 6.1.1 )
|
---|
893 | echo "For stable 6.1.1 book, please use jhalfs-0.2."
|
---|
894 | exit 0
|
---|
895 | ;;
|
---|
896 |
|
---|
897 | alpha*)
|
---|
898 | LFSVRS=alphabetical
|
---|
899 | ;;
|
---|
900 |
|
---|
901 | udev*)
|
---|
902 | LFSVRS=udev_update
|
---|
903 | ;;
|
---|
904 |
|
---|
905 | * )
|
---|
906 | echo "$1 is an unsupported version at this time."
|
---|
907 | exit 1
|
---|
908 | ;;
|
---|
909 | esac
|
---|
910 | ;;
|
---|
911 |
|
---|
912 | --directory | -d )
|
---|
913 | test $# = 1 && eval "$exit_missing_arg"
|
---|
914 | shift
|
---|
915 | BUILDDIR=$1
|
---|
916 | JHALFSDIR=$BUILDDIR/jhalfs
|
---|
917 | LOGDIR=$JHALFSDIR/logs
|
---|
918 | MKFILE=$JHALFSDIR/Makefile
|
---|
919 | ;;
|
---|
920 |
|
---|
921 | --rebuild ) CLEAN=1 ;;
|
---|
922 |
|
---|
923 | --download-client | -D )
|
---|
924 | test $# = 1 && eval "$exit_missing_arg"
|
---|
925 | shift
|
---|
926 | DL=$1
|
---|
927 | ;;
|
---|
928 |
|
---|
929 | --working-copy | -W )
|
---|
930 | test $# = 1 && eval "$exit_missing_arg"
|
---|
931 | shift
|
---|
932 | if [ -f $1/patches.ent ] ; then
|
---|
933 | WC=1
|
---|
934 | BOOK=$1
|
---|
935 | else
|
---|
936 | echo -e "\nLook like $1 isn't a supported working copy."
|
---|
937 | echo -e "Verify your selection and the command line.\n"
|
---|
938 | exit 1
|
---|
939 | fi
|
---|
940 | ;;
|
---|
941 |
|
---|
942 | --testsuites | -T ) TEST=1 ;;
|
---|
943 |
|
---|
944 | --get-packages | -P ) HPKG=1 ;;
|
---|
945 |
|
---|
946 | --run-make | -M ) RUNMAKE=1 ;;
|
---|
947 |
|
---|
948 | --no-toolchain-test ) TOOLCHAINTEST=0 ;;
|
---|
949 |
|
---|
950 | --no-strip ) STRIP=0 ;;
|
---|
951 |
|
---|
952 | --no-vim-lang ) VIMLANG=0 ;;
|
---|
953 |
|
---|
954 | --page_size )
|
---|
955 | test $# = 1 && eval "$exit_missing_arg"
|
---|
956 | shift
|
---|
957 | case $1 in
|
---|
958 | letter | A4 )
|
---|
959 | PAGE=$1
|
---|
960 | ;;
|
---|
961 | * )
|
---|
962 | echo "$1 isn't a supported page size."
|
---|
963 | exit 1
|
---|
964 | ;;
|
---|
965 | esac
|
---|
966 | ;;
|
---|
967 |
|
---|
968 |
|
---|
969 | --timezone )
|
---|
970 | test $# = 1 && eval "$exit_missing_arg"
|
---|
971 | shift
|
---|
972 | if [ -f /usr/share/zoneinfo/$1 ] ; then
|
---|
973 | TIMEZONE=$1
|
---|
974 | else
|
---|
975 | echo -e "\nLooks like $1 isn't a valid timezone description."
|
---|
976 | echo -e "Verify your selection and the command line.\n"
|
---|
977 | exit 1
|
---|
978 | fi
|
---|
979 | ;;
|
---|
980 |
|
---|
981 | --fstab )
|
---|
982 | test $# = 1 && eval "$exit_missing_arg"
|
---|
983 | shift
|
---|
984 | if [ -f $1 ] ; then
|
---|
985 | FSTAB=$1
|
---|
986 | else
|
---|
987 | echo -e "\nFile $1 not found. Verify your command line.\n"
|
---|
988 | exit 1
|
---|
989 | fi
|
---|
990 | ;;
|
---|
991 |
|
---|
992 | --kernel-config | -C )
|
---|
993 | test $# = 1 && eval "$exit_missing_arg"
|
---|
994 | shift
|
---|
995 | if [ -f $1 ] ; then
|
---|
996 | CONFIG=$1
|
---|
997 | else
|
---|
998 | echo -e "\nFile $1 not found. Verify your command line.\n"
|
---|
999 | exit 1
|
---|
1000 | fi
|
---|
1001 | ;;
|
---|
1002 |
|
---|
1003 | * )
|
---|
1004 | echo "$usage"
|
---|
1005 | exit 1
|
---|
1006 | ;;
|
---|
1007 | esac
|
---|
1008 | shift
|
---|
1009 | done
|
---|
1010 |
|
---|
1011 | # Prevents setting "-d /" by mistake.
|
---|
1012 |
|
---|
1013 | if [ $BUILDDIR = / ] ; then
|
---|
1014 | echo -ne "\nThe root directory can't be used to build LFS.\n\n"
|
---|
1015 | exit 1
|
---|
1016 | fi
|
---|
1017 |
|
---|
1018 | # If $BUILDDIR has subdirectories like tools/ or bin/, stop the run
|
---|
1019 | # and notify the user about that.
|
---|
1020 |
|
---|
1021 | if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] && [ -z $CLEAN ] ; then
|
---|
1022 | eval "$no_empty_builddir"
|
---|
1023 | fi
|
---|
1024 |
|
---|
1025 | # If requested, clean the build directory
|
---|
1026 | clean_builddir
|
---|
1027 |
|
---|
1028 | # Find the download client to use, if not already specified.
|
---|
1029 |
|
---|
1030 | if [ -z $DL ] ; then
|
---|
1031 | if [ `type -p wget` ] ; then
|
---|
1032 | DL=wget
|
---|
1033 | elif [ `type -p curl` ] ; then
|
---|
1034 | DL=curl
|
---|
1035 | else
|
---|
1036 | eval "$no_dl_client"
|
---|
1037 | fi
|
---|
1038 | fi
|
---|
1039 |
|
---|
1040 | if [ -z $BOOK ] ; then
|
---|
1041 | BOOK=lfs-$LFSVRS
|
---|
1042 | fi
|
---|
1043 |
|
---|
1044 | [[ ! -d $JHALFSDIR ]] && mkdir -pv $JHALFSDIR
|
---|
1045 | [[ "$PWD" != "$JHALFSDIR" ]] && cp -v $FILES $JHALFSDIR/ && \
|
---|
1046 | sed 's,FAKEDIR,'$BOOK',' $XSL > $JHALFSDIR/dump-lfs-scripts.xsl && \
|
---|
1047 | export XSL=$JHALFSDIR/dump-lfs-scripts.xsl
|
---|
1048 | [[ ! -d $LOGDIR ]] && mkdir -v $LOGDIR
|
---|
1049 | >$LOGDIR/$LOG
|
---|
1050 |
|
---|
1051 | get_book
|
---|
1052 | build_Makefile
|
---|
1053 | run_make
|
---|
1054 |
|
---|