source: CLFS/master.sh@ ff9938f

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

Adaptation to the new layout for CLFS systemd.
From a patch by W. Harrington

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