source: CLFS/master.sh@ ca6b261

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

Replaced CLFS BOOT_* functions by CHROOT_* functions due that are identical.

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