source: HLFS/master.sh@ 8f4d140

experimental
Last change on this file since 8f4d140 was 5365c39, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Fixed the creation of /etc/profile in HLFS module.

  • Property mode set to 100755
File size: 22.4 KB
RevLine 
[0170229]1#!/bin/sh
2set -e # Enable error trapping
3
[57ca090]4# $Id$
[0170229]5
6###################################
7### FUNCTIONS ###
8###################################
9
10
11#----------------------------#
12get_sources() { #
13#----------------------------#
14 local IFS
15
16 # Test if the packages must be downloaded
17 if [ ! "$HPKG" = "1" ] ; then
18 return
19 fi
20
21 # Modify the 'internal field separator' to break on 'LF' only
22 IFS=$'\x0A'
23
24 if [ ! -d $BUILDDIR/sources ] ; then mkdir $BUILDDIR/sources ; fi
25 cd $BUILDDIR/sources
26
27 > MISSING_FILES.DMP # Files not in md5sum end up here
28
29 if [ -f MD5SUMS ] ; then rm MD5SUMS ; fi
30 if [ -f MD5SUMS-$VERSION ] ; then rm MD5SUMS-$VERSION ; fi
31
32 # Retrieve the master md5sum file
33 download "" MD5SUMS
34
35 # Iterate through each package and grab it, along with any patches it needs.
36 for i in `cat $JHALFSDIR/packages` ; do
37 PKG=`echo $i | sed -e 's/-version.*//' \
38 -e 's/-file.*//' \
39 -e 's/uclibc/uClibc/' `
40
41 # Needed for Groff patchlevel patch on UTF-8 branch
42 GROFFLEVEL=`grep "groff-patchlevel" $JHALFSDIR/packages | sed -e 's/groff-patchlevel //' -e 's/"//g'`
43
44 #
45 # How to deal with orphan packages..??
46 #
47 VRS=`echo $i | sed -e 's/.* //' -e 's/"//g'`
48 case "$PKG" in
49 "expect-lib" ) continue ;; # not valid packages
50 "linux-dl" ) continue ;;
51 "groff-patchlevel" ) continue ;;
52 "uClibc-patch" ) continue ;;
53
54 "tcl" ) FILE="$PKG$VRS-src.tar.bz2" ; download $PKG $FILE ;;
55 "vim-lang" ) FILE="vim-$VRS-lang.tar.bz2"; PKG="vim" ; download $PKG $FILE ;;
56 "udev-config" ) FILE="$VRS" ; PKG="udev" ; download $PKG $FILE ;;
57
58 "uClibc-locale" ) FILE="$PKG-$VRS.tar.bz2" ; PKG="uClibc"
59 download $PKG $FILE
60 # There can be no patches for this file
61 continue ;;
62
63 "gcc" ) download $PKG "gcc-core-$VRS.tar.bz2"
64 download $PKG "gcc-g++-$VRS.tar.bz2"
[57ca090]65 if [ ! "$TEST" = "0" ] ; then
66 download $PKG "gcc-testsuite-$VRS.tar.bz2" ;
67 fi
[0170229]68 ;;
69 "glibc") download $PKG "$PKG-$VRS.tar.bz2"
70 download $PKG "$PKG-libidn-$VRS.tar.bz2"
71 ;;
72 * ) FILE="$PKG-$VRS.tar.bz2"
73 download $PKG $FILE
74 ;;
75 esac
76
77 for patch in `grep "$PKG-&$PKG" $JHALFSDIR/patches` ; do
78 PATCH=`echo $patch | sed 's@&'$PKG'-version;@'$VRS'@'`
79 download $PKG $PATCH
80 done
81
82 done
83
84 # .... U G L Y .... what to do with the grsecurity patch to the kernel..
85 download grsecurity `grep grsecurity $JHALFSDIR/patches`
86
87 # .... U G L Y .... deal with uClibc-locale-xxxxx.tar.bz2 format issue.
88 bzcat uClibc-locale-030818.tar.bz2 | gzip > uClibc-locale-030818.tgz
89
90 if [[ -s $BUILDDIR/sources/MISSING_FILES.DMP ]]; then
91 echo -e "\n\n${tab_}${RED} One or more files were not retrieved.\n${tab_} Check <MISSING_FILES.DMP> for names ${OFF}\n\n"
92 fi
93}
94
95
96#----------------------------#
97chapter4_Makefiles() { # Initialization of the system
98#----------------------------#
99 local TARGET LOADER
100
[57ca090]101 echo "${YELLOW} Processing Chapter-3 scripts ${OFF}"
[0170229]102
103 # Define a few model dependant variables
104 if [[ ${MODEL} = "uclibc" ]]; then
105 TARGET="tools-linux-uclibc"; LOADER="ld-uClibc.so.0"
106 else
107 TARGET="tools-linux-gnu"; LOADER="ld-linux.so.2"
108 fi
109
110 # 022-
111 # If /home/hlfs is already present in the host, we asume that the
112 # hlfs user and group are also presents in the host, and a backup
113 # of their bash init files is made.
114(
115cat << EOF
116020-creatingtoolsdir:
117 @\$(call echo_message, Building)
118 @mkdir -v \$(MOUNT_PT)/tools && \\
119 rm -fv /tools && \\
120 ln -sv \$(MOUNT_PT)/tools /
121 @if [ ! -d \$(MOUNT_PT)/sources ]; then \\
122 mkdir \$(MOUNT_PT)/sources; \\
123 fi;
124 @chmod a+wt \$(MOUNT_PT)/sources && \\
125 touch \$@
126
127021-addinguser: 020-creatingtoolsdir
128 @\$(call echo_message, Building)
129 @if [ ! -d /home/lfs ]; then \\
130 groupadd lfs; \\
131 useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\
132 else \\
133 touch user-lfs-exist; \\
134 fi;
135 @chown lfs \$(MOUNT_PT)/tools && \\
136 chown lfs \$(MOUNT_PT)/sources && \\
137 touch \$@
138
139022-settingenvironment: 021-addinguser
140 @\$(call echo_message, Building)
141 @if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\
142 mv -v /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\
143 fi;
144 @if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\
145 mv -v /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\
146 fi;
147 @echo "set +h" > /home/lfs/.bashrc && \\
148 echo "umask 022" >> /home/lfs/.bashrc && \\
149 echo "HLFS=\$(MOUNT_PT)" >> /home/lfs/.bashrc && \\
150 echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
151 echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
152 echo "export HLFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
153 echo "" >> /home/lfs/.bashrc && \\
154 echo "target=$(uname -m)-${TARGET}" >> /home/lfs/.bashrc && \\
155 echo "ldso=/tools/lib/${LOADER}" >> /home/lfs/.bashrc && \\
156 echo "export target ldso" >> /home/lfs/.bashrc && \\
157 echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc && \\
158 chown lfs:lfs /home/lfs/.bashrc && \\
159 touch envars && \\
160 touch \$@
161EOF
162) >> $MKFILE.tmp
163
164}
165
166#----------------------------#
167chapter5_Makefiles() { # Bootstrap or temptools phase
168#----------------------------#
169 local file
170 local this_script
[57ca090]171
[0170229]172 echo "${YELLOW} Processing Chapter-5 scripts${OFF}"
173
174 for file in chapter05/* ; do
175 # Keep the script file name
176 this_script=`basename $file`
177
178 # Skip this script depending on jhalfs.conf flags set.
179 case $this_script in
180 # If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
[821a2c6]181 *tcl* ) [[ "$TEST" = "0" ]] && continue; ;;
182 *expect* ) [[ "$TEST" = "0" ]] && continue; ;;
183 *dejagnu* ) [[ "$TEST" = "0" ]] && continue; ;;
[0170229]184 # Test if the stripping phase must be skipped
185 *stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
186 # Select the appropriate library
187 *glibc*) [[ ${MODEL} = "uclibc" ]] && continue ;;
188 *uclibc*) [[ ${MODEL} = "glibc" ]] && continue ;;
189 *) ;;
190 esac
191
192 # First append each name of the script files to a list (this will become
193 # the names of the targets in the Makefile
194 chapter5="$chapter5 $this_script"
195
196 # Grab the name of the target (minus the -headers or -cross in the case of gcc
197 # and binutils in chapter 5)
198 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-cross@@' -e 's@-headers@@'`
199
200 # >>>>>>>>>> U G L Y <<<<<<<<<
201 # Adjust 'name' and patch a few scripts on the fly..
202 case $name in
203 linux-libc) name=linux-libc-headers
204 ;;
205 uclibc) # this sucks as method to deal with gettext/libint inside uClibc
206 sed 's@^cd gettext-runtime@cd ../gettext-*/gettext-runtime@' -i chapter05/$this_script
207 ;;
208 gcc) # to compensate for the compiler test inside gcc (which fails), disable error trap
209 sed 's@^gcc -o test test.c@set +e; gcc -o test test.c@' -i chapter05/$this_script
210 ;;
211 esac
212
213 # Set the dependency for the first target.
214 if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
215
216
217 #--------------------------------------------------------------------#
218 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
219 #--------------------------------------------------------------------#
220 #
221 # Drop in the name of the target on a new line, and the previous target
222 # as a dependency. Also call the echo_message function.
223 wrt_target "$this_script" "$PREV"
224
225 # Find the version of the command files, if it corresponds with the building of
226 # a specific package
227 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
228 # If $vrs isn't empty, we've got a package...
229 if [ "$vrs" != "" ] ; then
230 # Deal with non-standard names
231 case $name in
232 tcl) FILE="$name$vrs-src.tar" ;;
233 uclibc) FILE="uClibc-$vrs.tar" ;;
234 gcc) FILE="gcc-core-$vrs.tar" ;;
235 *) FILE="$name-$vrs.tar" ;;
236 esac
237 # Insert instructions for unpacking the package and to set the PKGDIR variable.
238 wrt_unpack "$FILE"
239 fi
240
241 case $this_script in
242 *binutils* ) # Dump the path to sources directory for later removal
243 echo -e '\techo "$(MOUNT_PT)$(SRC)/$$ROOT" >> sources-dir' >> $MKFILE.tmp
244 ;;
245 *adjusting* ) # For the Adjusting phase we must to cd to the binutils-build directory.
246 echo -e '\t@echo "export PKGDIR=$(MOUNT_PT)$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
247 ;;
248 * ) # Everything else, add a true statment so we don't confuse make
249 echo -e '\ttrue' >> $MKFILE.tmp
250 ;;
251 esac
252
253 # Insert date and disk usage at the top of the log file, the script run
254 # and date and disk usage again at the bottom of the log file.
255 wrt_run_as_su "${this_script}" "${file}"
256
257 # Remove the build directory(ies) except if the package build fails
258 # (so we can review config.cache, config.log, etc.)
259 # For Binutils the sources must be retained for some time.
260 if [ "$vrs" != "" ] ; then
261 if [[ ! `_IS_ $this_script binutils` ]]; then
262 wrt_remove_build_dirs "$name"
263 fi
264 fi
265
266 # Remove the Binutils pass 1 sources after a successful Adjusting phase.
267 if [[ `_IS_ $this_script adjusting` ]] ; then
268(
269cat << EOF
270 @rm -r \`cat sources-dir\` && \\
271 rm -r \$(MOUNT_PT)\$(SRC)/binutils-build && \\
272 rm sources-dir
273EOF
274) >> $MKFILE.tmp
275 fi
276
277 # Include a touch of the target name so make can check if it's already been made.
278 echo -e '\t@touch $@' >> $MKFILE.tmp
279 #
280 #--------------------------------------------------------------------#
281 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
282 #--------------------------------------------------------------------#
283
284 # Keep the script file name for Makefile dependencies.
285 PREV=$this_script
286 done # end for file in chapter05/*
287}
288
289
290#----------------------------#
291chapter6_Makefiles() { # sysroot or chroot build phase
292#----------------------------#
293 local TARGET LOADER
294 local file
295 local this_script
296
297 #
298 # Set these definitions early and only once
299 #
300 if [[ ${MODEL} = "uclibc" ]]; then
301 TARGET="pc-linux-uclibc"; LOADER="ld-uClibc.so.0"
302 else
303 TARGET="pc-linux-gnu"; LOADER="ld-linux.so.2"
304 fi
305
306 echo -e "${YELLOW} Processing Chapter-6 scripts ${OFF}"
307 for file in chapter06/* ; do
308 # Keep the script file name
309 this_script=`basename $file`
310
311 # Skip this script depending on jhalfs.conf flags set.
312 case $this_script in
313 # We'll run the chroot commands differently than the others, so skip them in the
314 # dependencies and target creation.
315 *chroot* ) continue ;;
316 # Test if the stripping phase must be skipped
317 *-stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
318 # Select the appropriate library
319 *glibc*) [[ ${MODEL} = "uclibc" ]] && continue ;;
320 *uclibc*) [[ ${MODEL} = "glibc" ]] && continue ;;
321 *) ;;
322 esac
323
324 # First append each name of the script files to a list (this will become
325 # the names of the targets in the Makefile
326 chapter6="$chapter6 $this_script"
327
328 # Grab the name of the target
329 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
330
331 #
332 # Sed replacement for 'nodump' tag in xml scripts until Manuel has a chance to fix them
333 #
334 case $name in
[57ca090]335 kernfs)
[0170229]336 # We are using LFS instead of HLFS..
337 sed 's/HLFS/LFS/' -i chapter06/$this_script
338 # Remove sysctl code if host does not have grsecurity enabled
339 if [[ "$GRSECURITY_HOST" = "0" ]]; then
340 sed '/sysctl/d' -i chapter06/$this_script
[57ca090]341 fi
[0170229]342 ;;
343 module-init-tools)
344 if [[ "$TEST" = "0" ]]; then # This needs rework....
345 sed '/make distclean/d' -i chapter06/$this_script
346 fi
347 ;;
348 glibc) # PATCH.. Turn off error trapping for the remainder of the script.
349 sed 's|^make install|make install; set +e|' -i chapter06/$this_script
350 ;;
351 uclibc) # PATCH..
352 sed 's/EST5EDT/${TIMEZONE}/' -i chapter06/$this_script
353 # PATCH.. Cannot use interactive programs/scripts.
354 sed 's/make menuconfig/make oldconfig/' -i chapter06/$this_script
355 sed 's@^cd gettext-runtime@cd ../gettext-*/gettext-runtime@' -i chapter06/$this_script
356 ;;
357 gcc) # PATCH..
358 sed 's/rm /rm -f /' -i chapter06/$this_script
359 ;;
360 esac
361
362 #--------------------------------------------------------------------#
363 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
364 #--------------------------------------------------------------------#
365 #
366 # Drop in the name of the target on a new line, and the previous target
367 # as a dependency. Also call the echo_message function.
368 wrt_target "$this_script" "$PREV"
369
370 # Find the version of the command files, if it corresponds with the building of
371 # a specific package
372 vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
373
374 # If $vrs isn't empty, we've got a package...
375 # Insert instructions for unpacking the package and changing directories
376 if [ "$vrs" != "" ] ; then
377 # Deal with non-standard names
378 case $name in
379 tcl) FILE="$name$vrs-src.tar.*" ;;
380 uclibc) FILE="uClibc-$vrs.tar.*" ;;
381 gcc) FILE="gcc-core-$vrs.tar.*" ;;
382 *) FILE="$name-$vrs.tar.*" ;;
383 esac
384 wrt_unpack2 "$FILE"
385 wrt_target_vars
386 fi
387
388 case $this_script in
389 *readjusting*) # For the Re-Adjusting phase we must to cd to the binutils-build directory.
390 echo -e '\t@echo "export PKGDIR=$(SRC)/binutils-build" > envars' >> $MKFILE.tmp
391 ;;
392 *glibc* | *uclibc* ) # For glibc and uClibc we need to set TIMEZONE envar.
393 wrt_export_timezone
394 ;;
395 *groff* ) # For Groff we need to set PAGE envar.
396 wrt_export_pagesize
397 ;;
398 esac
399
400 # In the mount of kernel filesystems we need to set HLFS and not to use chroot.
401 if [[ `_IS_ $this_script kernfs` ]] ; then
402 wrt_run_as_root "${this_script}" "${file}"
403 #
404 # The rest of Chapter06
405 else
406 wrt_run_as_chroot1 "${this_script}" "${file}"
407 fi
408 #
409 # Remove the build directory(ies) except if the package build fails.
410 if [ "$vrs" != "" ] ; then
411 wrt_remove_build_dirs "$name"
412 fi
413 #
414 # Remove the Binutils pass 2 sources after a successful Re-Adjusting phase.
415 if [[ `_IS_ $this_script readjusting` ]] ; then
416(
417cat << EOF
418 @rm -r \`cat sources-dir\` && \\
419 rm -r \$(MOUNT_PT)\$(SRC)/binutils-build && \\
420 rm sources-dir
421EOF
422) >> $MKFILE.tmp
423 fi
424
425 # Include a touch of the target name so make can check if it's already been made.
426 echo -e '\t@touch $@' >> $MKFILE.tmp
427 #
428 #--------------------------------------------------------------------#
429 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
430 #--------------------------------------------------------------------#
431
432 # Keep the script file name for Makefile dependencies.
433 PREV=$this_script
434 done # end for file in chapter06/*
435
436}
437
438#----------------------------#
439chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..etc
440#----------------------------#
441 local file
442 local this_script
[57ca090]443
[0170229]444 echo "${YELLOW} Processing Chapter-7 scripts ${OFF}"
445 for file in chapter07/*; do
446 # Keep the script file name
447 this_script=`basename $file`
448
449 # Grub must be configured manually.
450 # The filesystems can't be unmounted via Makefile and the user
451 # should enter the chroot environment to create the root
452 # password, edit several files and setup Grub.
453 case $this_script in
454 *grub) continue ;;
455 *reboot) continue ;;
456 *console) continue ;; # Use the file generated by lfs-bootscripts
457
[57ca090]458 *kernel)
[821a2c6]459 # If no .config file is supplied, the kernel build is skipped
460 [[ -z $CONFIG ]] && continue
461 # How does Manuel add this string to the file..
[0170229]462 sed 's|cd \$PKGDIR.*||' -i chapter07/$this_script
463 # You cannot run menuconfig from within the makefile
464 sed 's|make menuconfig|make oldconfig|' -i chapter07/$this_script
465 # The files in the conglomeration dir are xxx.bz2
466 sed 's|.patch.gz|.patch.bz2|' -i chapter07/$this_script
467 sed 's|gunzip|bunzip2|' -i chapter07/$this_script
468 # If defined include the keymap in the kernel
469 if [[ -n "$KEYMAP" ]]; then
470 sed "s|^loadkeys -m.*>|loadkeys -m $KEYMAP >|" -i chapter07/$this_script
471 else
472 sed '/loadkeys -m/d' -i chapter07/$this_script
473 sed '/drivers\/char/d' -i chapter07/$this_script
474 fi
475 ;;
476 *usage) # The script bombs, disable error trapping
477 sed 's|set -e|set +e|' -i chapter07/$this_script
478 ;;
479 *profile) # Add the config values to the script
480 sed "s|LC_ALL=\*\*EDITME.*EDITME\*\*|LC_ALL=$LC_ALL|" -i chapter07/$this_script
481 sed "s|LANG=\*\*EDITME.*EDITME\*\*|LANG=$LANG|" -i chapter07/$this_script
482 ;;
483 esac
484
485 # First append then name of the script file to a list (this will become
486 # the names of the targets in the Makefile
487 chapter7="$chapter7 $this_script"
488
489 #--------------------------------------------------------------------#
490 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
491 #--------------------------------------------------------------------#
492 #
493 # Drop in the name of the target on a new line, and the previous target
494 # as a dependency. Also call the echo_message function.
495 wrt_target "$this_script" "$PREV"
496
497 if [[ `_IS_ $this_script bootscripts` ]] ; then
498 vrs=`grep "^lfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
499 FILE="lfs-bootscripts-$vrs.tar.*"
500 # The bootscript pkg references both lfs AND blfs bootscripts...
501 # see XML script for other additions to bootscripts file
502 # PATCH
503 vrs=`grep "^blfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
504 sed "s|make install$|make install; cd ../blfs-bootscripts-$vrs|" -i chapter07/$this_script
505 wrt_unpack2 "$FILE"
506(
507cat << EOF
508 echo "\$(MOUNT_PT)\$(SRC)/blfs-bootscripts-$vrs" > sources-dir
509EOF
510) >> $MKFILE.tmp
511 fi
512
513 if [[ `_IS_ $this_script kernel` ]] ; then
514 # not much really, script does everything..
515 echo -e "\t@cp -f $CONFIG \$(MOUNT_PT)/sources/kernel-config" >> $MKFILE.tmp
516 fi
517
[5365c39]518 case "${this_script}" in
519 *profile* ) wrt_export_lang2 ;; # For /etc/profile we need to set LANG envar.
520 esac
521
[0170229]522 # Check if we have a real /etc/fstab file
523 if [[ `_IS_ $this_script fstab` ]] && [[ -n "$FSTAB" ]] ; then
524 wrt_copy_fstab "$this_script"
525 else
526 # Initialize the log and run the script
527 wrt_run_as_chroot2 "${this_script}" "${file}"
528 fi
529
530 # Remove the build directory except if the package build fails.
531 if [[ `_IS_ $this_script bootscripts` ]]; then
532(
533cat << EOF
534 @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
535 rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT
536 @rm -r \`cat sources-dir\` && \\
537 rm sources-dir
538EOF
539) >> $MKFILE.tmp
540 fi
541
542 # Include a touch of the target name so make can check if it's already been made.
543 echo -e '\t@touch $@' >> $MKFILE.tmp
544 #
545 #--------------------------------------------------------------------#
546 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
547 #--------------------------------------------------------------------#
548
549 # Keep the script file name for Makefile dependencies.
550 PREV=$this_script
551 done # for file in chapter07/*
552}
553
554
555#----------------------------#
556build_Makefile() { # Construct a Makefile from the book scripts
557#----------------------------#
558 echo -e "${GREEN}Creating Makefile... ${OFF}"
559
560 cd $JHALFSDIR/${PROGNAME}-commands
561 # Start with a clean Makefile.tmp file
562 >$MKFILE.tmp
563
564 chapter4_Makefiles
565 chapter5_Makefiles
566 chapter6_Makefiles
567 chapter7_Makefiles
568
569 # Add a header, some variables and include the function file
570 # to the top of the real Makefile.
571(
572 cat << EOF
573$HEADER
574
575SRC= /sources
576MOUNT_PT= $BUILDDIR
577PAGE= $PAGE
578TIMEZONE= $TIMEZONE
[5365c39]579LC_ALL= $LC_ALL
580LANG= $LANG
[0170229]581
582include makefile-functions
583
584EOF
585) > $MKFILE
586
587
588 # Add chroot commands
589 i=1
590 for file in chapter06/*chroot* ; do
591 chroot=`cat $file | sed -e '/#!\/bin\/sh/d' \
592 -e '/^export/d' \
593 -e '/^logout/d' \
594 -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
595 -e 's|\\$|&&|g' \
596 -e 's|exit||g' \
597 -e 's|$| -c|' \
598 -e 's|"$$HLFS"|$(MOUNT_PT)|'\
599 -e 's|set -e||'`
600 echo -e "CHROOT$i= $chroot\n" >> $MKFILE
601 i=`expr $i + 1`
602 done
603
604 # Drop in the main target 'all:' and the chapter targets with each sub-target
605 # as a dependency.
606(
607 cat << EOF
608all: chapter4 chapter5 chapter6 chapter7
609 @\$(call echo_finished,$VERSION)
610
611chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
612
613chapter5: chapter4 $chapter5 restore-hlfs-env
614
615chapter6: chapter5 $chapter6
616
617chapter7: chapter6 $chapter7
618
619clean-all: clean
620 rm -rf ./{hlfs-commands,logs,Makefile,dump-hlfs-scripts.xsl,functions,packages,patches}
621
622clean: clean-chapter7 clean-chapter6 clean-chapter5 clean-chapter4
623
624clean-chapter4:
625 -if [ ! -f user-hlfs-exist ]; then \\
626 userdel hlfs; \\
627 rm -rf /home/hlfs; \\
628 fi;
629 rm -rf \$(MOUNT_PT)/tools
630 rm -f /tools
631 rm -f envars user-hlfs-exist
632 rm -f 02* logs/02*.log
633
634clean-chapter5:
635 rm -rf \$(MOUNT_PT)/tools/*
636 rm -f $chapter5 restore-hlfs-env sources-dir
637 cd logs && rm -f $chapter5 && cd ..
638
639clean-chapter6:
640 -umount \$(MOUNT_PT)/sys
641 -umount \$(MOUNT_PT)/proc
642 -umount \$(MOUNT_PT)/dev/shm
643 -umount \$(MOUNT_PT)/dev/pts
644 -umount \$(MOUNT_PT)/dev
645 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
646 rm -f $chapter6
647 cd logs && rm -f $chapter6 && cd ..
648
649clean-chapter7:
650 rm -f $chapter7
651 cd logs && rm -f $chapter7 && cd ..
652
653restore-hlfs-env:
654 @\$(call echo_message, Building)
655 @if [ -f /home/lfs/.bashrc.XXX ]; then \\
656 mv -fv /home/lfs/.bashrc.XXX /home/hlfs/.bashrc; \\
657 fi;
658 @if [ -f /home/hlfs/.bash_profile.XXX ]; then \\
659 mv -v /home/lfs/.bash_profile.XXX /home/hlfs/.bash_profile; \\
660 fi;
661 @chown lfs:lfs /home/lfs/.bash* && \\
662 touch \$@
663
664EOF
665) >> $MKFILE
666
667 # Bring over the items from the Makefile.tmp
668 cat $MKFILE.tmp >> $MKFILE
669 rm $MKFILE.tmp
670 echo -ne "${GREEN}done\n${OFF}"
671}
672
673
Note: See TracBrowser for help on using the repository browser.