source: CLFS/master.sh@ 47b363c

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

master.sh files don't need be executables.
Fixed chroot commands extraction.

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