source: CLFS/master.sh@ 21cab34

2.4 ablfs-more legacy new_features trunk
Last change on this file since 21cab34 was 608fbe1, checked in by Matthew Burgess <matthew@…>, 12 years ago

Fix various issues when building CLFS.

  • Property mode set to 100644
File size: 38.9 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 # Same for e2fsprogs (in CLFS 1.1.0)
229 # .. Customized makefile entry
230 case "${this_script}" in
231 *util-linux)
232 LUSER_wrt_target "${this_script}" "$PREV"
233 LUSER_wrt_unpack "$pkg_tarball"
234 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
235 LUSER_wrt_RunAsUser "${file}"
236 LUSER_RemoveBuildDirs "${name}"
237 wrt_touch
238 temptools="$temptools $this_script"
239 continue ;;
240 *util-linux-ng)
241 LUSER_wrt_target "${this_script}" "$PREV"
242 LUSER_wrt_unpack "$pkg_tarball"
243 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
244 LUSER_wrt_RunAsUser "${file}"
245 LUSER_RemoveBuildDirs "${name}"
246 wrt_touch
247 temptools="$temptools $this_script"
248 continue ;;
249 *util-linux-libs)
250 LUSER_wrt_target "${this_script}" "$PREV"
251 LUSER_wrt_unpack "$pkg_tarball"
252 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
253 LUSER_wrt_RunAsUser "${file}"
254 LUSER_RemoveBuildDirs "${name}"
255 wrt_touch
256 temptools="$temptools $this_script"
257 continue ;;
258 *e2fsprogs)
259 LUSER_wrt_target "${this_script}" "$PREV"
260 LUSER_wrt_unpack "$pkg_tarball"
261 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
262 LUSER_wrt_RunAsUser "${file}"
263 LUSER_RemoveBuildDirs "${name}"
264 wrt_touch
265 temptools="$temptools $this_script"
266 continue ;;
267 *e2fsprogs-libs)
268 LUSER_wrt_target "${this_script}" "$PREV"
269 LUSER_wrt_unpack "$pkg_tarball"
270 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
271 LUSER_wrt_RunAsUser "${file}"
272 LUSER_RemoveBuildDirs "${name}"
273 wrt_touch
274 temptools="$temptools $this_script"
275 continue ;;
276 esac
277
278
279 #--------------------------------------------------------------------#
280 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
281 #--------------------------------------------------------------------#
282 #
283 # Drop in the name of the target on a new line, and the previous target
284 # as a dependency. Also call the echo_message function.
285 CHROOT_wrt_target "${this_script}" "$PREV"
286 #
287 # If $pkg_tarball isn't empty, we've got a package...
288 # Insert instructions for unpacking the package and changing directories
289 #
290 if [ "$pkg_tarball" != "" ] ; then
291 CHROOT_Unpack "$pkg_tarball"
292 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
293 fi
294 #
295 # Select a script execution method
296 case $this_script in
297 *kernfs) wrt_RunAsRoot "${file}" ;;
298 *) CHROOT_wrt_RunAsRoot "${file}" ;;
299 esac
300 #
301 # Housekeeping...remove the build directory(ies), except if the package build fails.
302 [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
303 #
304 # Include a touch of the target name so make can check if it's already been made.
305 wrt_touch
306 #
307 #--------------------------------------------------------------------#
308 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
309 #--------------------------------------------------------------------#
310 #
311 # Keep the script file name for Makefile dependencies.
312 PREV=$this_script
313
314 done # for file in...
315}
316
317
318#--------------------------------------#
319boot_Makefiles() { #
320#--------------------------------------#
321
322 echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools BOOT ( LUSER ) ${R_arrow}"
323 #
324 # Create a target bootable partition containing a compile environment. Later
325 # on we boot into this environment and contine the build.
326 #
327 for file in boot/* ; do
328 # Keep the script file name
329 this_script=`basename $file`
330
331 # A little housekeeping on the scripts
332 case $this_script in
333 *grub | *aboot | *colo | *silo | *arcload | *lilo | *introduction ) continue ;;
334 *whatnext*) continue ;;
335 *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
336 *kernel) # if there is no kernel config file do not build the kernel
337 [[ -z $CONFIG ]] && continue
338 # Copy the config file to /sources with a standardized name
339 cp $BOOT_CONFIG $BUILDDIR/sources/bootkernel-config
340 ;;
341 esac
342 #
343 # First append each name of the script files to a list (this will become
344 # the names of the targets in the Makefile
345 case "${this_script}" in
346 *changingowner) orphan_scripts="${orphan_scripts} ${this_script}" ;;
347 *devices) orphan_scripts="${orphan_scripts} ${this_script}" ;;
348 *) boottools="$boottools $this_script" ;;
349 esac
350 #
351 # Grab the name of the target, strip id number and misc words.
352 case $this_script in
353 *kernel) name=linux ;;
354 *bootscripts) name="bootscripts-cross-lfs" ;;
355 *udev-rules) name="udev-cross-lfs" ;;
356 *grub-build) name=grub ;;
357 *-aboot-build) name=aboot ;;
358 *yaboot-build) name=yaboot ;;
359 *colo-build) name=colo ;;
360 *silo-build) name=silo ;;
361 *arcload-build) name=arcload ;;
362 *lilo-build) name=lilo ;;
363 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
364 esac
365 # Identify the unique version naming scheme for the clfs bootscripts..(bad boys)
366 pkg_tarball=$(get_package_tarball_name $name)
367
368 #--------------------------------------------------------------------#
369 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
370 #--------------------------------------------------------------------#
371 #
372 # Drop in the name of the target on a new line, and the previous target
373 # as a dependency. Also call the echo_message function.
374 LUSER_wrt_target "${this_script}" "$PREV"
375 #
376 # If $pkg_tarball isn't empty, we've got a package...
377 # Insert instructions for unpacking the package and changing directories
378 #
379 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
380 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
381 #
382 # Select a script execution method
383 case $this_script in
384 # The following 2 scripts are defined in the /boot directory but need
385 # to be run as a root user. Set them up here but run them in another phase
386 *changingowner*) wrt_RunAsRoot "${file}" ;;
387 *devices*) wrt_RunAsRoot "${file}" ;;
388 *fstab*) if [[ -n "$FSTAB" ]]; then
389 LUSER_wrt_CopyFstab
390 else
391 LUSER_wrt_RunAsUser "${file}"
392 fi
393 ;;
394 *) LUSER_wrt_RunAsUser "${file}" ;;
395 esac
396 #
397 # Housekeeping...remove any build directory(ies) except if the package build fails.
398 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
399 #
400 # Include a touch of the target name so make can check if it's already been made.
401 wrt_touch
402 #
403 #--------------------------------------------------------------------#
404 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
405 #--------------------------------------------------------------------#
406 #
407 # Keep the script file name for Makefile dependencies.
408 PREV=$this_script
409
410 done
411}
412
413
414#--------------------------------------#
415testsuite_tools_Makefiles() { #
416#--------------------------------------#
417
418 if [[ "${METHOD}" = "chroot" ]]; then
419 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools ( CHROOT ) ${R_arrow}"
420 else
421 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools ( ROOT ) ${R_arrow}"
422 PREV=""
423 fi
424
425 for file in testsuite-tools/* ; do
426 # Keep the script file name
427 this_script=`basename $file`
428
429 # First append each name of the script files to a list (this will become
430 # the names of the targets in the Makefile
431 testsuitetools="$testsuitetools $this_script"
432
433 # Grab the name of the target, strip id number, XXX-script
434 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
435 -e 's@-64bit@@' \
436 -e 's@-64@@' \
437 -e 's@64@@' \
438 -e 's@n32@@'`
439
440 pkg_tarball=$(get_package_tarball_name $name)
441
442 #--------------------------------------------------------------------#
443 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
444 #--------------------------------------------------------------------#
445 #
446 # Drop in the name of the target on a new line, and the previous target
447 # as a dependency. Also call the echo_message function.
448 CHROOT_wrt_target "${this_script}" "$PREV"
449 #
450 CHROOT_Unpack "$pkg_tarball"
451 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
452 #
453 CHROOT_wrt_RunAsRoot "${file}"
454 #
455 CHROOT_wrt_RemoveBuildDirs "${name}"
456 #
457 # Include a touch of the target name so make can check if it's already been made.
458 wrt_touch
459 #
460 #--------------------------------------------------------------------#
461 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
462 #--------------------------------------------------------------------#
463 #
464 # Keep the script file name for Makefile dependencies.
465 PREV=$this_script
466
467 done
468}
469
470
471#--------------------------------------#
472final_system_Makefiles() { #
473#--------------------------------------#
474 # Set envars and scripts for iteration targets
475 if [[ -z "$1" ]] ; then
476 local N=""
477 # In boot method the makesys phase was initiated in testsuite_tools_makefile
478 [[ "${METHOD}" = "boot" ]] && [[ "$TEST" = 0 ]] && PREV=""
479 else
480 local N=-build_$1
481 local basicsystem=""
482 mkdir final-system$N
483 cp final-system/* final-system$N
484 for script in final-system$N/* ; do
485 # Overwrite existing symlinks, files, and dirs
486 sed -e 's/ln -sv/&f/g' \
487 -e 's/mv -v/&f/g' \
488 -e 's/mkdir -v/&p/g' -i ${script}
489 # Rename the scripts
490 mv ${script} ${script}$N
491 done
492 # Remove Bzip2 binaries before make install (CLFS-1.0 compatibility)
493 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2$N
494 # Delete *old Readline libraries just after make install
495 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline$N
496 fi
497
498 if [[ "${METHOD}" = "chroot" ]]; then
499 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system$N ( CHROOT ) ${R_arrow}"
500 else
501 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system$N ( ROOT ) ${R_arrow}"
502 fi
503
504 for file in final-system$N/* ; do
505 # Keep the script file name
506 this_script=`basename $file`
507
508 # Test if the stripping phase must be skipped.
509 # Skip alsp temp-perl for iterative runs
510 case $this_script in
511 *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
512 *temp-perl*) [[ -n "$N" ]] && continue ;;
513 esac
514
515 # Grab the name of the target, strip id number, XXX-script
516 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
517 -e 's@temp-@@' \
518 -e 's@-64bit@@' \
519 -e 's@-64@@' \
520 -e 's@64@@' \
521 -e 's@n32@@' \
522 -e 's,'$N',,'`
523
524 # Find the version of the command files, if it corresponds with the building of
525 # a specific package. We need this here to can skip scripts not needed for
526 # iterations rebuilds
527 pkg_tarball=$(get_package_tarball_name $name)
528
529 if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
530 case "${this_script}" in
531 *stripping*) ;;
532 *) continue ;;
533 esac
534 fi
535
536 # Append each name of the script files to a list (this will become
537 # the names of the targets in the Makefile
538 basicsystem="$basicsystem ${this_script}"
539
540 #--------------------------------------------------------------------#
541 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
542 #--------------------------------------------------------------------#
543 #
544 # Drop in the name of the target on a new line, and the previous target
545 # as a dependency. Also call the echo_message function.
546 CHROOT_wrt_target "${this_script}" "$PREV"
547
548 # If $pkg_tarball isn't empty, we've got a package...
549 if [ "$pkg_tarball" != "" ] ; then
550 # Touch timestamp file if installed files logs will be created.
551 # But only for the firt build when running iterative builds.
552 if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
553 CHROOT_wrt_TouchTimestamp
554 fi
555 CHROOT_Unpack "$pkg_tarball"
556 # If the testsuites must be run, initialize the log file
557 case $name in
558 binutils | gcc | glibc | eglibc )
559 [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
560 ;;
561 * )
562 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
563 ;;
564 esac
565 # If using optimizations, write the instructions
566 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
567 fi
568 #
569 CHROOT_wrt_RunAsRoot "${file}"
570 #
571 # Write installed files log and remove the build directory(ies)
572 # except if the package build fails.
573 if [ "$pkg_tarball" != "" ] ; then
574 CHROOT_wrt_RemoveBuildDirs "$name"
575 if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
576 CHROOT_wrt_LogNewFiles "$name"
577 fi
578 fi
579 #
580 # Include a touch of the target name so make can check
581 # if it's already been made.
582 wrt_touch
583 #
584 #--------------------------------------------------------------------#
585 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
586 #--------------------------------------------------------------------#
587 #
588 # Keep the script file name for Makefile dependencies.
589 PREV=${this_script}
590 # Set system_build envar for iteration targets
591 system_build=$basicsystem
592 done # for file in final-system/* ...
593}
594
595#--------------------------------------#
596bootscripts_Makefiles() { #
597#--------------------------------------#
598
599 if [[ "${METHOD}" = "chroot" ]]; then
600 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts ( CHROOT ) ${R_arrow}"
601 else
602 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts ( ROOT ) ${R_arrow}"
603 fi
604
605 for file in bootscripts/* ; do
606 # Keep the script file name
607 this_script=`basename $file`
608
609 case $this_script in
610 *udev) continue ;; # This is not a script but a commentary, we want udev-rules
611 *console*) continue ;; # Use the files that came with the bootscripts
612 *) ;;
613 esac
614
615 # First append each name of the script files to a list (this will become
616 # the names of the targets in the Makefile
617 bootscripttools="$bootscripttools $this_script"
618
619 # Grab the name of the target, strip id number, XXX-script
620 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
621 -e 's@-64bit@@' \
622 -e 's@-64@@' \
623 -e 's@64@@' \
624 -e 's@n32@@'`
625 case $name in
626 *bootscripts*) name=bootscripts-cross-lfs ;;
627 *udev-rules) name=udev-cross-lfs ;;
628 esac
629
630 pkg_tarball=$(get_package_tarball_name $name)
631
632 #--------------------------------------------------------------------#
633 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
634 #--------------------------------------------------------------------#
635 #
636 # Drop in the name of the target on a new line, and the previous target
637 # as a dependency. Also call the echo_message function.
638 CHROOT_wrt_target "${this_script}" "$PREV"
639 #
640 # If $pkg_tarball isn't empty, we've got a package...
641 #
642 if [ "$pkg_tarball" != "" ] ; then
643 if [ "${INSTALL_LOG}" = "y" ] ; then
644 CHROOT_wrt_LogNewFiles "$name"
645 fi
646 CHROOT_Unpack "$pkg_tarball"
647 fi
648 #
649 CHROOT_wrt_RunAsRoot "${file}"
650 #
651 # Write installed files log and remove the build directory(ies)
652 # except if the package build fails.
653 if [ "$pkg_tarball" != "" ] ; then
654 CHROOT_wrt_RemoveBuildDirs "$name"
655 if [ "${INSTALL_LOG}" = "y" ] ; then
656 CHROOT_wrt_LogNewFiles "$name"
657 fi
658 fi
659 #
660 # Include a touch of the target name so make can check if it's already been made.
661 wrt_touch
662 #
663 #--------------------------------------------------------------------#
664 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
665 #--------------------------------------------------------------------#
666 #
667 # Keep the script file name for Makefile dependencies.
668 PREV=$this_script
669
670 done # for file in bootscripts/* ...
671}
672
673#--------------------------------------#
674network_Makefiles() { #
675#--------------------------------------#
676
677 if [[ "${METHOD}" = "chroot" ]]; then
678 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) network ( CHROOT ) ${R_arrow}"
679 else
680 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) network ( ROOT ) ${R_arrow}"
681 fi
682
683 for file in network/* ; do
684 # Keep the script file name
685 this_script=`basename $file`
686
687 case $this_script in
688 *choose) continue ;; # This is not a script but a commentary.
689 *dhcp) continue ;; # Assume static networking.
690 *dhcpcd) continue ;; # Assume static networking.
691 *) ;;
692 esac
693
694 # First append each name of the script files to a list (this will become
695 # the names of the targets in the Makefile
696 networktools="$networktools $this_script"
697
698 # Grab the name of the target, strip id number, XXX-script
699 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
700 -e 's@-64bit@@' \
701 -e 's@-64@@' \
702 -e 's@64@@' \
703 -e 's@n32@@'`
704 case $name in
705 *network*) name=network-cross-lfs ;;
706 esac
707
708 pkg_tarball=$(get_package_tarball_name $name)
709
710 #--------------------------------------------------------------------#
711 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
712 #--------------------------------------------------------------------#
713 #
714 # Drop in the name of the target on a new line, and the previous target
715 # as a dependency. Also call the echo_message function.
716 CHROOT_wrt_target "${this_script}" "$PREV"
717 #
718 # If $pkg_tarball isn't empty, we've got a package...
719 #
720 if [ "$pkg_tarball" != "" ] ; then
721 if [ "${INSTALL_LOG}" = "y" ] ; then
722 CHROOT_wrt_LogNewFiles "$name"
723 fi
724 CHROOT_Unpack "$pkg_tarball"
725 fi
726 #
727 CHROOT_wrt_RunAsRoot "${file}"
728 #
729 # Write installed files log and remove the build directory(ies)
730 # except if the package build fails.
731 if [ "$pkg_tarball" != "" ] ; then
732 CHROOT_wrt_RemoveBuildDirs "$name"
733 if [ "${INSTALL_LOG}" = "y" ] ; then
734 CHROOT_wrt_LogNewFiles "$name"
735 fi
736 fi
737 #
738 # Include a touch of the target name so make can check if it's already been made.
739 wrt_touch
740 #
741 #--------------------------------------------------------------------#
742 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
743 #--------------------------------------------------------------------#
744 #
745 # Keep the script file name for Makefile dependencies.
746 PREV=$this_script
747
748 done # for file in network/* ...
749}
750
751#--------------------------------------#
752bootable_Makefiles() { #
753#--------------------------------------#
754
755 if [[ "${METHOD}" = "chroot" ]]; then
756 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable ( CHROOT ) ${R_arrow}"
757 else
758 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable ( ROOT ) ${R_arrow}"
759 fi
760
761
762 for file in bootable/* ; do
763 # Keep the script file name
764 this_script=`basename $file`
765
766 # A little housekeeping on the scripts
767 case $this_script in
768 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
769 *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
770 *kernel) # if there is no kernel config file do not build the kernel
771 [[ -z $CONFIG ]] && continue
772 # Copy the config file to /sources with a standardized name
773 cp $CONFIG $BUILDDIR/sources/kernel-config
774 ;;
775 esac
776 #
777 # First append each name of the script files to a list (this will become
778 # the names of the targets in the Makefile
779 bootabletools="$bootabletools $this_script"
780 #
781 # Grab the name of the target, strip id number and misc words.
782 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
783 case $this_script in
784 *kernel*) name=linux
785 ;;
786 esac
787
788 pkg_tarball=$(get_package_tarball_name $name)
789
790 #--------------------------------------------------------------------#
791 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
792 #--------------------------------------------------------------------#
793 #
794 # Drop in the name of the target on a new line, and the previous target
795 # as a dependency. Also call the echo_message function.
796 CHROOT_wrt_target "${this_script}" "$PREV"
797 #
798 # If $pkg_tarball isn't empty, we've got a package...
799 # Insert instructions for unpacking the package and changing directories
800 #
801 if [ "$pkg_tarball" != "" ] ; then
802 if [ "${INSTALL_LOG}" = "y" ] ; then
803 CHROOT_wrt_LogNewFiles "$name"
804 fi
805 CHROOT_Unpack "$pkg_tarball"
806 fi
807 #
808 # Select a script execution method
809 case $this_script in
810 *fstab*) if [[ -n "$FSTAB" ]]; then
811 CHROOT_wrt_CopyFstab
812 else
813 CHROOT_wrt_RunAsRoot "${file}"
814 fi
815 ;;
816 *) CHROOT_wrt_RunAsRoot "${file}"
817 ;;
818 esac
819 #
820 # Write installed files log and remove the build directory(ies)
821 # except if the package build fails.
822 if [ "$pkg_tarball" != "" ] ; then
823 CHROOT_wrt_RemoveBuildDirs "$name"
824 if [ "${INSTALL_LOG}" = "y" ] ; then
825 CHROOT_wrt_LogNewFiles "$name"
826 fi
827 fi
828 #
829 # Include a touch of the target name so make can check if it's already been made.
830 wrt_touch
831 #
832 #--------------------------------------------------------------------#
833 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
834 #--------------------------------------------------------------------#
835 #
836 # Keep the script file name for Makefile dependencies.
837 PREV=$this_script
838
839 done
840
841}
842
843
844#--------------------------------------#
845build_Makefile() { # Construct a Makefile from the book scripts
846#--------------------------------------#
847 #
848 # Script crashes if error trapping is on
849 #
850set +e
851 declare -f method_cmds
852set -e
853
854 echo "...Creating Makefile... ${BOLD}START${OFF}"
855
856 cd $JHALFSDIR/${PROGNAME}-commands
857 # Start with a clean files
858 >$MKFILE
859 >$MKFILE.tmp
860
861 method_cmds=${METHOD}_Makefiles
862
863 host_prep_Makefiles # mk_SETUP (SETUP) $host_prep
864 cross_tools_Makefiles # mk_CROSS (LUSER) $cross_tools
865 temptools_Makefiles # mk_TEMP (LUSER) $temptools
866 $method_cmds # mk_SYSTOOLS (CHROOT) $chroottools/$boottools
867 if [[ ! $TEST = "0" ]]; then
868 testsuite_tools_Makefiles # mk_SYSTOOLS (CHROOT) $testsuitetools
869 fi
870 final_system_Makefiles # mk_FINAL (CHROOT) $basicsystem
871 # Add the iterations targets, if needed
872 [[ "$COMPARE" = "y" ]] && wrt_compare_targets
873 bootscripts_Makefiles # mk_BOOTSCRIPT (CHROOT) $bootscripttools
874 if [ -d network ]; then
875 network_Makefiles # If present, process network setup.
876 fi
877 bootable_Makefiles # mk_BOOTABLE (CHROOT) $bootabletools
878
879 # Add the CUSTOM_TOOLS targets, if needed
880 [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
881 # Add the BLFS_TOOL targets, if needed
882 [[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
883
884 # Add a header, some variables and include the function file
885 # to the top of the real Makefile.
886 wrt_Makefile_header
887
888 # Add chroot commands
889 if [ "$METHOD" = "chroot" ] ; then
890 CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
891 chroot=`cat chroot/???-chroot | \
892 sed -e "s@chroot@$CHROOT_LOC@" \
893 -e '/#!\/bin\/bash/d' \
894 -e '/^export/d' \
895 -e '/^logout/d' \
896 -e 's@ \\\@ @g' | \
897 tr -d '\n' | \
898 sed -e 's/ */ /g' \
899 -e 's|\\$|&&|g' \
900 -e 's|exit||g' \
901 -e 's|$| -c|' \
902 -e 's|"$${CLFS}"|$(MOUNT_PT)|'\
903 -e 's|set -e||' \
904 -e 's|set +h||'`
905 echo -e "CHROOT1= $chroot\n" >> $MKFILE
906 fi
907
908################## CHROOT ####################
909
910if [[ "${METHOD}" = "chroot" ]]; then
911(
912cat << EOF
913
914all: ck_UID mk_SETUP mk_CROSS mk_SUDO mk_SYSTOOLS create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL
915 @sudo make do-housekeeping
916 @echo "$VERSION - jhalfs build" > clfs-release && \\
917 sudo mv clfs-release \$(MOUNT_PT)/etc
918 @\$(call echo_finished,$VERSION)
919
920ck_UID:
921 @if [ \`id -u\` = "0" ]; then \\
922 echo "+--------------------------------------------------+"; \\
923 echo "|You cannot run this makefile from the root account|"; \\
924 echo "+--------------------------------------------------+"; \\
925 exit 1; \\
926 fi
927
928#---------------AS ROOT
929mk_SETUP:
930 @\$(call echo_SU_request)
931 @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
932 @touch \$@
933
934#---------------AS LUSER
935mk_CROSS: mk_SETUP
936 @\$(call echo_PHASE,Cross and Temporary Tools)
937 @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) AS_LUSER" )
938 @sudo make restore-luser-env
939 @touch \$@
940
941mk_SUDO: mk_CROSS
942 @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
943 @touch \$@
944
945#---------------CHROOT JAIL
946mk_SYSTOOLS: mk_SUDO
947 @\$(call echo_CHROOT_request)
948 @\$(call echo_PHASE, CHROOT JAIL )
949 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) PREP_CHROOT_JAIL")
950 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT_JAIL")
951 @touch \$@
952
953mk_CUSTOM_TOOLS: create-sbu_du-report
954 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
955 \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
956 sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
957 (sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
958 fi;
959 @touch \$@
960
961mk_BLFS_TOOL: mk_CUSTOM_TOOLS
962 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
963 \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
964 sudo mkdir -p $BUILDDIR$TRACKING_DIR; \\
965 sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"; \\
966 fi;
967 @touch \$@
968
969SETUP: $host_prep
970AS_LUSER: $cross_tools $temptools
971SUDO: $orphan_scripts
972PREP_CHROOT_JAIL: SHELL=/tools/bin/bash
973PREP_CHROOT_JAIL: ${chroottools}
974CHROOT_JAIL: SHELL=/tools/bin/bash
975CHROOT_JAIL: $testsuitetools $basicsystem $bootscripttools $bootabletools
976CUSTOM_TOOLS: $custom_list
977BLFS_TOOL: $blfs_tool
978
979
980create-sbu_du-report: mk_SYSTOOLS
981 @\$(call echo_message, Building)
982 @if [ "\$(ADD_REPORT)" = "y" ]; then \\
983 ./create-sbu_du-report.sh logs $VERSION; \\
984 \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
985 fi;
986 @touch \$@
987
988do-housekeeping:
989 @-umount \$(MOUNT_PT)/dev/pts
990 @-umount \$(MOUNT_PT)/dev/shm
991 @-umount \$(MOUNT_PT)/dev
992 @-umount \$(MOUNT_PT)/sys
993 @-umount \$(MOUNT_PT)/proc
994 @-rm /tools /cross-tools
995 @-if [ ! -f luser-exist ]; then \\
996 userdel \$(LUSER); \\
997 rm -rf \$(LUSER_HOME); \\
998 fi;
999
1000EOF
1001) >> $MKFILE
1002
1003fi
1004
1005################### BOOT #####################
1006
1007if [[ "${METHOD}" = "boot" ]]; then
1008(
1009cat << EOF
1010
1011all: ck_UID mk_SETUP mk_CROSS mk_SUDO
1012 @sudo make restore-luser-env
1013 @sudo make do-housekeeping
1014 @\$(call echo_boot_finished,$VERSION)
1015
1016makesys: mk_FINAL mk_CUSTOM_TOOLS mk_BLFS_TOOL
1017 @echo "$VERSION - jhalfs build" > /etc/clfs-release
1018 @\$(call echo_finished,$VERSION)
1019
1020
1021ck_UID:
1022 @if [ \`id -u\` = "0" ]; then \\
1023 echo "+--------------------------------------------------+"; \\
1024 echo "|You cannot run this makefile from the root account|"; \\
1025 echo "|However, if this is the boot environment |"; \\
1026 echo "| the command you are looking for is |"; \\
1027 echo "| make makesys |"; \\
1028 echo "| to finish off the build |"; \\
1029 echo "+--------------------------------------------------+"; \\
1030 exit 1; \\
1031 fi
1032
1033#---------------AS ROOT
1034
1035mk_SETUP:
1036 @\$(call echo_SU_request)
1037 @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
1038 @touch \$@
1039
1040#---------------AS LUSER
1041
1042mk_CROSS: mk_SETUP
1043 @\$(call echo_PHASE,Cross Tool)
1044 @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) AS_LUSER" )
1045 @touch \$@
1046
1047mk_SUDO: mk_CROSS
1048 @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
1049 @touch \$@
1050
1051#---------------AS ROOT
1052
1053mk_FINAL:
1054 @\$(call echo_PHASE,Final System)
1055 @( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) AS_ROOT )
1056 @touch \$@
1057
1058mk_CUSTOM_TOOLS: mk_FINAL
1059 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
1060 \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
1061 mkdir -p ${TRACKING_DIR}; \\
1062 ( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS ); \\
1063 fi;
1064 @touch \$@
1065
1066mk_BLFS_TOOL: mk_CUSTOM_TOOLS
1067 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
1068 \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
1069 mkdir -p $TRACKING_DIR; \\
1070 ( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL ); \\
1071 fi
1072 @touch \$@
1073
1074SETUP: $host_prep
1075AS_LUSER: $cross_tools $temptools ${boottools}
1076SUDO: $orphan_scripts
1077AS_ROOT: SHELL=/tools/bin/bash
1078AS_ROOT: $testsuitetools $basicsystem $bootscripttools $bootabletools
1079CUSTOM_TOOLS: $custom_list
1080BLFS_TOOL: $blfs_tool
1081
1082do-housekeeping:
1083 @-rm /tools /cross-tools
1084 @-if [ ! -f luser-exist ]; then \\
1085 userdel \$(LUSER); \\
1086 rm -rf \$(LUSER_HOME); \\
1087 fi;
1088
1089EOF
1090) >> $MKFILE
1091fi
1092
1093(
1094 cat << EOF
1095
1096restore-luser-env:
1097 @\$(call echo_message, Building)
1098 @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
1099 mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
1100 fi;
1101 @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
1102 mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
1103 fi;
1104 @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash* && \\
1105 touch \$@ && \\
1106 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
1107 echo --------------------------------------------------------------------------------\$(WHITE)
1108
1109########################################################
1110
1111
1112EOF
1113) >> $MKFILE
1114
1115 # Bring over the items from the Makefile.tmp
1116 cat $MKFILE.tmp >> $MKFILE
1117 rm $MKFILE.tmp
1118
1119 echo "Creating Makefile... ${BOLD}DONE${OFF}"
1120}
Note: See TracBrowser for help on using the repository browser.