source: CLFS/master.sh@ fcb540b

2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since fcb540b was fcb540b, checked in by George Boudreau <georgeb@…>, 18 years ago

CLFS:: Correct extraction of data from chroot file

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