source: HLFS/master.sh@ 4845f38

experimental
Last change on this file since 4845f38 was 0170229, checked in by Manuel Canales Esparcia <manuel@…>, 19 years ago

Added base files from George's jhalfs-experimental-2 POC.
WARNING: This code is broken due files renaming.

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