source: HLFS/master.sh@ a181405

experimental
Last change on this file since a181405 was 9272545, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Some comments fixes.
Trailing spaces cleam-up.
Removed obsolete code.

  • Property mode set to 100755
File size: 21.6 KB
RevLine 
[0170229]1#!/bin/sh
2set -e # Enable error trapping
3
[57ca090]4# $Id$
[0170229]5
6###################################
7### FUNCTIONS ###
8###################################
9
[65a2be6]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
[9272545]16
[65a2be6]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
[21dab83]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
[65a2be6]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
[21dab83]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 ;;
[a82bbc0]81
[21dab83]82 *)
[65a2be6]83(
84cat << EOF
85 @echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)" > envars
86EOF
87) >> $MKFILE.tmp
[21dab83]88 wrt_ExecuteAsUser "hlfs" "$toolchain" "$this_script"
89 ;;
90 esac
[a82bbc0]91 #
92 # Safe method to remove packages unpacked outside the toolchain
[65a2be6]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"
[21dab83]97 #
[65a2be6]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
[0170229]109
110#----------------------------#
[389fe2a]111chapter3_Makefiles() { # Initialization of the system
[0170229]112#----------------------------#
113
[e10232b]114 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter3${R_arrow}"
[0170229]115
[e840d27]116 # Define a few model dependant variables
117 if [[ ${MODEL} = "uclibc" ]]; then
118 TARGET="pc-linux-gnu"; LOADER="ld-uClibc.so.0"
119 else
120 TARGET="pc-linux-gnu"; LOADER="ld-linux.so.2"
121 fi
[0170229]122
[65a2be6]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
[0170229]125 # of their bash init files is made.
126(
127cat << EOF
128020-creatingtoolsdir:
129 @\$(call echo_message, Building)
[9199a13]130 @mkdir \$(MOUNT_PT)/tools && \\
131 rm -f /tools && \\
132 ln -s \$(MOUNT_PT)/tools /
[0170229]133 @if [ ! -d \$(MOUNT_PT)/sources ]; then \\
134 mkdir \$(MOUNT_PT)/sources; \\
135 fi;
136 @chmod a+wt \$(MOUNT_PT)/sources && \\
[9199a13]137 touch \$@ && \\
138 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
139 echo --------------------------------------------------------------------------------\$(WHITE)
[0170229]140
141021-addinguser: 020-creatingtoolsdir
142 @\$(call echo_message, Building)
[65a2be6]143 @if [ ! -d /home/hlfs ]; then \\
144 groupadd hlfs; \\
145 useradd -s /bin/bash -g hlfs -m -k /dev/null hlfs; \\
[0170229]146 else \\
[65a2be6]147 touch user-hlfs-exist; \\
[0170229]148 fi;
[65a2be6]149 @chown hlfs \$(MOUNT_PT)/tools && \\
150 chown hlfs \$(MOUNT_PT)/sources && \\
[9199a13]151 touch \$@ && \\
152 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
153 echo --------------------------------------------------------------------------------\$(WHITE)
[0170229]154
155022-settingenvironment: 021-addinguser
156 @\$(call echo_message, Building)
[65a2be6]157 @if [ -f /home/hlfs/.bashrc -a ! -f /home/hlfs/.bashrc.XXX ]; then \\
158 mv /home/hlfs/.bashrc /home/hlfs/.bashrc.XXX; \\
[0170229]159 fi;
[65a2be6]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; \\
[0170229]162 fi;
[65a2be6]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 && \\
[e840d27]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 && \\
[65a2be6]173 echo "source $JHALFSDIR/envars" >> /home/hlfs/.bashrc && \\
174 chown hlfs:hlfs /home/hlfs/.bashrc && \\
[0170229]175 touch envars && \\
[9199a13]176 touch \$@ && \\
177 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
178 echo --------------------------------------------------------------------------------\$(WHITE)
[0170229]179EOF
180) >> $MKFILE.tmp
181
182}
183
184#----------------------------#
185chapter5_Makefiles() { # Bootstrap or temptools phase
186#----------------------------#
187 local file
188 local this_script
[57ca090]189
[e10232b]190 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5${R_arrow}"
[0170229]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
[821a2c6]199 *tcl* ) [[ "$TEST" = "0" ]] && continue; ;;
200 *expect* ) [[ "$TEST" = "0" ]] && continue; ;;
201 *dejagnu* ) [[ "$TEST" = "0" ]] && continue; ;;
[7d018d1]202 # Nothing interestin in this script
203 *introduction* ) continue ;;
[0170229]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
[9272545]213 # Grab the name of the target
214 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
[0170229]215
[5c5a010]216 # Adjust 'name'
[0170229]217 case $name in
[3b63c8c]218 uclibc) name="uClibc" ;;
[0170229]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.
[9272545]230
[65a2be6]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 #
[0170229]242 wrt_target "$this_script" "$PREV"
243 # Find the version of the command files, if it corresponds with the building of
244 # a specific package
[3b63c8c]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
[29f9ec8]248 # Insert instructions for unpacking the package and to set the PKGDIR variable.
[65a2be6]249 wrt_Unpack_SetOwner "hlfs" "$pkg_tarball"
[e35e794]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
[c205656]253 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[29f9ec8]254 fi
[0170229]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.
[65a2be6]257 wrt_ExecuteAsUser "hlfs" "$this_script" "${file}"
[0170229]258
259 # Remove the build directory(ies) except if the package build fails
260 # (so we can review config.cache, config.log, etc.)
[3b63c8c]261 if [ "$pkg_tarball" != "" ] ; then
[65a2be6]262 wrt_remove_build_dirs "$name"
[0170229]263 fi
264
265 # Include a touch of the target name so make can check if it's already been made.
[9199a13]266 wrt_touch
[0170229]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
[c483858]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
[0170229]306
[c483858]307 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N${R_arrow}"
[0170229]308
[c483858]309 for file in chapter06$N/* ; do
[0170229]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
[3b63c8c]325 case $name in
326 uclibc) name="uClibc" ;;
327 esac
328
[c483858]329 # Find the version of the command files, if it corresponds with the building of
330 # a specific package
[3b63c8c]331 pkg_tarball=$(get_package_tarball_name $name)
[c483858]332
[3b63c8c]333 if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
[c483858]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
[7635367]345 # the names of the logs to be moved for each iteration)
346 LOGS="$LOGS ${this_script}"
[c483858]347
[0170229]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
[65a2be6]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
[c483858]363 wrt_target "${this_script}${N}" "$PREV"
[0170229]364
[3b63c8c]365 # If $pkg_tarball isn't empty, we've got a package...
[0170229]366 # Insert instructions for unpacking the package and changing directories
[3b63c8c]367 if [ "$pkg_tarball" != "" ] ; then
368 wrt_unpack2 "$pkg_tarball"
[e35e794]369 # If the testsuites must be run, initialize the log file
370 case $name in
[65a2be6]371 glibc )
[e35e794]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
[c205656]379 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[0170229]380 fi
381
[9272545]382 # In the mount of kernel filesystems we need to set HLFS and not to use chroot.
[5f4d08f]383 case "${this_script}" in
384 *kernfs*)
[21dab83]385 wrt_RunAsRoot "hlfs" "${this_script}" "${file}"
[5f4d08f]386 ;;
387 *) # The rest of Chapter06
388 wrt_run_as_chroot1 "${this_script}" "${file}"
389 ;;
390 esac
[0170229]391 #
392 # Remove the build directory(ies) except if the package build fails.
[3b63c8c]393 if [ "$pkg_tarball" != "" ] ; then
[0170229]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.
[9199a13]398 wrt_touch
[0170229]399 #
400 #--------------------------------------------------------------------#
401 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
402 #--------------------------------------------------------------------#
403
404 # Keep the script file name for Makefile dependencies.
[c483858]405 PREV=${this_script}${N}
406 # Set system_build envar for iteration targets
407 system_build=$chapter6
[0170229]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
[57ca090]417
[e10232b]418 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7${R_arrow}"
[0170229]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
[0ac273e]428 *usage) continue ;; # Contains example commands
[0170229]429 *grub) continue ;;
430 *console) continue ;; # Use the file generated by lfs-bootscripts
431
[57ca090]432 *kernel)
[821a2c6]433 # If no .config file is supplied, the kernel build is skipped
434 [[ -z $CONFIG ]] && continue
[1d756b0]435 cp $CONFIG $BUILDDIR/sources/kernel-config
[0170229]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
[5f4d08f]451 case "${this_script}" in
[db187c74]452 *bootscripts*)
[3b63c8c]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
[5f4d08f]456 ;;
457 esac
[0170229]458
[db187c74]459 case "${this_script}" in
[5f4d08f]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
[0170229]471
472 # Remove the build directory except if the package build fails.
[5f4d08f]473 case "${this_script}" in
474 *bootscripts*)
[0170229]475(
476cat << EOF
[460ea63]477 @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
[0170229]478 rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT
479 @rm -r \`cat sources-dir\` && \\
480 rm sources-dir
481EOF
482) >> $MKFILE.tmp
[5f4d08f]483 ;;
484 esac
[0170229]485
486 # Include a touch of the target name so make can check if it's already been made.
[9199a13]487 wrt_touch
[0170229]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/*
[9e4b9a1]496
497 # Add SBU-disk_usage report target if required
498 if [[ "$REPORT" = "1" ]] ; then wrt_report ; fi
[0170229]499}
500
501
502#----------------------------#
503build_Makefile() { # Construct a Makefile from the book scripts
504#----------------------------#
[a702b4d]505 echo "Creating Makefile... ${BOLD}START${OFF}"
[0170229]506
507 cd $JHALFSDIR/${PROGNAME}-commands
508 # Start with a clean Makefile.tmp file
509 >$MKFILE.tmp
510
[389fe2a]511 chapter3_Makefiles
[0170229]512 chapter5_Makefiles
513 chapter6_Makefiles
[c483858]514 # Add the iterations targets, if needed
515 [[ "$COMPARE" != "0" ]] && wrt_compare_targets
[0170229]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
[460ea63]526PKG_LST= $PKG_LST
[0170229]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
[3a27393]554all: chapter3 chapter5 chapter6 chapter7 do-housekeeping
[0170229]555 @\$(call echo_finished,$VERSION)
556
[0ac273e]557chapter3: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
[0170229]558
[65a2be6]559chapter5: chapter3 $chapter5 restore-hlfs-env
[0170229]560
561chapter6: chapter5 $chapter6
562
563chapter7: chapter6 $chapter7
564
565clean-all: clean
[bc097cd]566 rm -rf ./{hlfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
[0170229]567
[0ac273e]568clean: clean-chapter7 clean-chapter6 clean-chapter5 clean-chapter3
[0170229]569
[3b63c8c]570restart: restart_code all
571
[0ac273e]572clean-chapter3:
[65a2be6]573 -if [ ! -f user-hlfs-exist ]; then \\
574 userdel hlfs; \\
575 rm -rf /home/hlfs; \\
[0170229]576 fi;
577 rm -rf \$(MOUNT_PT)/tools
578 rm -f /tools
[65a2be6]579 rm -f envars user-hlfs-exist
[0170229]580 rm -f 02* logs/02*.log
581
582clean-chapter5:
583 rm -rf \$(MOUNT_PT)/tools/*
[65a2be6]584 rm -f $chapter5 restore-hlfs-env sources-dir
[0170229]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
[65a2be6]601restore-hlfs-env:
[0170229]602 @\$(call echo_message, Building)
[65a2be6]603 @if [ -f /home/hlfs/.bashrc.XXX ]; then \\
604 mv -f /home/hlfs/.bashrc.XXX /home/hlfs/.bashrc; \\
[0170229]605 fi;
[65a2be6]606 @if [ -f /home/hlfs/.bash_profile.XXX ]; then \\
607 mv /home/hlfs/.bash_profile.XXX /home/hlfs/.bash_profile; \\
[0170229]608 fi;
[65a2be6]609 @chown hlfs:hlfs /home/hlfs/.bash* && \\
[9199a13]610 touch \$@ && \\
611 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
612 echo --------------------------------------------------------------------------------\$(WHITE)
[0170229]613
[3a27393]614do-housekeeping:
[9199a13]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
[65a2be6]620 @-if [ ! -f user-hlfs-exist ]; then \\
621 userdel hlfs; \\
622 rm -rf /home/hlfs; \\
[3a27393]623 fi;
[460ea63]624
[3b63c8c]625restart_code:
[9272545]626 @echo ">>> This feature is experimental, BUGS may exist"
627
[3b63c8c]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;
[9272545]631
[3b63c8c]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;
[9272545]635
[3b63c8c]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;\\
[9272545]638 fi;
[3b63c8c]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
[0170229]666EOF
667) >> $MKFILE
668
669 # Bring over the items from the Makefile.tmp
670 cat $MKFILE.tmp >> $MKFILE
671 rm $MKFILE.tmp
[a702b4d]672 echo "Creating Makefile... ${BOLD}DONE${OFF}"
673
[0170229]674}
Note: See TracBrowser for help on using the repository browser.