source: HLFS/master.sh@ 9b09518

2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 9b09518 was d81c640, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Ported the new HLFS code from experimental branch.

  • Property mode set to 100755
File size: 21.6 KB
RevLine 
[877cc6a]1#!/bin/sh
2set -e # Enable error trapping
3
4# $Id$
5
6###################################
7### FUNCTIONS ###
8###################################
9
[d81c640]10#----------------------------------#
11wrt_ExecuteAsUser() { # Execute the file ($3) under the users account ($1), log in $2
12#----------------------------------#
13 local this_user=$1
14 local this_script=$2
15 local file=$3
16
17(
18cat << EOF
19 @( time { su - ${this_user} -c "source /home/${this_user}/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
20 echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
21EOF
22) >> $MKFILE.tmp
23}
24
25
26#----------------------------------#
27wrt_Unpack_SetOwner() { # Unpack and set owner. Assign 'ROOT' var
28#----------------------------------#
29 local USER_ACCT=$1
30 local FILE=$2
31 local optSAVE_PREVIOUS=$3
32
33 if [ "${optSAVE_PREVIOUS}" != "1" ]; then
34 wrt_remove_existing_dirs "$FILE"
35 fi
36(
37cat << EOF
38 @\$(call unpack,$FILE)
39 @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
40 echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
41 chown -R ${USER_ACCT} \$(MOUNT_PT)\$(SRC)/\$\$ROOT
42EOF
43) >> $MKFILE.tmp
44}
45
46#----------------------------------#
47wrt_RunAsRoot() { # Some scripts must be run as root..
48#----------------------------------#
49 local user_ACCT=$(echo $1 | tr [a-z] [A-Z])
50 local this_script=$2
51 local file=$3
52
53(
54cat << EOF
55 @( time { export ${user_ACCT}=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
56 echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
57EOF
58) >> $MKFILE.tmp
59}
60
61
62#----------------------------#
63process_toolchain() { # embryo,cocoon and butterfly need special handling
64#----------------------------#
65 local toolchain=$1
66 local this_script=$2
67 local tc_phase
68
69 echo "${tab_}${tab_}${GREEN}toolchain ${L_arrow}${toolchain}${R_arrow}"
70
71 case ${toolchain} in
72 *butterfly*)
73 [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
74(
75cat << EOF
76 @echo "export PKGDIR=\$(SRC)" > envars
77EOF
78) >> $MKFILE.tmp
79 wrt_run_as_chroot1 "$toolchain" "$this_script"
80 ;;
81
82 *)
83(
84cat << EOF
85 @echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)" > envars
86EOF
87) >> $MKFILE.tmp
88 wrt_ExecuteAsUser "hlfs" "$toolchain" "$this_script"
89 ;;
90 esac
91 #
92 # Safe method to remove packages unpacked outside the toolchain
93 pkg_tarball=$(get_package_tarball_name "binutils")
94 wrt_remove_existing_dirs "$pkg_tarball"
95 pkg_tarball=$(get_package_tarball_name "gcc-core")
96 wrt_remove_existing_dirs "$pkg_tarball"
97 #
98 # Manually remove the toolchain directories..
99 tc_phase=`echo $toolchain | sed -e 's@[0-9]\{3\}-@@' -e 's@-toolchain@@'`
100(
101cat << EOF
102 @rm -r \$(MOUNT_PT)\$(SRC)/${tc_phase}-toolchain && \\
103 rm -r \$(MOUNT_PT)\$(SRC)/${tc_phase}-build
104EOF
105) >> $MKFILE.tmp
106
107}
108
[877cc6a]109
110#----------------------------#
111chapter3_Makefiles() { # Initialization of the system
112#----------------------------#
113
114 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter3${R_arrow}"
115
116 # Define a few model dependant variables
117 if [[ ${MODEL} = "uclibc" ]]; then
[d81c640]118 TARGET="pc-linux-gnu"; LOADER="ld-uClibc.so.0"
[877cc6a]119 else
[d81c640]120 TARGET="pc-linux-gnu"; LOADER="ld-linux.so.2"
[877cc6a]121 fi
122
[d81c640]123 # If /home/hlfs is already present in the host, we asume that the
124 # hlfs user and group are also presents in the host, and a backup
[877cc6a]125 # of their bash init files is made.
126(
127cat << EOF
128020-creatingtoolsdir:
129 @\$(call echo_message, Building)
[e314f7e]130 @mkdir \$(MOUNT_PT)/tools && \\
131 rm -f /tools && \\
132 ln -s \$(MOUNT_PT)/tools /
[877cc6a]133 @if [ ! -d \$(MOUNT_PT)/sources ]; then \\
134 mkdir \$(MOUNT_PT)/sources; \\
135 fi;
136 @chmod a+wt \$(MOUNT_PT)/sources && \\
[93f38e7]137 touch \$@ && \\
138 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
139 echo --------------------------------------------------------------------------------\$(WHITE)
[877cc6a]140
141021-addinguser: 020-creatingtoolsdir
142 @\$(call echo_message, Building)
[d81c640]143 @if [ ! -d /home/hlfs ]; then \\
144 groupadd hlfs; \\
145 useradd -s /bin/bash -g hlfs -m -k /dev/null hlfs; \\
[877cc6a]146 else \\
[d81c640]147 touch user-hlfs-exist; \\
[877cc6a]148 fi;
[d81c640]149 @chown hlfs \$(MOUNT_PT)/tools && \\
150 chown hlfs \$(MOUNT_PT)/sources && \\
[93f38e7]151 touch \$@ && \\
152 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
153 echo --------------------------------------------------------------------------------\$(WHITE)
[877cc6a]154
155022-settingenvironment: 021-addinguser
156 @\$(call echo_message, Building)
[d81c640]157 @if [ -f /home/hlfs/.bashrc -a ! -f /home/hlfs/.bashrc.XXX ]; then \\
158 mv /home/hlfs/.bashrc /home/hlfs/.bashrc.XXX; \\
[877cc6a]159 fi;
[d81c640]160 @if [ -f /home/hlfs/.bash_profile -a ! -f /home/hlfs/.bash_profile.XXX ]; then \\
161 mv /home/hlfs/.bash_profile /home/hlfs/.bash_profile.XXX; \\
[877cc6a]162 fi;
[d81c640]163 @echo "set +h" > /home/hlfs/.bashrc && \\
164 echo "umask 022" >> /home/hlfs/.bashrc && \\
165 echo "HLFS=\$(MOUNT_PT)" >> /home/hlfs/.bashrc && \\
166 echo "LC_ALL=POSIX" >> /home/hlfs/.bashrc && \\
167 echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/hlfs/.bashrc && \\
168 echo "export HLFS LC_ALL PATH" >> /home/hlfs/.bashrc && \\
169 echo "" >> /home/hlfs/.bashrc && \\
[877cc6a]170 echo "target=$(uname -m)-${TARGET}" >> /home/lfs/.bashrc && \\
171 echo "ldso=/tools/lib/${LOADER}" >> /home/lfs/.bashrc && \\
172 echo "export target ldso" >> /home/lfs/.bashrc && \\
[d81c640]173 echo "source $JHALFSDIR/envars" >> /home/hlfs/.bashrc && \\
174 chown hlfs:hlfs /home/hlfs/.bashrc && \\
[877cc6a]175 touch envars && \\
[93f38e7]176 touch \$@ && \\
177 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
178 echo --------------------------------------------------------------------------------\$(WHITE)
[877cc6a]179EOF
180) >> $MKFILE.tmp
181
182}
183
184#----------------------------#
185chapter5_Makefiles() { # Bootstrap or temptools phase
186#----------------------------#
187 local file
188 local this_script
189
190 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5${R_arrow}"
191
192 for file in chapter05/* ; do
193 # Keep the script file name
194 this_script=`basename $file`
195
196 # Skip this script depending on jhalfs.conf flags set.
197 case $this_script in
198 # If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
199 *tcl* ) [[ "$TEST" = "0" ]] && continue; ;;
200 *expect* ) [[ "$TEST" = "0" ]] && continue; ;;
201 *dejagnu* ) [[ "$TEST" = "0" ]] && continue; ;;
202 # Nothing interestin in this script
203 *introduction* ) continue ;;
204 # Test if the stripping phase must be skipped
205 *stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
206 *) ;;
207 esac
208
209 # First append each name of the script files to a list (this will become
210 # the names of the targets in the Makefile
211 chapter5="$chapter5 $this_script"
212
[d81c640]213 # Grab the name of the target
214 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
[877cc6a]215
216 # Adjust 'name'
217 case $name in
[a160d86]218 uclibc) name="uClibc" ;;
[877cc6a]219 esac
220
221 # Set the dependency for the first target.
222 if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
223
224 #--------------------------------------------------------------------#
225 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
226 #--------------------------------------------------------------------#
227 #
228 # Drop in the name of the target on a new line, and the previous target
229 # as a dependency. Also call the echo_message function.
230
[d81c640]231 # This is a very special script and requires manual processing
232 # NO Optimization allowed
233 if [[ ${name} = "embryo-toolchain" ]] || \
234 [[ ${name} = "cocoon-toolchain" ]]; then
235 wrt_target "$this_script" "$PREV"
236 process_toolchain "${this_script}" "${file}"
237 wrt_touch
238 PREV=$this_script
239 continue
240 fi
241 #
242 wrt_target "$this_script" "$PREV"
[877cc6a]243 # Find the version of the command files, if it corresponds with the building of
244 # a specific package
[a160d86]245 pkg_tarball=$(get_package_tarball_name $name)
246 # If $pkg_tarball isn't empty, we've got a package...
247 if [ "$pkg_tarball" != "" ] ; then
[1b65a84]248 # Insert instructions for unpacking the package and to set the PKGDIR variable.
[d81c640]249 wrt_Unpack_SetOwner "hlfs" "$pkg_tarball"
[a229600]250 # If the testsuites must be run, initialize the log file
251 [[ "$TEST" = "3" ]] && wrt_test_log "${this_script}"
252 # If using optimizations, write the instructions
[1b65a84]253 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
254 fi
[877cc6a]255 # Insert date and disk usage at the top of the log file, the script run
256 # and date and disk usage again at the bottom of the log file.
[d81c640]257 wrt_ExecuteAsUser "hlfs" "$this_script" "${file}"
[877cc6a]258
259 # Remove the build directory(ies) except if the package build fails
260 # (so we can review config.cache, config.log, etc.)
[a160d86]261 if [ "$pkg_tarball" != "" ] ; then
[d81c640]262 wrt_remove_build_dirs "$name"
[877cc6a]263 fi
264
265 # Include a touch of the target name so make can check if it's already been made.
[93f38e7]266 wrt_touch
[877cc6a]267 #
268 #--------------------------------------------------------------------#
269 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
270 #--------------------------------------------------------------------#
271
272 # Keep the script file name for Makefile dependencies.
273 PREV=$this_script
274 done # end for file in chapter05/*
275}
276
277
278#----------------------------#
279chapter6_Makefiles() { # sysroot or chroot build phase
280#----------------------------#
281 local file
282 local this_script
[45f82718]283 # Set envars and scripts for iteration targets
284 LOGS="" # Start with an empty global LOGS envar
285 if [[ -z "$1" ]] ; then
286 local N=""
287 else
288 local N=-build_$1
289 local chapter6=""
290 mkdir chapter06$N
291 cp chapter06/* chapter06$N
292 for script in chapter06$N/* ; do
293 # Overwrite existing symlinks, files, and dirs
294 sed -e 's/ln -s /ln -sf /g' \
295 -e 's/^mv /&-f/g' -i ${script}
296 done
297 # Remove Bzip2 binaries before make install
298 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2
299 # Fix how Module-Init-Tools do the install target
300 sed -e 's@make install@make INSTALL=install install@' -i chapter06$N/*-module-init-tools
301 # Delete *old Readline libraries just after make install
302 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i chapter06$N/*-readline
303 # Don't readd already existing groups
304 sed -e '/groupadd/d' -i chapter06$N/*-udev
305 fi
[877cc6a]306
[45f82718]307 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N${R_arrow}"
[877cc6a]308
[45f82718]309 for file in chapter06$N/* ; do
[877cc6a]310 # Keep the script file name
311 this_script=`basename $file`
312
313 # Skip this script depending on jhalfs.conf flags set.
314 case $this_script in
315 # We'll run the chroot commands differently than the others, so skip them in the
316 # dependencies and target creation.
317 *chroot* ) continue ;;
318 # Test if the stripping phase must be skipped
319 *-stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
320 esac
321
322 # Grab the name of the target
323 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
324
[a160d86]325 case $name in
326 uclibc) name="uClibc" ;;
327 esac
328
[45f82718]329 # Find the version of the command files, if it corresponds with the building of
330 # a specific package
[a160d86]331 pkg_tarball=$(get_package_tarball_name $name)
[45f82718]332
[a160d86]333 if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
[45f82718]334 case "${this_script}" in
335 *stripping*) ;;
336 *) continue ;;
337 esac
338 fi
339
340 # Append each name of the script files to a list (this will become
341 # the names of the targets in the Makefile
342 chapter6="$chapter6 ${this_script}${N}"
343
344 # Append each name of the script files to a list (this will become
345 # the names of the logs to be moved for each iteration)
346 LOGS="$LOGS ${this_script}"
347
[877cc6a]348
349 #--------------------------------------------------------------------#
350 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
351 #--------------------------------------------------------------------#
352 #
353 # Drop in the name of the target on a new line, and the previous target
[d81c640]354 # as a dependency. Also call the echo_message function.
355 if [[ ${name} = "butterfly-toolchain" ]]; then
356 wrt_target "$this_script" "$PREV"
357 process_toolchain "${this_script}" "${file}"
358 wrt_touch
359 PREV=$this_script
360 continue
361 fi
362
[45f82718]363 wrt_target "${this_script}${N}" "$PREV"
[877cc6a]364
[a160d86]365 # If $pkg_tarball isn't empty, we've got a package...
[877cc6a]366 # Insert instructions for unpacking the package and changing directories
[a160d86]367 if [ "$pkg_tarball" != "" ] ; then
368 wrt_unpack2 "$pkg_tarball"
[a229600]369 # If the testsuites must be run, initialize the log file
370 case $name in
[d81c640]371 glibc )
[a229600]372 [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
373 ;;
374 * )
375 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && wrt_test_log2 "${this_script}"
376 ;;
377 esac
378 # If using optimizations, write the instructions
[1b65a84]379 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[877cc6a]380 fi
381
[d81c640]382 # In the mount of kernel filesystems we need to set HLFS and not to use chroot.
[877cc6a]383 case "${this_script}" in
384 *kernfs*)
[d81c640]385 wrt_RunAsRoot "hlfs" "${this_script}" "${file}"
[877cc6a]386 ;;
387 *) # The rest of Chapter06
388 wrt_run_as_chroot1 "${this_script}" "${file}"
389 ;;
390 esac
391 #
392 # Remove the build directory(ies) except if the package build fails.
[a160d86]393 if [ "$pkg_tarball" != "" ] ; then
[877cc6a]394 wrt_remove_build_dirs "$name"
395 fi
396 #
397 # Include a touch of the target name so make can check if it's already been made.
[93f38e7]398 wrt_touch
[877cc6a]399 #
400 #--------------------------------------------------------------------#
401 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
402 #--------------------------------------------------------------------#
403
404 # Keep the script file name for Makefile dependencies.
[45f82718]405 PREV=${this_script}${N}
406 # Set system_build envar for iteration targets
407 system_build=$chapter6
[877cc6a]408 done # end for file in chapter06/*
409
410}
411
412#----------------------------#
413chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..etc
414#----------------------------#
415 local file
416 local this_script
417
418 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7${R_arrow}"
419 for file in chapter07/*; do
420 # Keep the script file name
421 this_script=`basename $file`
422
423 # Grub must be configured manually.
424 # The filesystems can't be unmounted via Makefile and the user
425 # should enter the chroot environment to create the root
426 # password, edit several files and setup Grub.
427 case $this_script in
428 *usage) continue ;; # Contains example commands
429 *grub) continue ;;
430 *console) continue ;; # Use the file generated by lfs-bootscripts
431
432 *kernel)
433 # If no .config file is supplied, the kernel build is skipped
434 [[ -z $CONFIG ]] && continue
435 cp $CONFIG $BUILDDIR/sources/kernel-config
436 ;;
437 esac
438
439 # First append then name of the script file to a list (this will become
440 # the names of the targets in the Makefile
441 chapter7="$chapter7 $this_script"
442
443 #--------------------------------------------------------------------#
444 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
445 #--------------------------------------------------------------------#
446 #
447 # Drop in the name of the target on a new line, and the previous target
448 # as a dependency. Also call the echo_message function.
449 wrt_target "$this_script" "$PREV"
450
451 case "${this_script}" in
452 *bootscripts*)
[a160d86]453 wrt_unpack2 $(get_package_tarball_name "lfs-bootscripts")
454 blfs_bootscripts=$(get_package_tarball_name "blfs-bootscripts" | sed -e 's/.tar.*//' )
455 echo -e "\t@echo \"\$(MOUNT_PT)\$(SRC)/$blfs_bootscripts\" >> sources-dir" >> $MKFILE.tmp
[877cc6a]456 ;;
457 esac
458
459 case "${this_script}" in
460 *fstab*) # Check if we have a real /etc/fstab file
461 if [[ -n "$FSTAB" ]] ; then
462 wrt_copy_fstab "$this_script"
463 else # Initialize the log and run the script
464 wrt_run_as_chroot2 "${this_script}" "${file}"
465 fi
466 ;;
467 *) # All other scripts
468 wrt_run_as_chroot2 "${this_script}" "${file}"
469 ;;
470 esac
471
472 # Remove the build directory except if the package build fails.
473 case "${this_script}" in
474 *bootscripts*)
475(
476cat << EOF
[82eb8c1]477 @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
[877cc6a]478 rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT
479 @rm -r \`cat sources-dir\` && \\
480 rm sources-dir
481EOF
482) >> $MKFILE.tmp
483 ;;
484 esac
485
486 # Include a touch of the target name so make can check if it's already been made.
[93f38e7]487 wrt_touch
[877cc6a]488 #
489 #--------------------------------------------------------------------#
490 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
491 #--------------------------------------------------------------------#
492
493 # Keep the script file name for Makefile dependencies.
494 PREV=$this_script
495 done # for file in chapter07/*
[453bef0]496
497 # Add SBU-disk_usage report target if required
498 if [[ "$REPORT" = "1" ]] ; then wrt_report ; fi
[877cc6a]499}
500
501
502#----------------------------#
503build_Makefile() { # Construct a Makefile from the book scripts
504#----------------------------#
[c7c5a53]505 echo "Creating Makefile... ${BOLD}START${OFF}"
[877cc6a]506
507 cd $JHALFSDIR/${PROGNAME}-commands
508 # Start with a clean Makefile.tmp file
509 >$MKFILE.tmp
510
511 chapter3_Makefiles
512 chapter5_Makefiles
513 chapter6_Makefiles
[45f82718]514 # Add the iterations targets, if needed
515 [[ "$COMPARE" != "0" ]] && wrt_compare_targets
[877cc6a]516 chapter7_Makefiles
517
518 # Add a header, some variables and include the function file
519 # to the top of the real Makefile.
520(
521 cat << EOF
522$HEADER
523
524SRC= /sources
525MOUNT_PT= $BUILDDIR
[82eb8c1]526PKG_LST= $PKG_LST
[877cc6a]527
528include makefile-functions
529
530EOF
531) > $MKFILE
532
533
534 # Add chroot commands
535 i=1
536 for file in chapter06/*chroot* ; do
537 chroot=`cat $file | sed -e '/#!\/bin\/sh/d' \
538 -e '/^export/d' \
539 -e '/^logout/d' \
540 -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
541 -e 's|\\$|&&|g' \
542 -e 's|exit||g' \
543 -e 's|$| -c|' \
544 -e 's|"$$HLFS"|$(MOUNT_PT)|'\
545 -e 's|set -e||'`
546 echo -e "CHROOT$i= $chroot\n" >> $MKFILE
547 i=`expr $i + 1`
548 done
549
550 # Drop in the main target 'all:' and the chapter targets with each sub-target
551 # as a dependency.
552(
553 cat << EOF
[c8f9cd8]554all: chapter3 chapter5 chapter6 chapter7 do-housekeeping
[877cc6a]555 @\$(call echo_finished,$VERSION)
556
557chapter3: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
558
[d81c640]559chapter5: chapter3 $chapter5 restore-hlfs-env
[877cc6a]560
561chapter6: chapter5 $chapter6
562
563chapter7: chapter6 $chapter7
564
565clean-all: clean
566 rm -rf ./{hlfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
567
568clean: clean-chapter7 clean-chapter6 clean-chapter5 clean-chapter3
569
[a160d86]570restart: restart_code all
571
[877cc6a]572clean-chapter3:
[d81c640]573 -if [ ! -f user-hlfs-exist ]; then \\
574 userdel hlfs; \\
575 rm -rf /home/hlfs; \\
[877cc6a]576 fi;
577 rm -rf \$(MOUNT_PT)/tools
578 rm -f /tools
[d81c640]579 rm -f envars user-hlfs-exist
[877cc6a]580 rm -f 02* logs/02*.log
581
582clean-chapter5:
583 rm -rf \$(MOUNT_PT)/tools/*
[d81c640]584 rm -f $chapter5 restore-hlfs-env sources-dir
[877cc6a]585 cd logs && rm -f $chapter5 && cd ..
586
587clean-chapter6:
588 -umount \$(MOUNT_PT)/sys
589 -umount \$(MOUNT_PT)/proc
590 -umount \$(MOUNT_PT)/dev/shm
591 -umount \$(MOUNT_PT)/dev/pts
592 -umount \$(MOUNT_PT)/dev
593 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
594 rm -f $chapter6
595 cd logs && rm -f $chapter6 && cd ..
596
597clean-chapter7:
598 rm -f $chapter7
599 cd logs && rm -f $chapter7 && cd ..
600
[d81c640]601restore-hlfs-env:
[877cc6a]602 @\$(call echo_message, Building)
[d81c640]603 @if [ -f /home/hlfs/.bashrc.XXX ]; then \\
604 mv -f /home/hlfs/.bashrc.XXX /home/hlfs/.bashrc; \\
[877cc6a]605 fi;
[d81c640]606 @if [ -f /home/hlfs/.bash_profile.XXX ]; then \\
607 mv /home/hlfs/.bash_profile.XXX /home/hlfs/.bash_profile; \\
[877cc6a]608 fi;
[d81c640]609 @chown hlfs:hlfs /home/hlfs/.bash* && \\
[93f38e7]610 touch \$@ && \\
611 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
612 echo --------------------------------------------------------------------------------\$(WHITE)
[877cc6a]613
[7d9a82d]614do-housekeeping:
[4524fb2]615 @-umount \$(MOUNT_PT)/dev/pts
616 @-umount \$(MOUNT_PT)/dev/shm
617 @-umount \$(MOUNT_PT)/dev
618 @-umount \$(MOUNT_PT)/sys
619 @-umount \$(MOUNT_PT)/proc
[d81c640]620 @-if [ ! -f user-hlfs-exist ]; then \\
621 userdel hlfs; \\
622 rm -rf /home/hlfs; \\
[7d9a82d]623 fi;
[a858a78]624
[a160d86]625restart_code:
[d81c640]626 @echo ">>> This feature is experimental, BUGS may exist"
627
[a160d86]628 @if [ ! -L /tools ]; then \\
629 echo -e "\\nERROR::\\n /tools is NOT a symlink.. /tools must point to \$(MOUNT_PT)/tools\\n" && false;\\
630 fi;
[d81c640]631
[a160d86]632 @if [ ! -e /tools ]; then \\
633 echo -e "\\nERROR::\\nThe target /tools points to does not exist.\\nVerify the target.. \$(MOUNT_PT)/tools\\n" && false;\\
634 fi;
[d81c640]635
[a160d86]636 @if ! stat -c %N /tools | grep "\$(MOUNT_PT)/tools" >/dev/null ; then \\
637 echo -e "\\nERROR::\\nThe symlink \\"/tools\\" does not point to \\"\$(MOUNT_PT)/tools\\".\\nCorrect the problem and rerun\\n" && false;\\
[d81c640]638 fi;
[a160d86]639
640 @if [ -f ???-kernfs ]; then \\
641 mkdir -pv \$(MOUNT_PT)/{proc,sys};\\
642 if ! mount -l | "\$(MOUNT_PT)/dev" >/dev/null ; then \\
643 mount -vt ramfs ramfs \$(MOUNT_PT)/dev;\\
644 fi;\\
645 if [ ! -e \$(MOUNT_PT)/dev/console ]; then \\
646 mknod -m 600 \$(MOUNT_PT)/dev/console c 5 1;\\
647 fi;\\
648 if [ ! -e \$(MOUNT_PT)/dev/null ]; then \\
649 mknod -m 666 \$(MOUNT_PT)/dev/null c 1 3;\\
650 fi;\\
651 if ! mount -l | grep "\$(MOUNT_PT)/dev/pts" >/dev/null ; then \\
652 mount -vt devpts -o gid=4,mode=620 devpts \$(MOUNT_PT)/dev/pts;\\
653 fi;\\
654 if ! mount -l | grep "\$(MOUNT_PT)/dev/shm" >/dev/null ; then \\
655 mount -vt tmpfs shm \$(MOUNT_PT)/dev/shm;\\
656 fi;\\
657 if ! mount -l | grep "\$(MOUNT_PT)/proc" >/dev/null ; then \\
658 mount -vt proc proc \$(MOUNT_PT)/proc;\\
659 fi;\\
660 if ! mount -l | grep "\$(MOUNT_PT)/sys" >/dev/null ; then \\
661 mount -vt sysfs sysfs \$(MOUNT_PT)/sys;\\
662 fi;\\
663 fi;
664
665
[877cc6a]666EOF
667) >> $MKFILE
668
669 # Bring over the items from the Makefile.tmp
670 cat $MKFILE.tmp >> $MKFILE
671 rm $MKFILE.tmp
[c7c5a53]672 echo "Creating Makefile... ${BOLD}DONE${OFF}"
673
[877cc6a]674}
Note: See TracBrowser for help on using the repository browser.