source: CLFS/master.sh@ d55a1a1

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

Using only one set of functions for both chroot and boot methods in CLFS Makefile creation.

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