source: HLFS/master.sh@ 610a5c4

ablfs-more legacy trunk
Last change on this file since 610a5c4 was fd4a798, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Remove $Id$ comments, they are useless with git

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