source: CLFS/master.sh@ f1da335

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

Revert a previous fix, which could not work when user clfs did not exist yet

  • Property mode set to 100644
File size: 39.0 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 *udev-rules) name="udev-cross-lfs" ;;
362 *grub-build) name=grub ;;
363 *-aboot-build) name=aboot ;;
364 *yaboot-build) name=yaboot ;;
365 *colo-build) name=colo ;;
366 *silo-build) name=silo ;;
367 *arcload-build) name=arcload ;;
368 *lilo-build) name=lilo ;;
369 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
370 esac
371 # Identify the unique version naming scheme for the clfs bootscripts..(bad boys)
372 pkg_tarball=$(get_package_tarball_name $name)
373
374 #--------------------------------------------------------------------#
375 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
376 #--------------------------------------------------------------------#
377 #
378 # Drop in the name of the target on a new line, and the previous target
379 # as a dependency. Also call the echo_message function.
380 LUSER_wrt_target "${this_script}" "$PREV"
381 #
382 # If $pkg_tarball isn't empty, we've got a package...
383 # Insert instructions for unpacking the package and changing directories
384 #
385 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
386 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
387 #
388 # Select a script execution method
389 case $this_script in
390 # The following 2 scripts are defined in the /boot directory but need
391 # to be run as a root user. Set them up here but run them in another phase
392 *changingowner*) wrt_RunAsRoot "${file}" ;;
393 *devices*) wrt_RunAsRoot "${file}" ;;
394 *fstab*) if [[ -n "$FSTAB" ]]; then
395 LUSER_wrt_CopyFstab
396 else
397 LUSER_wrt_RunAsUser "${file}"
398 fi
399 ;;
400 *) LUSER_wrt_RunAsUser "${file}" ;;
401 esac
402 #
403 # Housekeeping...remove any build directory(ies) except if the package build fails.
404 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
405 #
406 # Include a touch of the target name so make can check if it's already been made.
407 wrt_touch
408 #
409 #--------------------------------------------------------------------#
410 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
411 #--------------------------------------------------------------------#
412 #
413 # Keep the script file name for Makefile dependencies.
414 PREV=$this_script
415
416 done
417}
418
419
420#--------------------------------------#
421testsuite_tools_Makefiles() { #
422#--------------------------------------#
423
424 if [[ "${METHOD}" = "chroot" ]]; then
425 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools ( CHROOT ) ${R_arrow}"
426 else
427 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools ( ROOT ) ${R_arrow}"
428 PREV=""
429 fi
430
431 for file in testsuite-tools/* ; do
432 # Keep the script file name
433 this_script=`basename $file`
434
435 # First append each name of the script files to a list (this will become
436 # the names of the targets in the Makefile
437 testsuitetools="$testsuitetools $this_script"
438
439 # Grab the name of the target, strip id number, XXX-script
440 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
441 -e 's@-64bit@@' \
442 -e 's@-64@@' \
443 -e 's@64@@' \
444 -e 's@n32@@'`
445
446 pkg_tarball=$(get_package_tarball_name $name)
447
448 #--------------------------------------------------------------------#
449 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
450 #--------------------------------------------------------------------#
451 #
452 # Drop in the name of the target on a new line, and the previous target
453 # as a dependency. Also call the echo_message function.
454 CHROOT_wrt_target "${this_script}" "$PREV"
455 #
456 CHROOT_Unpack "$pkg_tarball"
457 [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
458 #
459 CHROOT_wrt_RunAsRoot "${file}"
460 #
461 CHROOT_wrt_RemoveBuildDirs "${name}"
462 #
463 # Include a touch of the target name so make can check if it's already been made.
464 wrt_touch
465 #
466 #--------------------------------------------------------------------#
467 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
468 #--------------------------------------------------------------------#
469 #
470 # Keep the script file name for Makefile dependencies.
471 PREV=$this_script
472
473 done
474}
475
476
477#--------------------------------------#
478final_system_Makefiles() { #
479#--------------------------------------#
480 # Set envars and scripts for iteration targets
481 if [[ -z "$1" ]] ; then
482 local N=""
483 # In boot method the makesys phase was initiated in testsuite_tools_makefile
484 [[ "${METHOD}" = "boot" ]] && [[ "$TEST" = 0 ]] && PREV=""
485 else
486 local N=-build_$1
487 local basicsystem=""
488 mkdir final-system$N
489 cp final-system/* final-system$N
490 for script in final-system$N/* ; do
491 # Overwrite existing symlinks, files, and dirs
492 sed -e 's/ln -sv/&f/g' \
493 -e 's/mv -v/&f/g' \
494 -e 's/mkdir -v/&p/g' -i ${script}
495 # Rename the scripts
496 mv ${script} ${script}$N
497 done
498 # Remove Bzip2 binaries before make install (CLFS-1.0 compatibility)
499 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2$N
500 # Delete *old Readline libraries just after make install
501 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline$N
502 fi
503
504 if [[ "${METHOD}" = "chroot" ]]; then
505 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system$N ( CHROOT ) ${R_arrow}"
506 else
507 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system$N ( ROOT ) ${R_arrow}"
508 fi
509
510 for file in final-system$N/* ; do
511 # Keep the script file name
512 this_script=`basename $file`
513
514 # Test if the stripping phase must be skipped.
515 # Skip alsp temp-perl for iterative runs
516 case $this_script in
517 *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
518 *temp-perl*) [[ -n "$N" ]] && continue ;;
519 esac
520
521 # Grab the name of the target, strip id number, XXX-script
522 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
523 -e 's@temp-@@' \
524 -e 's@-64bit@@' \
525 -e 's@-64@@' \
526 -e 's@64@@' \
527 -e 's@n32@@' \
528 -e 's,'$N',,'`
529
530 # Find the version of the command files, if it corresponds with the building of
531 # a specific package. We need this here to can skip scripts not needed for
532 # iterations rebuilds
533 pkg_tarball=$(get_package_tarball_name $name)
534
535 if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
536 case "${this_script}" in
537 *stripping*) ;;
538 *) continue ;;
539 esac
540 fi
541
542 # Append each name of the script files to a list (this will become
543 # the names of the targets in the Makefile
544 basicsystem="$basicsystem ${this_script}"
545
546 #--------------------------------------------------------------------#
547 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
548 #--------------------------------------------------------------------#
549 #
550 # Drop in the name of the target on a new line, and the previous target
551 # as a dependency. Also call the echo_message function.
552 CHROOT_wrt_target "${this_script}" "$PREV"
553
554 # If $pkg_tarball isn't empty, we've got a package...
555 if [ "$pkg_tarball" != "" ] ; then
556 # Touch timestamp file if installed files logs will be created.
557 # But only for the firt build when running iterative builds.
558 if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
559 CHROOT_wrt_TouchTimestamp
560 fi
561 CHROOT_Unpack "$pkg_tarball"
562 # If the testsuites must be run, initialize the log file
563 case $name in
564 binutils | gcc | glibc | eglibc | gmp | mpfr | mpc | isl | cloog )
565 [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
566 ;;
567 * )
568 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
569 ;;
570 esac
571 # If using optimizations, write the instructions
572 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
573 fi
574 #
575 CHROOT_wrt_RunAsRoot "${file}"
576 #
577 # Write installed files log and remove the build directory(ies)
578 # except if the package build fails.
579 if [ "$pkg_tarball" != "" ] ; then
580 CHROOT_wrt_RemoveBuildDirs "$name"
581 if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
582 CHROOT_wrt_LogNewFiles "$name"
583 fi
584 fi
585 #
586 # Include a touch of the target name so make can check
587 # if it's already been made.
588 wrt_touch
589 #
590 #--------------------------------------------------------------------#
591 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
592 #--------------------------------------------------------------------#
593 #
594 # Keep the script file name for Makefile dependencies.
595 PREV=${this_script}
596 # Set system_build envar for iteration targets
597 system_build=$basicsystem
598 done # for file in final-system/* ...
599}
600
601#--------------------------------------#
602bootscripts_Makefiles() { #
603#--------------------------------------#
604
605 if [[ "${METHOD}" = "chroot" ]]; then
606 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts ( CHROOT ) ${R_arrow}"
607 else
608 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts ( ROOT ) ${R_arrow}"
609 fi
610
611 for file in bootscripts/* ; do
612 # Keep the script file name
613 this_script=`basename $file`
614
615 case $this_script in
616 *udev) continue ;; # This is not a script but a commentary, we want udev-rules
617 *console*) continue ;; # Use the files that came with the bootscripts
618 *) ;;
619 esac
620
621 # First append each name of the script files to a list (this will become
622 # the names of the targets in the Makefile
623 bootscripttools="$bootscripttools $this_script"
624
625 # Grab the name of the target, strip id number, XXX-script
626 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
627 -e 's@-64bit@@' \
628 -e 's@-64@@' \
629 -e 's@64@@' \
630 -e 's@n32@@'`
631 case $name in
632 *bootscripts*) name=bootscripts-cross-lfs ;;
633 *udev-rules) name=udev-cross-lfs ;;
634 esac
635
636 pkg_tarball=$(get_package_tarball_name $name)
637
638 #--------------------------------------------------------------------#
639 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
640 #--------------------------------------------------------------------#
641 #
642 # Drop in the name of the target on a new line, and the previous target
643 # as a dependency. Also call the echo_message function.
644 CHROOT_wrt_target "${this_script}" "$PREV"
645 #
646 # If $pkg_tarball isn't empty, we've got a package...
647 #
648 if [ "$pkg_tarball" != "" ] ; then
649 if [ "${INSTALL_LOG}" = "y" ] ; then
650 CHROOT_wrt_LogNewFiles "$name"
651 fi
652 CHROOT_Unpack "$pkg_tarball"
653 fi
654 #
655 CHROOT_wrt_RunAsRoot "${file}"
656 #
657 # Write installed files log and remove the build directory(ies)
658 # except if the package build fails.
659 if [ "$pkg_tarball" != "" ] ; then
660 CHROOT_wrt_RemoveBuildDirs "$name"
661 if [ "${INSTALL_LOG}" = "y" ] ; then
662 CHROOT_wrt_LogNewFiles "$name"
663 fi
664 fi
665 #
666 # Include a touch of the target name so make can check if it's already been made.
667 wrt_touch
668 #
669 #--------------------------------------------------------------------#
670 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
671 #--------------------------------------------------------------------#
672 #
673 # Keep the script file name for Makefile dependencies.
674 PREV=$this_script
675
676 done # for file in bootscripts/* ...
677}
678
679#--------------------------------------#
680network_Makefiles() { #
681#--------------------------------------#
682
683 if [[ "${METHOD}" = "chroot" ]]; then
684 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) network ( CHROOT ) ${R_arrow}"
685 else
686 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) network ( ROOT ) ${R_arrow}"
687 fi
688
689 for file in network/* ; do
690 # Keep the script file name
691 this_script=`basename $file`
692
693 case $this_script in
694 *choose) continue ;; # This is not a script but a commentary.
695 *dhcp) continue ;; # Assume static networking.
696 *dhcpcd) continue ;; # Assume static networking.
697 *) ;;
698 esac
699
700 # First append each name of the script files to a list (this will become
701 # the names of the targets in the Makefile
702 networktools="$networktools $this_script"
703
704 # Grab the name of the target, strip id number, XXX-script
705 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
706 -e 's@-64bit@@' \
707 -e 's@-64@@' \
708 -e 's@64@@' \
709 -e 's@n32@@'`
710 case $name in
711 *network*) name=network-cross-lfs ;;
712 esac
713
714 pkg_tarball=$(get_package_tarball_name $name)
715
716 #--------------------------------------------------------------------#
717 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
718 #--------------------------------------------------------------------#
719 #
720 # Drop in the name of the target on a new line, and the previous target
721 # as a dependency. Also call the echo_message function.
722 CHROOT_wrt_target "${this_script}" "$PREV"
723 #
724 # If $pkg_tarball isn't empty, we've got a package...
725 #
726 if [ "$pkg_tarball" != "" ] ; then
727 if [ "${INSTALL_LOG}" = "y" ] ; then
728 CHROOT_wrt_LogNewFiles "$name"
729 fi
730 CHROOT_Unpack "$pkg_tarball"
731 fi
732 #
733 CHROOT_wrt_RunAsRoot "${file}"
734 #
735 # Write installed files log and remove the build directory(ies)
736 # except if the package build fails.
737 if [ "$pkg_tarball" != "" ] ; then
738 CHROOT_wrt_RemoveBuildDirs "$name"
739 if [ "${INSTALL_LOG}" = "y" ] ; then
740 CHROOT_wrt_LogNewFiles "$name"
741 fi
742 fi
743 #
744 # Include a touch of the target name so make can check if it's already been made.
745 wrt_touch
746 #
747 #--------------------------------------------------------------------#
748 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
749 #--------------------------------------------------------------------#
750 #
751 # Keep the script file name for Makefile dependencies.
752 PREV=$this_script
753
754 done # for file in network/* ...
755}
756
757#--------------------------------------#
758bootable_Makefiles() { #
759#--------------------------------------#
760
761 if [[ "${METHOD}" = "chroot" ]]; then
762 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable ( CHROOT ) ${R_arrow}"
763 else
764 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable ( ROOT ) ${R_arrow}"
765 fi
766
767
768 for file in bootable/* ; do
769 # Keep the script file name
770 this_script=`basename $file`
771
772 # A little housekeeping on the scripts
773 case $this_script in
774 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
775 *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
776 *kernel) # if there is no kernel config file do not build the kernel
777 [[ -z $CONFIG ]] && continue
778 # Copy the config file to /sources with a standardized name
779 cp $CONFIG $BUILDDIR/sources/kernel-config
780 ;;
781 esac
782 #
783 # First append each name of the script files to a list (this will become
784 # the names of the targets in the Makefile
785 bootabletools="$bootabletools $this_script"
786 #
787 # Grab the name of the target, strip id number and misc words.
788 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
789 case $this_script in
790 *kernel*) name=linux
791 ;;
792 esac
793
794 pkg_tarball=$(get_package_tarball_name $name)
795
796 #--------------------------------------------------------------------#
797 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
798 #--------------------------------------------------------------------#
799 #
800 # Drop in the name of the target on a new line, and the previous target
801 # as a dependency. Also call the echo_message function.
802 CHROOT_wrt_target "${this_script}" "$PREV"
803 #
804 # If $pkg_tarball isn't empty, we've got a package...
805 # Insert instructions for unpacking the package and changing directories
806 #
807 if [ "$pkg_tarball" != "" ] ; then
808 if [ "${INSTALL_LOG}" = "y" ] ; then
809 CHROOT_wrt_LogNewFiles "$name"
810 fi
811 CHROOT_Unpack "$pkg_tarball"
812 fi
813 #
814 # Select a script execution method
815 case $this_script in
816 *fstab*) if [[ -n "$FSTAB" ]]; then
817 CHROOT_wrt_CopyFstab
818 else
819 CHROOT_wrt_RunAsRoot "${file}"
820 fi
821 ;;
822 *) CHROOT_wrt_RunAsRoot "${file}"
823 ;;
824 esac
825 #
826 # Write installed files log and remove the build directory(ies)
827 # except if the package build fails.
828 if [ "$pkg_tarball" != "" ] ; then
829 CHROOT_wrt_RemoveBuildDirs "$name"
830 if [ "${INSTALL_LOG}" = "y" ] ; then
831 CHROOT_wrt_LogNewFiles "$name"
832 fi
833 fi
834 #
835 # Include a touch of the target name so make can check if it's already been made.
836 wrt_touch
837 #
838 #--------------------------------------------------------------------#
839 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
840 #--------------------------------------------------------------------#
841 #
842 # Keep the script file name for Makefile dependencies.
843 PREV=$this_script
844
845 done
846
847}
848
849
850#--------------------------------------#
851build_Makefile() { # Construct a Makefile from the book scripts
852#--------------------------------------#
853
854 echo "...Creating Makefile... ${BOLD}START${OFF}"
855
856 cd $JHALFSDIR/${PROGNAME}-commands
857 # Start with clean files
858 >$MKFILE
859 >$MKFILE.tmp
860
861 method_cmds=${METHOD}_Makefiles
862
863 host_prep_Makefiles # mk_SETUP (SETUP) $host_prep
864 cross_tools_Makefiles # mk_CROSS (LUSER) $cross_tools
865 temptools_Makefiles # mk_TEMP (LUSER) $temptools
866 $method_cmds # mk_SYSTOOLS (CHROOT) $chroottools/$boottools
867 if [[ ! $TEST = "0" ]]; then
868 testsuite_tools_Makefiles # mk_SYSTOOLS (CHROOT) $testsuitetools
869 fi
870 final_system_Makefiles # mk_FINAL (CHROOT) $basicsystem
871 # Add the iterations targets, if needed
872 [[ "$COMPARE" = "y" ]] && wrt_compare_targets
873 bootscripts_Makefiles # mk_BOOTSCRIPT (CHROOT) $bootscripttools
874 if [ -d network ]; then
875 network_Makefiles # If present, process network setup.
876 fi
877 bootable_Makefiles # mk_BOOTABLE (CHROOT) $bootabletools
878
879 # Add the CUSTOM_TOOLS targets, if needed
880 [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
881
882 # Add a header, some variables and include the function file
883 # to the top of the real Makefile.
884 wrt_Makefile_header
885
886 # Add chroot commands
887 if [ "$METHOD" = "chroot" ] ; then
888 CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
889 chroot=`cat chroot/???-chroot | \
890 sed -e "s@chroot@$CHROOT_LOC@" \
891 -e '/#!\/bin\/bash/d' \
892 -e '/^export/d' \
893 -e '/^logout/d' \
894 -e 's@ \\\@ @g' | \
895 tr -d '\n' | \
896 sed -e 's/ */ /g' \
897 -e 's|\\$|&&|g' \
898 -e 's|exit||g' \
899 -e 's|$| -c|' \
900 -e 's|"$${CLFS}"|$(MOUNT_PT)|'\
901 -e 's|set -e||' \
902 -e 's|set +h||'`
903 echo -e "CHROOT1= $chroot\n" >> $MKFILE
904 fi
905
906################## CHROOT ####################
907
908if [[ "${METHOD}" = "chroot" ]]; then
909(
910cat << EOF
911
912all: ck_UID mk_SETUP mk_CROSS mk_SUDO mk_SYSTOOLS create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL
913 @sudo make do-housekeeping
914 @echo "$VERSION - jhalfs build" > clfs-release && \\
915 sudo mv clfs-release \$(MOUNT_PT)/etc && \\
916 sudo chown root:root \$(MOUNT_PT)/etc/clfs-release
917 @\$(call echo_finished,$VERSION)
918
919ck_UID:
920 @if [ \`id -u\` = "0" ]; then \\
921 echo "+--------------------------------------------------+"; \\
922 echo "|You cannot run this makefile from the root account|"; \\
923 echo "+--------------------------------------------------+"; \\
924 exit 1; \\
925 fi
926
927#---------------AS ROOT
928mk_SETUP:
929 @\$(call echo_SU_request)
930 @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
931 @touch \$@
932
933#---------------AS LUSER
934mk_CROSS: mk_SETUP
935 @\$(call echo_PHASE,Cross and Temporary Tools)
936 @( \$(SU_LUSER) "make -C \$(MOUNT_PT)/\$(SCRIPT_ROOT) BREAKPOINT=\$(BREAKPOINT) AS_LUSER" )
937 @sudo make restore-luser-env
938 @touch \$@
939
940mk_SUDO: mk_CROSS
941 @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
942 @touch \$@
943
944#---------------CHROOT JAIL
945mk_SYSTOOLS: mk_SUDO
946 @\$(call echo_CHROOT_request)
947 @\$(call echo_PHASE, CHROOT JAIL )
948 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) PREP_CHROOT_JAIL")
949 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT_JAIL")
950 @touch \$@
951
952mk_BLFS_TOOL: create-sbu_du-report
953 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
954 \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
955 (sudo \$(CHROOT1) "make -C $BLFS_ROOT/work"); \\
956 fi;
957 @touch \$@
958
959mk_CUSTOM_TOOLS: mk_BLFS_TOOL
960 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
961 \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
962 sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
963 (sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
964 fi;
965 @touch \$@
966
967SETUP: $host_prep
968AS_LUSER: $cross_tools $temptools
969SUDO: $orphan_scripts
970PREP_CHROOT_JAIL: SHELL=/tools/bin/bash
971PREP_CHROOT_JAIL: ${chroottools}
972CHROOT_JAIL: SHELL=/tools/bin/bash
973CHROOT_JAIL: $testsuitetools $basicsystem $bootscripttools $bootabletools
974CUSTOM_TOOLS: $custom_list
975
976
977create-sbu_du-report: mk_SYSTOOLS
978 @\$(call echo_message, Building)
979 @if [ "\$(ADD_REPORT)" = "y" ]; then \\
980 ./create-sbu_du-report.sh logs $VERSION; \\
981 \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
982 fi;
983 @touch \$@
984
985do-housekeeping:
986 @-umount \$(MOUNT_PT)/dev/pts
987 @-if [ -h \$(MOUNT_PT)/dev/shm ]; then \\
988 link=\$\$(readlink \$(MOUNT_PT)/dev/shm); \\
989 umount \$(MOUNT_PT)/\$\$link; \\
990 unset link; \\
991 else \\
992 umount \$(MOUNT_PT)/dev/shm; \\
993 fi
994 @-umount \$(MOUNT_PT)/dev
995 @-umount \$(MOUNT_PT)/sys
996 @-umount \$(MOUNT_PT)/proc
997 @-rm /tools /cross-tools
998 @-if [ ! -f luser-exist ]; then \\
999 userdel \$(LUSER); \\
1000 rm -rf \$(LUSER_HOME); \\
1001 fi;
1002
1003EOF
1004) >> $MKFILE
1005
1006fi
1007
1008################### BOOT #####################
1009
1010if [[ "${METHOD}" = "boot" ]]; then
1011(
1012cat << EOF
1013
1014all: ck_UID mk_SETUP mk_CROSS mk_SUDO
1015 @sudo make restore-luser-env
1016 @sudo make do-housekeeping
1017 @\$(call echo_boot_finished,$VERSION)
1018
1019makesys: mk_FINAL mk_CUSTOM_TOOLS mk_BLFS_TOOL
1020 @echo "$VERSION - jhalfs build" > /etc/clfs-release
1021 @\$(call echo_finished,$VERSION)
1022
1023
1024ck_UID:
1025 @if [ \`id -u\` = "0" ]; then \\
1026 echo "+--------------------------------------------------+"; \\
1027 echo "|You cannot run this makefile from the root account|"; \\
1028 echo "|However, if this is the boot environment |"; \\
1029 echo "| the command you are looking for is |"; \\
1030 echo "| make makesys |"; \\
1031 echo "| to complete the build |"; \\
1032 echo "+--------------------------------------------------+"; \\
1033 exit 1; \\
1034 fi
1035
1036#---------------AS ROOT
1037
1038mk_SETUP:
1039 @\$(call echo_SU_request)
1040 @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
1041 @touch \$@
1042
1043#---------------AS LUSER
1044
1045mk_CROSS: mk_SETUP
1046 @\$(call echo_PHASE,Cross Tool)
1047 @( \$(SU_LUSER) "make -C \$(MOUNT_PT)/\$(SCRIPT_ROOT) BREAKPOINT=\$(BREAKPOINT) AS_LUSER" )
1048 @touch \$@
1049
1050mk_SUDO: mk_CROSS
1051 @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
1052 @touch \$@
1053
1054#---------------AS ROOT
1055
1056mk_FINAL:
1057 @\$(call echo_PHASE,Final System)
1058 @( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) AS_ROOT )
1059 @touch \$@
1060
1061mk_BLFS_TOOL: mk_FINAL
1062 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
1063 \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
1064 ( make -C $BLFS_ROOT/work ); \\
1065 fi;
1066 @touch \$@
1067
1068mk_CUSTOM_TOOLS: mk_BLFS_TOOL
1069 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
1070 \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
1071 mkdir -p ${TRACKING_DIR}; \\
1072 ( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS ); \\
1073 fi;
1074 @touch \$@
1075
1076SETUP: $host_prep
1077AS_LUSER: $cross_tools $temptools ${boottools}
1078SUDO: $orphan_scripts
1079AS_ROOT: SHELL=/tools/bin/bash
1080AS_ROOT: $testsuitetools $basicsystem $bootscripttools $bootabletools
1081CUSTOM_TOOLS: $custom_list
1082
1083do-housekeeping:
1084 @-rm /tools /cross-tools
1085 @-if [ ! -f luser-exist ]; then \\
1086 userdel \$(LUSER); \\
1087 rm -rf \$(LUSER_HOME); \\
1088 fi;
1089
1090EOF
1091) >> $MKFILE
1092fi
1093
1094(
1095 cat << EOF
1096
1097restore-luser-env:
1098 @\$(call echo_message, Building)
1099 @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
1100 mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
1101 fi;
1102 @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
1103 mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
1104 fi;
1105 @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash* && \\
1106 touch \$@ && \\
1107 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
1108 echo --------------------------------------------------------------------------------\$(WHITE)
1109
1110########################################################
1111
1112
1113EOF
1114) >> $MKFILE
1115
1116 # Bring over the items from the Makefile.tmp
1117 cat $MKFILE.tmp >> $MKFILE
1118 rm $MKFILE.tmp
1119
1120 echo "Creating Makefile... ${BOLD}DONE${OFF}"
1121}
Note: See TracBrowser for help on using the repository browser.