source: HLFS/master.sh@ d14903f

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

Last corrections to HLFS makefile generation

  • Property mode set to 100755
File size: 21.3 KB
RevLine 
[0170229]1#!/bin/sh
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
[50fb011]22 tc_phase=`echo $toolchain | sed -e 's@[0-9]\{3\}-@@' -e 's@-toolchain@@'`
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
[e840d27]96 # Define a few model dependant variables
97 if [[ ${MODEL} = "uclibc" ]]; then
98 TARGET="pc-linux-gnu"; LOADER="ld-uClibc.so.0"
99 else
[50fb011]100 TARGET="pc-linux-gnu"; LOADER="ld-linux.so.2"
[e840d27]101 fi
[0170229]102
[30737ea8]103 # If /home/$LUSER is already present in the host, we asume that the
[65a2be6]104 # hlfs user and group are also presents in the host, and a backup
[0170229]105 # of their bash init files is made.
106(
107cat << EOF
108020-creatingtoolsdir:
109 @\$(call echo_message, Building)
[9199a13]110 @mkdir \$(MOUNT_PT)/tools && \\
111 rm -f /tools && \\
112 ln -s \$(MOUNT_PT)/tools /
[0170229]113 @if [ ! -d \$(MOUNT_PT)/sources ]; then \\
114 mkdir \$(MOUNT_PT)/sources; \\
115 fi;
116 @chmod a+wt \$(MOUNT_PT)/sources && \\
[9199a13]117 touch \$@ && \\
118 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
119 echo --------------------------------------------------------------------------------\$(WHITE)
[0170229]120
121021-addinguser: 020-creatingtoolsdir
122 @\$(call echo_message, Building)
[9485eba]123 @if [ ! -d /home/\$(LUSER) ]; then \\
124 groupadd \$(LGROUP); \\
125 useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
[0170229]126 else \\
[30737ea8]127 touch luser-exist; \\
[0170229]128 fi;
[9485eba]129 @chown \$(LUSER) \$(MOUNT_PT)/tools && \\
[08a4953]130 chown -R \$(LUSER) \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
[9485eba]131 chown \$(LUSER) \$(MOUNT_PT)/sources && \\
[9199a13]132 touch \$@ && \\
133 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
134 echo --------------------------------------------------------------------------------\$(WHITE)
[0170229]135
136022-settingenvironment: 021-addinguser
137 @\$(call echo_message, Building)
[9485eba]138 @if [ -f /home/\$(LUSER)/.bashrc -a ! -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
139 mv /home/\$(LUSER)/.bashrc /home/\$(LUSER)/.bashrc.XXX; \\
[0170229]140 fi;
[9485eba]141 @if [ -f /home/\$(LUSER)/.bash_profile -a ! -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
142 mv /home/\$(LUSER)/.bash_profile /home/\$(LUSER)/.bash_profile.XXX; \\
[0170229]143 fi;
[9485eba]144 @echo "set +h" > /home/\$(LUSER)/.bashrc && \\
145 echo "umask 022" >> /home/\$(LUSER)/.bashrc && \\
146 echo "HLFS=\$(MOUNT_PT)" >> /home/\$(LUSER)/.bashrc && \\
147 echo "LC_ALL=POSIX" >> /home/\$(LUSER)/.bashrc && \\
148 echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/\$(LUSER)/.bashrc && \\
149 echo "export HLFS LC_ALL PATH" >> /home/\$(LUSER)/.bashrc && \\
150 echo "" >> /home/\$(LUSER)/.bashrc && \\
151 echo "target=$(uname -m)-${TARGET}" >> /home/\$(LUSER)/.bashrc && \\
152 echo "ldso=/tools/lib/${LOADER}" >> /home/\$(LUSER)/.bashrc && \\
153 echo "export target ldso" >> /home/\$(LUSER)/.bashrc && \\
154 echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc && \\
155 chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\
[0170229]156 touch envars && \\
[08a4953]157 chown \$(LUSER) envars && \\
[9199a13]158 touch \$@ && \\
159 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
160 echo --------------------------------------------------------------------------------\$(WHITE)
[0170229]161EOF
162) >> $MKFILE.tmp
[50fb011]163 chapter3=" 020-creatingtoolsdir 021-addinguser 022-settingenvironment"
[0170229]164}
165
166#----------------------------#
167chapter5_Makefiles() { # Bootstrap or temptools phase
168#----------------------------#
169 local file
170 local this_script
[57ca090]171
[50fb011]172 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5 ( LUSER ) ${R_arrow}"
[0170229]173
174 for file in chapter05/* ; do
175 # Keep the script file name
176 this_script=`basename $file`
177
178 # Skip this script depending on jhalfs.conf flags set.
179 case $this_script in
180 # If no testsuites will be run, then TCL, Expect and DejaGNU aren't needed
[821a2c6]181 *tcl* ) [[ "$TEST" = "0" ]] && continue; ;;
182 *expect* ) [[ "$TEST" = "0" ]] && continue; ;;
183 *dejagnu* ) [[ "$TEST" = "0" ]] && continue; ;;
[7d018d1]184 # Nothing interestin in this script
185 *introduction* ) continue ;;
[0170229]186 # Test if the stripping phase must be skipped
[47fddc8]187 *stripping* ) [[ "$STRIP" = "n" ]] && continue ;;
[0170229]188 *) ;;
189 esac
190
191 # First append each name of the script files to a list (this will become
192 # the names of the targets in the Makefile
193 chapter5="$chapter5 $this_script"
194
[9272545]195 # Grab the name of the target
196 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
[0170229]197
[5c5a010]198 # Adjust 'name'
[0170229]199 case $name in
[3b63c8c]200 uclibc) name="uClibc" ;;
[0170229]201 esac
202
203 # Set the dependency for the first target.
204 if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
205
206 #--------------------------------------------------------------------#
207 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
208 #--------------------------------------------------------------------#
209 #
210 # Drop in the name of the target on a new line, and the previous target
211 # as a dependency. Also call the echo_message function.
[9272545]212
[65a2be6]213 # This is a very special script and requires manual processing
214 # NO Optimization allowed
215 if [[ ${name} = "embryo-toolchain" ]] || \
216 [[ ${name} = "cocoon-toolchain" ]]; then
[50fb011]217 LUSER_wrt_target "$this_script" "$PREV"
[65a2be6]218 process_toolchain "${this_script}" "${file}"
219 wrt_touch
220 PREV=$this_script
221 continue
222 fi
223 #
[50fb011]224 LUSER_wrt_target "$this_script" "$PREV"
[0170229]225 # Find the version of the command files, if it corresponds with the building of
226 # a specific package
[3b63c8c]227 pkg_tarball=$(get_package_tarball_name $name)
228 # If $pkg_tarball isn't empty, we've got a package...
229 if [ "$pkg_tarball" != "" ] ; then
[29f9ec8]230 # Insert instructions for unpacking the package and to set the PKGDIR variable.
[50fb011]231 LUSER_wrt_unpack "$pkg_tarball"
[e35e794]232 # If using optimizations, write the instructions
[c205656]233 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[29f9ec8]234 fi
[0170229]235 # Insert date and disk usage at the top of the log file, the script run
236 # and date and disk usage again at the bottom of the log file.
[50fb011]237 LUSER_wrt_RunAsUser "${file}"
[0170229]238
239 # Remove the build directory(ies) except if the package build fails
240 # (so we can review config.cache, config.log, etc.)
[3b63c8c]241 if [ "$pkg_tarball" != "" ] ; then
[50fb011]242 LUSER_RemoveBuildDirs "$name"
[0170229]243 fi
244
245 # Include a touch of the target name so make can check if it's already been made.
[9199a13]246 wrt_touch
[0170229]247 #
248 #--------------------------------------------------------------------#
249 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
250 #--------------------------------------------------------------------#
251
252 # Keep the script file name for Makefile dependencies.
253 PREV=$this_script
254 done # end for file in chapter05/*
255}
256
257
258#----------------------------#
259chapter6_Makefiles() { # sysroot or chroot build phase
260#----------------------------#
261 local file
262 local this_script
[c483858]263 # Set envars and scripts for iteration targets
264 LOGS="" # Start with an empty global LOGS envar
265 if [[ -z "$1" ]] ; then
266 local N=""
267 else
268 local N=-build_$1
269 local chapter6=""
270 mkdir chapter06$N
271 cp chapter06/* chapter06$N
272 for script in chapter06$N/* ; do
273 # Overwrite existing symlinks, files, and dirs
274 sed -e 's/ln -s /ln -sf /g' \
275 -e 's/^mv /&-f/g' -i ${script}
276 done
277 # Remove Bzip2 binaries before make install
278 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2
279 # Fix how Module-Init-Tools do the install target
280 sed -e 's@make install@make INSTALL=install install@' -i chapter06$N/*-module-init-tools
281 # Delete *old Readline libraries just after make install
282 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i chapter06$N/*-readline
283 # Don't readd already existing groups
284 sed -e '/groupadd/d' -i chapter06$N/*-udev
285 fi
[0170229]286
[50fb011]287 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N ( CHROOT ) ${R_arrow}"
[0170229]288
[c483858]289 for file in chapter06$N/* ; do
[0170229]290 # Keep the script file name
291 this_script=`basename $file`
292
293 # Skip this script depending on jhalfs.conf flags set.
294 case $this_script in
295 # We'll run the chroot commands differently than the others, so skip them in the
296 # dependencies and target creation.
297 *chroot* ) continue ;;
298 # Test if the stripping phase must be skipped
[47fddc8]299 *-stripping* ) [[ "$STRIP" = "n" ]] && continue ;;
[0170229]300 esac
301
302 # Grab the name of the target
303 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
304
[3b63c8c]305 case $name in
306 uclibc) name="uClibc" ;;
307 esac
308
[c483858]309 # Find the version of the command files, if it corresponds with the building of
310 # a specific package
[3b63c8c]311 pkg_tarball=$(get_package_tarball_name $name)
[c483858]312
[3b63c8c]313 if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
[c483858]314 case "${this_script}" in
315 *stripping*) ;;
316 *) continue ;;
317 esac
318 fi
319
320 # Append each name of the script files to a list (this will become
321 # the names of the targets in the Makefile
322 chapter6="$chapter6 ${this_script}${N}"
323
324 # Append each name of the script files to a list (this will become
[7635367]325 # the names of the logs to be moved for each iteration)
326 LOGS="$LOGS ${this_script}"
[c483858]327
[0170229]328
329 #--------------------------------------------------------------------#
330 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
331 #--------------------------------------------------------------------#
332 #
333 # Drop in the name of the target on a new line, and the previous target
[65a2be6]334 # as a dependency. Also call the echo_message function.
335 if [[ ${name} = "butterfly-toolchain" ]]; then
[50fb011]336 CHROOT_wrt_target "${this_script}${N}" "$PREV"
[65a2be6]337 process_toolchain "${this_script}" "${file}"
338 wrt_touch
339 PREV=$this_script
340 continue
341 fi
342
[50fb011]343 CHROOT_wrt_target "${this_script}${N}" "$PREV"
[0170229]344
[3b63c8c]345 # If $pkg_tarball isn't empty, we've got a package...
[0170229]346 # Insert instructions for unpacking the package and changing directories
[3b63c8c]347 if [ "$pkg_tarball" != "" ] ; then
[50fb011]348 CHROOT_Unpack "$pkg_tarball"
[e35e794]349 # If the testsuites must be run, initialize the log file
[7cd9186]350 # butterfly-toolchain tests are enabled in 'process_tookchain' function
[e35e794]351 case $name in
[50fb011]352 glibc ) [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
[e35e794]353 ;;
[50fb011]354 * ) [[ "$TEST" > "1" ]] && CHROOT_wrt_test_log "${this_script}"
[e35e794]355 ;;
356 esac
357 # If using optimizations, write the instructions
[c205656]358 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[0170229]359 fi
360
[9272545]361 # In the mount of kernel filesystems we need to set HLFS and not to use chroot.
[5f4d08f]362 case "${this_script}" in
[b179a81]363 *kernfs* | *changingowner*)
[9485eba]364 wrt_RunAsRoot "${this_script}" "${file}"
[5f4d08f]365 ;;
366 *) # The rest of Chapter06
[50fb011]367 CHROOT_wrt_RunAsRoot "${file}"
[5f4d08f]368 ;;
369 esac
[0170229]370 #
371 # Remove the build directory(ies) except if the package build fails.
[3b63c8c]372 if [ "$pkg_tarball" != "" ] ; then
[50fb011]373 CHROOT_wrt_RemoveBuildDirs "$name"
[0170229]374 fi
375 #
376 # Include a touch of the target name so make can check if it's already been made.
[9199a13]377 wrt_touch
[0170229]378 #
379 #--------------------------------------------------------------------#
380 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
381 #--------------------------------------------------------------------#
382
383 # Keep the script file name for Makefile dependencies.
[c483858]384 PREV=${this_script}${N}
385 # Set system_build envar for iteration targets
386 system_build=$chapter6
[0170229]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
[57ca090]396
[50fb011]397 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7 ( BOOT ) ${R_arrow}"
[0170229]398 for file in chapter07/*; do
399 # Keep the script file name
400 this_script=`basename $file`
401
402 # Grub must be configured manually.
403 # The filesystems can't be unmounted via Makefile and the user
404 # should enter the chroot environment to create the root
405 # password, edit several files and setup Grub.
406 case $this_script in
[0ac273e]407 *usage) continue ;; # Contains example commands
[0170229]408 *grub) continue ;;
409 *console) continue ;; # Use the file generated by lfs-bootscripts
[50fb011]410 *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab
411 ;;
412 *kernel) # If no .config file is supplied, the kernel build is skipped
413 [[ -z $CONFIG ]] && continue
414 cp $CONFIG $BUILDDIR/sources/kernel-config
415 ;;
[0170229]416 esac
417
418 # First append then name of the script file to a list (this will become
419 # the names of the targets in the Makefile
420 chapter7="$chapter7 $this_script"
421
422 #--------------------------------------------------------------------#
423 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
424 #--------------------------------------------------------------------#
425 #
426 # Drop in the name of the target on a new line, and the previous target
427 # as a dependency. Also call the echo_message function.
[50fb011]428 CHROOT_wrt_target "$this_script" "$PREV"
[0170229]429
[5f4d08f]430 case "${this_script}" in
[db187c74]431 *bootscripts*)
[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 ;;
436 esac
[0170229]437
[db187c74]438 case "${this_script}" in
[5f4d08f]439 *fstab*) # Check if we have a real /etc/fstab file
440 if [[ -n "$FSTAB" ]] ; then
[50fb011]441 CHROOT_wrt_CopyFstab
442 else
443 CHROOT_wrt_RunAsRoot "$file"
[5f4d08f]444 fi
445 ;;
446 *) # All other scripts
[50fb011]447 CHROOT_wrt_RunAsRoot "${file}"
[5f4d08f]448 ;;
449 esac
[0170229]450
451 # Remove the build directory except if the package build fails.
[5f4d08f]452 case "${this_script}" in
453 *bootscripts*)
[0170229]454(
455cat << EOF
[50fb011]456 @ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
457 rm -r \$(SRC)/\$\$ROOT
[0170229]458 @rm -r \`cat sources-dir\` && \\
459 rm sources-dir
460EOF
461) >> $MKFILE.tmp
[5f4d08f]462 ;;
463 esac
[0170229]464
465 # Include a touch of the target name so make can check if it's already been made.
[9199a13]466 wrt_touch
[0170229]467 #
468 #--------------------------------------------------------------------#
469 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
470 #--------------------------------------------------------------------#
471
472 # Keep the script file name for Makefile dependencies.
473 PREV=$this_script
474 done # for file in chapter07/*
[9e4b9a1]475
476 # Add SBU-disk_usage report target if required
[47fddc8]477 if [[ "$REPORT" = "y" ]] ; then wrt_report ; fi
[0170229]478}
479
480
481#----------------------------#
482build_Makefile() { # Construct a Makefile from the book scripts
483#----------------------------#
[a702b4d]484 echo "Creating Makefile... ${BOLD}START${OFF}"
[0170229]485
486 cd $JHALFSDIR/${PROGNAME}-commands
487 # Start with a clean Makefile.tmp file
488 >$MKFILE.tmp
489
[389fe2a]490 chapter3_Makefiles
[0170229]491 chapter5_Makefiles
492 chapter6_Makefiles
[c483858]493 # Add the iterations targets, if needed
[47fddc8]494 [[ "$COMPARE" = "y" ]] && wrt_compare_targets
[0170229]495 chapter7_Makefiles
496
497 # Add a header, some variables and include the function file
498 # to the top of the real Makefile.
499(
500 cat << EOF
501$HEADER
502
[398a037]503SRC = /sources
504MOUNT_PT = $BUILDDIR
505PKG_LST = $PKG_LST
506LUSER = $LUSER
507LGROUP = $LGROUP
508SCRIPT_ROOT = $SCRIPT_ROOT
509
510BASEDIR = \$(MOUNT_PT)
511SRCSDIR = \$(BASEDIR)/sources
512CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$PROGNAME-commands
513LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/logs
514TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/test-logs
515
516crSRCSDIR = /sources
517crCMDSDIR = /\$(SCRIPT_ROOT)/$PROGNAME-commands
518crLOGDIR = /\$(SCRIPT_ROOT)/logs
519crTESTLOGDIR = /\$(SCRIPT_ROOT)/test-logs
520
521SU_LUSER = su - \$(LUSER) -c
522LUSER_HOME = /home/\$(LUSER)
523PRT_DU = echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n"
[b179a81]524PRT_DU_CR = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) / \`\n"
[0170229]525
526include makefile-functions
527
528EOF
529) > $MKFILE
530
531
532 # Add chroot commands
[8381f6e]533 CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
[0170229]534 i=1
535 for file in chapter06/*chroot* ; do
[8381f6e]536 chroot=`cat $file | \
537 sed -e "s@chroot@$CHROOT_LOC@" \
538 -e '/#!\/bin\/sh/d' \
539 -e '/^export/d' \
540 -e '/^logout/d' \
541 -e 's@ \\\@ @g' | \
542 tr -d '\n' | \
543 sed -e 's/ */ /g' \
544 -e 's|\\$|&&|g' \
545 -e 's|exit||g' \
546 -e 's|$| -c|' \
547 -e 's|"$$HLFS"|$(MOUNT_PT)|'\
548 -e 's|set -e||'`
[0170229]549 echo -e "CHROOT$i= $chroot\n" >> $MKFILE
550 i=`expr $i + 1`
551 done
552
553 # Drop in the main target 'all:' and the chapter targets with each sub-target
554 # as a dependency.
555(
556 cat << EOF
[50fb011]557
[08a4953]558all: mk_SETUP mk_LUSER mk_CHROOT mk_BOOT do-housekeeping
[50fb011]559 @\$(call echo_finished,$VERSION)
560
561
562mk_SETUP:
563 @\$(call echo_SU_request)
564 @sudo make SETUP
565 @touch \$@
566
567mk_LUSER: mk_SETUP
568 @\$(call echo_SULUSER_request)
569 @( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make LUSER" )
570 @touch \$@
571
[b179a81]572mk_CHROOT: mk_LUSER 060-kernfs 062-changingowner
[50fb011]573 @mkdir \$(MOUNT_PT)/bin && \
574 cd \$(MOUNT_PT)/bin && \
575 ln -sf /tools/bin/bash bash; ln -sf bash sh
[b179a81]576 @sed -e 's|^ln -vs|ln -svf|' -i \$(CMDSDIR)/chapter06/064-createfiles
[50fb011]577 @\$(call echo_CHROOT_request)
[b179a81]578 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make CHROOT")
[50fb011]579 @touch \$@
580
581mk_BOOT: mk_CHROOT
582 @\$(call echo_CHROOT_request)
583 @( sudo \$(CHROOT2) "cd \$(SCRIPT_ROOT) && make BOOT")
584 @touch \$@
585
586
587SETUP: $chapter3
588
589LUSER: $chapter5
590
591CHROOT: $chapter6
592
593BOOT: $chapter7
594
595
[3b63c8c]596restart: restart_code all
597
[30737ea8]598restore-luser-env:
[0170229]599 @\$(call echo_message, Building)
[9485eba]600 @if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
601 mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
[0170229]602 fi;
[9485eba]603 @if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
604 mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
[0170229]605 fi;
[9485eba]606 @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
[9199a13]607 touch \$@ && \\
608 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
609 echo --------------------------------------------------------------------------------\$(WHITE)
[0170229]610
[3a27393]611do-housekeeping:
[9199a13]612 @-umount \$(MOUNT_PT)/dev/pts
613 @-umount \$(MOUNT_PT)/dev/shm
614 @-umount \$(MOUNT_PT)/dev
615 @-umount \$(MOUNT_PT)/sys
616 @-umount \$(MOUNT_PT)/proc
[30737ea8]617 @-if [ ! -f luser-exist ]; then \\
[9485eba]618 userdel \$(LUSER); \\
619 rm -rf /home/\$(LUSER); \\
[3a27393]620 fi;
[460ea63]621
[3b63c8c]622restart_code:
[9272545]623 @echo ">>> This feature is experimental, BUGS may exist"
624
[3b63c8c]625 @if [ ! -L /tools ]; then \\
626 echo -e "\\nERROR::\\n /tools is NOT a symlink.. /tools must point to \$(MOUNT_PT)/tools\\n" && false;\\
627 fi;
[9272545]628
[3b63c8c]629 @if [ ! -e /tools ]; then \\
630 echo -e "\\nERROR::\\nThe target /tools points to does not exist.\\nVerify the target.. \$(MOUNT_PT)/tools\\n" && false;\\
631 fi;
[9272545]632
[3b63c8c]633 @if ! stat -c %N /tools | grep "\$(MOUNT_PT)/tools" >/dev/null ; then \\
634 echo -e "\\nERROR::\\nThe symlink \\"/tools\\" does not point to \\"\$(MOUNT_PT)/tools\\".\\nCorrect the problem and rerun\\n" && false;\\
[9272545]635 fi;
[3b63c8c]636
637 @if [ -f ???-kernfs ]; then \\
638 mkdir -pv \$(MOUNT_PT)/{proc,sys};\\
639 if ! mount -l | "\$(MOUNT_PT)/dev" >/dev/null ; then \\
640 mount -vt ramfs ramfs \$(MOUNT_PT)/dev;\\
641 fi;\\
642 if [ ! -e \$(MOUNT_PT)/dev/console ]; then \\
643 mknod -m 600 \$(MOUNT_PT)/dev/console c 5 1;\\
644 fi;\\
645 if [ ! -e \$(MOUNT_PT)/dev/null ]; then \\
646 mknod -m 666 \$(MOUNT_PT)/dev/null c 1 3;\\
647 fi;\\
648 if ! mount -l | grep "\$(MOUNT_PT)/dev/pts" >/dev/null ; then \\
649 mount -vt devpts -o gid=4,mode=620 devpts \$(MOUNT_PT)/dev/pts;\\
650 fi;\\
651 if ! mount -l | grep "\$(MOUNT_PT)/dev/shm" >/dev/null ; then \\
652 mount -vt tmpfs shm \$(MOUNT_PT)/dev/shm;\\
653 fi;\\
654 if ! mount -l | grep "\$(MOUNT_PT)/proc" >/dev/null ; then \\
655 mount -vt proc proc \$(MOUNT_PT)/proc;\\
656 fi;\\
657 if ! mount -l | grep "\$(MOUNT_PT)/sys" >/dev/null ; then \\
658 mount -vt sysfs sysfs \$(MOUNT_PT)/sys;\\
659 fi;\\
660 fi;
661
662
[0170229]663EOF
664) >> $MKFILE
665
666 # Bring over the items from the Makefile.tmp
667 cat $MKFILE.tmp >> $MKFILE
668 rm $MKFILE.tmp
[a702b4d]669 echo "Creating Makefile... ${BOLD}DONE${OFF}"
670
[0170229]671}
Note: See TracBrowser for help on using the repository browser.