source: CLFS/master.sh@ 113d767

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

CLFS: *util-linux is not an otphan_script.

  • Property mode set to 100644
File size: 34.4 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
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 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_CUSTOM_TOOLS: create-sbu_du-report
820 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
821 \$(call echo_PHASE,Building CUSTOM_TOOLS); \\
822 \$(call echo_CHROOT_request); \\
823 sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
824 (sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make CUSTOM_TOOLS"); \\
825 fi;
826 @touch \$@
827
828mk_BLFS_TOOL: mk_CUSTOM_TOOLS
829 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
830 \$(call echo_PHASE,Building BLFS_TOOL); \\
831 \$(call echo_CHROOT_request); \\
832 sudo mkdir -p $BUILDDIR$TRACKING_DIR; \\
833 sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BLFS_TOOL"; \\
834 fi;
835 @touch \$@
836
837SETUP: $host_prep
838AS_LUSER: $cross_tools $temptools
839SUDO: $orphan_scripts
840CHROOT_JAIL: ${chroottools} $testsuitetools $basicsystem $bootscripttools $bootabletools
841CUSTOM_TOOLS: $custom_list
842BLFS_TOOL: $blfs_tool
843
844
845create-sbu_du-report: mk_SYSTOOLS
846 @\$(call echo_message, Building)
847 @if [ "\$(ADD_REPORT)" = "y" ]; then \\
848 ./create-sbu_du-report.sh logs $VERSION; \\
849 \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
850 fi;
851 @touch \$@
852
853do-housekeeping:
854 @-umount \$(MOUNT_PT)/dev/pts
855 @-umount \$(MOUNT_PT)/dev/shm
856 @-umount \$(MOUNT_PT)/dev
857 @-umount \$(MOUNT_PT)/sys
858 @-umount \$(MOUNT_PT)/proc
859 @-rm /tools /cross-tools
860 @-if [ ! -f luser-exist ]; then \\
861 userdel \$(LUSER); \\
862 rm -rf /home/\$(LUSER); \\
863 fi;
864
865EOF
866) >> $MKFILE
867
868fi
869
870################### BOOT #####################
871
872if [[ "${METHOD}" = "boot" ]]; then
873(
874cat << EOF
875
876all: ck_UID mk_SETUP mk_CROSS mk_SUDO
877 @sudo make restore-luser-env
878 @sudo make do-housekeeping
879 @\$(call echo_boot_finished,$VERSION)
880
881makesys: mk_FINAL mk_CUSTOM_TOOLS mk_BLFS_TOOL
882 @echo "$VERSION - jhalfs build" > /etc/clfs-release
883 @\$(call echo_finished,$VERSION)
884
885
886ck_UID:
887 @if [ \`id -u\` = "0" ]; then \\
888 echo "+--------------------------------------------------+"; \\
889 echo "|You cannot run this makefile from the root account|"; \\
890 echo "|However, if this is the boot environment |"; \\
891 echo "| the command you are looking for is |"; \\
892 echo "| make makesys |"; \\
893 echo "| to finish off the build |"; \\
894 echo "+--------------------------------------------------+"; \\
895 exit 1; \\
896 fi
897
898#---------------AS ROOT
899
900mk_SETUP:
901 @\$(call echo_SU_request)
902 @sudo make SHELL=/bin/bash SETUP
903 @touch \$@
904
905#---------------AS LUSER
906
907mk_CROSS: mk_SETUP
908 @\$(call echo_PHASE,Cross Tool)
909 @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make SHELL=/bin/bash AS_LUSER" )
910 @touch \$@
911
912mk_SUDO: mk_CROSS
913 @sudo make SHELL=/bin/bash SUDO
914 @touch \$@
915
916#---------------AS ROOT
917
918mk_FINAL:
919 @\$(call echo_PHASE,Final System)
920 @( source /root/.bash_profile && make AS_ROOT )
921 @touch \$@
922
923mk_CUSTOM_TOOLS: mk_FINAL
924 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
925 mkdir -p ${TRACKING_DIR}; \\
926 \$(call echo_PHASE,Building CUSTOM_TOOLS); \\
927 ( source /root/.bash_profile && make CUSTOM_TOOLS"); \\
928 fi;
929 @touch \$@
930
931mk_BLFS_TOOL: mk_CUSTOM_TOOLS
932 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
933 mkdir -p $TRACKING_DIR; \\
934 \$(call echo_PHASE,Building BLFS_TOOL); \\
935 ( source /root/.bash_profile && make BLFS_TOOL ); \\
936 fi
937 @touch \$@
938
939SETUP: $host_prep
940AS_LUSER: $cross_tools $temptools ${boottools}
941SUDO: $orphan_scripts
942AS_ROOT: $testsuitetools $basicsystem $bootscripttools $bootabletools
943CUSTOM_TOOLS: $custom_list
944BLFS_TOOL: $blfs_tool
945
946do-housekeeping:
947 @-rm /tools /cross-tools
948 @-if [ ! -f luser-exist ]; then \\
949 userdel \$(LUSER); \\
950 rm -rf /home/\$(LUSER); \\
951 fi;
952
953EOF
954) >> $MKFILE
955fi
956
957(
958 cat << EOF
959
960restore-luser-env:
961 @\$(call echo_message, Building)
962 @if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
963 mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
964 fi;
965 @if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
966 mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
967 fi;
968 @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
969 touch \$@ && \\
970 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
971 echo --------------------------------------------------------------------------------\$(WHITE)
972
973########################################################
974
975
976EOF
977) >> $MKFILE
978
979 # Bring over the items from the Makefile.tmp
980 cat $MKFILE.tmp >> $MKFILE
981 rm $MKFILE.tmp
982
983 echo "Creating Makefile... ${BOLD}DONE${OFF}"
984}
Note: See TracBrowser for help on using the repository browser.