source: HLFS/master.sh@ f9bfa72

experimental
Last change on this file since f9bfa72 was 9c9775f, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Updated experimental branch to current trunk code.

  • Property mode set to 100644
File size: 21.1 KB
RevLine 
[9c9775f]1#!/bin/bash
[0170229]2set -e # Enable error trapping
3
[57ca090]4# $Id$
[0170229]5
6###################################
7### FUNCTIONS ###
8###################################
9
[50fb011]10
[65a2be6]11#----------------------------#
12process_toolchain() { # embryo,cocoon and butterfly need special handling
13#----------------------------#
14 local toolchain=$1
[08a4953]15 local this_file=$2
[50fb011]16 local tc_phase
[398a037]17 local binutil_tarball
18 local gcc_core_tarball
[50fb011]19 local TC_MountPT
20 local remove_existing
[08a4953]21
[9c9775f]22 tc_phase=`echo $toolchain | sed -e 's@[0-9]\{3\}-@@' -e 's@-toolchain@@' -e 's,'$N',,'`
[50fb011]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
[65a2be6]34
[89ddac0]35 #
36 # Safe method to remove existing toolchain dirs
[398a037]37 binutil_tarball=$(get_package_tarball_name "binutils")
38 gcc_core_tarball=$(get_package_tarball_name "gcc-core")
39(
40cat << EOF
[50fb011]41 @\$(call ${remove_existing},$binutil_tarball)
42 @\$(call ${remove_existing},$gcc_core_tarball)
[398a037]43EOF
44) >> $MKFILE.tmp
45
[89ddac0]46 #
47 # Manually remove the toolchain directories..
48(
49cat << EOF
[50fb011]50 @rm -rf ${TC_MountPT}/${tc_phase}-toolchain && \\
51 rm -rf ${TC_MountPT}/${tc_phase}-build
[89ddac0]52EOF
53) >> $MKFILE.tmp
54
[a82bbc0]55
[65a2be6]56(
57cat << EOF
[50fb011]58 @echo "export PKGDIR=${TC_MountPT}" > envars
[65a2be6]59EOF
60) >> $MKFILE.tmp
[50fb011]61
62 case ${tc_phase} in
63 butterfly)
[08a4953]64 [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${toolchain}"
65 CHROOT_wrt_RunAsRoot "$this_file"
[50fb011]66 ;;
[08a4953]67 *) LUSER_wrt_RunAsUser "$this_file"
[21dab83]68 ;;
69 esac
[a82bbc0]70 #
[398a037]71(
72cat << EOF
[50fb011]73 @\$(call ${remove_existing},$binutil_tarball)
74 @\$(call ${remove_existing},$gcc_core_tarball)
[398a037]75EOF
76) >> $MKFILE.tmp
77
[21dab83]78 #
[65a2be6]79 # Manually remove the toolchain directories..
80(
81cat << EOF
[50fb011]82 @rm -rf ${TC_MountPT}/${tc_phase}-toolchain && \\
83 rm -rf ${TC_MountPT}/${tc_phase}-build
[65a2be6]84EOF
85) >> $MKFILE.tmp
86
87}
88
[0170229]89
90#----------------------------#
[389fe2a]91chapter3_Makefiles() { # Initialization of the system
[0170229]92#----------------------------#
93
[50fb011]94 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter3 ( SETUP ) ${R_arrow}"
[0170229]95
[9c9775f]96 # If $LUSER_HOME is already present in the host, we asume that the
[65a2be6]97 # hlfs user and group are also presents in the host, and a backup
[0170229]98 # of their bash init files is made.
99(
100cat << EOF
101020-creatingtoolsdir:
102 @\$(call echo_message, Building)
[9199a13]103 @mkdir \$(MOUNT_PT)/tools && \\
104 rm -f /tools && \\
105 ln -s \$(MOUNT_PT)/tools /
[9c9775f]106 @\$(call housekeeping)
[0170229]107
108021-addinguser: 020-creatingtoolsdir
109 @\$(call echo_message, Building)
[9c9775f]110 @if [ ! -d \$(LUSER_HOME) ]; then \\
[9485eba]111 groupadd \$(LGROUP); \\
112 useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
[0170229]113 else \\
[30737ea8]114 touch luser-exist; \\
[0170229]115 fi;
[9485eba]116 @chown \$(LUSER) \$(MOUNT_PT)/tools && \\
[9c9775f]117 chmod -R a+wt \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
118 chmod a+wt \$(SRCSDIR)
119 @\$(call housekeeping)
[0170229]120
121022-settingenvironment: 021-addinguser
122 @\$(call echo_message, Building)
[9c9775f]123 @if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
124 mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
[0170229]125 fi;
[9c9775f]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; \\
[0170229]128 fi;
[9c9775f]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 && \\
[7d4cc81]138 chmod -R a+wt \$(MOUNT_PT) && \\
[0170229]139 touch envars && \\
[9c9775f]140 chown \$(LUSER) envars
141 @\$(call housekeeping)
[0170229]142EOF
143) >> $MKFILE.tmp
[50fb011]144 chapter3=" 020-creatingtoolsdir 021-addinguser 022-settingenvironment"
[0170229]145}
146
147#----------------------------#
148chapter5_Makefiles() { # Bootstrap or temptools phase
149#----------------------------#
150 local file
151 local this_script
[57ca090]152
[50fb011]153 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5 ( LUSER ) ${R_arrow}"
[0170229]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
[821a2c6]162 *tcl* ) [[ "$TEST" = "0" ]] && continue; ;;
163 *expect* ) [[ "$TEST" = "0" ]] && continue; ;;
164 *dejagnu* ) [[ "$TEST" = "0" ]] && continue; ;;
[0170229]165 # Test if the stripping phase must be skipped
[47fddc8]166 *stripping* ) [[ "$STRIP" = "n" ]] && continue ;;
[0170229]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
[9272545]174 # Grab the name of the target
[9c9775f]175 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-pass[0-9]\{1\}@@'`
[0170229]176
[5c5a010]177 # Adjust 'name'
[0170229]178 case $name in
[3b63c8c]179 uclibc) name="uClibc" ;;
[0170229]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.
[9272545]191
[65a2be6]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
[50fb011]196 LUSER_wrt_target "$this_script" "$PREV"
[65a2be6]197 process_toolchain "${this_script}" "${file}"
198 wrt_touch
199 PREV=$this_script
200 continue
201 fi
202 #
[50fb011]203 LUSER_wrt_target "$this_script" "$PREV"
[0170229]204 # Find the version of the command files, if it corresponds with the building of
[9c9775f]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
[3b63c8c]210 # If $pkg_tarball isn't empty, we've got a package...
211 if [ "$pkg_tarball" != "" ] ; then
[29f9ec8]212 # Insert instructions for unpacking the package and to set the PKGDIR variable.
[50fb011]213 LUSER_wrt_unpack "$pkg_tarball"
[e35e794]214 # If using optimizations, write the instructions
[c205656]215 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[29f9ec8]216 fi
[0170229]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.
[50fb011]219 LUSER_wrt_RunAsUser "${file}"
[0170229]220
221 # Remove the build directory(ies) except if the package build fails
222 # (so we can review config.cache, config.log, etc.)
[3b63c8c]223 if [ "$pkg_tarball" != "" ] ; then
[50fb011]224 LUSER_RemoveBuildDirs "$name"
[0170229]225 fi
226
227 # Include a touch of the target name so make can check if it's already been made.
[9199a13]228 wrt_touch
[0170229]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
[c483858]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' \
[9c9775f]256 -e 's/^mv /&-f /g' \
257 -e 's/mkdir -v/&p/g' -i ${script}
258 # Rename the scripts
259 mv ${script} ${script}$N
[c483858]260 done
261 # Remove Bzip2 binaries before make install
[9c9775f]262 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2$N
[c483858]263 # Fix how Module-Init-Tools do the install target
[9c9775f]264 sed -e 's@make install@make INSTALL=install install@' -i chapter06$N/*-module-init-tools$N
[c483858]265 # Don't readd already existing groups
[9c9775f]266 sed -e '/groupadd/d' -i chapter06$N/*-udev$N
[c483858]267 fi
[0170229]268
[50fb011]269 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N ( CHROOT ) ${R_arrow}"
[0170229]270
[c483858]271 for file in chapter06$N/* ; do
[0170229]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
[47fddc8]281 *-stripping* ) [[ "$STRIP" = "n" ]] && continue ;;
[9c9775f]282 # Skip linux-headers in iterative builds
283 *linux-headers*) [[ -n "$N" ]] && continue ;;
[0170229]284 esac
285
286 # Grab the name of the target
[9c9775f]287 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's,'$N',,'`
[0170229]288
[3b63c8c]289 case $name in
290 uclibc) name="uClibc" ;;
291 esac
292
[c483858]293 # Find the version of the command files, if it corresponds with the building of
[9c9775f]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
[c483858]299
[3b63c8c]300 if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
[c483858]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
[9c9775f]309 case "${this_script}" in
310 *kernfs* ) runasroot=" ${this_script}" ;;
311 * ) chapter6="$chapter6 ${this_script}" ;;
312 esac
[c483858]313
[0170229]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
[65a2be6]320 # as a dependency. Also call the echo_message function.
321 if [[ ${name} = "butterfly-toolchain" ]]; then
[9c9775f]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
[65a2be6]335 fi
[9c9775f]336 # kernfs is run in SUDO target
337 case "${this_script}" in
338 *kernfs* ) LUSER_wrt_target "${this_script}" "$PREV" ;;
339 * ) CHROOT_wrt_target "${this_script}" "$PREV" ;;
340 esac
[0170229]341
[3b63c8c]342 # If $pkg_tarball isn't empty, we've got a package...
[0170229]343 # Insert instructions for unpacking the package and changing directories
[3b63c8c]344 if [ "$pkg_tarball" != "" ] ; then
[9c9775f]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
[50fb011]350 CHROOT_Unpack "$pkg_tarball"
[e35e794]351 # If the testsuites must be run, initialize the log file
[7cd9186]352 # butterfly-toolchain tests are enabled in 'process_tookchain' function
[9c9775f]353 # 2.4-branch toolchain is ernabled here.
[e35e794]354 case $name in
[9c9775f]355 glibc | gcc | binutils)
356 [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}" ;;
357 * ) [[ "$TEST" > "1" ]] && CHROOT_wrt_test_log "${this_script}" ;;
[e35e794]358 esac
359 # If using optimizations, write the instructions
[c205656]360 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[0170229]361 fi
362
[9c9775f]363 # In kernfs we need to set HLFS and not to use chroot.
[5f4d08f]364 case "${this_script}" in
[9c9775f]365 *kernfs* ) wrt_RunAsRoot "${file}" ;;
366 * ) CHROOT_wrt_RunAsRoot "${file}" ;;
[5f4d08f]367 esac
[0170229]368 #
[9c9775f]369 # Write installed files log and remove the build directory(ies)
370 # except if the package build fails.
[3b63c8c]371 if [ "$pkg_tarball" != "" ] ; then
[50fb011]372 CHROOT_wrt_RemoveBuildDirs "$name"
[9c9775f]373 if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
374 CHROOT_wrt_LogNewFiles "$name"
375 fi
[0170229]376 fi
377 #
378 # Include a touch of the target name so make can check if it's already been made.
[9199a13]379 wrt_touch
[0170229]380 #
381 #--------------------------------------------------------------------#
382 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
383 #--------------------------------------------------------------------#
384
385 # Keep the script file name for Makefile dependencies.
[9c9775f]386 PREV=${this_script}
[c483858]387 # Set system_build envar for iteration targets
388 system_build=$chapter6
[0170229]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
[57ca090]398
[50fb011]399 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7 ( BOOT ) ${R_arrow}"
[0170229]400 for file in chapter07/*; do
401 # Keep the script file name
402 this_script=`basename $file`
403
404 case $this_script in
[9c9775f]405 *grub) continue ;; # Grub must be configured manually.
406 *console) continue ;; # Use the file generated by lfs-bootscripts
407 *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab
[50fb011]408 ;;
[9c9775f]409 *kernel) # If no .config file is supplied, the kernel build is skipped
410 [[ -z $CONFIG ]] && continue
411 cp $CONFIG $BUILDDIR/sources/kernel-config
[50fb011]412 ;;
[0170229]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.
[50fb011]425 CHROOT_wrt_target "$this_script" "$PREV"
[0170229]426
[5f4d08f]427 case "${this_script}" in
[db187c74]428 *bootscripts*)
[9c9775f]429 if [ "${INSTALL_LOG}" = "y" ] ; then
430 CHROOT_wrt_TouchTimestamp
431 fi
[50fb011]432 CHROOT_Unpack $(get_package_tarball_name "lfs-bootscripts")
[3b63c8c]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
[5f4d08f]435 ;;
[9c9775f]436 *kernel)
437 name="linux"
438 pkg_tarball=$(get_package_tarball_name $name)
439 if [ "${INSTALL_LOG}" = "y" ] ; then
440 CHROOT_wrt_TouchTimestamp
441 fi
442 CHROOT_Unpack "$pkg_tarball"
443 ;;
[5f4d08f]444 esac
[0170229]445
[db187c74]446 case "${this_script}" in
[5f4d08f]447 *fstab*) # Check if we have a real /etc/fstab file
448 if [[ -n "$FSTAB" ]] ; then
[50fb011]449 CHROOT_wrt_CopyFstab
450 else
451 CHROOT_wrt_RunAsRoot "$file"
[5f4d08f]452 fi
453 ;;
454 *) # All other scripts
[50fb011]455 CHROOT_wrt_RunAsRoot "${file}"
[5f4d08f]456 ;;
457 esac
[0170229]458
459 # Remove the build directory except if the package build fails.
[5f4d08f]460 case "${this_script}" in
461 *bootscripts*)
[0170229]462(
463cat << EOF
[50fb011]464 @ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
465 rm -r \$(SRC)/\$\$ROOT
[9c9775f]466 @rm -rf \`cat sources-dir\` && \\
[0170229]467 rm sources-dir
468EOF
469) >> $MKFILE.tmp
[9c9775f]470 if [ "${INSTALL_LOG}" = "y" ] ; then
471 CHROOT_wrt_LogNewFiles "$name"
472 fi
[5f4d08f]473 ;;
[9c9775f]474 *kernel) CHROOT_wrt_RemoveBuildDirs "dummy"
475 if [ "${INSTALL_LOG}" = "y" ] ; then
476 CHROOT_wrt_LogNewFiles "$name"
477 fi ;;
[5f4d08f]478 esac
[0170229]479
480 # Include a touch of the target name so make can check if it's already been made.
[9199a13]481 wrt_touch
[0170229]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#----------------------------#
[a702b4d]496 echo "Creating Makefile... ${BOLD}START${OFF}"
[0170229]497
498 cd $JHALFSDIR/${PROGNAME}-commands
499 # Start with a clean Makefile.tmp file
500 >$MKFILE.tmp
501
[389fe2a]502 chapter3_Makefiles
[0170229]503 chapter5_Makefiles
504 chapter6_Makefiles
[c483858]505 # Add the iterations targets, if needed
[47fddc8]506 [[ "$COMPARE" = "y" ]] && wrt_compare_targets
[0170229]507 chapter7_Makefiles
[9c9775f]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
[0170229]512
513 # Add a header, some variables and include the function file
514 # to the top of the real Makefile.
[9c9775f]515 wrt_Makefile_header
[0170229]516
517 # Add chroot commands
[8381f6e]518 CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
[0170229]519 i=1
520 for file in chapter06/*chroot* ; do
[8381f6e]521 chroot=`cat $file | \
522 sed -e "s@chroot@$CHROOT_LOC@" \
[9c9775f]523 -e '/#!\/bin\/bash/d' \
[8381f6e]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)|'\
[9c9775f]533 -e 's|set -e||' \
534 -e 's|set +h||'`
[0170229]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
[50fb011]543
[9c9775f]544all: ck_UID mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL
[7d4cc81]545 @sudo make do-housekeeping
[9c9775f]546 @echo "$VERSION - jhalfs build" > hlfs-release && \\
547 sudo install -m444 hlfs-release \$(MOUNT_PT)/etc/hlfs-release
[50fb011]548 @\$(call echo_finished,$VERSION)
549
[7d4cc81]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
[50fb011]557
558mk_SETUP:
559 @\$(call echo_SU_request)
[9c9775f]560 @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
[50fb011]561 @touch \$@
[0167dd8]562
[50fb011]563mk_LUSER: mk_SETUP
564 @\$(call echo_SULUSER_request)
[9c9775f]565 @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) LUSER" )
[7d4cc81]566 @sudo make restore-luser-env
[50fb011]567 @touch \$@
568
[7d4cc81]569mk_SUDO: mk_LUSER
570 @sudo make SUDO
571 @touch \$@
[0167dd8]572
573mk_CHROOT: mk_SUDO
[9c9775f]574 @if [ ! -e \$(MOUNT_PT)/dev ]; then \\
575 mkdir \$(MOUNT_PT)/dev && \\
576 sudo mknod -m 666 \$(MOUNT_PT)/dev/null c 1 3 && \\
577 sudo mknod -m 600 \$(MOUNT_PT)/dev/console c 5 1 && \\
578 sudo chown -R 0:0 \$(MOUNT_PT)/dev; \\
[496f8f3]579 fi;
[50fb011]580 @\$(call echo_CHROOT_request)
[9c9775f]581 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT")
[50fb011]582 @touch \$@
583
[0167dd8]584mk_BOOT: mk_CHROOT
[50fb011]585 @\$(call echo_CHROOT_request)
[9c9775f]586 @( sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
[50fb011]587 @touch \$@
[0167dd8]588
[9c9775f]589mk_CUSTOM_TOOLS: create-sbu_du-report
590 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
591 \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
592 sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
593 (sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
594 fi;
595 @touch \$@
[50fb011]596
[9c9775f]597mk_BLFS_TOOL: mk_CUSTOM_TOOLS
598 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
599 \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
600 sudo mkdir -p $BUILDDIR$TRACKING_DIR; \\
601 (sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"); \\
602 fi;
603 @touch \$@
[50fb011]604
[7d4cc81]605
[9c9775f]606SETUP: $chapter3
607LUSER: $chapter5
608SUDO: $runasroot
609CHROOT: SHELL=/tools/bin/bash
610CHROOT: $chapter6
611BOOT: $chapter7
612CUSTOM_TOOLS: $custom_list
613BLFS_TOOL: $blfs_tool
[50fb011]614
615
[9c9775f]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 \$@
[50fb011]623
[30737ea8]624restore-luser-env:
[0170229]625 @\$(call echo_message, Building)
[9c9775f]626 @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
627 mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
[0170229]628 fi;
[9c9775f]629 @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
630 mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
[0170229]631 fi;
[9c9775f]632 @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash* && \\
[9199a13]633 touch \$@ && \\
634 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
635 echo --------------------------------------------------------------------------------\$(WHITE)
[0170229]636
[3a27393]637do-housekeeping:
[9199a13]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
[0167dd8]643 @-rm /tools
[30737ea8]644 @-if [ ! -f luser-exist ]; then \\
[9485eba]645 userdel \$(LUSER); \\
[9c9775f]646 rm -rf \$(LUSER_HOME); \\
[3a27393]647 fi;
[460ea63]648
[3b63c8c]649
650
[0170229]651EOF
652) >> $MKFILE
653
654 # Bring over the items from the Makefile.tmp
655 cat $MKFILE.tmp >> $MKFILE
656 rm $MKFILE.tmp
[a702b4d]657 echo "Creating Makefile... ${BOLD}DONE${OFF}"
658
[0170229]659}
Note: See TracBrowser for help on using the repository browser.