source: CLFS/master.sh@ 9ae0875

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

CLFSx: Revised host_prep_Makefile targets.

  • Property mode set to 100644
File size: 33.5 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 *util-linux) orphan_scripts="${orphan_scripts} ${this_script}" ;;
227 *kernfs) orphan_scripts="${orphan_scripts} ${this_script}" ;;
228 *) chroottools="$chroottools $this_script" ;;
229 esac
230
231 # Grab the name of the target, strip id number, XXX-script
232 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
233
234 pkg_tarball=$(get_package_tarball_name $name)
235
236 # This is very ugly:: util-linux is in /chroot but must be run under LUSER
237 # .. Customized makefile entry
238 case "${this_script}" in
239 *util-linux)
240 LUSER_wrt_target "${this_script}" "$PREV"
241 LUSER_wrt_unpack "$pkg_tarball"
242 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
243 LUSER_wrt_RunAsUser "${file}"
244 LUSER_RemoveBuildDirs "${name}"
245 wrt_touch
246 temptools="$temptools $this_script"
247 continue ;;
248 esac
249
250
251 #--------------------------------------------------------------------#
252 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
253 #--------------------------------------------------------------------#
254 #
255 # Drop in the name of the target on a new line, and the previous target
256 # as a dependency. Also call the echo_message function.
257 CHROOT_wrt_target "${this_script}" "$PREV"
258 #
259 # If $pkg_tarball isn't empty, we've got a package...
260 # Insert instructions for unpacking the package and changing directories
261 #
262 if [ "$pkg_tarball" != "" ] ; then
263 CHROOT_Unpack "$pkg_tarball"
264 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
265 fi
266 #
267 # Select a script execution method
268 case $this_script in
269 *kernfs) wrt_RunAsRoot "${file}" ;;
270 *) CHROOT_wrt_RunAsRoot "${file}" ;;
271 esac
272 #
273 # Housekeeping...remove the build directory(ies), except if the package build fails.
274 [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
275 #
276 # Include a touch of the target name so make can check if it's already been made.
277 wrt_touch
278 #
279 #--------------------------------------------------------------------#
280 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
281 #--------------------------------------------------------------------#
282 #
283 # Keep the script file name for Makefile dependencies.
284 PREV=$this_script
285
286 done # for file in...
287}
288
289
290#--------------------------------------#
291boot_Makefiles() { #
292#--------------------------------------#
293
294 echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools BOOT ( LUSER ) ${R_arrow}"
295 #
296 # Create a target bootable partition containing a compile environment. Later
297 # on we boot into this environment and contine the build.
298 #
299 for file in boot/* ; do
300 # Keep the script file name
301 this_script=`basename $file`
302
303 # A little housekeeping on the scripts
304 case $this_script in
305 *grub | *aboot | *colo | *silo | *arcload | *lilo ) continue ;;
306 *whatnext*) continue ;;
307 *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
308 *kernel) # if there is no kernel config file do not build the kernel
309 [[ -z $CONFIG ]] && continue
310 # Copy the config file to /sources with a standardized name
311 cp $BOOT_CONFIG $BUILDDIR/sources/bootkernel-config
312 ;;
313 esac
314 #
315 # First append each name of the script files to a list (this will become
316 # the names of the targets in the Makefile
317 case "${this_script}" in
318 *changingowner) orphan_scripts="${orphan_scripts} ${this_script}" ;;
319 *devices) orphan_scripts="${orphan_scripts} ${this_script}" ;;
320 *) boottools="$boottools $this_script" ;;
321 esac
322 #
323 # Grab the name of the target, strip id number and misc words.
324 case $this_script in
325 *kernel) name=linux ;;
326 *bootscripts) name="bootscripts-cross-lfs" ;;
327 *udev-rules) name="udev-cross-lfs" ;;
328 *grub-build) name=grub ;;
329 *-aboot-build) name=aboot ;;
330 *yaboot-build) name=yaboot ;;
331 *colo-build) name=colo ;;
332 *silo-build) name=silo ;;
333 *arcload-build) name=arcload ;;
334 *lilo-build) name=lilo ;;
335 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
336 esac
337 # Identify the unique version naming scheme for the clfs bootscripts..(bad boys)
338 pkg_tarball=$(get_package_tarball_name $name)
339
340 #--------------------------------------------------------------------#
341 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
342 #--------------------------------------------------------------------#
343 #
344 # Drop in the name of the target on a new line, and the previous target
345 # as a dependency. Also call the echo_message function.
346 LUSER_wrt_target "${this_script}" "$PREV"
347 #
348 # If $pkg_tarball isn't empty, we've got a package...
349 # Insert instructions for unpacking the package and changing directories
350 #
351 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
352 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
353 #
354 # Select a script execution method
355 case $this_script in
356 # The following 2 scripts are defined in the /boot directory but need
357 # to be run as a root user. Set them up here but run them in another phase
358 *changingowner*) wrt_RunAsRoot "${file}" ;;
359 *devices*) wrt_RunAsRoot "${file}" ;;
360 *fstab*) if [[ -n "$FSTAB" ]]; then
361 LUSER_wrt_CopyFstab
362 else
363 LUSER_wrt_RunAsUser "${file}"
364 fi
365 ;;
366 *) LUSER_wrt_RunAsUser "${file}" ;;
367 esac
368 #
369 # Housekeeping...remove any build directory(ies) except if the package build fails.
370 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
371 #
372 # Include a touch of the target name so make can check if it's already been made.
373 wrt_touch
374 #
375 #--------------------------------------------------------------------#
376 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
377 #--------------------------------------------------------------------#
378 #
379 # Keep the script file name for Makefile dependencies.
380 PREV=$this_script
381
382 done
383}
384
385
386#--------------------------------------#
387testsuite_tools_Makefiles() { #
388#--------------------------------------#
389
390 if [[ "${METHOD}" = "chroot" ]]; then
391 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools ( CHROOT ) ${R_arrow}"
392 else
393 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools ( ROOT ) ${R_arrow}"
394 PREV=""
395 fi
396
397 for file in testsuite-tools/* ; do
398 # Keep the script file name
399 this_script=`basename $file`
400
401 # First append each name of the script files to a list (this will become
402 # the names of the targets in the Makefile
403 testsuitetools="$testsuitetools $this_script"
404
405 # Grab the name of the target, strip id number, XXX-script
406 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
407 -e 's@-64bit@@' \
408 -e 's@-64@@' \
409 -e 's@64@@' \
410 -e 's@n32@@'`
411
412 pkg_tarball=$(get_package_tarball_name $name)
413
414 #--------------------------------------------------------------------#
415 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
416 #--------------------------------------------------------------------#
417 #
418 # Drop in the name of the target on a new line, and the previous target
419 # as a dependency. Also call the echo_message function.
420 CHROOT_wrt_target "${this_script}" "$PREV"
421 #
422 CHROOT_Unpack "$pkg_tarball"
423 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
424 #
425 CHROOT_wrt_RunAsRoot "${file}"
426 #
427 CHROOT_wrt_RemoveBuildDirs "${name}"
428 #
429 # Include a touch of the target name so make can check if it's already been made.
430 wrt_touch
431 #
432 #--------------------------------------------------------------------#
433 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
434 #--------------------------------------------------------------------#
435 #
436 # Keep the script file name for Makefile dependencies.
437 PREV=$this_script
438
439 done
440}
441
442
443#--------------------------------------#
444final_system_Makefiles() { #
445#--------------------------------------#
446 # Set envars and scripts for iteration targets
447 if [[ -z "$1" ]] ; then
448 local N=""
449 # In boot method the makesys phase was initiated in testsuite_tools_makefile
450 [[ "${METHOD}" = "boot" ]] && [[ "$TEST" = 0 ]] && PREV=""
451 else
452 local N=-build_$1
453 local basicsystem=""
454 mkdir final-system$N
455 cp final-system/* final-system$N
456 for script in final-system$N/* ; do
457 # Overwrite existing symlinks, files, and dirs
458 sed -e 's/ln -sv/&f/g' \
459 -e 's/mv -v/&f/g' \
460 -e 's/mkdir -v/&p/g' -i ${script}
461 # Rename the scripts
462 mv ${script} ${script}$N
463 done
464 # Remove Bzip2 binaries before make install
465 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2$N
466 # Delete *old Readline libraries just after make install
467 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline$N
468 fi
469
470 if [[ "${METHOD}" = "chroot" ]]; then
471 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system$N ( CHROOT ) ${R_arrow}"
472 else
473 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system$N ( ROOT ) ${R_arrow}"
474 fi
475
476 for file in final-system$N/* ; do
477 # Keep the script file name
478 this_script=`basename $file`
479
480 # Test if the stripping phase must be skipped.
481 # Skip alsp temp-perl for iterative runs
482 case $this_script in
483 *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
484 *temp-perl*) [[ -n "$N" ]] && continue ;;
485 esac
486
487 # Grab the name of the target, strip id number, XXX-script
488 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
489 -e 's@temp-@@' \
490 -e 's@-64bit@@' \
491 -e 's@-64@@' \
492 -e 's@64@@' \
493 -e 's@n32@@' \
494 -e 's,'$N',,'`
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}"
511
512 #--------------------------------------------------------------------#
513 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
514 #--------------------------------------------------------------------#
515 #
516 # Drop in the name of the target on a new line, and the previous target
517 # as a dependency. Also call the echo_message function.
518 CHROOT_wrt_target "${this_script}" "$PREV"
519
520 # If $pkg_tarball isn't empty, we've got a package...
521 if [ "$pkg_tarball" != "" ] ; then
522 CHROOT_Unpack "$pkg_tarball"
523 # If the testsuites must be run, initialize the log file
524 case $name in
525 binutils | gcc | glibc )
526 [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
527 ;;
528 * )
529 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
530 ;;
531 esac
532 # If using optimizations, write the instructions
533 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
534 fi
535 #
536 CHROOT_wrt_RunAsRoot "${file}"
537 #
538 [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
539 #
540 # Include a touch of the target name so make can check if it's already been made.
541 wrt_touch
542 #
543 #--------------------------------------------------------------------#
544 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
545 #--------------------------------------------------------------------#
546 #
547 # Keep the script file name for Makefile dependencies.
548 PREV=${this_script}
549 # Set system_build envar for iteration targets
550 system_build=$basicsystem
551 done # for file in final-system/* ...
552}
553
554#--------------------------------------#
555bootscripts_Makefiles() { #
556#--------------------------------------#
557
558 if [[ "${METHOD}" = "chroot" ]]; then
559 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts ( CHROOT ) ${R_arrow}"
560 else
561 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts ( ROOT ) ${R_arrow}"
562 fi
563
564 for file in bootscripts/* ; do
565 # Keep the script file name
566 this_script=`basename $file`
567
568 case $this_script in
569 *udev) continue ;; # This is not a script but a commentary, we want udev-rules
570 *console*) continue ;; # Use the files that came with the bootscripts
571 *) ;;
572 esac
573
574 # First append each name of the script files to a list (this will become
575 # the names of the targets in the Makefile
576 bootscripttools="$bootscripttools $this_script"
577
578 # Grab the name of the target, strip id number, XXX-script
579 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
580 -e 's@-64bit@@' \
581 -e 's@-64@@' \
582 -e 's@64@@' \
583 -e 's@n32@@'`
584 case $name in
585 *bootscripts*) name=bootscripts-cross-lfs ;;
586 *udev-rules) name=udev-cross-lfs ;;
587 esac
588
589 pkg_tarball=$(get_package_tarball_name $name)
590
591 #--------------------------------------------------------------------#
592 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
593 #--------------------------------------------------------------------#
594 #
595 # Drop in the name of the target on a new line, and the previous target
596 # as a dependency. Also call the echo_message function.
597 CHROOT_wrt_target "${this_script}" "$PREV"
598 #
599 # If $pkg_tarball isn't empty, we've got a package...
600 #
601 [[ "$pkg_tarball" != "" ]] && CHROOT_Unpack "$pkg_tarball"
602 #
603 CHROOT_wrt_RunAsRoot "${file}"
604 #
605 [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
606 #
607 # Include a touch of the target name so make can check if it's already been made.
608 wrt_touch
609 #
610 #--------------------------------------------------------------------#
611 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
612 #--------------------------------------------------------------------#
613 #
614 # Keep the script file name for Makefile dependencies.
615 PREV=$this_script
616
617 done # for file in bootscripts/* ...
618}
619
620#--------------------------------------#
621bootable_Makefiles() { #
622#--------------------------------------#
623
624 if [[ "${METHOD}" = "chroot" ]]; then
625 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable ( CHROOT ) ${R_arrow}"
626 else
627 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable ( ROOT ) ${R_arrow}"
628 fi
629
630
631 for file in {bootable,the-end}/* ; do
632 # Keep the script file name
633 this_script=`basename $file`
634
635 # A little housekeeping on the scripts
636 case $this_script in
637 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
638 *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
639 *kernel) # if there is no kernel config file do not build the kernel
640 [[ -z $CONFIG ]] && continue
641 # Copy the config file to /sources with a standardized name
642 cp $CONFIG $BUILDDIR/sources/kernel-config
643 ;;
644 esac
645 #
646 # First append each name of the script files to a list (this will become
647 # the names of the targets in the Makefile
648 bootabletools="$bootabletools $this_script"
649 #
650 # Grab the name of the target, strip id number and misc words.
651 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
652 case $this_script in
653 *kernel*) name=linux
654 ;;
655 esac
656
657 pkg_tarball=$(get_package_tarball_name $name)
658
659 #--------------------------------------------------------------------#
660 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
661 #--------------------------------------------------------------------#
662 #
663 # Drop in the name of the target on a new line, and the previous target
664 # as a dependency. Also call the echo_message function.
665 CHROOT_wrt_target "${this_script}" "$PREV"
666 #
667 # If $pkg_tarball isn't empty, we've got a package...
668 # Insert instructions for unpacking the package and changing directories
669 #
670 [[ "$pkg_tarball" != "" ]] && CHROOT_Unpack "$pkg_tarball"
671 #
672 # Select a script execution method
673 case $this_script in
674 *fstab*) if [[ -n "$FSTAB" ]]; then
675 CHROOT_wrt_CopyFstab
676 else
677 CHROOT_wrt_RunAsRoot "${file}"
678 fi
679 ;;
680 *) CHROOT_wrt_RunAsRoot "${file}"
681 ;;
682 esac
683 #
684 # Housekeeping...remove any build directory(ies) except if the package build fails.
685 [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
686 #
687 # Include a touch of the target name so make can check if it's already been made.
688 wrt_touch
689 #
690 #--------------------------------------------------------------------#
691 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
692 #--------------------------------------------------------------------#
693 #
694 # Keep the script file name for Makefile dependencies.
695 PREV=$this_script
696
697 done
698
699}
700
701
702#--------------------------------------#
703build_Makefile() { # Construct a Makefile from the book scripts
704#--------------------------------------#
705 #
706 # Script crashes if error trapping is on
707 #
708set +e
709 declare -f method_cmds
710set -e
711
712 echo "...Creating Makefile... ${BOLD}START${OFF}"
713
714 cd $JHALFSDIR/${PROGNAME}-commands
715 # Start with a clean files
716 >$MKFILE
717 >$MKFILE.tmp
718
719 method_cmds=${METHOD}_Makefiles
720
721 host_prep_Makefiles # mk_SETUP (SETUP) $host_prep
722 cross_tools_Makefiles # mk_CROSS (LUSER) $cross_tools
723 temptools_Makefiles # mk_TEMP (LUSER) $temptools
724 $method_cmds # mk_SYSTOOLS (CHROOT) $chroottools/$boottools
725 if [[ ! $TEST = "0" ]]; then
726 testsuite_tools_Makefiles # mk_SYSTOOLS (CHROOT) $testsuitetools
727 fi
728 final_system_Makefiles # mk_FINAL (CHROOT) $basicsystem
729 # Add the iterations targets, if needed
730 [[ "$COMPARE" = "y" ]] && wrt_compare_targets
731 bootscripts_Makefiles # mk_BOOTSCRIPT (CHROOT) $bootscripttools
732 bootable_Makefiles # mk_BOOTABLE (CHROOT) $bootabletools
733
734 # Add the BLFS_TOOL targets, if needed
735 [[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
736
737 # Add a header, some variables and include the function file
738 # to the top of the real Makefile.
739 wrt_Makefile_header
740
741 # Add chroot commands
742 if [ "$METHOD" = "chroot" ] ; then
743 CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
744 chroot=`cat chroot/*chroot* | \
745 sed -e "s@chroot@$CHROOT_LOC@" \
746 -e '/#!\/tools\/bin\/bash/d' \
747 -e '/^export/d' \
748 -e '/^logout/d' \
749 -e 's@ \\\@ @g' | \
750 tr -d '\n' | \
751 sed -e 's/ */ /g' \
752 -e 's|\\$|&&|g' \
753 -e 's|exit||g' \
754 -e 's|$| -c|' \
755 -e 's|"$${CLFS}"|$(MOUNT_PT)|'\
756 -e 's|set -e||' \
757 -e 's|set +h||'`
758 echo -e "CHROOT1= $chroot\n" >> $MKFILE
759 fi
760
761################## CHROOT ####################
762
763if [[ "${METHOD}" = "chroot" ]]; then
764(
765cat << EOF
766
767all: ck_UID mk_SETUP mk_CROSS mk_SUDO mk_SYSTOOLS create-sbu_du-report mk_BLFS_TOOL
768 @sudo make do-housekeeping
769 @\$(call echo_finished,$VERSION)
770
771ck_UID:
772 @if [ \`id -u\` = "0" ]; then \\
773 echo "+--------------------------------------------------+"; \\
774 echo "|You cannot run this makefile from the root account|"; \\
775 echo "+--------------------------------------------------+"; \\
776 exit 1; \\
777 fi
778
779#---------------AS ROOT
780mk_SETUP:
781 @\$(call echo_SU_request)
782 @sudo make SHELL=/bin/bash SETUP
783 @touch \$@
784
785#---------------AS LUSER
786mk_CROSS: mk_SETUP
787 @\$(call echo_PHASE,Cross and Temporary Tools)
788 @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make SHELL=/bin/bash AS_LUSER" )
789 @sudo make restore-luser-env
790 @touch \$@
791
792mk_SUDO: mk_CROSS
793 @sudo make SHELL=/bin/bash SUDO
794 @touch \$@
795#
796# The convoluted piece of code below is necessary to provide 'make' with a valid shell in the
797# chroot environment. (Unless someone knows a different way)
798# Manually create the /bin directory and provide link to the /tools dir.
799# Also change the original symlink creation to include (f)orce to prevent failure due to
800# pre-existing links.
801
802#---------------CHROOT JAIL
803mk_SYSTOOLS: mk_SUDO
804 @if [ ! -e \$(MOUNT_PT)/bin ]; then \\
805 mkdir \$(MOUNT_PT)/bin; \\
806 cd \$(MOUNT_PT)/bin && \\
807 ln -svf /tools/bin/bash bash; ln -sf bash sh; \\
808 sudo chown -R 0:0 \$(MOUNT_PT)/bin; \\
809 fi;
810 @sudo sed -e 's|^ln -sv |ln -svf |' -i \$(CMDSDIR)/chroot/*-createfiles
811 @\$(call echo_CHROOT_request)
812 @\$(call echo_PHASE, CHROOT JAIL )
813 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make CHROOT_JAIL")
814 @touch \$@
815
816mk_BLFS_TOOL: create-sbu_du-report
817 @\$(call echo_PHASE,Building BLFS-TOOLS)
818 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
819 sudo mkdir -p $BUILDDIR$TRACKING_DIR; \\
820 sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BLFS_TOOL"; \\
821 fi;
822 @touch \$@
823
824SETUP: $host_prep
825AS_LUSER: $cross_tools $temptools
826SUDO: $orphan_scripts
827CHROOT_JAIL: ${chroottools} $testsuitetools $basicsystem $bootscripttools $bootabletools
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_BLFS_TOOL
868 @\$(call echo_finished,$VERSION)
869
870
871ck_UID:
872 @if [ \`id -u\` = "0" ]; then \\
873 echo "+--------------------------------------------------+"; \\
874 echo "|You cannot run this makefile from the root account|"; \\
875 echo "|However, if this is the boot environment |"; \\
876 echo "| the command you are looking for is |"; \\
877 echo "| make makesys |"; \\
878 echo "| to finish off the build |"; \\
879 echo "+--------------------------------------------------+"; \\
880 exit 1; \\
881 fi
882
883#---------------AS ROOT
884
885mk_SETUP:
886 @\$(call echo_SU_request)
887 @sudo make SHELL=/bin/bash SETUP
888 @touch \$@
889
890#---------------AS LUSER
891
892mk_CROSS: mk_SETUP
893 @\$(call echo_PHASE,Cross Tool)
894 @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make SHELL=/bin/bash AS_LUSER" )
895 @touch \$@
896
897mk_SUDO: mk_CROSS
898 @sudo make SHELL=/bin/bash SUDO
899 @touch \$@
900
901#---------------AS ROOT
902
903mk_FINAL:
904 @\$(call echo_PHASE,Final System)
905 @( source /root/.bash_profile && make AS_ROOT )
906 @touch \$@
907
908mk_BLFS_TOOL: mk_FINAL
909 @\$(call echo_PHASE,Building BLFS-TOOLS)
910 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
911 mkdir -p $TRACKING_DIR; \\
912 ( make BLFS_TOOL ); \\
913 fi
914 @touch \$@
915
916SETUP: $host_prep
917AS_LUSER: $cross_tools $temptools ${boottools}
918SUDO: $orphan_scripts
919AS_ROOT: $testsuitetools $basicsystem $bootscripttools $bootabletools
920BLFS_TOOL: $blfs_tool
921
922do-housekeeping:
923 @-rm /tools /cross-tools
924 @-if [ ! -f luser-exist ]; then \\
925 userdel \$(LUSER); \\
926 rm -rf /home/\$(LUSER); \\
927 fi;
928
929EOF
930) >> $MKFILE
931fi
932
933(
934 cat << EOF
935
936restore-luser-env:
937 @\$(call echo_message, Building)
938 @if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
939 mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
940 fi;
941 @if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
942 mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
943 fi;
944 @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
945 touch \$@ && \\
946 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
947 echo --------------------------------------------------------------------------------\$(WHITE)
948
949########################################################
950
951
952EOF
953) >> $MKFILE
954
955 # Bring over the items from the Makefile.tmp
956 cat $MKFILE.tmp >> $MKFILE
957 rm $MKFILE.tmp
958
959 echo "Creating Makefile... ${BOLD}DONE${OFF}"
960}
Note: See TracBrowser for help on using the repository browser.