source: HLFS/master.sh@ d540567

experimental
Last change on this file since d540567 was 7d018d1, checked in by George Boudreau <georgeb@…>, 18 years ago

corrections to hlfs group, build makefile

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