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