source: CLFS/master.sh@ 97b041f

2.3 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 97b041f was f940c29, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

CLFS: In the boot method skip *introduction run. The $MOUNT_PT write permission issue is already handled in 026-settingenvironment.

  • Property mode set to 100644
File size: 34.7 KB
Line 
1#!/bin/bash
2# $Id$
3
4
5orphan_scripts="" # 2 scripts do not fit BOOT_Makefiles LUSER environment
6
7
8#--------------------------------------#
9host_prep_Makefiles() { #
10#--------------------------------------#
11 local CLFS_HOST
12
13 echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}"
14
15 # defined here, only for ease of reading
16 CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
17(
18cat << EOF
19023-creatingtoolsdir:
20 @\$(call echo_message, Building)
21 @mkdir \$(MOUNT_PT)/tools && \\
22 rm -f /tools && \\
23 ln -s \$(MOUNT_PT)/tools /
24 @\$(call housekeeping)
25
26024-creatingcrossdir: 023-creatingtoolsdir
27 @\$(call echo_message, Building)
28 @mkdir -v \$(MOUNT_PT)/cross-tools && \\
29 rm -f /cross-tools && \\
30 ln -s \$(MOUNT_PT)/cross-tools /
31 @\$(call housekeeping)
32
33025-addinguser: 024-creatingcrossdir
34 @\$(call echo_message, Building)
35 @if [ ! -d \$(LUSER_HOME) ]; then \\
36 groupadd \$(LGROUP); \\
37 useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
38 else \\
39 touch luser-exist; \\
40 fi;
41 @chown \$(LUSER) \$(MOUNT_PT)/tools && \\
42 chown \$(LUSER) \$(MOUNT_PT)/cross-tools && \\
43 chmod -R a+wt \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
44 chmod a+wt \$(SRCSDIR)
45 @\$(call housekeeping)
46
47026-settingenvironment: 025-addinguser
48 @\$(call echo_message, Building)
49 @if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
50 mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
51 fi;
52 @if [ -f \$(LUSER_HOME)/.bash_profile -a ! -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
53 mv \$(LUSER_HOME)/.bash_profile \$(LUSER_HOME)/.bash_profile.XXX; \\
54 fi;
55 @echo "set +h" > \$(LUSER_HOME)/.bashrc && \\
56 echo "umask 022" >> \$(LUSER_HOME)/.bashrc && \\
57 echo "CLFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\
58 echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
59 echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
60 echo "export CLFS LC_ALL PATH" >> \$(LUSER_HOME)/.bashrc && \\
61 echo "" >> \$(LUSER_HOME)/.bashrc && \\
62 echo "unset CFLAGS" >> \$(LUSER_HOME)/.bashrc && \\
63 echo "unset CXXFLAGS" >> \$(LUSER_HOME)/.bashrc && \\
64 echo "" >> \$(LUSER_HOME)/.bashrc && \\
65 echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> \$(LUSER_HOME)/.bashrc && \\
66 echo "export CLFS_TARGET=\"${TARGET}\"" >> \$(LUSER_HOME)/.bashrc && \\
67 echo "export CLFS_TARGET32=\"${TARGET32}\"" >> \$(LUSER_HOME)/.bashrc && \\
68 echo "source $JHALFSDIR/envars" >> \$(LUSER_HOME)/.bashrc
69 @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc && \\
70 touch envars && \\
71 chmod -R a+wt \$(MOUNT_PT) && \\
72 chown -R \$(LUSER) \$(MOUNT_PT)/\$(SCRIPT_ROOT)
73 @\$(call housekeeping)
74EOF
75) >> $MKFILE.tmp
76 host_prep=" 023-creatingtoolsdir 024-creatingcrossdir 026-settingenvironment"
77
78}
79
80#--------------------------------------#
81cross_tools_Makefiles() { #
82#--------------------------------------#
83 echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}"
84
85 for file in cross-tools/* ; do
86 # Keep the script file name
87 this_script=`basename $file`
88 #
89 # Skip this script...
90 case $this_script in
91 *cflags* | *variables* ) # work done in host_prep_Makefiles
92 continue; ;;
93 *) ;;
94 esac
95 #
96 # Set the dependency for the first target.
97 if [ -z $PREV ] ; then PREV=026-settingenvironment ; fi
98
99 # First append each name of the script files to a list (this will become
100 # the names of the targets in the Makefile
101 cross_tools="$cross_tools $this_script"
102
103 # Grab the name of the target (minus the -headers or -cross in the case of gcc
104 # and binutils in chapter 5)
105 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
106 -e 's@-static@@' \
107 -e 's@-final@@' \
108 -e 's@-64@@' \
109 -e 's@-n32@@'`
110 pkg_tarball=$(get_package_tarball_name $name)
111
112 #--------------------------------------------------------------------#
113 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
114 #--------------------------------------------------------------------#
115 #
116 # Drop in the name of the target on a new line, and the previous target
117 # as a dependency. Also call the echo_message function.
118 LUSER_wrt_target "${this_script}" "$PREV"
119 #
120 # If $pkg_tarball isn't empty, we've got a package...
121 #
122 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
123 #
124 LUSER_wrt_RunAsUser "${file}"
125 #
126 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
127 #
128 # Include a touch of the target name so make can check if it's already been made.
129 wrt_touch
130 #
131 #--------------------------------------------------------------------#
132 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
133 #--------------------------------------------------------------------#
134 #
135 # Keep the script file name for Makefile dependencies.
136 PREV=$this_script
137
138 done # for file in ....
139}
140
141#--------------------------------------#
142temptools_Makefiles() { #
143#--------------------------------------#
144 echo "${tab_}${GREEN}Processing... ${L_arrow}temp system ( LUSER ) ${R_arrow}"
145
146 for file in temp-system/* ; do
147 # Keep the script file name
148 this_script=`basename $file`
149 #
150 # Deal with any odd scripts..
151 case $this_script in
152 *choose) # The choose script will fail if you cannot enter the new environment
153 # If the 'boot' build method was chosen don't run the script
154 [[ $METHOD = "boot" ]] && continue; ;;
155 *) ;;
156 esac
157
158 #
159 # First append each name of the script files to a list (this will become
160 # the names of the targets in the Makefile
161 temptools="$temptools $this_script"
162
163 #
164 # Grab the name of the target, strip id number, XXX-script
165 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
166 #
167 pkg_tarball=$(get_package_tarball_name $name)
168
169 #--------------------------------------------------------------------#
170 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
171 #--------------------------------------------------------------------#
172 #
173 # Drop in the name of the target on a new line, and the previous target
174 # as a dependency. Also call the echo_message function.
175 LUSER_wrt_target "${this_script}" "$PREV"
176 #
177 # If $pkg_tarball isn't empty, we've got a package...
178 # Insert instructions for unpacking the package and to set the PKGDIR variable.
179 #
180 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
181 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
182 #
183 LUSER_wrt_RunAsUser "${file}"
184 #
185 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
186 #
187 # Include a touch of the target name so make can check if it's already been made.
188 wrt_touch
189 #
190 #--------------------------------------------------------------------#
191 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
192 #--------------------------------------------------------------------#
193 #
194 # Keep the script file name for Makefile dependencies.
195 PREV=$this_script
196 done # for file in ....
197}
198
199
200#--------------------------------------#
201chroot_Makefiles() { #
202#--------------------------------------#
203 echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools CHROOT ( CHROOT ) ${R_arrow}"
204
205 for file in chroot/* ; do
206 # Keep the script file name
207 this_script=`basename $file`
208 #
209 # Skipping scripts is done now and not included in the build tree.
210 case $this_script in
211 *chroot*) continue ;;
212 esac
213
214 #
215 # First append each name of the script files to a list (this will become
216 # the names of the targets in the Makefile
217 case "${this_script}" in
218 *kernfs) orphan_scripts="${orphan_scripts} ${this_script}" ;;
219 *) chroottools="$chroottools $this_script" ;;
220 esac
221
222 # Grab the name of the target, strip id number, XXX-script
223 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
224
225 pkg_tarball=$(get_package_tarball_name $name)
226
227 # This is very ugly:: util-linux is in /chroot but must be run under LUSER
228 # .. Customized makefile entry
229 case "${this_script}" in
230 *util-linux)
231 LUSER_wrt_target "${this_script}" "$PREV"
232 LUSER_wrt_unpack "$pkg_tarball"
233 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
234 LUSER_wrt_RunAsUser "${file}"
235 LUSER_RemoveBuildDirs "${name}"
236 wrt_touch
237 temptools="$temptools $this_script"
238 continue ;;
239 esac
240
241
242 #--------------------------------------------------------------------#
243 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
244 #--------------------------------------------------------------------#
245 #
246 # Drop in the name of the target on a new line, and the previous target
247 # as a dependency. Also call the echo_message function.
248 CHROOT_wrt_target "${this_script}" "$PREV"
249 #
250 # If $pkg_tarball isn't empty, we've got a package...
251 # Insert instructions for unpacking the package and changing directories
252 #
253 if [ "$pkg_tarball" != "" ] ; then
254 CHROOT_Unpack "$pkg_tarball"
255 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
256 fi
257 #
258 # Select a script execution method
259 case $this_script in
260 *kernfs) wrt_RunAsRoot "${file}" ;;
261 *) CHROOT_wrt_RunAsRoot "${file}" ;;
262 esac
263 #
264 # Housekeeping...remove the build directory(ies), except if the package build fails.
265 [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
266 #
267 # Include a touch of the target name so make can check if it's already been made.
268 wrt_touch
269 #
270 #--------------------------------------------------------------------#
271 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
272 #--------------------------------------------------------------------#
273 #
274 # Keep the script file name for Makefile dependencies.
275 PREV=$this_script
276
277 done # for file in...
278}
279
280
281#--------------------------------------#
282boot_Makefiles() { #
283#--------------------------------------#
284
285 echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools BOOT ( LUSER ) ${R_arrow}"
286 #
287 # Create a target bootable partition containing a compile environment. Later
288 # on we boot into this environment and contine the build.
289 #
290 for file in boot/* ; do
291 # Keep the script file name
292 this_script=`basename $file`
293
294 # A little housekeeping on the scripts
295 case $this_script in
296 *grub | *aboot | *colo | *silo | *arcload | *lilo | *introduction ) continue ;;
297 *whatnext*) continue ;;
298 *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
299 *kernel) # if there is no kernel config file do not build the kernel
300 [[ -z $CONFIG ]] && continue
301 # Copy the config file to /sources with a standardized name
302 cp $BOOT_CONFIG $BUILDDIR/sources/bootkernel-config
303 ;;
304 esac
305 #
306 # First append each name of the script files to a list (this will become
307 # the names of the targets in the Makefile
308 case "${this_script}" in
309 *changingowner) orphan_scripts="${orphan_scripts} ${this_script}" ;;
310 *devices) orphan_scripts="${orphan_scripts} ${this_script}" ;;
311 *) boottools="$boottools $this_script" ;;
312 esac
313 #
314 # Grab the name of the target, strip id number and misc words.
315 case $this_script in
316 *kernel) name=linux ;;
317 *bootscripts) name="bootscripts-cross-lfs" ;;
318 *udev-rules) name="udev-cross-lfs" ;;
319 *grub-build) name=grub ;;
320 *-aboot-build) name=aboot ;;
321 *yaboot-build) name=yaboot ;;
322 *colo-build) name=colo ;;
323 *silo-build) name=silo ;;
324 *arcload-build) name=arcload ;;
325 *lilo-build) name=lilo ;;
326 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
327 esac
328 # Identify the unique version naming scheme for the clfs bootscripts..(bad boys)
329 pkg_tarball=$(get_package_tarball_name $name)
330
331 #--------------------------------------------------------------------#
332 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
333 #--------------------------------------------------------------------#
334 #
335 # Drop in the name of the target on a new line, and the previous target
336 # as a dependency. Also call the echo_message function.
337 LUSER_wrt_target "${this_script}" "$PREV"
338 #
339 # If $pkg_tarball isn't empty, we've got a package...
340 # Insert instructions for unpacking the package and changing directories
341 #
342 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
343 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
344 #
345 # Select a script execution method
346 case $this_script in
347 # The following 2 scripts are defined in the /boot directory but need
348 # to be run as a root user. Set them up here but run them in another phase
349 *changingowner*) wrt_RunAsRoot "${file}" ;;
350 *devices*) wrt_RunAsRoot "${file}" ;;
351 *fstab*) if [[ -n "$FSTAB" ]]; then
352 LUSER_wrt_CopyFstab
353 else
354 LUSER_wrt_RunAsUser "${file}"
355 fi
356 ;;
357 *) LUSER_wrt_RunAsUser "${file}" ;;
358 esac
359 #
360 # Housekeeping...remove any build directory(ies) except if the package build fails.
361 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
362 #
363 # Include a touch of the target name so make can check if it's already been made.
364 wrt_touch
365 #
366 #--------------------------------------------------------------------#
367 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
368 #--------------------------------------------------------------------#
369 #
370 # Keep the script file name for Makefile dependencies.
371 PREV=$this_script
372
373 done
374}
375
376
377#--------------------------------------#
378testsuite_tools_Makefiles() { #
379#--------------------------------------#
380
381 if [[ "${METHOD}" = "chroot" ]]; then
382 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools ( CHROOT ) ${R_arrow}"
383 else
384 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools ( ROOT ) ${R_arrow}"
385 PREV=""
386 fi
387
388 for file in testsuite-tools/* ; do
389 # Keep the script file name
390 this_script=`basename $file`
391
392 # First append each name of the script files to a list (this will become
393 # the names of the targets in the Makefile
394 testsuitetools="$testsuitetools $this_script"
395
396 # Grab the name of the target, strip id number, XXX-script
397 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
398 -e 's@-64bit@@' \
399 -e 's@-64@@' \
400 -e 's@64@@' \
401 -e 's@n32@@'`
402
403 pkg_tarball=$(get_package_tarball_name $name)
404
405 #--------------------------------------------------------------------#
406 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
407 #--------------------------------------------------------------------#
408 #
409 # Drop in the name of the target on a new line, and the previous target
410 # as a dependency. Also call the echo_message function.
411 CHROOT_wrt_target "${this_script}" "$PREV"
412 #
413 CHROOT_Unpack "$pkg_tarball"
414 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
415 #
416 CHROOT_wrt_RunAsRoot "${file}"
417 #
418 CHROOT_wrt_RemoveBuildDirs "${name}"
419 #
420 # Include a touch of the target name so make can check if it's already been made.
421 wrt_touch
422 #
423 #--------------------------------------------------------------------#
424 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
425 #--------------------------------------------------------------------#
426 #
427 # Keep the script file name for Makefile dependencies.
428 PREV=$this_script
429
430 done
431}
432
433
434#--------------------------------------#
435final_system_Makefiles() { #
436#--------------------------------------#
437 # Set envars and scripts for iteration targets
438 if [[ -z "$1" ]] ; then
439 local N=""
440 # In boot method the makesys phase was initiated in testsuite_tools_makefile
441 [[ "${METHOD}" = "boot" ]] && [[ "$TEST" = 0 ]] && PREV=""
442 else
443 local N=-build_$1
444 local basicsystem=""
445 mkdir final-system$N
446 cp final-system/* final-system$N
447 for script in final-system$N/* ; do
448 # Overwrite existing symlinks, files, and dirs
449 sed -e 's/ln -sv/&f/g' \
450 -e 's/mv -v/&f/g' \
451 -e 's/mkdir -v/&p/g' -i ${script}
452 # Rename the scripts
453 mv ${script} ${script}$N
454 done
455 # Remove Bzip2 binaries before make install (CLFS-1.0 compatibility)
456 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2$N
457 # Delete *old Readline libraries just after make install
458 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline$N
459 fi
460
461 if [[ "${METHOD}" = "chroot" ]]; then
462 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system$N ( CHROOT ) ${R_arrow}"
463 else
464 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system$N ( ROOT ) ${R_arrow}"
465 fi
466
467 for file in final-system$N/* ; do
468 # Keep the script file name
469 this_script=`basename $file`
470
471 # Test if the stripping phase must be skipped.
472 # Skip alsp temp-perl for iterative runs
473 case $this_script in
474 *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
475 *temp-perl*) [[ -n "$N" ]] && continue ;;
476 esac
477
478 # Grab the name of the target, strip id number, XXX-script
479 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
480 -e 's@temp-@@' \
481 -e 's@-64bit@@' \
482 -e 's@-64@@' \
483 -e 's@64@@' \
484 -e 's@n32@@' \
485 -e 's,'$N',,'`
486
487 # Find the version of the command files, if it corresponds with the building of
488 # a specific package. We need this here to can skip scripts not needed for
489 # iterations rebuilds
490 pkg_tarball=$(get_package_tarball_name $name)
491
492 if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
493 case "${this_script}" in
494 *stripping*) ;;
495 *) continue ;;
496 esac
497 fi
498
499 # Append each name of the script files to a list (this will become
500 # the names of the targets in the Makefile
501 basicsystem="$basicsystem ${this_script}"
502
503 #--------------------------------------------------------------------#
504 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
505 #--------------------------------------------------------------------#
506 #
507 # Drop in the name of the target on a new line, and the previous target
508 # as a dependency. Also call the echo_message function.
509 CHROOT_wrt_target "${this_script}" "$PREV"
510
511 # If $pkg_tarball isn't empty, we've got a package...
512 if [ "$pkg_tarball" != "" ] ; then
513 # Touch timestamp file if installed files logs will be created.
514 # But only for the firt build when running iterative builds.
515 if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
516 CHROOT_wrt_TouchTimestamp
517 fi
518 CHROOT_Unpack "$pkg_tarball"
519 # If the testsuites must be run, initialize the log file
520 case $name in
521 binutils | gcc | glibc )
522 [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
523 ;;
524 * )
525 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
526 ;;
527 esac
528 # If using optimizations, write the instructions
529 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
530 fi
531 #
532 CHROOT_wrt_RunAsRoot "${file}"
533 #
534 # Write installed files log and remove the build directory(ies)
535 # except if the package build fails.
536 if [ "$pkg_tarball" != "" ] ; then
537 CHROOT_wrt_RemoveBuildDirs "$name"
538 if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
539 CHROOT_wrt_LogNewFiles "$name"
540 fi
541 fi
542 #
543 # Include a touch of the target name so make can check
544 # if it's already been made.
545 wrt_touch
546 #
547 #--------------------------------------------------------------------#
548 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
549 #--------------------------------------------------------------------#
550 #
551 # Keep the script file name for Makefile dependencies.
552 PREV=${this_script}
553 # Set system_build envar for iteration targets
554 system_build=$basicsystem
555 done # for file in final-system/* ...
556}
557
558#--------------------------------------#
559bootscripts_Makefiles() { #
560#--------------------------------------#
561
562 if [[ "${METHOD}" = "chroot" ]]; then
563 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts ( CHROOT ) ${R_arrow}"
564 else
565 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts ( ROOT ) ${R_arrow}"
566 fi
567
568 for file in bootscripts/* ; do
569 # Keep the script file name
570 this_script=`basename $file`
571
572 case $this_script in
573 *udev) continue ;; # This is not a script but a commentary, we want udev-rules
574 *console*) continue ;; # Use the files that came with the bootscripts
575 *) ;;
576 esac
577
578 # First append each name of the script files to a list (this will become
579 # the names of the targets in the Makefile
580 bootscripttools="$bootscripttools $this_script"
581
582 # Grab the name of the target, strip id number, XXX-script
583 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
584 -e 's@-64bit@@' \
585 -e 's@-64@@' \
586 -e 's@64@@' \
587 -e 's@n32@@'`
588 case $name in
589 *bootscripts*) name=bootscripts-cross-lfs ;;
590 *udev-rules) name=udev-cross-lfs ;;
591 esac
592
593 pkg_tarball=$(get_package_tarball_name $name)
594
595 #--------------------------------------------------------------------#
596 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
597 #--------------------------------------------------------------------#
598 #
599 # Drop in the name of the target on a new line, and the previous target
600 # as a dependency. Also call the echo_message function.
601 CHROOT_wrt_target "${this_script}" "$PREV"
602 #
603 # If $pkg_tarball isn't empty, we've got a package...
604 #
605 if [ "$pkg_tarball" != "" ] ; then
606 if [ "${INSTALL_LOG}" = "y" ] ; then
607 CHROOT_wrt_LogNewFiles "$name"
608 fi
609 CHROOT_Unpack "$pkg_tarball"
610 fi
611 #
612 CHROOT_wrt_RunAsRoot "${file}"
613 #
614 # Write installed files log and remove the build directory(ies)
615 # except if the package build fails.
616 if [ "$pkg_tarball" != "" ] ; then
617 CHROOT_wrt_RemoveBuildDirs "$name"
618 if [ "${INSTALL_LOG}" = "y" ] ; then
619 CHROOT_wrt_LogNewFiles "$name"
620 fi
621 fi
622 #
623 # Include a touch of the target name so make can check if it's already been made.
624 wrt_touch
625 #
626 #--------------------------------------------------------------------#
627 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
628 #--------------------------------------------------------------------#
629 #
630 # Keep the script file name for Makefile dependencies.
631 PREV=$this_script
632
633 done # for file in bootscripts/* ...
634}
635
636#--------------------------------------#
637bootable_Makefiles() { #
638#--------------------------------------#
639
640 if [[ "${METHOD}" = "chroot" ]]; then
641 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable ( CHROOT ) ${R_arrow}"
642 else
643 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable ( ROOT ) ${R_arrow}"
644 fi
645
646
647 for file in bootable/* ; do
648 # Keep the script file name
649 this_script=`basename $file`
650
651 # A little housekeeping on the scripts
652 case $this_script in
653 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
654 *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
655 *kernel) # if there is no kernel config file do not build the kernel
656 [[ -z $CONFIG ]] && continue
657 # Copy the config file to /sources with a standardized name
658 cp $CONFIG $BUILDDIR/sources/kernel-config
659 ;;
660 esac
661 #
662 # First append each name of the script files to a list (this will become
663 # the names of the targets in the Makefile
664 bootabletools="$bootabletools $this_script"
665 #
666 # Grab the name of the target, strip id number and misc words.
667 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
668 case $this_script in
669 *kernel*) name=linux
670 ;;
671 esac
672
673 pkg_tarball=$(get_package_tarball_name $name)
674
675 #--------------------------------------------------------------------#
676 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
677 #--------------------------------------------------------------------#
678 #
679 # Drop in the name of the target on a new line, and the previous target
680 # as a dependency. Also call the echo_message function.
681 CHROOT_wrt_target "${this_script}" "$PREV"
682 #
683 # If $pkg_tarball isn't empty, we've got a package...
684 # Insert instructions for unpacking the package and changing directories
685 #
686 if [ "$pkg_tarball" != "" ] ; then
687 if [ "${INSTALL_LOG}" = "y" ] ; then
688 CHROOT_wrt_LogNewFiles "$name"
689 fi
690 CHROOT_Unpack "$pkg_tarball"
691 fi
692 #
693 # Select a script execution method
694 case $this_script in
695 *fstab*) if [[ -n "$FSTAB" ]]; then
696 CHROOT_wrt_CopyFstab
697 else
698 CHROOT_wrt_RunAsRoot "${file}"
699 fi
700 ;;
701 *) CHROOT_wrt_RunAsRoot "${file}"
702 ;;
703 esac
704 #
705 # Write installed files log and remove the build directory(ies)
706 # except if the package build fails.
707 if [ "$pkg_tarball" != "" ] ; then
708 CHROOT_wrt_RemoveBuildDirs "$name"
709 if [ "${INSTALL_LOG}" = "y" ] ; then
710 CHROOT_wrt_LogNewFiles "$name"
711 fi
712 fi
713 #
714 # Include a touch of the target name so make can check if it's already been made.
715 wrt_touch
716 #
717 #--------------------------------------------------------------------#
718 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
719 #--------------------------------------------------------------------#
720 #
721 # Keep the script file name for Makefile dependencies.
722 PREV=$this_script
723
724 done
725
726}
727
728
729#--------------------------------------#
730build_Makefile() { # Construct a Makefile from the book scripts
731#--------------------------------------#
732 #
733 # Script crashes if error trapping is on
734 #
735set +e
736 declare -f method_cmds
737set -e
738
739 echo "...Creating Makefile... ${BOLD}START${OFF}"
740
741 cd $JHALFSDIR/${PROGNAME}-commands
742 # Start with a clean files
743 >$MKFILE
744 >$MKFILE.tmp
745
746 method_cmds=${METHOD}_Makefiles
747
748 host_prep_Makefiles # mk_SETUP (SETUP) $host_prep
749 cross_tools_Makefiles # mk_CROSS (LUSER) $cross_tools
750 temptools_Makefiles # mk_TEMP (LUSER) $temptools
751 $method_cmds # mk_SYSTOOLS (CHROOT) $chroottools/$boottools
752 if [[ ! $TEST = "0" ]]; then
753 testsuite_tools_Makefiles # mk_SYSTOOLS (CHROOT) $testsuitetools
754 fi
755 final_system_Makefiles # mk_FINAL (CHROOT) $basicsystem
756 # Add the iterations targets, if needed
757 [[ "$COMPARE" = "y" ]] && wrt_compare_targets
758 bootscripts_Makefiles # mk_BOOTSCRIPT (CHROOT) $bootscripttools
759 bootable_Makefiles # mk_BOOTABLE (CHROOT) $bootabletools
760
761 # Add the CUSTOM_TOOLS targets, if needed
762 [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
763 # Add the BLFS_TOOL targets, if needed
764 [[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
765
766 # Add a header, some variables and include the function file
767 # to the top of the real Makefile.
768 wrt_Makefile_header
769
770 # Add chroot commands
771 if [ "$METHOD" = "chroot" ] ; then
772 CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
773 chroot=`cat chroot/*chroot* | \
774 sed -e "s@chroot@$CHROOT_LOC@" \
775 -e '/#!\/bin\/bash/d' \
776 -e '/^export/d' \
777 -e '/^logout/d' \
778 -e 's@ \\\@ @g' | \
779 tr -d '\n' | \
780 sed -e 's/ */ /g' \
781 -e 's|\\$|&&|g' \
782 -e 's|exit||g' \
783 -e 's|$| -c|' \
784 -e 's|"$${CLFS}"|$(MOUNT_PT)|'\
785 -e 's|set -e||' \
786 -e 's|set +h||'`
787 echo -e "CHROOT1= $chroot\n" >> $MKFILE
788 fi
789
790################## CHROOT ####################
791
792if [[ "${METHOD}" = "chroot" ]]; then
793(
794cat << EOF
795
796all: ck_UID mk_SETUP mk_CROSS mk_SUDO mk_SYSTOOLS create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL
797 @sudo make do-housekeeping
798 @echo "$VERSION - jhalfs build" > clfs-release && \\
799 sudo mv clfs-release \$(MOUNT_PT)/etc
800 @\$(call echo_finished,$VERSION)
801
802ck_UID:
803 @if [ \`id -u\` = "0" ]; then \\
804 echo "+--------------------------------------------------+"; \\
805 echo "|You cannot run this makefile from the root account|"; \\
806 echo "+--------------------------------------------------+"; \\
807 exit 1; \\
808 fi
809
810#---------------AS ROOT
811mk_SETUP:
812 @\$(call echo_SU_request)
813 @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
814 @touch \$@
815
816#---------------AS LUSER
817mk_CROSS: mk_SETUP
818 @\$(call echo_PHASE,Cross and Temporary Tools)
819 @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) AS_LUSER" )
820 @sudo make restore-luser-env
821 @touch \$@
822
823mk_SUDO: mk_CROSS
824 @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
825 @touch \$@
826
827#---------------CHROOT JAIL
828mk_SYSTOOLS: mk_SUDO
829 @\$(call echo_CHROOT_request)
830 @\$(call echo_PHASE, CHROOT JAIL )
831 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) PREP_CHROOT_JAIL")
832 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT_JAIL")
833 @touch \$@
834
835mk_CUSTOM_TOOLS: create-sbu_du-report
836 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
837 \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
838 sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
839 (sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
840 fi;
841 @touch \$@
842
843mk_BLFS_TOOL: mk_CUSTOM_TOOLS
844 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
845 \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
846 sudo mkdir -p $BUILDDIR$TRACKING_DIR; \\
847 sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"; \\
848 fi;
849 @touch \$@
850
851SETUP: $host_prep
852AS_LUSER: $cross_tools $temptools
853SUDO: $orphan_scripts
854PREP_CHROOT_JAIL: SHELL=/tools/bin/bash
855PREP_CHROOT_JAIL: ${chroottools}
856CHROOT_JAIL: SHELL=/tools/bin/bash
857CHROOT_JAIL: $testsuitetools $basicsystem $bootscripttools $bootabletools
858CUSTOM_TOOLS: $custom_list
859BLFS_TOOL: $blfs_tool
860
861
862create-sbu_du-report: mk_SYSTOOLS
863 @\$(call echo_message, Building)
864 @if [ "\$(ADD_REPORT)" = "y" ]; then \\
865 ./create-sbu_du-report.sh logs $VERSION; \\
866 \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
867 fi;
868 @touch \$@
869
870do-housekeeping:
871 @-umount \$(MOUNT_PT)/dev/pts
872 @-umount \$(MOUNT_PT)/dev/shm
873 @-umount \$(MOUNT_PT)/dev
874 @-umount \$(MOUNT_PT)/sys
875 @-umount \$(MOUNT_PT)/proc
876 @-rm /tools /cross-tools
877 @-if [ ! -f luser-exist ]; then \\
878 userdel \$(LUSER); \\
879 rm -rf \$(LUSER_HOME); \\
880 fi;
881
882EOF
883) >> $MKFILE
884
885fi
886
887################### BOOT #####################
888
889if [[ "${METHOD}" = "boot" ]]; then
890(
891cat << EOF
892
893all: ck_UID mk_SETUP mk_CROSS mk_SUDO
894 @sudo make restore-luser-env
895 @sudo make do-housekeeping
896 @\$(call echo_boot_finished,$VERSION)
897
898makesys: mk_FINAL mk_CUSTOM_TOOLS mk_BLFS_TOOL
899 @echo "$VERSION - jhalfs build" > /etc/clfs-release
900 @\$(call echo_finished,$VERSION)
901
902
903ck_UID:
904 @if [ \`id -u\` = "0" ]; then \\
905 echo "+--------------------------------------------------+"; \\
906 echo "|You cannot run this makefile from the root account|"; \\
907 echo "|However, if this is the boot environment |"; \\
908 echo "| the command you are looking for is |"; \\
909 echo "| make makesys |"; \\
910 echo "| to finish off the build |"; \\
911 echo "+--------------------------------------------------+"; \\
912 exit 1; \\
913 fi
914
915#---------------AS ROOT
916
917mk_SETUP:
918 @\$(call echo_SU_request)
919 @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
920 @touch \$@
921
922#---------------AS LUSER
923
924mk_CROSS: mk_SETUP
925 @\$(call echo_PHASE,Cross Tool)
926 @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) AS_LUSER" )
927 @touch \$@
928
929mk_SUDO: mk_CROSS
930 @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
931 @touch \$@
932
933#---------------AS ROOT
934
935mk_FINAL:
936 @\$(call echo_PHASE,Final System)
937 @( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) AS_ROOT )
938 @touch \$@
939
940mk_CUSTOM_TOOLS: mk_FINAL
941 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
942 \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
943 mkdir -p ${TRACKING_DIR}; \\
944 ( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS ); \\
945 fi;
946 @touch \$@
947
948mk_BLFS_TOOL: mk_CUSTOM_TOOLS
949 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
950 \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
951 mkdir -p $TRACKING_DIR; \\
952 ( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL ); \\
953 fi
954 @touch \$@
955
956SETUP: $host_prep
957AS_LUSER: $cross_tools $temptools ${boottools}
958SUDO: $orphan_scripts
959AS_ROOT: SHELL=/tools/bin/bash
960AS_ROOT: $testsuitetools $basicsystem $bootscripttools $bootabletools
961CUSTOM_TOOLS: $custom_list
962BLFS_TOOL: $blfs_tool
963
964do-housekeeping:
965 @-rm /tools /cross-tools
966 @-if [ ! -f luser-exist ]; then \\
967 userdel \$(LUSER); \\
968 rm -rf \$(LUSER_HOME); \\
969 fi;
970
971EOF
972) >> $MKFILE
973fi
974
975(
976 cat << EOF
977
978restore-luser-env:
979 @\$(call echo_message, Building)
980 @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
981 mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
982 fi;
983 @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
984 mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
985 fi;
986 @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash* && \\
987 touch \$@ && \\
988 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
989 echo --------------------------------------------------------------------------------\$(WHITE)
990
991########################################################
992
993
994EOF
995) >> $MKFILE
996
997 # Bring over the items from the Makefile.tmp
998 cat $MKFILE.tmp >> $MKFILE
999 rm $MKFILE.tmp
1000
1001 echo "Creating Makefile... ${BOLD}DONE${OFF}"
1002}
Note: See TracBrowser for help on using the repository browser.