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 | fi;
|
---|
349 | @chown lfs \$(LFS)/tools && \\
|
---|
350 | chown lfs \$(LFS)/sources && \\
|
---|
351 | touch \$@
|
---|
352 |
|
---|
353 | 022-settingenvironment: 021-addinguser
|
---|
354 | @\$(call echo_message, Building)
|
---|
355 | @if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\
|
---|
356 | mv -v /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\
|
---|
357 | fi;
|
---|
358 | @if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\
|
---|
359 | mv -v /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\
|
---|
360 | fi;
|
---|
361 | @echo "set +h" > /home/lfs/.bashrc && \\
|
---|
362 | echo "umask 022" >> /home/lfs/.bashrc && \\
|
---|
363 | echo "LFS=/mnt/lfs" >> /home/lfs/.bashrc && \\
|
---|
364 | echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
|
---|
365 | echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
|
---|
366 | echo "export LFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
|
---|
367 | echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc && \\
|
---|
368 | chown lfs:lfs /home/lfs/.bashrc && \\
|
---|
369 | touch envars && \\
|
---|
370 | touch \$@
|
---|
371 | EOF
|
---|
372 | ) >> $MKFILE.tmp
|
---|
373 | }
|
---|
374 |
|
---|
375 | #----------------------------#
|
---|
376 | chapter5_Makefiles() {
|
---|
377 | #----------------------------#
|
---|
378 | for file in chapter05/* ; do
|
---|
379 | # Keep the script file name
|
---|
380 | i=`basename $file`
|
---|
381 |
|
---|
382 | # If no testsuites will be run, then TCL, Expect and DejaGNU isn't needed
|
---|
383 | if [ "$TOOLCHAINTEST" = "0" ]; then
|
---|
384 | if [[ `_IS_ $i tcl` ]] || [[ `_IS_ $i expect` ]] || [[ `_IS_ $i dejagnu` ]] ; then
|
---|
385 | continue
|
---|
386 | fi
|
---|
387 | fi
|
---|
388 |
|
---|
389 | # Test if the stripping phase must be skipped
|
---|
390 | if [ "$STRIP" = "0" ] && [[ `_IS_ $i stripping` ]] ; then
|
---|
391 | continue
|
---|
392 | fi
|
---|
393 |
|
---|
394 | # First append each name of the script files to a list (this will become
|
---|
395 | # the names of the targets in the Makefile
|
---|
396 | chapter5="$chapter5 $i"
|
---|
397 |
|
---|
398 | # Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc
|
---|
399 | # and binutils in chapter 5)
|
---|
400 | name=`echo $i | sed -e 's@[0-9]\{3\}-@@' -e 's@-pass[0-9]\{1\}@@'`
|
---|
401 |
|
---|
402 | # Set the dependency for the first target.
|
---|
403 | if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
|
---|
404 |
|
---|
405 | # Drop in the name of the target on a new line, and the previous target
|
---|
406 | # as a dependency. Also call the echo_message function.
|
---|
407 | (
|
---|
408 | cat << EOF
|
---|
409 |
|
---|
410 | $i: $PREV
|
---|
411 | @\$(call echo_message, Building)
|
---|
412 | EOF
|
---|
413 | ) >> $MKFILE.tmp
|
---|
414 |
|
---|
415 | # Find the version of the command files, if it corresponds with the building of
|
---|
416 | # a specific package
|
---|
417 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
418 |
|
---|
419 | # If $vrs isn't empty, we've got a package...
|
---|
420 | if [ "$vrs" != "" ] ; then
|
---|
421 | if [ "$name" = "tcl" ] ; then
|
---|
422 | FILE="$name$vrs-src.tar"
|
---|
423 | else
|
---|
424 | FILE="$name-$vrs.tar"
|
---|
425 | fi
|
---|
426 |
|
---|
427 | # Insert instructions for unpacking the package and to set
|
---|
428 | # the PKGDIR variable.
|
---|
429 | (
|
---|
430 | cat << EOF
|
---|
431 | @\$(call unpack,$FILE)
|
---|
432 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
433 | chown -R lfs \$(LFS)\$(SRC)/\$\$ROOT && \\
|
---|
434 | echo "PKGDIR=\$(LFS)\$(SRC)/\$\$ROOT" > envars && \\
|
---|
435 | echo "export PKGDIR" >> envars && \\
|
---|
436 | EOF
|
---|
437 | ) >> $MKFILE.tmp
|
---|
438 |
|
---|
439 | fi
|
---|
440 |
|
---|
441 | # Dump the path to the Binutils or TCL sources directory.
|
---|
442 | if [[ `_IS_ $i binutils` ]] || [[ `_IS_ $i tcl` ]] ; then
|
---|
443 | (
|
---|
444 | cat << EOF
|
---|
445 | echo "\$(LFS)\$(SRC)/\$\$ROOT" > sources-dir
|
---|
446 | EOF
|
---|
447 | ) >> $MKFILE.tmp
|
---|
448 |
|
---|
449 | # For the Adjusting phase we must to cd to the binutils-build directory.
|
---|
450 | elif [[ `_IS_ $i adjusting` ]] ; then
|
---|
451 | (
|
---|
452 | cat << EOF
|
---|
453 | @echo "PKGDIR=\$(LFS)\$(SRC)/binutils-build" > envars && \\
|
---|
454 | echo "export PKGDIR" >> envars
|
---|
455 | EOF
|
---|
456 | ) >> $MKFILE.tmp
|
---|
457 |
|
---|
458 | # For the Expect build we need to set the TCLPATH envar.
|
---|
459 | elif [[ `_IS_ $i expect` ]] ; then
|
---|
460 | (
|
---|
461 | cat << EOF
|
---|
462 | echo "TCLPATH=\`cat sources-dir\`" >> envars && \\
|
---|
463 | echo "export TCLPATH" >> envars
|
---|
464 | EOF
|
---|
465 | ) >> $MKFILE.tmp
|
---|
466 |
|
---|
467 | # Everything else, add a true statment so we don't confuse make
|
---|
468 | else
|
---|
469 | (
|
---|
470 | cat << EOF
|
---|
471 | true
|
---|
472 | EOF
|
---|
473 | ) >> $MKFILE.tmp
|
---|
474 | fi
|
---|
475 |
|
---|
476 | # Insert date and disk usage at the top of the log file, the script run
|
---|
477 | # and date and disk usage again at the bottom of the log file.
|
---|
478 | (
|
---|
479 | cat << EOF
|
---|
480 | @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
---|
481 | su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/commands/$file" >>logs/$i 2>&1 && \\
|
---|
482 | echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
---|
483 | EOF
|
---|
484 | ) >> $MKFILE.tmp
|
---|
485 |
|
---|
486 | # Remove the build directory(ies) except if the package build fails
|
---|
487 | # (to can review config.cache, config.log, and like.)
|
---|
488 | # For Binutils and TCL the sources must be retained some time.
|
---|
489 | if [ "$vrs" != "" ] ; then
|
---|
490 | if [[ ! `_IS_ $i binutils` ]] && [[ ! `_IS_ $i tcl` ]] ; then
|
---|
491 | (
|
---|
492 | cat << EOF
|
---|
493 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
494 | rm -r \$(LFS)\$(SRC)/\$\$ROOT && \\
|
---|
495 | if [ -e \$(LFS)\$(SRC)/$name-build ]; then \\
|
---|
496 | rm -r \$(LFS)\$(SRC)/$name-build; \\
|
---|
497 | fi;
|
---|
498 | EOF
|
---|
499 | ) >> $MKFILE.tmp
|
---|
500 | fi
|
---|
501 | fi
|
---|
502 |
|
---|
503 | # Remove the Binutils pass 1 sources after a successful Adjusting phase.
|
---|
504 | if [[ `_IS_ $i adjusting` ]] ; then
|
---|
505 | (
|
---|
506 | cat << EOF
|
---|
507 | @rm -r \`cat sources-dir\` && \\
|
---|
508 | rm -r \$(LFS)\$(SRC)/binutils-build && \\
|
---|
509 | rm sources-dir
|
---|
510 | EOF
|
---|
511 | ) >> $MKFILE.tmp
|
---|
512 | fi
|
---|
513 |
|
---|
514 | # Remove the TCL sources after a successful Expect build.
|
---|
515 | if [[ `_IS_ $i expect` ]] ; then
|
---|
516 | (
|
---|
517 | cat << EOF
|
---|
518 | @rm -r \`cat sources-dir\` && \\
|
---|
519 | rm sources-dir
|
---|
520 | EOF
|
---|
521 | ) >> $MKFILE.tmp
|
---|
522 | fi
|
---|
523 |
|
---|
524 | # Include a touch of the target name so make can check
|
---|
525 | # if it's already been made.
|
---|
526 | (
|
---|
527 | cat << EOF
|
---|
528 | @touch \$@
|
---|
529 | EOF
|
---|
530 | ) >> $MKFILE.tmp
|
---|
531 |
|
---|
532 | # Keep the script file name for Makefile dependencies.
|
---|
533 | PREV=$i
|
---|
534 | done # end for file in chapter05/*
|
---|
535 | }
|
---|
536 |
|
---|
537 | #----------------------------#
|
---|
538 | chapter6_Makefiles() {
|
---|
539 | #----------------------------#
|
---|
540 | for file in chapter06/* ; do
|
---|
541 | # Keep the script file name
|
---|
542 | i=`basename $file`
|
---|
543 |
|
---|
544 | # We'll run the chroot commands differently than the others, so skip them in the
|
---|
545 | # dependencies and target creation.
|
---|
546 | if [[ `_IS_ $i chroot` ]] ; then
|
---|
547 | continue
|
---|
548 | fi
|
---|
549 |
|
---|
550 | # Test if the stripping phase must be skipped
|
---|
551 | if [ "$STRIP" = "0" ] && [[ `_IS_ $i stripping` ]] ; then
|
---|
552 | continue
|
---|
553 | fi
|
---|
554 |
|
---|
555 | # First append each name of the script files to a list (this will become
|
---|
556 | # the names of the targets in the Makefile
|
---|
557 | chapter6="$chapter6 $i"
|
---|
558 |
|
---|
559 | # Grab the name of the target
|
---|
560 | name=`echo $i | sed -e 's@[0-9]\{3\}-@@'`
|
---|
561 |
|
---|
562 | # Drop in the name of the target on a new line, and the previous target
|
---|
563 | # as a dependency. Also call the echo_message function.
|
---|
564 | (
|
---|
565 | cat << EOF
|
---|
566 |
|
---|
567 | $i: $PREV
|
---|
568 | @\$(call echo_message, Building)
|
---|
569 | EOF
|
---|
570 | ) >> $MKFILE.tmp
|
---|
571 |
|
---|
572 | # Find the version of the command files, if it corresponds with the building of
|
---|
573 | # a specific package
|
---|
574 | vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
575 |
|
---|
576 | # If $vrs isn't empty, we've got a package...
|
---|
577 | # Insert instructions for unpacking the package and changing directories
|
---|
578 | if [ "$vrs" != "" ] ; then
|
---|
579 | FILE="$name-$vrs.tar.*"
|
---|
580 | (
|
---|
581 | cat << EOF
|
---|
582 | @\$(call unpack2,$FILE)
|
---|
583 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
584 | echo "PKGDIR=\$(SRC)/\$\$ROOT" > envars && \\
|
---|
585 | echo "export PKGDIR" >> envars
|
---|
586 | EOF
|
---|
587 | ) >> $MKFILE.tmp
|
---|
588 | fi
|
---|
589 |
|
---|
590 | # For the Re-Adjusting phase we must to cd to the binutils-build directory.
|
---|
591 | if [[ `_IS_ $i readjusting` ]] ; then
|
---|
592 | (
|
---|
593 | cat << EOF
|
---|
594 | @echo "PKGDIR=\$(SRC)/binutils-build" > envars && \\
|
---|
595 | echo "export PKGDIR" >> envars
|
---|
596 | EOF
|
---|
597 | ) >> $MKFILE.tmp
|
---|
598 |
|
---|
599 | # For Glibc we need to set TIMEZONE envar.
|
---|
600 | elif [[ `_IS_ $i glibc` ]] ; then
|
---|
601 | (
|
---|
602 | cat << EOF
|
---|
603 | @echo "TIMEZONE=\$(TIMEZONE)" >> envars && \\
|
---|
604 | echo "export TIMEZONE" >> envars
|
---|
605 | EOF
|
---|
606 | ) >> $MKFILE.tmp
|
---|
607 |
|
---|
608 | # For Groff we need to set PAGE envar.
|
---|
609 | elif [[ `_IS_ $i groff` ]] ; then
|
---|
610 | (
|
---|
611 | cat << EOF
|
---|
612 | @echo "PAGE=\$(PAGE)" >> envars && \\
|
---|
613 | echo "export PAGE" >> envars
|
---|
614 | EOF
|
---|
615 | ) >> $MKFILE.tmp
|
---|
616 | fi
|
---|
617 |
|
---|
618 | # In the mount of kernel filesystems we need to set LFS
|
---|
619 | # and not to use chroot.
|
---|
620 | if [[ `_IS_ $i kernfs` ]] ; then
|
---|
621 | (
|
---|
622 | cat << EOF
|
---|
623 | @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
---|
624 | export LFS=\$(LFS) && commands/$file >>logs/$i 2>&1 && \\
|
---|
625 | echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
---|
626 | EOF
|
---|
627 | ) >> $MKFILE.tmp
|
---|
628 |
|
---|
629 | # The rest of Chapter06
|
---|
630 | else
|
---|
631 | (
|
---|
632 | cat << EOF
|
---|
633 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
---|
634 | \$(CHROOT1) 'cd /jhalfs && source envars && /jhalfs/commands/$file >>/jhalfs/logs/$i 2>&1' && \\
|
---|
635 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
---|
636 | EOF
|
---|
637 | ) >> $MKFILE.tmp
|
---|
638 | fi
|
---|
639 |
|
---|
640 | # Remove the build directory(ies) except if the package build fails.
|
---|
641 | if [ "$vrs" != "" ] ; then
|
---|
642 | (
|
---|
643 | cat << EOF
|
---|
644 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
645 | rm -r \$(LFS)\$(SRC)/\$\$ROOT && \\
|
---|
646 | if [ -e \$(LFS)\$(SRC)/$name-build ]; then \\
|
---|
647 | rm -r \$(LFS)\$(SRC)/$name-build; \\
|
---|
648 | fi;
|
---|
649 | EOF
|
---|
650 | ) >> $MKFILE.tmp
|
---|
651 | fi
|
---|
652 |
|
---|
653 | # Remove the Binutils pass 2 sources after a successful Re-Adjusting phase.
|
---|
654 | if [[ `_IS_ $i readjusting` ]] ; then
|
---|
655 | (
|
---|
656 | cat << EOF
|
---|
657 | @rm -r \`cat sources-dir\` && \\
|
---|
658 | rm -r \$(LFS)\$(SRC)/binutils-build && \\
|
---|
659 | rm sources-dir
|
---|
660 | EOF
|
---|
661 | ) >> $MKFILE.tmp
|
---|
662 | fi
|
---|
663 |
|
---|
664 | # Include a touch of the target name so make can check
|
---|
665 | # if it's already been made.
|
---|
666 | (
|
---|
667 | cat << EOF
|
---|
668 | @touch \$@
|
---|
669 | EOF
|
---|
670 | ) >> $MKFILE.tmp
|
---|
671 |
|
---|
672 | # Keep the script file name for Makefile dependencies.
|
---|
673 | PREV=$i
|
---|
674 | done # end for file in chapter06/*
|
---|
675 | }
|
---|
676 |
|
---|
677 | #----------------------------#
|
---|
678 | chapter789_Makefiles() {
|
---|
679 | #----------------------------#
|
---|
680 | for file in chapter0{7,8,9}/* ; do
|
---|
681 | # Keep the script file name
|
---|
682 | i=`basename $file`
|
---|
683 |
|
---|
684 | # Grub must be configured manually.
|
---|
685 | # The filesystems can't be unmounted via Makefile and the user
|
---|
686 | # should to enter to the chroot environment to create the root
|
---|
687 | # password, edit several files and setup Grub,
|
---|
688 | if [[ `_IS_ $i grub` ]] || [[ `_IS_ $i reboot` ]] ; then
|
---|
689 | continue
|
---|
690 | fi
|
---|
691 |
|
---|
692 | # If no .config file is supplied, the kernel build is skipped
|
---|
693 | if [ -z $CONFIG ] && [[ `_IS_ $i kernel` ]] ; then
|
---|
694 | continue
|
---|
695 | fi
|
---|
696 |
|
---|
697 | # First append each name of the script files to a list (this will become
|
---|
698 | # the names of the targets in the Makefile
|
---|
699 | chapter789="$chapter789 $i"
|
---|
700 |
|
---|
701 | # Drop in the name of the target on a new line, and the previous target
|
---|
702 | # as a dependency. Also call the echo_message function.
|
---|
703 | (
|
---|
704 | cat << EOF
|
---|
705 |
|
---|
706 | $i: $PREV
|
---|
707 | @\$(call echo_message, Building)
|
---|
708 | EOF
|
---|
709 | ) >> $MKFILE.tmp
|
---|
710 |
|
---|
711 | # Find the the bootscripts and kernel package names
|
---|
712 | if [[ `_IS_ $i bootscripts` ]] || [[ `_IS_ $i kernel` ]] ; then
|
---|
713 | if [[ `_IS_ $i bootscripts` ]] ; then
|
---|
714 | vrs=`grep "^lfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
715 | FILE="lfs-bootscripts-$vrs.tar.*"
|
---|
716 | elif [[ `_IS_ $i kernel` ]] ; then
|
---|
717 | vrs=`grep "^linux-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
|
---|
718 | FILE="linux-$vrs.tar.*"
|
---|
719 | fi
|
---|
720 | (
|
---|
721 | cat << EOF
|
---|
722 | @\$(call unpack2,$FILE)
|
---|
723 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
724 | echo "PKGDIR=\$(SRC)/\$\$ROOT" > envars && \\
|
---|
725 | echo "export PKGDIR" >> envars
|
---|
726 | EOF
|
---|
727 | ) >> $MKFILE.tmp
|
---|
728 | fi
|
---|
729 |
|
---|
730 | # Put in place the kernel .config file
|
---|
731 | if [[ `_IS_ $i kernel` ]] ; then
|
---|
732 | (
|
---|
733 | cat << EOF
|
---|
734 | @cp $CONFIG \$(LFS)/sources/kernel-config
|
---|
735 | EOF
|
---|
736 | ) >> $MKFILE.tmp
|
---|
737 | fi
|
---|
738 |
|
---|
739 | # Check if we have a real /etc/fstab file
|
---|
740 | if [[ `_IS_ $i fstab` ]] && [[ -n "$FSTAB" ]] ; then
|
---|
741 | (
|
---|
742 | cat << EOF
|
---|
743 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
---|
744 | cp -v $FSTAB \$(LFS)/etc/fstab >>logs/$i 2>&1 && \\
|
---|
745 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
---|
746 | EOF
|
---|
747 | ) >> $MKFILE.tmp
|
---|
748 | else
|
---|
749 | # Initialize the log an run the script
|
---|
750 | (
|
---|
751 | cat << EOF
|
---|
752 | @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
|
---|
753 | \$(CHROOT2) 'cd /jhalfs && source envars && /jhalfs/commands/$file >>/jhalfs/logs/$i 2>&1' && \\
|
---|
754 | echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
|
---|
755 | EOF
|
---|
756 | ) >> $MKFILE.tmp
|
---|
757 | fi
|
---|
758 |
|
---|
759 | # Remove the build directory except if the package build fails.
|
---|
760 | if [[ `_IS_ $i bootscripts` ]] || [[ `_IS_ $i kernel` ]] ; then
|
---|
761 | (
|
---|
762 | cat << EOF
|
---|
763 | @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
|
---|
764 | rm -r \$(LFS)\$(SRC)/\$\$ROOT
|
---|
765 | EOF
|
---|
766 | ) >> $MKFILE.tmp
|
---|
767 | fi
|
---|
768 |
|
---|
769 | # Include a touch of the target name so make can check
|
---|
770 | # if it's already been made.
|
---|
771 | (
|
---|
772 | cat << EOF
|
---|
773 | @touch \$@
|
---|
774 | EOF
|
---|
775 | ) >> $MKFILE.tmp
|
---|
776 |
|
---|
777 | # Keep the script file name for Makefile dependencies.
|
---|
778 | PREV=$i
|
---|
779 | done # for file in chapter0{7,8,9}/*
|
---|
780 | }
|
---|
781 |
|
---|
782 |
|
---|
783 | #----------------------------#
|
---|
784 | build_Makefile() {
|
---|
785 | #----------------------------#
|
---|
786 | echo -n "Creating Makefile... "
|
---|
787 | cd $JHALFSDIR/commands
|
---|
788 |
|
---|
789 | # Start with a clean Makefile.tmp file
|
---|
790 | >$MKFILE.tmp
|
---|
791 |
|
---|
792 | chapter4_Makefiles
|
---|
793 | chapter5_Makefiles
|
---|
794 | chapter6_Makefiles
|
---|
795 | chapter789_Makefiles
|
---|
796 |
|
---|
797 |
|
---|
798 | # Add a header, some variables and include the function file
|
---|
799 | # to the top of the real Makefile.
|
---|
800 | (
|
---|
801 | cat << EOF
|
---|
802 | $HEADER
|
---|
803 |
|
---|
804 | SRC= /sources
|
---|
805 | LFS= $BUILDDIR
|
---|
806 | PAGE= $PAGE
|
---|
807 | TIMEZONE= $TIMEZONE
|
---|
808 |
|
---|
809 | include functions
|
---|
810 |
|
---|
811 | EOF
|
---|
812 | ) > $MKFILE
|
---|
813 |
|
---|
814 |
|
---|
815 | # Add chroot commands
|
---|
816 | i=1
|
---|
817 | for file in chapter06/*chroot* ; do
|
---|
818 | chroot=`cat $file | sed -e '/#!\/bin\/sh/d' -e 's@ \\\@ @g' | tr -d '\n' | sed \
|
---|
819 | -e 's/ */ /g' -e 's|\\$|&&|g' -e 's|exit||g' -e 's|$| -c|' \
|
---|
820 | -e 's|"$$LFS"|$(LFS)|' -e 's|set -e||'`
|
---|
821 | echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
---|
822 | i=`expr $i + 1`
|
---|
823 | done
|
---|
824 |
|
---|
825 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
826 | # as a dependency.
|
---|
827 | (
|
---|
828 | cat << EOF
|
---|
829 | all: chapter4 chapter5 chapter6 chapter789
|
---|
830 | @\$(call echo_finished,$VERSION)
|
---|
831 |
|
---|
832 | chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
|
---|
833 |
|
---|
834 | chapter5: chapter4 $chapter5 restore-lfs-env
|
---|
835 |
|
---|
836 | chapter6: chapter5 $chapter6
|
---|
837 |
|
---|
838 | chapter789: chapter6 $chapter789
|
---|
839 |
|
---|
840 | clean-all: clean
|
---|
841 | rm -rf ./*
|
---|
842 |
|
---|
843 | clean: clean-chapter789 clean-chapter6 clean-chapter5 clean-chapter4
|
---|
844 |
|
---|
845 | clean-chapter4:
|
---|
846 | -userdel lfs
|
---|
847 | rm -rf /home/lfs
|
---|
848 | rm -rf \$(LFS)/tools
|
---|
849 | rm -f /tools
|
---|
850 | rm -f envars
|
---|
851 | rm -f 02* logs/02*.log
|
---|
852 |
|
---|
853 | clean-chapter5:
|
---|
854 | rm -rf \$(LFS)/tools/*
|
---|
855 | rm -f $chapter5 restore-lfs-env
|
---|
856 | cd logs && rm -f $chapter5 && cd ..
|
---|
857 |
|
---|
858 | clean-chapter6:
|
---|
859 | -umount \$(LFS)/sys
|
---|
860 | -umount \$(LFS)/proc
|
---|
861 | -umount \$(LFS)/dev/shm
|
---|
862 | -umount \$(LFS)/dev/pts
|
---|
863 | -umount \$(LFS)/dev
|
---|
864 | rm -rf \$(LFS)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
|
---|
865 | rm -f $chapter6
|
---|
866 | cd logs && rm -f $chapter6 && cd ..
|
---|
867 |
|
---|
868 | clean-chapter789:
|
---|
869 | rm -f $chapter789
|
---|
870 | cd logs && rm -f $chapter789 && cd ..
|
---|
871 |
|
---|
872 | restore-lfs-env:
|
---|
873 | @\$(call echo_message, Building)
|
---|
874 | @if [ -f /home/lfs/.bashrc.XXX ]; then \\
|
---|
875 | mv -fv /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
|
---|
876 | fi;
|
---|
877 | @if [ -f /home/lfs/.bash_profile.XXX ]; then \\
|
---|
878 | mv -v /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
|
---|
879 | fi;
|
---|
880 | @chown lfs:lfs /home/lfs/.bash* && \\
|
---|
881 | touch \$@
|
---|
882 |
|
---|
883 | EOF
|
---|
884 | ) >> $MKFILE
|
---|
885 |
|
---|
886 | # Bring over the items from the Makefile.tmp
|
---|
887 | cat $MKFILE.tmp >> $MKFILE
|
---|
888 | rm $MKFILE.tmp
|
---|
889 | echo -ne "done\n"
|
---|
890 | }
|
---|
891 |
|
---|
892 | #----------------------------#
|
---|
893 | run_make() {
|
---|
894 | #----------------------------#
|
---|
895 | # Test if make must be run.
|
---|
896 | if [ "$RUNMAKE" = "1" ] ; then
|
---|
897 | # Test to make sure we're running the build as root
|
---|
898 | if [ "$UID" != "0" ] ; then
|
---|
899 | echo "You must be logged in as root to successfully build LFS."
|
---|
900 | exit 1
|
---|
901 | fi
|
---|
902 | # Build the system
|
---|
903 | if [ -e $MKFILE ] ; then
|
---|
904 | echo -ne "Building the LFS system...\n"
|
---|
905 | cd $JHALFSDIR && make
|
---|
906 | echo -ne "done\n"
|
---|
907 | fi
|
---|
908 | fi
|
---|
909 | }
|
---|
910 |
|
---|
911 |
|
---|
912 |
|
---|
913 | ###################################
|
---|
914 | ### MAIN ###
|
---|
915 | ###################################
|
---|
916 |
|
---|
917 | # Evaluate any command line switches
|
---|
918 |
|
---|
919 | while test $# -gt 0 ; do
|
---|
920 | case $1 in
|
---|
921 | --version | -V )
|
---|
922 | echo "$version"
|
---|
923 | exit 0
|
---|
924 | ;;
|
---|
925 |
|
---|
926 | --help | -h )
|
---|
927 | echo "$usage"
|
---|
928 | exit 0
|
---|
929 | ;;
|
---|
930 |
|
---|
931 | --LFS-version | -L )
|
---|
932 | test $# = 1 && eval "$exit_missing_arg"
|
---|
933 | shift
|
---|
934 | case $1 in
|
---|
935 | dev* | SVN | trunk )
|
---|
936 | LFSVRS=development
|
---|
937 | ;;
|
---|
938 | testing | 6.1.1 )
|
---|
939 | LFSVRS=6.1.1
|
---|
940 | ;;
|
---|
941 |
|
---|
942 | alpha*)
|
---|
943 | LFSVRS=alphabetical
|
---|
944 | ;;
|
---|
945 | * )
|
---|
946 | echo "$1 is an unsupported version at this time."
|
---|
947 | exit 1
|
---|
948 | ;;
|
---|
949 | esac
|
---|
950 | ;;
|
---|
951 |
|
---|
952 | --directory | -d )
|
---|
953 | test $# = 1 && eval "$exit_missing_arg"
|
---|
954 | shift
|
---|
955 | BUILDDIR=$1
|
---|
956 | JHALFSDIR=$BUILDDIR/jhalfs
|
---|
957 | LOGDIR=$JHALFSDIR/logs
|
---|
958 | MKFILE=$JHALFSDIR/Makefile
|
---|
959 | ;;
|
---|
960 |
|
---|
961 | --download-client | -D )
|
---|
962 | test $# = 1 && eval "$exit_missing_arg"
|
---|
963 | shift
|
---|
964 | DL=$1
|
---|
965 | ;;
|
---|
966 |
|
---|
967 | --working-copy | -W )
|
---|
968 | test $# = 1 && eval "$exit_missing_arg"
|
---|
969 | shift
|
---|
970 | if [ -f $1/patches.ent ] ; then
|
---|
971 | WC=1
|
---|
972 | BOOK=$1
|
---|
973 | else
|
---|
974 | echo -e "\nLook like $1 isn't a supported working copy."
|
---|
975 | echo -e "Verify your selection and the command line.\n"
|
---|
976 | exit 1
|
---|
977 | fi
|
---|
978 | ;;
|
---|
979 |
|
---|
980 | --testsuites | -T ) TEST=1 ;;
|
---|
981 |
|
---|
982 | --get-packages | -P ) HPKG=1 ;;
|
---|
983 |
|
---|
984 | --run-make | -M ) RUNMAKE=1 ;;
|
---|
985 |
|
---|
986 | --no-toolchain-test ) TOOLCHAINTEST=0 ;;
|
---|
987 |
|
---|
988 | --no-strip ) STRIP=0 ;;
|
---|
989 |
|
---|
990 | --no-vim-lang ) VIMLANG=0 ;;
|
---|
991 |
|
---|
992 | --page_size )
|
---|
993 | test $# = 1 && eval "$exit_missing_arg"
|
---|
994 | shift
|
---|
995 | case $1 in
|
---|
996 | letter | A4 )
|
---|
997 | PAGE=$1
|
---|
998 | ;;
|
---|
999 | * )
|
---|
1000 | echo "$1 isn't a supported page size."
|
---|
1001 | exit 1
|
---|
1002 | ;;
|
---|
1003 | esac
|
---|
1004 | ;;
|
---|
1005 |
|
---|
1006 |
|
---|
1007 | --timezone )
|
---|
1008 | test $# = 1 && eval "$exit_missing_arg"
|
---|
1009 | shift
|
---|
1010 | if [ -f /usr/share/zoneinfo/$1 ] ; then
|
---|
1011 | TIMEZONE=$1
|
---|
1012 | else
|
---|
1013 | echo -e "\nLook like $1 isn't a valid timezone description."
|
---|
1014 | echo -e "Verify your selection and the command line.\n"
|
---|
1015 | exit 1
|
---|
1016 | fi
|
---|
1017 | ;;
|
---|
1018 |
|
---|
1019 | --fstab )
|
---|
1020 | test $# = 1 && eval "$exit_missing_arg"
|
---|
1021 | shift
|
---|
1022 | if [ -f $1 ] ; then
|
---|
1023 | FSTAB=$1
|
---|
1024 | else
|
---|
1025 | echo -e "\nFile $1 not found. Verify your command line.\n"
|
---|
1026 | exit 1
|
---|
1027 | fi
|
---|
1028 | ;;
|
---|
1029 |
|
---|
1030 | --kernel-config | -C )
|
---|
1031 | test $# = 1 && eval "$exit_missing_arg"
|
---|
1032 | shift
|
---|
1033 | if [ -f $1 ] ; then
|
---|
1034 | CONFIG=$1
|
---|
1035 | else
|
---|
1036 | echo -e "\nFile $1 not found. Verify your command line.\n"
|
---|
1037 | exit 1
|
---|
1038 | fi
|
---|
1039 | ;;
|
---|
1040 |
|
---|
1041 | * )
|
---|
1042 | echo "$usage"
|
---|
1043 | exit 1
|
---|
1044 | ;;
|
---|
1045 | esac
|
---|
1046 | shift
|
---|
1047 | done
|
---|
1048 |
|
---|
1049 | # If $BUILDDIR have subdirectories like tools/ or bin/, stop the run
|
---|
1050 | # and notify the user about that. This also prevents setting "-d /"
|
---|
1051 | # by mistake.
|
---|
1052 |
|
---|
1053 | if [ -d $BUILDDIR/tools -o -d $BUILDDIR/bin ] ; then
|
---|
1054 | eval "$no_empty_builddir"
|
---|
1055 | fi
|
---|
1056 |
|
---|
1057 | # Find the download client to use, if not already specified.
|
---|
1058 |
|
---|
1059 | if [ -z $DL ] ; then
|
---|
1060 | if [ `type -p wget` ] ; then
|
---|
1061 | DL=wget
|
---|
1062 | elif [ `type -p curl` ] ; then
|
---|
1063 | DL=curl
|
---|
1064 | else
|
---|
1065 | eval "$no_dl_client"
|
---|
1066 | fi
|
---|
1067 | fi
|
---|
1068 |
|
---|
1069 | [[ ! -d $JHALFSDIR ]] && mkdir -pv $JHALFSDIR
|
---|
1070 | [[ "$PWD" != "$JHALFSDIR" ]] && cp -v $FILES $JHALFSDIR/ && \
|
---|
1071 | sed -e 's,FAKEDIR,'$BOOK',' $XSL > $JHALFSDIR/dump-lfs-scripts.xsl && \
|
---|
1072 | export XSL=$JHALFSDIR/dump-lfs-scripts.xsl
|
---|
1073 | [[ ! -d $LOGDIR ]] && mkdir -v $LOGDIR
|
---|
1074 | >$LOGDIR/$LOG
|
---|
1075 |
|
---|
1076 | get_book
|
---|
1077 | build_Makefile
|
---|
1078 | run_make
|
---|
1079 |
|
---|