source: CLFS/master.sh@ e9642b9

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

Remove unnecessary flow tests. Added missing function, wrt_report. Added restore-luser-env to chroot build

  • Property mode set to 100755
File size: 46.6 KB
Line 
1#!/bin/sh
2# $Id$
3
4
5orphan_scripts="" # 2 scripts do not fit BOOT_Makefiles LUSER environment
6
7###################################
8### FUNCTIONS ###
9###################################
10
11#--------------------------------------#
12BOOT_wrt_target() { # "${this_script}" "$PREV"
13#--------------------------------------#
14 local i=$1
15 local PREV=$2
16 case $i in
17 iteration* ) local LOGFILE=$this_script.log ;;
18 * ) local LOGFILE=$this_script ;;
19 esac
20(
21cat << EOF
22
23$i: $PREV
24 @\$(call echo_message, Building)
25 @./progress_bar.sh \$@ \$\$PPID &
26 @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=${SCRIPT_ROOT}\`\n" >logs/$LOGFILE
27EOF
28) >> $MKFILE.tmp
29}
30
31#--------------------------------------#
32BOOT_wrt_Unpack() { # "$pkg_tarball"
33#--------------------------------------#
34 local FILE=$1
35 local optSAVE_PREVIOUS=$2
36
37 if [ "${optSAVE_PREVIOUS}" != "1" ]; then
38(
39cat << EOF
40 @\$(call remove_existing_dirs2,$FILE)
41EOF
42) >> $MKFILE.tmp
43 fi
44(
45cat << EOF
46 @\$(call unpack3,$FILE)
47 @\$(call get_pkg_root2)
48EOF
49) >> $MKFILE.tmp
50}
51
52#----------------------------------#
53BOOT_wrt_RunAsRoot() { # "${this_script}" "${file}"
54#----------------------------------#
55 local this_script=$1
56 local file=$2
57(
58cat << EOF
59 @( time { source envars && ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
60 echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \`\n" >>logs/\$@
61EOF
62) >> $MKFILE.tmp
63}
64
65#--------------------------------------#
66BOOT_wrt_RemoveBuildDirs() { # "${name}"
67#--------------------------------------#
68 local name=$1
69(
70cat << EOF
71 @\$(call remove_build_dirs2,$name)
72EOF
73) >> $MKFILE.tmp
74}
75
76#----------------------------------#
77BOOT_wrt_test_log() { #
78#----------------------------------#
79 local TESTLOGFILE=$1
80(
81cat << EOF
82 @echo "export TEST_LOG=/\$(SCRIPT_ROOT)/test-logs/$TESTLOGFILE" >> envars && \\
83 echo -e "\n\`date\`\n" >test-logs/$TESTLOGFILE
84EOF
85) >> $MKFILE.tmp
86}
87
88#----------------------------------#
89BOOT_wrt_CopyFstab() { #
90#----------------------------------#
91(
92cat << EOF
93 @( time { cp -v /sources/fstab /etc/fstab >>logs/${this_script} 2>&1 ; } ) 2>>logs/${this_script}
94EOF
95) >> $MKFILE.tmp
96}
97
98
99########################################
100
101
102#--------------------------------------#
103host_prep_Makefiles() { #
104#--------------------------------------#
105 local CLFS_HOST
106
107 echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}"
108
109 # defined here, only for ease of reading
110 CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
111(
112cat << EOF
113023-creatingtoolsdir:
114 @\$(call echo_message, Building)
115 @mkdir \$(MOUNT_PT)/tools && \\
116 rm -f /tools && \\
117 ln -s \$(MOUNT_PT)/tools /
118 @if [ ! -d \$(MOUNT_PT)/sources ]; then \\
119 mkdir \$(MOUNT_PT)/sources; \\
120 fi;
121 @chmod a+wt \$(MOUNT_PT)/sources && \\
122 touch \$@ && \\
123 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
124 echo --------------------------------------------------------------------------------\$(WHITE)
125
126024-creatingcrossdir: 023-creatingtoolsdir
127 @mkdir -v \$(MOUNT_PT)/cross-tools && \\
128 rm -f /cross-tools && \\
129 ln -s \$(MOUNT_PT)/cross-tools /
130 @touch \$@ && \\
131 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
132 echo --------------------------------------------------------------------------------\$(WHITE)
133
134025-addinguser: 024-creatingcrossdir
135 @\$(call echo_message, Building)
136 @if [ ! -d /home/\$(LUSER) ]; then \\
137 groupadd \$(LGROUP); \\
138 useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
139 else \\
140 touch luser-exist; \\
141 fi;
142 @chown \$(LUSER) \$(MOUNT_PT) && \\
143 chown \$(LUSER) \$(MOUNT_PT)/tools && \\
144 chown \$(LUSER) \$(MOUNT_PT)/cross-tools && \\
145 chown \$(LUSER) \$(MOUNT_PT)/sources && \\
146 touch \$@ && \\
147 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
148 echo --------------------------------------------------------------------------------\$(WHITE)
149
150026-settingenvironment: 025-addinguser
151 @\$(call echo_message, Building)
152 @if [ -f /home/\$(LUSER)/.bashrc -a ! -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
153 mv /home/\$(LUSER)/.bashrc /home/\$(LUSER)/.bashrc.XXX; \\
154 fi;
155 @if [ -f /home/\$(LUSER)/.bash_profile -a ! -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
156 mv /home/\$(LUSER)/.bash_profile /home/\$(LUSER)/.bash_profile.XXX; \\
157 fi;
158 @echo "set +h" > /home/\$(LUSER)/.bashrc && \\
159 echo "umask 022" >> /home/\$(LUSER)/.bashrc && \\
160 echo "CLFS=\$(MOUNT_PT)" >> /home/\$(LUSER)/.bashrc && \\
161 echo "LC_ALL=POSIX" >> /home/\$(LUSER)/.bashrc && \\
162 echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> /home/\$(LUSER)/.bashrc && \\
163 echo "export CLFS LC_ALL PATH" >> /home/\$(LUSER)/.bashrc && \\
164 echo "" >> /home/\$(LUSER)/.bashrc && \\
165 echo "unset CFLAGS" >> /home/\$(LUSER)/.bashrc && \\
166 echo "unset CXXFLAGS" >> /home/\$(LUSER)/.bashrc && \\
167 echo "" >> /home/\$(LUSER)/.bashrc && \\
168 echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> /home/\$(LUSER)/.bashrc && \\
169 echo "export CLFS_TARGET=\"${TARGET}\"" >> /home/\$(LUSER)/.bashrc && \\
170 echo "export CLFS_TARGET32=\"${TARGET32}\"" >> /home/\$(LUSER)/.bashrc && \\
171 echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc
172 @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\
173 touch envars && \\
174 chown -R \$(LUSER) \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
175 touch \$@ && \\
176 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
177 echo --------------------------------------------------------------------------------\$(WHITE)
178EOF
179) >> $MKFILE.tmp
180 host_prep=" 023-creatingtoolsdir 024-creatingcrossdir 026-settingenvironment"
181
182}
183
184#--------------------------------------#
185cross_tools_Makefiles() { #
186#--------------------------------------#
187 echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}"
188
189 for file in cross-tools/* ; do
190 # Keep the script file name
191 this_script=`basename $file`
192 #
193 # Skip this script...
194 case $this_script in
195 *cflags* | *variables* ) # work done in host_prep_Makefiles
196 continue; ;;
197 *) ;;
198 esac
199 #
200 # Set the dependency for the first target.
201 if [ -z $PREV ] ; then PREV=026-settingenvironment ; fi
202
203 # First append each name of the script files to a list (this will become
204 # the names of the targets in the Makefile
205 cross_tools="$cross_tools $this_script"
206
207 # Grab the name of the target (minus the -headers or -cross in the case of gcc
208 # and binutils in chapter 5)
209 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
210 -e 's@-static@@' \
211 -e 's@-final@@' \
212 -e 's@-64@@' \
213 -e 's@-n32@@'`
214 pkg_tarball=$(get_package_tarball_name $name)
215
216 #--------------------------------------------------------------------#
217 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
218 #--------------------------------------------------------------------#
219 #
220 # Drop in the name of the target on a new line, and the previous target
221 # as a dependency. Also call the echo_message function.
222 LUSER_wrt_target "${this_script}" "$PREV"
223 #
224 # If $pkg_tarball isn't empty, we've got a package...
225 #
226 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
227 #
228 LUSER_wrt_RunAsUser "${file}"
229 #
230 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
231 #
232 # Include a touch of the target name so make can check if it's already been made.
233 wrt_touch
234 #
235 #--------------------------------------------------------------------#
236 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
237 #--------------------------------------------------------------------#
238 #
239 # Keep the script file name for Makefile dependencies.
240 PREV=$this_script
241
242 done # for file in ....
243}
244
245#--------------------------------------#
246temptools_Makefiles() { #
247#--------------------------------------#
248 echo "${tab_}${GREEN}Processing... ${L_arrow}temp system ( LUSER ) ${R_arrow}"
249
250 for file in temp-system/* ; do
251 # Keep the script file name
252 this_script=`basename $file`
253 #
254 # Deal with any odd scripts..
255 case $this_script in
256 *choose) # The choose script will fail if you cannot enter the new environment
257 # If the 'boot' build method was chosen don't run the script
258 [[ $METHOD = "boot" ]] && continue; ;;
259 *) ;;
260 esac
261
262 #
263 # First append each name of the script files to a list (this will become
264 # the names of the targets in the Makefile
265 temptools="$temptools $this_script"
266
267 #
268 # Grab the name of the target, strip id number, XXX-script
269 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
270 #
271 pkg_tarball=$(get_package_tarball_name $name)
272
273 #--------------------------------------------------------------------#
274 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
275 #--------------------------------------------------------------------#
276 #
277 # Drop in the name of the target on a new line, and the previous target
278 # as a dependency. Also call the echo_message function.
279 LUSER_wrt_target "${this_script}" "$PREV"
280 #
281 # If $pkg_tarball isn't empty, we've got a package...
282 # Insert instructions for unpacking the package and to set the PKGDIR variable.
283 #
284 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
285 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
286 #
287 LUSER_wrt_RunAsUser "${file}"
288 #
289 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
290 #
291 # Include a touch of the target name so make can check if it's already been made.
292 wrt_touch
293 #
294 #--------------------------------------------------------------------#
295 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
296 #--------------------------------------------------------------------#
297 #
298 # Keep the script file name for Makefile dependencies.
299 PREV=$this_script
300 done # for file in ....
301}
302
303
304#--------------------------------------#
305chroot_Makefiles() { #
306#--------------------------------------#
307 echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools CHROOT ( CHROOT ) ${R_arrow}"
308
309 for file in chroot/* ; do
310 # Keep the script file name
311 this_script=`basename $file`
312 #
313 # Skipping scripts is done now and not included in the build tree.
314 case $this_script in
315 *chroot*) continue ;;
316 esac
317
318 #
319 # First append each name of the script files to a list (this will become
320 # the names of the targets in the Makefile
321 case "${this_script}" in
322 *util-linux) : ;;
323 *kernfs) orphan_scripts="${orphan_scripts} ${this_script}" ;;
324 *) chroottools="$chroottools $this_script" ;;
325 esac
326
327 # Grab the name of the target, strip id number, XXX-script
328 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
329
330 pkg_tarball=$(get_package_tarball_name $name)
331
332 # This is very ugly:: util-linux is in /chroot but must be run under LUSER
333 # .. Customized makefile entry
334 case "${this_script}" in
335 *util-linux)
336 LUSER_wrt_target "${this_script}" "$PREV"
337 LUSER_wrt_unpack "$pkg_tarball"
338 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
339 LUSER_wrt_RunAsUser "${file}"
340 LUSER_RemoveBuildDirs "${name}"
341 wrt_touch
342 temptools="$temptools $this_script"
343 continue ;;
344 esac
345
346
347 #--------------------------------------------------------------------#
348 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
349 #--------------------------------------------------------------------#
350 #
351 # Drop in the name of the target on a new line, and the previous target
352 # as a dependency. Also call the echo_message function.
353 CHROOT_wrt_target "${this_script}" "$PREV"
354 #
355 # If $pkg_tarball isn't empty, we've got a package...
356 # Insert instructions for unpacking the package and changing directories
357 #
358 if [ "$pkg_tarball" != "" ] ; then
359 case $this_script in
360 *util-linux) ROOT_Unpack "$pkg_tarball" ;;
361 *) CHROOT_Unpack "$pkg_tarball" ;;
362 esac
363 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
364 fi
365 #
366 # Select a script execution method
367 case $this_script in
368 *kernfs) wrt_RunAsRoot "${this_script}" "${file}" ;;
369 *util-linux) ROOT_RunAsRoot "${file}" ;;
370 *) CHROOT_wrt_RunAsRoot "${file}" ;;
371 esac
372 #
373 # Housekeeping...remove the build directory(ies), except if the package build fails.
374 [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
375 #
376 # Include a touch of the target name so make can check if it's already been made.
377 wrt_touch
378 #
379 #--------------------------------------------------------------------#
380 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
381 #--------------------------------------------------------------------#
382 #
383 # Keep the script file name for Makefile dependencies.
384 PREV=$this_script
385
386 done # for file in...
387}
388
389
390#--------------------------------------#
391boot_Makefiles() { #
392#--------------------------------------#
393
394 echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools BOOT ( LUSER ) ${R_arrow}"
395 #
396 # Create a target bootable partition containing a compile environment. Later
397 # on we boot into this environment and contine the build.
398 #
399 for file in boot/* ; do
400 # Keep the script file name
401 this_script=`basename $file`
402
403 # A little housekeeping on the scripts
404 case $this_script in
405 *grub | *aboot | *colo | *silo | *arcload | *lilo ) continue ;;
406 *whatnext*) continue ;;
407 *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
408 *kernel) # if there is no kernel config file do not build the kernel
409 [[ -z $CONFIG ]] && continue
410 # Copy the config file to /sources with a standardized name
411 cp $BOOT_CONFIG $BUILDDIR/sources/bootkernel-config
412 ;;
413 esac
414 #
415 # First append each name of the script files to a list (this will become
416 # the names of the targets in the Makefile
417 case "${this_script}" in
418 *changingowner) orphan_scripts="${orphan_scripts} ${this_script}" ;;
419 *devices) orphan_scripts="${orphan_scripts} ${this_script}" ;;
420 *) boottools="$boottools $this_script" ;;
421 esac
422 #
423 # Grab the name of the target, strip id number and misc words.
424 case $this_script in
425 *kernel) name=linux ;;
426 *bootscripts) name="bootscripts-cross-lfs" ;;
427 *udev-rules) name="udev-cross-lfs" ;;
428 *grub-build) name=grub ;;
429 *-aboot-build) name=aboot ;;
430 *yaboot-build) name=yaboot ;;
431 *colo-build) name=colo ;;
432 *silo-build) name=silo ;;
433 *arcload-build) name=arcload ;;
434 *lilo-build) name=lilo ;;
435 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
436 esac
437 # Identify the unique version naming scheme for the clfs bootscripts..(bad boys)
438 pkg_tarball=$(get_package_tarball_name $name)
439
440 #--------------------------------------------------------------------#
441 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
442 #--------------------------------------------------------------------#
443 #
444 # Drop in the name of the target on a new line, and the previous target
445 # as a dependency. Also call the echo_message function.
446 LUSER_wrt_target "${this_script}" "$PREV"
447 #
448 # If $pkg_tarball isn't empty, we've got a package...
449 # Insert instructions for unpacking the package and changing directories
450 #
451 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
452 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
453 #
454 # Select a script execution method
455 case $this_script in
456 # The following 2 scripts are defined in the /boot directory but need
457 # to be run as a root user. Set them up here but run them in another phase
458 *changingowner*) wrt_RunAsRoot "${this_script}" "${file}" ;;
459 *devices*) wrt_RunAsRoot "${this_script}" "${file}" ;;
460 *fstab*) if [[ -n "$FSTAB" ]]; then
461 LUSER_wrt_CopyFstab
462 else
463 LUSER_wrt_RunAsUser "${file}"
464 fi
465 ;;
466 *) LUSER_wrt_RunAsUser "${file}" ;;
467 esac
468 #
469 # Housekeeping...remove any build directory(ies) except if the package build fails.
470 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
471 #
472 # Include a touch of the target name so make can check if it's already been made.
473 wrt_touch
474 #
475 #--------------------------------------------------------------------#
476 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
477 #--------------------------------------------------------------------#
478 #
479 # Keep the script file name for Makefile dependencies.
480 PREV=$this_script
481
482 done
483}
484
485
486#--------------------------------------#
487chroot_testsuite_tools_Makefiles() { #
488#--------------------------------------#
489 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools ( CHROOT ) ${R_arrow}"
490
491 for file in testsuite-tools/* ; do
492 # Keep the script file name
493 this_script=`basename $file`
494
495 # First append each name of the script files to a list (this will become
496 # the names of the targets in the Makefile
497 testsuitetools="$testsuitetools $this_script"
498
499 # Grab the name of the target, strip id number, XXX-script
500 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
501 -e 's@-64bit@@' \
502 -e 's@-64@@' \
503 -e 's@64@@' \
504 -e 's@n32@@'`
505
506 pkg_tarball=$(get_package_tarball_name $name)
507
508 #--------------------------------------------------------------------#
509 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
510 #--------------------------------------------------------------------#
511 #
512 # Drop in the name of the target on a new line, and the previous target
513 # as a dependency. Also call the echo_message function.
514 CHROOT_wrt_target "${this_script}" "$PREV"
515 #
516 CHROOT_Unpack "$pkg_tarball"
517 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
518 #
519 CHROOT_wrt_RunAsRoot "${file}"
520 #
521 CHROOT_wrt_RemoveBuildDirs "${name}"
522 #
523 # Include a touch of the target name so make can check if it's already been made.
524 wrt_touch
525 #
526 #--------------------------------------------------------------------#
527 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
528 #--------------------------------------------------------------------#
529 #
530 # Keep the script file name for Makefile dependencies.
531 PREV=$this_script
532
533 done
534}
535
536#--------------------------------------#
537boot_testsuite_tools_Makefiles() { #
538#--------------------------------------#
539 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools ( ROOT ) ${R_arrow}"
540 for file in testsuite-tools/* ; do
541 # Keep the script file name
542 this_script=`basename $file`
543
544 # First append each name of the script files to a list (this will become
545 # the names of the targets in the Makefile
546 PREV=
547 testsuitetools="$testsuitetools $this_script"
548
549 # Grab the name of the target, strip id number, XXX-script
550 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
551 -e 's@-64bit@@' \
552 -e 's@-64@@' \
553 -e 's@64@@' \
554 -e 's@n32@@'`
555
556 pkg_tarball=$(get_package_tarball_name $name)
557
558 #--------------------------------------------------------------------#
559 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
560 #--------------------------------------------------------------------#
561 #
562 # Drop in the name of the target on a new line, and the previous target
563 # as a dependency. Also call the echo_message function.
564 BOOT_wrt_target "${this_script}" "$PREV"
565 #
566 BOOT_wrt_Unpack "$pkg_tarball"
567 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
568 #
569 BOOT_wrt_RunAsRoot "${this_script}" "${file}"
570 #
571 BOOT_wrt_RemoveBuildDirs "${name}"
572 #
573 # Include a touch of the target name so make can check if it's already been made.
574 wrt_touch
575 #
576 #--------------------------------------------------------------------#
577 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
578 #--------------------------------------------------------------------#
579 #
580 # Keep the script file name for Makefile dependencies.
581 PREV=$this_script
582
583 done
584
585}
586
587
588#--------------------------------------#
589chroot_final_system_Makefiles() { #
590#--------------------------------------#
591 # Set envars and scripts for iteration targets
592 LOGS="" # Start with an empty global LOGS envar
593 if [[ -z "$1" ]] ; then
594 local N=""
595 else
596 local N=-build_$1
597 local basicsystem=""
598 mkdir final-system$N
599 cp final-system/* final-system$N
600 for script in final-system$N/* ; do
601 # Overwrite existing symlinks, files, and dirs
602 sed -e 's/ln -sv/&f/g' \
603 -e 's/mv -v/&f/g' \
604 -e 's/mkdir -v/&p/g' -i ${script}
605 done
606 # Remove Bzip2 binaries before make install
607 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2
608 # Delete *old Readline libraries just after make install
609 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline
610 fi
611
612 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system$N ( CHROOT ) ${R_arrow}"
613
614 for file in final-system$N/* ; do
615 # Keep the script file name
616 this_script=`basename $file`
617
618 # Test if the stripping phase must be skipped.
619 # Skip alsp temp-perl for iterative runs
620 case $this_script in
621 *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
622 *temp-perl*) [[ -n "$N" ]] && continue ;;
623 esac
624
625 # Grab the name of the target, strip id number, XXX-script
626 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
627 -e 's@temp-@@' \
628 -e 's@-64bit@@' \
629 -e 's@-64@@' \
630 -e 's@64@@' \
631 -e 's@n32@@'`
632
633 # Find the version of the command files, if it corresponds with the building of
634 # a specific package. We need this here to can skip scripts not needed for
635 # iterations rebuilds
636 pkg_tarball=$(get_package_tarball_name $name)
637
638 if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
639 case "${this_script}" in
640 *stripping*) ;;
641 *) continue ;;
642 esac
643 fi
644
645 # Append each name of the script files to a list (this will become
646 # the names of the targets in the Makefile
647 basicsystem="$basicsystem ${this_script}${N}"
648
649 # Append each name of the script files to a list (this will become
650 # the names of the logs to be moved for each iteration)
651 LOGS="$LOGS ${this_script}"
652
653 #--------------------------------------------------------------------#
654 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
655 #--------------------------------------------------------------------#
656 #
657 # Drop in the name of the target on a new line, and the previous target
658 # as a dependency. Also call the echo_message function.
659 CHROOT_wrt_target "${this_script}${N}" "$PREV"
660
661 # If $pkg_tarball isn't empty, we've got a package...
662 if [ "$pkg_tarball" != "" ] ; then
663 CHROOT_Unpack "$pkg_tarball"
664 # If the testsuites must be run, initialize the log file
665 case $name in
666 binutils | gcc | glibc )
667 [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
668 ;;
669 * )
670 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
671 ;;
672 esac
673 # If using optimizations, write the instructions
674 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
675 fi
676 #
677 CHROOT_wrt_RunAsRoot "${file}"
678 #
679 [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
680 #
681 # Include a touch of the target name so make can check if it's already been made.
682 wrt_touch
683 #
684 #--------------------------------------------------------------------#
685 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
686 #--------------------------------------------------------------------#
687 #
688 # Keep the script file name for Makefile dependencies.
689 PREV=${this_script}${N}
690 # Set system_build envar for iteration targets
691 system_build=$basicsystem
692 done # for file in final-system/* ...
693}
694
695#--------------------------------------#
696boot_final_system_Makefiles() { #
697#--------------------------------------#
698 # Set envars and scripts for iteration targets
699 LOGS="" # Start with an empty global LOGS envar
700 if [[ -z "$1" ]] ; then
701 local N=""
702 # The makesys phase was initiated in bm_testsuite_tools_makefile
703 [[ "$TEST" = 0 ]] && PREV=""
704 else
705 local N=-build_$1
706 local basicsystem=""
707 mkdir final-system$N
708 cp final-system/* final-system$N
709 for script in final-system$N/* ; do
710 # Overwrite existing symlinks, files, and dirs
711 sed -e 's/ln -sv/&f/g' \
712 -e 's/mv -v/&f/g' \
713 -e 's/mkdir -v/&p/g' -i ${script}
714 done
715 # Remove Bzip2 binaries before make install
716 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2
717 # Delete *old Readline libraries just after make install
718 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline
719 fi
720
721 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system$N ( ROOT ) ${R_arrow}"
722
723 for file in final-system$N/* ; do
724 # Keep the script file name
725 this_script=`basename $file`
726
727 # Test if the stripping phase must be skipped
728 # Skip alsp temp-perl for iterative runs
729 case $this_script in
730 *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
731 *temp-perl*) [[ -n "$N" ]] && continue ;;
732 esac
733
734 # Grab the name of the target, strip id number, XXX-script
735 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
736 -e 's@temp-@@' \
737 -e 's@-64bit@@' \
738 -e 's@-64@@' \
739 -e 's@64@@' \
740 -e 's@n32@@'`
741
742 # Find the version of the command files, if it corresponds with the building of
743 # a specific package. We need this here to can skip scripts not needed for
744 # iterations rebuilds
745
746 pkg_tarball=$(get_package_tarball_name $name)
747
748 if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
749 case "${this_script}" in
750 *stripping*) ;;
751 *) continue ;;
752 esac
753 fi
754
755 # Append each name of the script files to a list (this will become
756 # the names of the targets in the Makefile
757 basicsystem="$basicsystem ${this_script}${N}"
758
759 # Append each name of the script files to a list (this will become
760 # the names of the logs to be moved for each iteration)
761 LOGS="$LOGS ${this_script}"
762
763 #--------------------------------------------------------------------#
764 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
765 #--------------------------------------------------------------------#
766 #
767 # Drop in the name of the target on a new line, and the previous target
768 # as a dependency. Also call the echo_message function.
769 BOOT_wrt_target "${this_script}${N}" "$PREV"
770
771 # If $pkg_tarball isn't empty, we've got a package...
772 if [ "$pkg_tarball" != "" ] ; then
773 FILE="$pkg_tarball"
774 BOOT_wrt_Unpack "$FILE"
775 # If the testsuites must be run, initialize the log file
776 case $name in
777 binutils | gcc | glibc )
778 [[ "$TEST" != "0" ]] && BOOT_wrt_test_log "${this_script}"
779 ;;
780 * )
781 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && BOOT_wrt_test_log "${this_script}"
782 ;;
783 esac
784 # If using optimizations, write the instructions
785 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
786 fi
787 #
788 BOOT_wrt_RunAsRoot "${this_script}" "${file}"
789 #
790 [[ "$pkg_tarball" != "" ]] && BOOT_wrt_RemoveBuildDirs "${name}"
791 #
792 # Include a touch of the target name so make can check if it's already been made.
793 wrt_touch
794 #
795 #--------------------------------------------------------------------#
796 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
797 #--------------------------------------------------------------------#
798 #
799 # Keep the script file name for Makefile dependencies.
800 PREV=${this_script}${N}
801 # Set system_build envar for iteration targets
802 system_build=$basicsystem
803 done # for file in final-system/* ...
804
805}
806
807#--------------------------------------#
808chroot_bootscripts_Makefiles() { #
809#--------------------------------------#
810 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts ( CHROOT ) ${R_arrow}"
811
812 for file in bootscripts/* ; do
813 # Keep the script file name
814 this_script=`basename $file`
815
816 case $this_script in
817 *udev) continue ;; # This is not a script but a commentary, we want udev-rules
818 *console*) continue ;; # Use the files that came with the bootscripts
819 *) ;;
820 esac
821
822 # First append each name of the script files to a list (this will become
823 # the names of the targets in the Makefile
824 bootscripttools="$bootscripttools $this_script"
825
826 # Grab the name of the target, strip id number, XXX-script
827 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
828 -e 's@-64bit@@' \
829 -e 's@-64@@' \
830 -e 's@64@@' \
831 -e 's@n32@@'`
832 case $name in
833 *bootscripts*) name=bootscripts-cross-lfs ;;
834 *udev-rules) name=udev-cross-lfs ;;
835 esac
836
837 pkg_tarball=$(get_package_tarball_name $name)
838
839 #--------------------------------------------------------------------#
840 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
841 #--------------------------------------------------------------------#
842 #
843 # Drop in the name of the target on a new line, and the previous target
844 # as a dependency. Also call the echo_message function.
845 CHROOT_wrt_target "${this_script}" "$PREV"
846 #
847 # If $pkg_tarball isn't empty, we've got a package...
848 #
849 [[ "$pkg_tarball" != "" ]] && CHROOT_Unpack "$pkg_tarball"
850 #
851 CHROOT_wrt_RunAsRoot "${file}"
852 #
853 [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
854 #
855 # Include a touch of the target name so make can check if it's already been made.
856 wrt_touch
857 #
858 #--------------------------------------------------------------------#
859 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
860 #--------------------------------------------------------------------#
861 #
862 # Keep the script file name for Makefile dependencies.
863 PREV=$this_script
864
865 done # for file in bootscripts/* ...
866}
867
868#--------------------------------------#
869boot_bootscripts_Makefiles() { #
870#--------------------------------------#
871 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts ( ROOT ) ${R_arrow}"
872
873 for file in bootscripts/* ; do
874 # Keep the script file name
875 this_script=`basename $file`
876
877 case $this_script in
878 *udev) continue ;; # This is not a script but a commentary
879 *console*) continue ;; # Use the files that came with the bootscripts
880 *) ;;
881 esac
882
883 # First append each name of the script files to a list (this will become
884 # the names of the targets in the Makefile
885 bootscripttools="$bootscripttools $this_script"
886
887 # Grab the name of the target, strip id number, XXX-script
888 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
889 -e 's@-64bit@@' \
890 -e 's@-64@@' \
891 -e 's@64@@' \
892 -e 's@n32@@'`
893 case $name in
894 *bootscripts*) name=bootscripts-cross-lfs ;;
895 *udev-rules) name=udev-cross-lfs ;;
896 esac
897
898 pkg_tarball=$(get_package_tarball_name $name)
899
900 #--------------------------------------------------------------------#
901 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
902 #--------------------------------------------------------------------#
903 #
904 # Drop in the name of the target on a new line, and the previous target
905 # as a dependency. Also call the echo_message function.
906 BOOT_wrt_target "${this_script}" "$PREV"
907 #
908 # If $pkg_tarball isn't empty, we've got a package...
909 #
910 [[ "$pkg_tarball" != "" ]] && BOOT_wrt_Unpack "$pkg_tarball"
911 #
912 BOOT_wrt_RunAsRoot "${this_script}" "${file}"
913 #
914 [[ "$pkg_tarball" != "" ]] && BOOT_wrt_RemoveBuildDirs "${name}"
915 #
916 # Include a touch of the target name so make can check if it's already been made.
917 wrt_touch
918 #
919 #--------------------------------------------------------------------#
920 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
921 #--------------------------------------------------------------------#
922 #
923 # Keep the script file name for Makefile dependencies.
924 PREV=$this_script
925
926 done # for file in bootscripts/* ...
927}
928
929#--------------------------------------#
930chroot_bootable_Makefiles() { #
931#--------------------------------------#
932 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable ( CHROOT ) ${R_arrow}"
933
934 for file in {bootable,the-end}/* ; do
935 # Keep the script file name
936 this_script=`basename $file`
937
938 # A little housekeeping on the scripts
939 case $this_script in
940 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
941 *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
942 *kernel) # if there is no kernel config file do not build the kernel
943 [[ -z $CONFIG ]] && continue
944 # Copy the config file to /sources with a standardized name
945 cp $CONFIG $BUILDDIR/sources/kernel-config
946 ;;
947 esac
948 #
949 # First append each name of the script files to a list (this will become
950 # the names of the targets in the Makefile
951 bootabletools="$bootabletools $this_script"
952 #
953 # Grab the name of the target, strip id number and misc words.
954 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
955 case $this_script in
956 *kernel*) name=linux
957 ;;
958 esac
959
960 pkg_tarball=$(get_package_tarball_name $name)
961
962 #--------------------------------------------------------------------#
963 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
964 #--------------------------------------------------------------------#
965 #
966 # Drop in the name of the target on a new line, and the previous target
967 # as a dependency. Also call the echo_message function.
968 CHROOT_wrt_target "${this_script}" "$PREV"
969 #
970 # If $pkg_tarball isn't empty, we've got a package...
971 # Insert instructions for unpacking the package and changing directories
972 #
973 [[ "$pkg_tarball" != "" ]] && CHROOT_Unpack "$pkg_tarball"
974 #
975 # Select a script execution method
976 case $this_script in
977 *fstab*) if [[ -n "$FSTAB" ]]; then
978 CHROOT_wrt_CopyFstab
979 else
980 CHROOT_wrt_RunAsRoot "${file}"
981 fi
982 ;;
983 *) CHROOT_wrt_RunAsRoot "${file}"
984 ;;
985 esac
986 #
987 # Housekeeping...remove any build directory(ies) except if the package build fails.
988 [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
989 #
990 # Include a touch of the target name so make can check if it's already been made.
991 wrt_touch
992 #
993 #--------------------------------------------------------------------#
994 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
995 #--------------------------------------------------------------------#
996 #
997 # Keep the script file name for Makefile dependencies.
998 PREV=$this_script
999
1000 done
1001
1002 # Add SBU-disk_usage report target if required
1003 if [[ "$REPORT" = "y" ]] ; then wrt_report ; fi
1004
1005}
1006
1007#--------------------------------------#
1008boot_bootable_Makefiles() { #
1009#--------------------------------------#
1010 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable ( ROOT ) ${R_arrow}"
1011
1012 for file in {bootable,the-end}/* ; do
1013 # Keep the script file name
1014 this_script=`basename $file`
1015
1016 # A little housekeeping on the scripts
1017 case $this_script in
1018 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
1019 *kernel) # if there is no kernel config file do not build the kernel
1020 [[ -z $CONFIG ]] && continue
1021 # Copy the named config file to /sources with a standardized name
1022 cp $CONFIG $BUILDDIR/sources/kernel-config
1023 ;;
1024 esac
1025 #
1026 # First append each name of the script files to a list (this will become
1027 # the names of the targets in the Makefile
1028 bootabletools="$bootabletools $this_script"
1029 #
1030 # Grab the name of the target, strip id number and misc words.
1031 case $this_script in
1032 *kernel) name=linux ;;
1033 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
1034 esac
1035
1036 pkg_tarball=$(get_package_tarball_name $name)
1037
1038 #--------------------------------------------------------------------#
1039 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
1040 #--------------------------------------------------------------------#
1041 #
1042 # Drop in the name of the target on a new line, and the previous target
1043 # as a dependency. Also call the echo_message function.
1044 BOOT_wrt_target "${this_script}" "$PREV"
1045 #
1046 # If $pkg_tarball isn't empty, we've got a package...
1047 # Insert instructions for unpacking the package and changing directories
1048 #
1049 [[ "$pkg_tarball" != "" ]] && BOOT_wrt_Unpack "$pkg_tarball"
1050 #
1051 # Select a script execution method
1052 case $this_script in
1053 *fstab*) if [[ -n "$FSTAB" ]]; then
1054 # Minimal boot mode has no access to original file, store in /sources
1055 cp $FSTAB $BUILDDIR/sources/fstab
1056 BOOT_wrt_CopyFstab "${this_script}"
1057 else
1058 BOOT_wrt_RunAsRoot "${this_script}" "${file}"
1059 fi
1060 ;;
1061 *) BOOT_wrt_RunAsRoot "${this_script}" "${file}" ;;
1062 esac
1063 #
1064 # Housekeeping...remove any build directory(ies) except if the package build fails.
1065 [[ "$pkg_tarball" != "" ]] && BOOT_wrt_RemoveBuildDirs "${name}"
1066 #
1067 # Include a touch of the target name so make can check if it's already been made.
1068 wrt_touch
1069 #
1070 #--------------------------------------------------------------------#
1071 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
1072 #--------------------------------------------------------------------#
1073 #
1074 # Keep the script file name for Makefile dependencies.
1075 PREV=$this_script
1076 done
1077
1078 # Add SBU-disk_usage report target if required
1079 if [[ "$REPORT" = "y" ]] ; then wrt_report ; fi
1080
1081
1082}
1083
1084
1085#--------------------------------------#
1086build_Makefile() { # Construct a Makefile from the book scripts
1087#--------------------------------------#
1088 #
1089 # Script crashes if error trapping is on
1090 #
1091set +e
1092 declare -f method_cmds
1093 declare -f testsuite_cmds
1094 declare -f final_sys_cmds
1095 declare -f bootscripts_cmds
1096 declare -f bootable_cmds
1097set -e
1098
1099 echo "...Creating Makefile... ${BOLD}START${OFF}"
1100
1101 cd $JHALFSDIR/${PROGNAME}-commands
1102 # Start with a clean files
1103 >$MKFILE
1104 >$MKFILE.tmp
1105
1106 method_cmds=${METHOD}_Makefiles
1107 testsuite_cmds=${METHOD}_testsuite_tools_Makefiles
1108 final_sys_cmds=${METHOD}_final_system_Makefiles
1109 bootscripts_cmds=${METHOD}_bootscripts_Makefiles
1110 bootable_cmds=${METHOD}_bootable_Makefiles
1111
1112 host_prep_Makefiles # mk_SETUP (SETUP) $host_prep
1113 cross_tools_Makefiles # mk_CROSS (LUSER) $cross_tools
1114 temptools_Makefiles # mk_TEMP (LUSER) $temptools
1115 $method_cmds # mk_SYSTOOLS (CHROOT) $chroottools/$boottools
1116 if [[ ! $TEST = "0" ]]; then
1117 $testsuite_cmds # mk_SYSTOOLS (CHROOT) $testsuitetools
1118 fi
1119 $final_sys_cmds # mk_FINAL (CHROOT) $basicsystem
1120 # Add the iterations targets, if needed
1121 [[ "$COMPARE" = "y" ]] && wrt_compare_targets
1122 $bootscripts_cmds # mk_BOOTSCRIPT (CHROOT) $bootscripttools
1123 $bootable_cmds # mk_BOOTABLE (CHROOT) $bootabletools
1124
1125 # Add a header, some variables and include the function file
1126 # to the top of the real Makefile.
1127(
1128 cat << EOF
1129$HEADER
1130
1131SRC = /sources
1132MOUNT_PT = $BUILDDIR
1133PKG_LST = $PKG_LST
1134LUSER = $LUSER
1135LGROUP = $LGROUP
1136SCRIPT_ROOT = $SCRIPT_ROOT
1137
1138BASEDIR = \$(MOUNT_PT)
1139SRCSDIR = \$(BASEDIR)/sources
1140CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$PROGNAME-commands
1141LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/logs
1142TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/test-logs
1143
1144crSRCSDIR = /sources
1145crCMDSDIR = /\$(SCRIPT_ROOT)/$PROGNAME-commands
1146crLOGDIR = /\$(SCRIPT_ROOT)/logs
1147crTESTLOGDIR = /\$(SCRIPT_ROOT)/test-logs
1148
1149SU_LUSER = su - \$(LUSER) -c
1150LUSER_HOME = /home/\$(LUSER)
1151PRT_DU = echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n"
1152PRT_DU_CR = echo -e "\nKB: \`du -skx --exclude=\$(SCRIPT_ROOT) / \`\n"
1153
1154include makefile-functions
1155
1156EOF
1157) > $MKFILE
1158
1159 # Add chroot commands
1160 if [ "$METHOD" = "chroot" ] ; then
1161 CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
1162 chroot=`cat chroot/*chroot* | \
1163 sed -e "s@chroot@$CHROOT_LOC@" \
1164 -e '/#!\/tools\/bin\/bash/d' \
1165 -e '/^export/d' \
1166 -e '/^logout/d' \
1167 -e 's@ \\\@ @g' | \
1168 tr -d '\n' | \
1169 sed -e 's/ */ /g' \
1170 -e 's|\\$|&&|g' \
1171 -e 's|exit||g' \
1172 -e 's|$| -c|' \
1173 -e 's|"$$CLFS"|$(MOUNT_PT)|'\
1174 -e 's|set -e||'`
1175 echo -e "CHROOT1= $chroot\n" >> $MKFILE
1176 fi
1177
1178################## CHROOT ####################
1179
1180if [[ "${METHOD}" = "chroot" ]]; then
1181(
1182cat << EOF
1183
1184all: mk_SETUP mk_CROSS mk_TEMP restore_luser_env mk_SYSTOOLS mk_FINAL mk_BOOTSCRIPT mk_BOOTABLE do-housekeeping
1185 @\$(call echo_finished,$VERSION)
1186
1187#---------------AS ROOT
1188mk_SETUP:
1189 @\$(call echo_SU_request)
1190 @sudo make SETUP
1191 @touch \$@
1192
1193#---------------AS LUSER
1194mk_CROSS: mk_SETUP
1195 @\$(call echo_PHASE,Cross Tool)
1196 @( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make CROSS" )
1197 @touch \$@
1198
1199mk_TEMP: mk_CROSS
1200 @\$(call echo_PHASE,Temporary Tools)
1201 @( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make TEMP" )
1202 @touch \$@
1203
1204#
1205# The convoluted piece of code below is necessary to provide 'make' with a valid shell in the
1206# chroot environment. (Unless someone knows a different way)
1207# Manually create the /bin directory and provide link to the /tools dir.
1208# Also change the original symlink creation to include (f)orce to prevent failure due to
1209# pre-existing links.
1210
1211#---------------CHROOT JAIL
1212mk_SYSTOOLS: mk_TEMP $orphan_scripts
1213 @mkdir \$(MOUNT_PT)/bin && \\
1214 cd \$(MOUNT_PT)/bin && \\
1215 ln -sf /tools/bin/bash bash; ln -sf bash sh
1216 @sed -e 's|^ln -sv|ln -svf|' -i \$(CMDSDIR)/chroot/082-createfiles
1217 @\$(call echo_CHROOT_request)
1218 @\$(call echo_PHASE, Chroot systools)
1219 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make SYSTOOLS")
1220 @touch \$@
1221
1222mk_FINAL: mk_SYSTOOLS
1223 @\$(call echo_PHASE,Final System)
1224 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make FINAL")
1225 @touch \$@
1226
1227mk_BOOTSCRIPT: mk_FINAL
1228 @\$(call echo_PHASE,Bootscript)
1229 @\$(call echo_CHROOT_request)
1230 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BOOTSCRIPT")
1231 @touch \$@
1232
1233mk_BOOTABLE: mk_BOOTSCRIPT
1234 @\$(call echo_PHASE, Make bootable )
1235 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BOOTABLE")
1236 @touch \$@
1237
1238EOF
1239) >> $MKFILE
1240fi
1241
1242################### BOOT #####################
1243
1244if [[ "${METHOD}" = "boot" ]]; then
1245(
1246cat << EOF
1247
1248all: mk_SETUP mk_CROSS mk_TEMP mk_SYSTOOLS $orphan_scripts restore-luser-env
1249 @\$(call echo_boot_finished,$VERSION)
1250
1251makesys: mk_FINAL mk_BOOTSCRIPT mk_BOOTABLE
1252 @\$(call echo_finished,$VERSION)
1253
1254#---------------AS ROOT
1255
1256mk_SETUP:
1257 @\$(call echo_SU_request)
1258 @sudo make SETUP
1259 @touch \$@
1260
1261#---------------AS LUSER
1262
1263mk_CROSS: mk_SETUP
1264 @\$(call echo_PHASE,Cross Tool)
1265 @( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make CROSS" )
1266 @touch \$@
1267
1268mk_TEMP: mk_CROSS
1269 @\$(call echo_PHASE,Temporary Tools)
1270 @( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make TEMP" )
1271 @touch \$@
1272
1273mk_SYSTOOLS: mk_TEMP
1274 @\$(call echo_PHASE,Minimal Boot system)
1275 @( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make SYSTOOLS" )
1276 @touch \$@
1277
1278#---------------AS ROOT
1279
1280mk_FINAL:
1281 @\$(call echo_PHASE,Final System)
1282 @( make FINAL )
1283 @touch \$@
1284
1285mk_BOOTSCRIPT: mk_FINAL
1286 @\$(call echo_PHASE,Bootscript)
1287 @( make BOOTSCRIPT )
1288 @touch \$@
1289
1290mk_BOOTABLE: mk_BOOTSCRIPT
1291 @\$(call echo_PHASE,Making Bootable)
1292 @( make BOOTABLE )
1293 @touch \$@
1294
1295EOF
1296) >> $MKFILE
1297fi
1298
1299(
1300 cat << EOF
1301
1302SETUP: $host_prep
1303CROSS: $cross_tools
1304TEMP: $temptools
1305SYSTOOLS: ${chroottools}${boottools}
1306FINAL: $testsuitetools $basicsystem
1307BOOTSCRIPT: $bootscripttools
1308BOOTABLE: $bootabletools
1309
1310restart:
1311 @echo "This feature does not exist for the CLFS makefile. (yet)"
1312
1313restore-luser-env:
1314 @\$(call echo_message, Building)
1315 @if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
1316 mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
1317 fi;
1318 @if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
1319 mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
1320 fi;
1321 @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
1322 touch \$@ && \\
1323 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
1324 echo --------------------------------------------------------------------------------\$(WHITE)
1325
1326do-housekeeping:
1327 @-umount \$(MOUNT_PT)/dev/pts
1328 @-umount \$(MOUNT_PT)/dev/shm
1329 @-umount \$(MOUNT_PT)/dev
1330 @-umount \$(MOUNT_PT)/sys
1331 @-umount \$(MOUNT_PT)/proc
1332 @-if [ ! -f luser-exist ]; then \\
1333 userdel \$(LUSER); \\
1334 rm -rf /home/\$(LUSER); \\
1335 fi;
1336
1337########################################################
1338
1339
1340EOF
1341) >> $MKFILE
1342
1343 # Bring over the items from the Makefile.tmp
1344 cat $MKFILE.tmp >> $MKFILE
1345 rm $MKFILE.tmp
1346
1347 echo "Creating Makefile... ${BOLD}DONE${OFF}"
1348}
Note: See TracBrowser for help on using the repository browser.