source: CLFS/master.sh@ be22162

experimental
Last change on this file since be22162 was 9c9775f, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Updated experimental branch to current trunk code.

  • Property mode set to 100644
File size: 34.7 KB
RevLine 
[9c9775f]1#!/bin/bash
[1ce084e]2# $Id$
[0170229]3
[d14903f]4
5orphan_scripts="" # 2 scripts do not fit BOOT_Makefiles LUSER environment
6
7
8#--------------------------------------#
9host_prep_Makefiles() { #
10#--------------------------------------#
[3b63c8c]11 local CLFS_HOST
[0170229]12
[d14903f]13 echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}"
[0170229]14
15 # defined here, only for ease of reading
[3b63c8c]16 CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
[0170229]17(
18cat << EOF
19023-creatingtoolsdir:
20 @\$(call echo_message, Building)
[9199a13]21 @mkdir \$(MOUNT_PT)/tools && \\
22 rm -f /tools && \\
23 ln -s \$(MOUNT_PT)/tools /
[9c9775f]24 @\$(call housekeeping)
[0170229]25
26024-creatingcrossdir: 023-creatingtoolsdir
[9c9775f]27 @\$(call echo_message, Building)
[0170229]28 @mkdir -v \$(MOUNT_PT)/cross-tools && \\
[9199a13]29 rm -f /cross-tools && \\
30 ln -s \$(MOUNT_PT)/cross-tools /
[9c9775f]31 @\$(call housekeeping)
[0170229]32
33025-addinguser: 024-creatingcrossdir
34 @\$(call echo_message, Building)
[9c9775f]35 @if [ ! -d \$(LUSER_HOME) ]; then \\
[9485eba]36 groupadd \$(LGROUP); \\
37 useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
[0170229]38 else \\
[30737ea8]39 touch luser-exist; \\
[0170229]40 fi;
[9c9775f]41 @chown \$(LUSER) \$(MOUNT_PT)/tools && \\
[9485eba]42 chown \$(LUSER) \$(MOUNT_PT)/cross-tools && \\
[9c9775f]43 chmod -R a+wt \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
44 chmod a+wt \$(SRCSDIR)
45 @\$(call housekeeping)
[0170229]46
47026-settingenvironment: 025-addinguser
48 @\$(call echo_message, Building)
[9c9775f]49 @if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
50 mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
[0170229]51 fi;
[9c9775f]52 @if [ -f \$(LUSER_HOME)/.bash_profile -a ! -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
53 mv \$(LUSER_HOME)/.bash_profile \$(LUSER_HOME)/.bash_profile.XXX; \\
[0170229]54 fi;
[9c9775f]55 @echo "set +h" > \$(LUSER_HOME)/.bashrc && \\
56 echo "umask 022" >> \$(LUSER_HOME)/.bashrc && \\
57 echo "CLFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\
58 echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
59 echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
60 echo "export CLFS LC_ALL PATH" >> \$(LUSER_HOME)/.bashrc && \\
61 echo "" >> \$(LUSER_HOME)/.bashrc && \\
62 echo "unset CFLAGS" >> \$(LUSER_HOME)/.bashrc && \\
63 echo "unset CXXFLAGS" >> \$(LUSER_HOME)/.bashrc && \\
64 echo "" >> \$(LUSER_HOME)/.bashrc && \\
65 echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> \$(LUSER_HOME)/.bashrc && \\
66 echo "export CLFS_TARGET=\"${TARGET}\"" >> \$(LUSER_HOME)/.bashrc && \\
67 echo "export CLFS_TARGET32=\"${TARGET32}\"" >> \$(LUSER_HOME)/.bashrc && \\
68 echo "source $JHALFSDIR/envars" >> \$(LUSER_HOME)/.bashrc
69 @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc && \\
[0170229]70 touch envars && \\
[7d4cc81]71 chmod -R a+wt \$(MOUNT_PT) && \\
[9c9775f]72 chown -R \$(LUSER) \$(MOUNT_PT)/\$(SCRIPT_ROOT)
73 @\$(call housekeeping)
[0170229]74EOF
75) >> $MKFILE.tmp
[d14903f]76 host_prep=" 023-creatingtoolsdir 024-creatingcrossdir 026-settingenvironment"
[0170229]77
78}
79
[d14903f]80#--------------------------------------#
81cross_tools_Makefiles() { #
82#--------------------------------------#
83 echo "${tab_}${GREEN}Processing... ${L_arrow}cross tools ( LUSER ) ${R_arrow}"
[0170229]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@@' \
[9c9775f]108 -e 's@-64@@' \
[0170229]109 -e 's@-n32@@'`
[3b63c8c]110 pkg_tarball=$(get_package_tarball_name $name)
[0170229]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.
[d14903f]118 LUSER_wrt_target "${this_script}" "$PREV"
[0170229]119 #
[3b63c8c]120 # If $pkg_tarball isn't empty, we've got a package...
[0170229]121 #
[d14903f]122 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
[0170229]123 #
[d14903f]124 LUSER_wrt_RunAsUser "${file}"
[0170229]125 #
[d14903f]126 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
[0170229]127 #
128 # Include a touch of the target name so make can check if it's already been made.
[9199a13]129 wrt_touch
[0170229]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
[d14903f]141#--------------------------------------#
142temptools_Makefiles() { #
143#--------------------------------------#
144 echo "${tab_}${GREEN}Processing... ${L_arrow}temp system ( LUSER ) ${R_arrow}"
[0170229]145
146 for file in temp-system/* ; do
147 # Keep the script file name
148 this_script=`basename $file`
[3b63c8c]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
157
[0170229]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 #
[3b63c8c]167 pkg_tarball=$(get_package_tarball_name $name)
[0170229]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.
[d14903f]175 LUSER_wrt_target "${this_script}" "$PREV"
[0170229]176 #
[3b63c8c]177 # If $pkg_tarball isn't empty, we've got a package...
[0170229]178 # Insert instructions for unpacking the package and to set the PKGDIR variable.
179 #
[d14903f]180 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
[3b63c8c]181 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[0170229]182 #
[d14903f]183 LUSER_wrt_RunAsUser "${file}"
[0170229]184 #
[d14903f]185 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
[0170229]186 #
187 # Include a touch of the target name so make can check if it's already been made.
[9199a13]188 wrt_touch
[0170229]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
[d14903f]200#--------------------------------------#
201chroot_Makefiles() { #
202#--------------------------------------#
203 echo "${tab_}${GREEN}Processing... ${L_arrow}tmptools CHROOT ( CHROOT ) ${R_arrow}"
[0170229]204
[d14903f]205 for file in chroot/* ; do
[0170229]206 # Keep the script file name
207 this_script=`basename $file`
[d14903f]208 #
209 # Skipping scripts is done now and not included in the build tree.
[0170229]210 case $this_script in
[d14903f]211 *chroot*) continue ;;
[0170229]212 esac
[d14903f]213
[0170229]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
[d14903f]217 case "${this_script}" in
[7d4cc81]218 *kernfs) orphan_scripts="${orphan_scripts} ${this_script}" ;;
219 *) chroottools="$chroottools $this_script" ;;
[0167dd8]220 esac
[d14903f]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
[3b63c8c]225 pkg_tarball=$(get_package_tarball_name $name)
[0167dd8]226
[1ba5024]227 # This is very ugly:: util-linux is in /chroot but must be run under LUSER
[0167dd8]228 # .. Customized makefile entry
[d14903f]229 case "${this_script}" in
[0167dd8]230 *util-linux)
[d14903f]231 LUSER_wrt_target "${this_script}" "$PREV"
[1ba5024]232 LUSER_wrt_unpack "$pkg_tarball"
233 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[d14903f]234 LUSER_wrt_RunAsUser "${file}"
235 LUSER_RemoveBuildDirs "${name}"
236 wrt_touch
[9c9775f]237 temptools="$temptools $this_script"
238 continue ;;
[d14903f]239 esac
240
[0170229]241
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.
[d14903f]248 CHROOT_wrt_target "${this_script}" "$PREV"
[0170229]249 #
[3b63c8c]250 # If $pkg_tarball isn't empty, we've got a package...
[0170229]251 # Insert instructions for unpacking the package and changing directories
252 #
[d14903f]253 if [ "$pkg_tarball" != "" ] ; then
[9c9775f]254 CHROOT_Unpack "$pkg_tarball"
[d14903f]255 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
256 fi
[0170229]257 #
258 # Select a script execution method
259 case $this_script in
[9c9775f]260 *kernfs) wrt_RunAsRoot "${file}" ;;
[d14903f]261 *) CHROOT_wrt_RunAsRoot "${file}" ;;
[0170229]262 esac
263 #
[d14903f]264 # Housekeeping...remove the build directory(ies), except if the package build fails.
265 [[ "$pkg_tarball" != "" ]] && CHROOT_wrt_RemoveBuildDirs "${name}"
[0170229]266 #
267 # Include a touch of the target name so make can check if it's already been made.
[9199a13]268 wrt_touch
[0170229]269 #
270 #--------------------------------------------------------------------#
271 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
272 #--------------------------------------------------------------------#
273 #
274 # Keep the script file name for Makefile dependencies.
275 PREV=$this_script
276
[d14903f]277 done # for file in...
[0170229]278}
279
280
[d14903f]281#--------------------------------------#
282boot_Makefiles() { #
283#--------------------------------------#
[0167dd8]284
[d14903f]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
[0170229]291 # Keep the script file name
292 this_script=`basename $file`
[d14903f]293
294 # A little housekeeping on the scripts
[fd5cb46]295 case $this_script in
[9c9775f]296 *grub | *aboot | *colo | *silo | *arcload | *lilo | *introduction ) continue ;;
[d14903f]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 ;;
[fd5cb46]304 esac
[0170229]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
[d14903f]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)
[3b63c8c]329 pkg_tarball=$(get_package_tarball_name $name)
[0170229]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.
[d14903f]337 LUSER_wrt_target "${this_script}" "$PREV"
[0170229]338 #
[3b63c8c]339 # If $pkg_tarball isn't empty, we've got a package...
[0170229]340 # Insert instructions for unpacking the package and changing directories
341 #
[d14903f]342 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
343 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[0170229]344 #
345 # Select a script execution method
346 case $this_script in
[d14903f]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
[9c9775f]349 *changingowner*) wrt_RunAsRoot "${file}" ;;
350 *devices*) wrt_RunAsRoot "${file}" ;;
[d14903f]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}" ;;
[0170229]358 esac
359 #
[d14903f]360 # Housekeeping...remove any build directory(ies) except if the package build fails.
361 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
[0170229]362 #
363 # Include a touch of the target name so make can check if it's already been made.
[9199a13]364 wrt_touch
[0170229]365 #
366 #--------------------------------------------------------------------#
367 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
368 #--------------------------------------------------------------------#
369 #
370 # Keep the script file name for Makefile dependencies.
371 PREV=$this_script
372
[d14903f]373 done
[0170229]374}
375
376
[d14903f]377#--------------------------------------#
[9c9775f]378testsuite_tools_Makefiles() { #
[d14903f]379#--------------------------------------#
[9c9775f]380
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}"
385 PREV=""
386 fi
[0170229]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
[3b63c8c]403 pkg_tarball=$(get_package_tarball_name $name)
[0170229]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.
[d14903f]411 CHROOT_wrt_target "${this_script}" "$PREV"
[0170229]412 #
[d14903f]413 CHROOT_Unpack "$pkg_tarball"
[c205656]414 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[0170229]415 #
[d14903f]416 CHROOT_wrt_RunAsRoot "${file}"
[0170229]417 #
[d14903f]418 CHROOT_wrt_RemoveBuildDirs "${name}"
[0170229]419 #
420 # Include a touch of the target name so make can check if it's already been made.
[9199a13]421 wrt_touch
[0170229]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
[d14903f]434#--------------------------------------#
[9c9775f]435final_system_Makefiles() { #
[d14903f]436#--------------------------------------#
[b12abe1]437 # Set envars and scripts for iteration targets
438 if [[ -z "$1" ]] ; then
439 local N=""
[9c9775f]440 # In boot method the makesys phase was initiated in testsuite_tools_makefile
441 [[ "${METHOD}" = "boot" ]] && [[ "$TEST" = 0 ]] && PREV=""
[b12abe1]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}
[9c9775f]452 # Rename the scripts
453 mv ${script} ${script}$N
[b12abe1]454 done
[9c9775f]455 # Remove Bzip2 binaries before make install (CLFS-1.0 compatibility)
456 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2$N
[b12abe1]457 # Delete *old Readline libraries just after make install
[9c9775f]458 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline$N
[b12abe1]459 fi
460
[9c9775f]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
[0170229]466
[b12abe1]467 for file in final-system$N/* ; do
[0170229]468 # Keep the script file name
469 this_script=`basename $file`
470
[b12abe1]471 # Test if the stripping phase must be skipped.
472 # Skip alsp temp-perl for iterative runs
[fd5cb46]473 case $this_script in
[47fddc8]474 *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
[b12abe1]475 *temp-perl*) [[ -n "$N" ]] && continue ;;
[fd5cb46]476 esac
[3fcd63e]477
[0170229]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@@' \
[9c9775f]484 -e 's@n32@@' \
485 -e 's,'$N',,'`
[0170229]486
[b12abe1]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
[3b63c8c]490 pkg_tarball=$(get_package_tarball_name $name)
[0170229]491
[3b63c8c]492 if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
[b12abe1]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
[9c9775f]501 basicsystem="$basicsystem ${this_script}"
[b12abe1]502
[0170229]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.
[9c9775f]509 CHROOT_wrt_target "${this_script}" "$PREV"
[0170229]510
[3b63c8c]511 # If $pkg_tarball isn't empty, we've got a package...
512 if [ "$pkg_tarball" != "" ] ; then
[9c9775f]513 # Touch timestamp file if installed files logs will be created.
514 # But only for the firt build when running iterative builds.
515 if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
516 CHROOT_wrt_TouchTimestamp
517 fi
[d14903f]518 CHROOT_Unpack "$pkg_tarball"
[e35e794]519 # If the testsuites must be run, initialize the log file
520 case $name in
521 binutils | gcc | glibc )
[d14903f]522 [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
[e35e794]523 ;;
524 * )
[d14903f]525 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
[e35e794]526 ;;
527 esac
528 # If using optimizations, write the instructions
[c205656]529 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[0170229]530 fi
531 #
[d14903f]532 CHROOT_wrt_RunAsRoot "${file}"
[0170229]533 #
[9c9775f]534 # Write installed files log and remove the build directory(ies)
535 # except if the package build fails.
[3b63c8c]536 if [ "$pkg_tarball" != "" ] ; then
[9c9775f]537 CHROOT_wrt_RemoveBuildDirs "$name"
538 if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
539 CHROOT_wrt_LogNewFiles "$name"
540 fi
[0170229]541 fi
542 #
[9c9775f]543 # Include a touch of the target name so make can check
544 # if it's already been made.
[9199a13]545 wrt_touch
[0170229]546 #
547 #--------------------------------------------------------------------#
548 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
549 #--------------------------------------------------------------------#
550 #
551 # Keep the script file name for Makefile dependencies.
[9c9775f]552 PREV=${this_script}
[b12abe1]553 # Set system_build envar for iteration targets
554 system_build=$basicsystem
[0170229]555 done # for file in final-system/* ...
[d14903f]556}
[0170229]557
[d14903f]558#--------------------------------------#
[9c9775f]559bootscripts_Makefiles() { #
[d14903f]560#--------------------------------------#
[9c9775f]561
562 if [[ "${METHOD}" = "chroot" ]]; then
563 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) bootscripts ( CHROOT ) ${R_arrow}"
564 else
565 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) bootscripts ( ROOT ) ${R_arrow}"
566 fi
[0170229]567
568 for file in bootscripts/* ; do
569 # Keep the script file name
570 this_script=`basename $file`
571
572 case $this_script in
[eba62c0]573 *udev) continue ;; # This is not a script but a commentary, we want udev-rules
[0170229]574 *console*) continue ;; # Use the files that came with the bootscripts
575 *) ;;
576 esac
577
578 # First append each name of the script files to a list (this will become
579 # the names of the targets in the Makefile
580 bootscripttools="$bootscripttools $this_script"
581
582 # Grab the name of the target, strip id number, XXX-script
583 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
584 -e 's@-64bit@@' \
585 -e 's@-64@@' \
586 -e 's@64@@' \
587 -e 's@n32@@'`
[fd5cb46]588 case $name in
[eba62c0]589 *bootscripts*) name=bootscripts-cross-lfs ;;
590 *udev-rules) name=udev-cross-lfs ;;
[fd5cb46]591 esac
[3b63c8c]592
593 pkg_tarball=$(get_package_tarball_name $name)
[0170229]594
595 #--------------------------------------------------------------------#
596 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
597 #--------------------------------------------------------------------#
598 #
599 # Drop in the name of the target on a new line, and the previous target
600 # as a dependency. Also call the echo_message function.
[d14903f]601 CHROOT_wrt_target "${this_script}" "$PREV"
[0170229]602 #
[3b63c8c]603 # If $pkg_tarball isn't empty, we've got a package...
[0170229]604 #
[9c9775f]605 if [ "$pkg_tarball" != "" ] ; then
606 if [ "${INSTALL_LOG}" = "y" ] ; then
607 CHROOT_wrt_LogNewFiles "$name"
608 fi
609 CHROOT_Unpack "$pkg_tarball"
610 fi
[0170229]611 #
[d14903f]612 CHROOT_wrt_RunAsRoot "${file}"
[0170229]613 #
[9c9775f]614 # Write installed files log and remove the build directory(ies)
615 # except if the package build fails.
616 if [ "$pkg_tarball" != "" ] ; then
617 CHROOT_wrt_RemoveBuildDirs "$name"
618 if [ "${INSTALL_LOG}" = "y" ] ; then
619 CHROOT_wrt_LogNewFiles "$name"
620 fi
621 fi
[0170229]622 #
623 # Include a touch of the target name so make can check if it's already been made.
[9199a13]624 wrt_touch
[0170229]625 #
626 #--------------------------------------------------------------------#
627 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
628 #--------------------------------------------------------------------#
629 #
630 # Keep the script file name for Makefile dependencies.
631 PREV=$this_script
632
633 done # for file in bootscripts/* ...
634}
635
[d14903f]636#--------------------------------------#
[9c9775f]637bootable_Makefiles() { #
[d14903f]638#--------------------------------------#
[0170229]639
[9c9775f]640 if [[ "${METHOD}" = "chroot" ]]; then
641 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable ( CHROOT ) ${R_arrow}"
642 else
643 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable ( ROOT ) ${R_arrow}"
644 fi
[0170229]645
646
[9c9775f]647 for file in bootable/* ; do
[0170229]648 # Keep the script file name
649 this_script=`basename $file`
650
651 # A little housekeeping on the scripts
652 case $this_script in
[7f38b6d]653 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
[d14903f]654 *fstab) [[ ! -z ${FSTAB} ]] && cp ${FSTAB} $BUILDDIR/sources/fstab ;;
[87b93b4]655 *kernel) # if there is no kernel config file do not build the kernel
[4845f38]656 [[ -z $CONFIG ]] && continue
[0271c0c]657 # Copy the config file to /sources with a standardized name
[1917cad]658 cp $CONFIG $BUILDDIR/sources/kernel-config
[87b93b4]659 ;;
[0170229]660 esac
661 #
662 # First append each name of the script files to a list (this will become
663 # the names of the targets in the Makefile
664 bootabletools="$bootabletools $this_script"
665 #
666 # Grab the name of the target, strip id number and misc words.
667 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
[fd5cb46]668 case $this_script in
669 *kernel*) name=linux
670 ;;
671 esac
[3b63c8c]672
673 pkg_tarball=$(get_package_tarball_name $name)
[0170229]674
675 #--------------------------------------------------------------------#
676 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
677 #--------------------------------------------------------------------#
678 #
679 # Drop in the name of the target on a new line, and the previous target
680 # as a dependency. Also call the echo_message function.
[d14903f]681 CHROOT_wrt_target "${this_script}" "$PREV"
[0170229]682 #
[3b63c8c]683 # If $pkg_tarball isn't empty, we've got a package...
[0170229]684 # Insert instructions for unpacking the package and changing directories
685 #
[9c9775f]686 if [ "$pkg_tarball" != "" ] ; then
687 if [ "${INSTALL_LOG}" = "y" ] ; then
688 CHROOT_wrt_LogNewFiles "$name"
689 fi
690 CHROOT_Unpack "$pkg_tarball"
691 fi
[0170229]692 #
693 # Select a script execution method
694 case $this_script in
[d14903f]695 *fstab*) if [[ -n "$FSTAB" ]]; then
696 CHROOT_wrt_CopyFstab
697 else
698 CHROOT_wrt_RunAsRoot "${file}"
699 fi
700 ;;
701 *) CHROOT_wrt_RunAsRoot "${file}"
702 ;;
[0170229]703 esac
704 #
[9c9775f]705 # Write installed files log and remove the build directory(ies)
706 # except if the package build fails.
707 if [ "$pkg_tarball" != "" ] ; then
708 CHROOT_wrt_RemoveBuildDirs "$name"
709 if [ "${INSTALL_LOG}" = "y" ] ; then
710 CHROOT_wrt_LogNewFiles "$name"
711 fi
712 fi
[0170229]713 #
714 # Include a touch of the target name so make can check if it's already been made.
[9199a13]715 wrt_touch
[0170229]716 #
717 #--------------------------------------------------------------------#
718 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
719 #--------------------------------------------------------------------#
720 #
721 # Keep the script file name for Makefile dependencies.
722 PREV=$this_script
723
724 done
725
726}
727
728
[d14903f]729#--------------------------------------#
730build_Makefile() { # Construct a Makefile from the book scripts
731#--------------------------------------#
732 #
733 # Script crashes if error trapping is on
734 #
735set +e
736 declare -f method_cmds
737set -e
738
739 echo "...Creating Makefile... ${BOLD}START${OFF}"
[0170229]740
741 cd $JHALFSDIR/${PROGNAME}-commands
[d14903f]742 # Start with a clean files
743 >$MKFILE
[0170229]744 >$MKFILE.tmp
745
[9c9775f]746 method_cmds=${METHOD}_Makefiles
[0167dd8]747
[d14903f]748 host_prep_Makefiles # mk_SETUP (SETUP) $host_prep
749 cross_tools_Makefiles # mk_CROSS (LUSER) $cross_tools
750 temptools_Makefiles # mk_TEMP (LUSER) $temptools
751 $method_cmds # mk_SYSTOOLS (CHROOT) $chroottools/$boottools
752 if [[ ! $TEST = "0" ]]; then
[9c9775f]753 testsuite_tools_Makefiles # mk_SYSTOOLS (CHROOT) $testsuitetools
[0170229]754 fi
[9c9775f]755 final_system_Makefiles # mk_FINAL (CHROOT) $basicsystem
[d14903f]756 # Add the iterations targets, if needed
757 [[ "$COMPARE" = "y" ]] && wrt_compare_targets
[9c9775f]758 bootscripts_Makefiles # mk_BOOTSCRIPT (CHROOT) $bootscripttools
759 bootable_Makefiles # mk_BOOTABLE (CHROOT) $bootabletools
[0170229]760
[9c9775f]761 # Add the CUSTOM_TOOLS targets, if needed
762 [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
[2ee1d11]763 # Add the BLFS_TOOL targets, if needed
764 [[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
765
[0170229]766 # Add a header, some variables and include the function file
767 # to the top of the real Makefile.
[9c9775f]768 wrt_Makefile_header
[0170229]769
770 # Add chroot commands
[e676ffa]771 if [ "$METHOD" = "chroot" ] ; then
[8381f6e]772 CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
773 chroot=`cat chroot/*chroot* | \
774 sed -e "s@chroot@$CHROOT_LOC@" \
[9c9775f]775 -e '/#!\/bin\/bash/d' \
[8381f6e]776 -e '/^export/d' \
777 -e '/^logout/d' \
778 -e 's@ \\\@ @g' | \
779 tr -d '\n' | \
780 sed -e 's/ */ /g' \
781 -e 's|\\$|&&|g' \
782 -e 's|exit||g' \
783 -e 's|$| -c|' \
[9c9775f]784 -e 's|"$${CLFS}"|$(MOUNT_PT)|'\
785 -e 's|set -e||' \
786 -e 's|set +h||'`
[e676ffa]787 echo -e "CHROOT1= $chroot\n" >> $MKFILE
788 fi
[0170229]789
[d14903f]790################## CHROOT ####################
791
[39d4d5c]792if [[ "${METHOD}" = "chroot" ]]; then
[0170229]793(
[d14903f]794cat << EOF
795
[9c9775f]796all: ck_UID mk_SETUP mk_CROSS mk_SUDO mk_SYSTOOLS create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL
[7d4cc81]797 @sudo make do-housekeeping
[9c9775f]798 @echo "$VERSION - jhalfs build" > clfs-release && \\
799 sudo mv clfs-release \$(MOUNT_PT)/etc
[0170229]800 @\$(call echo_finished,$VERSION)
801
[7d4cc81]802ck_UID:
803 @if [ \`id -u\` = "0" ]; then \\
[17cde98]804 echo "+--------------------------------------------------+"; \\
805 echo "|You cannot run this makefile from the root account|"; \\
806 echo "+--------------------------------------------------+"; \\
[7d4cc81]807 exit 1; \\
808 fi
809
[d14903f]810#---------------AS ROOT
811mk_SETUP:
812 @\$(call echo_SU_request)
[9c9775f]813 @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
[d14903f]814 @touch \$@
[0167dd8]815
[d14903f]816#---------------AS LUSER
817mk_CROSS: mk_SETUP
[17cde98]818 @\$(call echo_PHASE,Cross and Temporary Tools)
[9c9775f]819 @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) AS_LUSER" )
[621f01f]820 @sudo make restore-luser-env
[d14903f]821 @touch \$@
822
[17cde98]823mk_SUDO: mk_CROSS
[9c9775f]824 @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
[7d4cc81]825 @touch \$@
[d14903f]826
827#---------------CHROOT JAIL
[0167dd8]828mk_SYSTOOLS: mk_SUDO
[d14903f]829 @\$(call echo_CHROOT_request)
[17cde98]830 @\$(call echo_PHASE, CHROOT JAIL )
[9c9775f]831 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) PREP_CHROOT_JAIL")
832 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT_JAIL")
833 @touch \$@
834
835mk_CUSTOM_TOOLS: create-sbu_du-report
836 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
837 \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
838 sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
839 (sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
840 fi;
[d14903f]841 @touch \$@
842
[9c9775f]843mk_BLFS_TOOL: mk_CUSTOM_TOOLS
[2ee1d11]844 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
[9c9775f]845 \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
[2ee1d11]846 sudo mkdir -p $BUILDDIR$TRACKING_DIR; \\
[9c9775f]847 sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL"; \\
848 fi;
[2ee1d11]849 @touch \$@
[d14903f]850
[9c9775f]851SETUP: $host_prep
852AS_LUSER: $cross_tools $temptools
853SUDO: $orphan_scripts
854PREP_CHROOT_JAIL: SHELL=/tools/bin/bash
855PREP_CHROOT_JAIL: ${chroottools}
856CHROOT_JAIL: SHELL=/tools/bin/bash
857CHROOT_JAIL: $testsuitetools $basicsystem $bootscripttools $bootabletools
858CUSTOM_TOOLS: $custom_list
859BLFS_TOOL: $blfs_tool
860
861
862create-sbu_du-report: mk_SYSTOOLS
863 @\$(call echo_message, Building)
864 @if [ "\$(ADD_REPORT)" = "y" ]; then \\
865 ./create-sbu_du-report.sh logs $VERSION; \\
866 \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
867 fi;
868 @touch \$@
[0170229]869
[621f01f]870do-housekeeping:
871 @-umount \$(MOUNT_PT)/dev/pts
872 @-umount \$(MOUNT_PT)/dev/shm
873 @-umount \$(MOUNT_PT)/dev
874 @-umount \$(MOUNT_PT)/sys
875 @-umount \$(MOUNT_PT)/proc
876 @-rm /tools /cross-tools
877 @-if [ ! -f luser-exist ]; then \\
878 userdel \$(LUSER); \\
[9c9775f]879 rm -rf \$(LUSER_HOME); \\
[621f01f]880 fi;
881
882EOF
883) >> $MKFILE
884
[d14903f]885fi
[0170229]886
[d14903f]887################### BOOT #####################
[0170229]888
[d14903f]889if [[ "${METHOD}" = "boot" ]]; then
890(
891cat << EOF
[0170229]892
[17cde98]893all: ck_UID mk_SETUP mk_CROSS mk_SUDO
[7d4cc81]894 @sudo make restore-luser-env
[3f90849]895 @sudo make do-housekeeping
[d14903f]896 @\$(call echo_boot_finished,$VERSION)
[0170229]897
[9c9775f]898makesys: mk_FINAL mk_CUSTOM_TOOLS mk_BLFS_TOOL
899 @echo "$VERSION - jhalfs build" > /etc/clfs-release
[d14903f]900 @\$(call echo_finished,$VERSION)
[0170229]901
[7d4cc81]902
903ck_UID:
904 @if [ \`id -u\` = "0" ]; then \\
[17cde98]905 echo "+--------------------------------------------------+"; \\
906 echo "|You cannot run this makefile from the root account|"; \\
907 echo "|However, if this is the boot environment |"; \\
908 echo "| the command you are looking for is |"; \\
909 echo "| make makesys |"; \\
910 echo "| to finish off the build |"; \\
911 echo "+--------------------------------------------------+"; \\
[7d4cc81]912 exit 1; \\
913 fi
914
[d14903f]915#---------------AS ROOT
[0170229]916
[d14903f]917mk_SETUP:
918 @\$(call echo_SU_request)
[9c9775f]919 @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
[d14903f]920 @touch \$@
[0170229]921
[d14903f]922#---------------AS LUSER
[0167dd8]923
[d14903f]924mk_CROSS: mk_SETUP
925 @\$(call echo_PHASE,Cross Tool)
[9c9775f]926 @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) AS_LUSER" )
[7d4cc81]927 @touch \$@
928
[2ee1d11]929mk_SUDO: mk_CROSS
[9c9775f]930 @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
[d14903f]931 @touch \$@
932
933#---------------AS ROOT
[0170229]934
[d14903f]935mk_FINAL:
936 @\$(call echo_PHASE,Final System)
[9c9775f]937 @( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) AS_ROOT )
938 @touch \$@
939
940mk_CUSTOM_TOOLS: mk_FINAL
941 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
942 \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
943 mkdir -p ${TRACKING_DIR}; \\
944 ( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS ); \\
945 fi;
[d14903f]946 @touch \$@
947
[9c9775f]948mk_BLFS_TOOL: mk_CUSTOM_TOOLS
[2ee1d11]949 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
[9c9775f]950 \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
[2ee1d11]951 mkdir -p $TRACKING_DIR; \\
[9c9775f]952 ( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) BLFS_TOOL ); \\
[2ee1d11]953 fi
954 @touch \$@
955
[9c9775f]956SETUP: $host_prep
957AS_LUSER: $cross_tools $temptools ${boottools}
958SUDO: $orphan_scripts
959AS_ROOT: SHELL=/tools/bin/bash
960AS_ROOT: $testsuitetools $basicsystem $bootscripttools $bootabletools
961CUSTOM_TOOLS: $custom_list
962BLFS_TOOL: $blfs_tool
[d14903f]963
[3f90849]964do-housekeeping:
965 @-rm /tools /cross-tools
966 @-if [ ! -f luser-exist ]; then \\
967 userdel \$(LUSER); \\
[9c9775f]968 rm -rf \$(LUSER_HOME); \\
[3f90849]969 fi;
970
[d14903f]971EOF
972) >> $MKFILE
973fi
974
975(
976 cat << EOF
977
[30737ea8]978restore-luser-env:
[0170229]979 @\$(call echo_message, Building)
[9c9775f]980 @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
981 mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
[0170229]982 fi;
[9c9775f]983 @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
984 mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
[0170229]985 fi;
[9c9775f]986 @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash* && \\
[9199a13]987 touch \$@ && \\
988 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
989 echo --------------------------------------------------------------------------------\$(WHITE)
[0170229]990
[d14903f]991########################################################
[39d4d5c]992
[3a27393]993
[39d4d5c]994EOF
995) >> $MKFILE
[0170229]996
997 # Bring over the items from the Makefile.tmp
998 cat $MKFILE.tmp >> $MKFILE
999 rm $MKFILE.tmp
1000
[d14903f]1001 echo "Creating Makefile... ${BOLD}DONE${OFF}"
[0170229]1002}
Note: See TracBrowser for help on using the repository browser.