source: HLFS/master.sh@ 725ae5a

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

Touch up work to Config.in

  • Property mode set to 100755
File size: 21.5 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 using optimizations, write the instructions
[c205656]251 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[29f9ec8]252 fi
[0170229]253 # Insert date and disk usage at the top of the log file, the script run
254 # and date and disk usage again at the bottom of the log file.
[65a2be6]255 wrt_ExecuteAsUser "hlfs" "$this_script" "${file}"
[0170229]256
257 # Remove the build directory(ies) except if the package build fails
258 # (so we can review config.cache, config.log, etc.)
[3b63c8c]259 if [ "$pkg_tarball" != "" ] ; then
[65a2be6]260 wrt_remove_build_dirs "$name"
[0170229]261 fi
262
263 # Include a touch of the target name so make can check if it's already been made.
[9199a13]264 wrt_touch
[0170229]265 #
266 #--------------------------------------------------------------------#
267 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
268 #--------------------------------------------------------------------#
269
270 # Keep the script file name for Makefile dependencies.
271 PREV=$this_script
272 done # end for file in chapter05/*
273}
274
275
276#----------------------------#
277chapter6_Makefiles() { # sysroot or chroot build phase
278#----------------------------#
279 local file
280 local this_script
[c483858]281 # Set envars and scripts for iteration targets
282 LOGS="" # Start with an empty global LOGS envar
283 if [[ -z "$1" ]] ; then
284 local N=""
285 else
286 local N=-build_$1
287 local chapter6=""
288 mkdir chapter06$N
289 cp chapter06/* chapter06$N
290 for script in chapter06$N/* ; do
291 # Overwrite existing symlinks, files, and dirs
292 sed -e 's/ln -s /ln -sf /g' \
293 -e 's/^mv /&-f/g' -i ${script}
294 done
295 # Remove Bzip2 binaries before make install
296 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2
297 # Fix how Module-Init-Tools do the install target
298 sed -e 's@make install@make INSTALL=install install@' -i chapter06$N/*-module-init-tools
299 # Delete *old Readline libraries just after make install
300 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i chapter06$N/*-readline
301 # Don't readd already existing groups
302 sed -e '/groupadd/d' -i chapter06$N/*-udev
303 fi
[0170229]304
[c483858]305 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N${R_arrow}"
[0170229]306
[c483858]307 for file in chapter06$N/* ; do
[0170229]308 # Keep the script file name
309 this_script=`basename $file`
310
311 # Skip this script depending on jhalfs.conf flags set.
312 case $this_script in
313 # We'll run the chroot commands differently than the others, so skip them in the
314 # dependencies and target creation.
315 *chroot* ) continue ;;
316 # Test if the stripping phase must be skipped
317 *-stripping* ) [[ "$STRIP" = "0" ]] && continue ;;
318 esac
319
320 # Grab the name of the target
321 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
322
[3b63c8c]323 case $name in
324 uclibc) name="uClibc" ;;
325 esac
326
[c483858]327 # Find the version of the command files, if it corresponds with the building of
328 # a specific package
[3b63c8c]329 pkg_tarball=$(get_package_tarball_name $name)
[c483858]330
[3b63c8c]331 if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
[c483858]332 case "${this_script}" in
333 *stripping*) ;;
334 *) continue ;;
335 esac
336 fi
337
338 # Append each name of the script files to a list (this will become
339 # the names of the targets in the Makefile
340 chapter6="$chapter6 ${this_script}${N}"
341
342 # Append each name of the script files to a list (this will become
[7635367]343 # the names of the logs to be moved for each iteration)
344 LOGS="$LOGS ${this_script}"
[c483858]345
[0170229]346
347 #--------------------------------------------------------------------#
348 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
349 #--------------------------------------------------------------------#
350 #
351 # Drop in the name of the target on a new line, and the previous target
[65a2be6]352 # as a dependency. Also call the echo_message function.
353 if [[ ${name} = "butterfly-toolchain" ]]; then
[7cd9186]354 wrt_target "${this_script}${N}" "$PREV"
[65a2be6]355 process_toolchain "${this_script}" "${file}"
356 wrt_touch
357 PREV=$this_script
358 continue
359 fi
360
[c483858]361 wrt_target "${this_script}${N}" "$PREV"
[0170229]362
[3b63c8c]363 # If $pkg_tarball isn't empty, we've got a package...
[0170229]364 # Insert instructions for unpacking the package and changing directories
[3b63c8c]365 if [ "$pkg_tarball" != "" ] ; then
366 wrt_unpack2 "$pkg_tarball"
[e35e794]367 # If the testsuites must be run, initialize the log file
[7cd9186]368 # butterfly-toolchain tests are enabled in 'process_tookchain' function
[e35e794]369 case $name in
[7cd9186]370 glibc ) [[ "$TEST" != "0" ]] && wrt_test_log2 "${this_script}"
[e35e794]371 ;;
[725ae5a]372 * ) [[ "$TEST" = "2" ]] && [[ "$TEST" = "3" ]] && wrt_test_log2 "${this_script}"
[e35e794]373 ;;
374 esac
375 # If using optimizations, write the instructions
[c205656]376 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[0170229]377 fi
378
[9272545]379 # In the mount of kernel filesystems we need to set HLFS and not to use chroot.
[5f4d08f]380 case "${this_script}" in
381 *kernfs*)
[21dab83]382 wrt_RunAsRoot "hlfs" "${this_script}" "${file}"
[5f4d08f]383 ;;
384 *) # The rest of Chapter06
385 wrt_run_as_chroot1 "${this_script}" "${file}"
386 ;;
387 esac
[0170229]388 #
389 # Remove the build directory(ies) except if the package build fails.
[3b63c8c]390 if [ "$pkg_tarball" != "" ] ; then
[0170229]391 wrt_remove_build_dirs "$name"
392 fi
393 #
394 # Include a touch of the target name so make can check if it's already been made.
[9199a13]395 wrt_touch
[0170229]396 #
397 #--------------------------------------------------------------------#
398 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
399 #--------------------------------------------------------------------#
400
401 # Keep the script file name for Makefile dependencies.
[c483858]402 PREV=${this_script}${N}
403 # Set system_build envar for iteration targets
404 system_build=$chapter6
[0170229]405 done # end for file in chapter06/*
406
407}
408
409#----------------------------#
410chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..etc
411#----------------------------#
412 local file
413 local this_script
[57ca090]414
[e10232b]415 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7${R_arrow}"
[0170229]416 for file in chapter07/*; do
417 # Keep the script file name
418 this_script=`basename $file`
419
420 # Grub must be configured manually.
421 # The filesystems can't be unmounted via Makefile and the user
422 # should enter the chroot environment to create the root
423 # password, edit several files and setup Grub.
424 case $this_script in
[0ac273e]425 *usage) continue ;; # Contains example commands
[0170229]426 *grub) continue ;;
427 *console) continue ;; # Use the file generated by lfs-bootscripts
428
[57ca090]429 *kernel)
[821a2c6]430 # If no .config file is supplied, the kernel build is skipped
431 [[ -z $CONFIG ]] && continue
[1d756b0]432 cp $CONFIG $BUILDDIR/sources/kernel-config
[0170229]433 ;;
434 esac
435
436 # First append then name of the script file to a list (this will become
437 # the names of the targets in the Makefile
438 chapter7="$chapter7 $this_script"
439
440 #--------------------------------------------------------------------#
441 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
442 #--------------------------------------------------------------------#
443 #
444 # Drop in the name of the target on a new line, and the previous target
445 # as a dependency. Also call the echo_message function.
446 wrt_target "$this_script" "$PREV"
447
[5f4d08f]448 case "${this_script}" in
[db187c74]449 *bootscripts*)
[3b63c8c]450 wrt_unpack2 $(get_package_tarball_name "lfs-bootscripts")
451 blfs_bootscripts=$(get_package_tarball_name "blfs-bootscripts" | sed -e 's/.tar.*//' )
452 echo -e "\t@echo \"\$(MOUNT_PT)\$(SRC)/$blfs_bootscripts\" >> sources-dir" >> $MKFILE.tmp
[5f4d08f]453 ;;
454 esac
[0170229]455
[db187c74]456 case "${this_script}" in
[5f4d08f]457 *fstab*) # Check if we have a real /etc/fstab file
458 if [[ -n "$FSTAB" ]] ; then
459 wrt_copy_fstab "$this_script"
460 else # Initialize the log and run the script
461 wrt_run_as_chroot2 "${this_script}" "${file}"
462 fi
463 ;;
464 *) # All other scripts
465 wrt_run_as_chroot2 "${this_script}" "${file}"
466 ;;
467 esac
[0170229]468
469 # Remove the build directory except if the package build fails.
[5f4d08f]470 case "${this_script}" in
471 *bootscripts*)
[0170229]472(
473cat << EOF
[460ea63]474 @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
[0170229]475 rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT
476 @rm -r \`cat sources-dir\` && \\
477 rm sources-dir
478EOF
479) >> $MKFILE.tmp
[5f4d08f]480 ;;
481 esac
[0170229]482
483 # Include a touch of the target name so make can check if it's already been made.
[9199a13]484 wrt_touch
[0170229]485 #
486 #--------------------------------------------------------------------#
487 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
488 #--------------------------------------------------------------------#
489
490 # Keep the script file name for Makefile dependencies.
491 PREV=$this_script
492 done # for file in chapter07/*
[9e4b9a1]493
494 # Add SBU-disk_usage report target if required
495 if [[ "$REPORT" = "1" ]] ; then wrt_report ; fi
[0170229]496}
497
498
499#----------------------------#
500build_Makefile() { # Construct a Makefile from the book scripts
501#----------------------------#
[a702b4d]502 echo "Creating Makefile... ${BOLD}START${OFF}"
[0170229]503
504 cd $JHALFSDIR/${PROGNAME}-commands
505 # Start with a clean Makefile.tmp file
506 >$MKFILE.tmp
507
[389fe2a]508 chapter3_Makefiles
[0170229]509 chapter5_Makefiles
510 chapter6_Makefiles
[c483858]511 # Add the iterations targets, if needed
512 [[ "$COMPARE" != "0" ]] && wrt_compare_targets
[0170229]513 chapter7_Makefiles
514
515 # Add a header, some variables and include the function file
516 # to the top of the real Makefile.
517(
518 cat << EOF
519$HEADER
520
521SRC= /sources
522MOUNT_PT= $BUILDDIR
[460ea63]523PKG_LST= $PKG_LST
[0170229]524
525include makefile-functions
526
527EOF
528) > $MKFILE
529
530
531 # Add chroot commands
532 i=1
533 for file in chapter06/*chroot* ; do
534 chroot=`cat $file | sed -e '/#!\/bin\/sh/d' \
535 -e '/^export/d' \
536 -e '/^logout/d' \
537 -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
538 -e 's|\\$|&&|g' \
539 -e 's|exit||g' \
540 -e 's|$| -c|' \
541 -e 's|"$$HLFS"|$(MOUNT_PT)|'\
542 -e 's|set -e||'`
543 echo -e "CHROOT$i= $chroot\n" >> $MKFILE
544 i=`expr $i + 1`
545 done
546
547 # Drop in the main target 'all:' and the chapter targets with each sub-target
548 # as a dependency.
549(
550 cat << EOF
[3a27393]551all: chapter3 chapter5 chapter6 chapter7 do-housekeeping
[0170229]552 @\$(call echo_finished,$VERSION)
553
[0ac273e]554chapter3: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
[0170229]555
[65a2be6]556chapter5: chapter3 $chapter5 restore-hlfs-env
[0170229]557
558chapter6: chapter5 $chapter6
559
560chapter7: chapter6 $chapter7
561
562clean-all: clean
[bc097cd]563 rm -rf ./{hlfs-commands,logs,Makefile,*.xsl,makefile-functions,packages,patches}
[0170229]564
[0ac273e]565clean: clean-chapter7 clean-chapter6 clean-chapter5 clean-chapter3
[0170229]566
[3b63c8c]567restart: restart_code all
568
[0ac273e]569clean-chapter3:
[65a2be6]570 -if [ ! -f user-hlfs-exist ]; then \\
571 userdel hlfs; \\
572 rm -rf /home/hlfs; \\
[0170229]573 fi;
574 rm -rf \$(MOUNT_PT)/tools
575 rm -f /tools
[65a2be6]576 rm -f envars user-hlfs-exist
[0170229]577 rm -f 02* logs/02*.log
578
579clean-chapter5:
580 rm -rf \$(MOUNT_PT)/tools/*
[65a2be6]581 rm -f $chapter5 restore-hlfs-env sources-dir
[0170229]582 cd logs && rm -f $chapter5 && cd ..
583
584clean-chapter6:
585 -umount \$(MOUNT_PT)/sys
586 -umount \$(MOUNT_PT)/proc
587 -umount \$(MOUNT_PT)/dev/shm
588 -umount \$(MOUNT_PT)/dev/pts
589 -umount \$(MOUNT_PT)/dev
590 rm -rf \$(MOUNT_PT)/{bin,boot,dev,etc,home,lib,media,mnt,opt,proc,root,sbin,srv,sys,tmp,usr,var}
591 rm -f $chapter6
592 cd logs && rm -f $chapter6 && cd ..
593
594clean-chapter7:
595 rm -f $chapter7
596 cd logs && rm -f $chapter7 && cd ..
597
[65a2be6]598restore-hlfs-env:
[0170229]599 @\$(call echo_message, Building)
[65a2be6]600 @if [ -f /home/hlfs/.bashrc.XXX ]; then \\
601 mv -f /home/hlfs/.bashrc.XXX /home/hlfs/.bashrc; \\
[0170229]602 fi;
[65a2be6]603 @if [ -f /home/hlfs/.bash_profile.XXX ]; then \\
604 mv /home/hlfs/.bash_profile.XXX /home/hlfs/.bash_profile; \\
[0170229]605 fi;
[65a2be6]606 @chown hlfs:hlfs /home/hlfs/.bash* && \\
[9199a13]607 touch \$@ && \\
608 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
609 echo --------------------------------------------------------------------------------\$(WHITE)
[0170229]610
[3a27393]611do-housekeeping:
[9199a13]612 @-umount \$(MOUNT_PT)/dev/pts
613 @-umount \$(MOUNT_PT)/dev/shm
614 @-umount \$(MOUNT_PT)/dev
615 @-umount \$(MOUNT_PT)/sys
616 @-umount \$(MOUNT_PT)/proc
[65a2be6]617 @-if [ ! -f user-hlfs-exist ]; then \\
618 userdel hlfs; \\
619 rm -rf /home/hlfs; \\
[3a27393]620 fi;
[460ea63]621
[3b63c8c]622restart_code:
[9272545]623 @echo ">>> This feature is experimental, BUGS may exist"
624
[3b63c8c]625 @if [ ! -L /tools ]; then \\
626 echo -e "\\nERROR::\\n /tools is NOT a symlink.. /tools must point to \$(MOUNT_PT)/tools\\n" && false;\\
627 fi;
[9272545]628
[3b63c8c]629 @if [ ! -e /tools ]; then \\
630 echo -e "\\nERROR::\\nThe target /tools points to does not exist.\\nVerify the target.. \$(MOUNT_PT)/tools\\n" && false;\\
631 fi;
[9272545]632
[3b63c8c]633 @if ! stat -c %N /tools | grep "\$(MOUNT_PT)/tools" >/dev/null ; then \\
634 echo -e "\\nERROR::\\nThe symlink \\"/tools\\" does not point to \\"\$(MOUNT_PT)/tools\\".\\nCorrect the problem and rerun\\n" && false;\\
[9272545]635 fi;
[3b63c8c]636
637 @if [ -f ???-kernfs ]; then \\
638 mkdir -pv \$(MOUNT_PT)/{proc,sys};\\
639 if ! mount -l | "\$(MOUNT_PT)/dev" >/dev/null ; then \\
640 mount -vt ramfs ramfs \$(MOUNT_PT)/dev;\\
641 fi;\\
642 if [ ! -e \$(MOUNT_PT)/dev/console ]; then \\
643 mknod -m 600 \$(MOUNT_PT)/dev/console c 5 1;\\
644 fi;\\
645 if [ ! -e \$(MOUNT_PT)/dev/null ]; then \\
646 mknod -m 666 \$(MOUNT_PT)/dev/null c 1 3;\\
647 fi;\\
648 if ! mount -l | grep "\$(MOUNT_PT)/dev/pts" >/dev/null ; then \\
649 mount -vt devpts -o gid=4,mode=620 devpts \$(MOUNT_PT)/dev/pts;\\
650 fi;\\
651 if ! mount -l | grep "\$(MOUNT_PT)/dev/shm" >/dev/null ; then \\
652 mount -vt tmpfs shm \$(MOUNT_PT)/dev/shm;\\
653 fi;\\
654 if ! mount -l | grep "\$(MOUNT_PT)/proc" >/dev/null ; then \\
655 mount -vt proc proc \$(MOUNT_PT)/proc;\\
656 fi;\\
657 if ! mount -l | grep "\$(MOUNT_PT)/sys" >/dev/null ; then \\
658 mount -vt sysfs sysfs \$(MOUNT_PT)/sys;\\
659 fi;\\
660 fi;
661
662
[0170229]663EOF
664) >> $MKFILE
665
666 # Bring over the items from the Makefile.tmp
667 cat $MKFILE.tmp >> $MKFILE
668 rm $MKFILE.tmp
[a702b4d]669 echo "Creating Makefile... ${BOLD}DONE${OFF}"
670
[0170229]671}
Note: See TracBrowser for help on using the repository browser.