source: CLFS/master.sh@ 8f2c086

2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 8f2c086 was 8f2c086, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Functions clean-up.

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