source: HLFS/master.sh@ 6d48bb7

2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 6d48bb7 was f546320, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Ported INSTALL_LOG support to all books.

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