source: CLFS/master.sh@ d66cbc2

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

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

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