source: CLFS/master.sh@ 16938b0

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

Sets chrootttols targets to a separate PREP_CHROOT_JAIL.
That is needed for multilib builds to can load the /root/.bash_profile file generated in 089-flags.
Thanks to Mario Lang for report and patch.

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