source: HLFS/master.sh@ b9c3497

2.4 ablfs-more legacy new_features trunk
Last change on this file since b9c3497 was 3d75bc2, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

HLFS: XSL clean-up,
fixed Glibc commads when the testsuite is not run,
and export CONFIG_SITE from inside adjusting script
instead of exporting target and ldso from inside
settingenvironment target.

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