source: CLFS/master.sh@ 730436a

2.4 ablfs-more legacy new_features trunk
Last change on this file since 730436a was 730436a, checked in by Pierre Labastie <pierre@…>, 11 years ago

Change SU_LUSER commands in CLFS for being able to interrupt
the build in the cross-tools and temptools phase

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