source: CLFS/master.sh@ a8ceefc

2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since a8ceefc was a8ceefc, checked in by George Boudreau <georgeb@…>, 18 years ago

Remove unnecessary text messages

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