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