source: CLFS/master.sh@ 830f28d

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

CLFS-svn, changes to chroot extraction for makefile

  • Property mode set to 100644
File size: 33.7 KB
RevLine 
[91ff6a9]1#!/bin/bash
[877cc6a]2# $Id$
3
[045b2dc]4
5orphan_scripts="" # 2 scripts do not fit BOOT_Makefiles LUSER environment
6
7
8#--------------------------------------#
9host_prep_Makefiles() { #
10#--------------------------------------#
[e2ec07a]11 local CLFS_HOST
[877cc6a]12
[045b2dc]13 echo "${tab_}${GREEN}Processing... ${L_arrow}host prep files ( SETUP ) ${R_arrow}"
[877cc6a]14
15 # defined here, only for ease of reading
[ff4d1ab]16 CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo $MACHTYPE | cut -d- -f2)/cross/")"
[877cc6a]17(
18cat << EOF
19023-creatingtoolsdir:
20 @\$(call echo_message, Building)
[e314f7e]21 @mkdir \$(MOUNT_PT)/tools && \\
22 rm -f /tools && \\
[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 && \\
[830f28d]65 echo "PATH=\$(MOUNT_PT)/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
[c10570d]734 # Add the BLFS_TOOL targets, if needed
735 [[ "$BLFS_TOOL" = "y" ]] && wrt_blfs_tool_targets
736
[877cc6a]737 # Add a header, some variables and include the function file
738 # to the top of the real Makefile.
[195ed9f]739 wrt_Makefile_header
[877cc6a]740
741 # Add chroot commands
742 if [ "$METHOD" = "chroot" ] ; then
[6ad5a2f]743 CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
744 chroot=`cat chroot/*chroot* | \
745 sed -e "s@chroot@$CHROOT_LOC@" \
[830f28d]746 -e '/#!\/bin\/bash/d' \
[6ad5a2f]747 -e '/^export/d' \
748 -e '/^logout/d' \
749 -e 's@ \\\@ @g' | \
750 tr -d '\n' | \
751 sed -e 's/ */ /g' \
752 -e 's|\\$|&&|g' \
753 -e 's|exit||g' \
754 -e 's|$| -c|' \
[f4d9a48]755 -e 's|"$${CLFS}"|$(MOUNT_PT)|'\
[f3a7f3b]756 -e 's|set -e||' \
757 -e 's|set +h||'`
[877cc6a]758 echo -e "CHROOT1= $chroot\n" >> $MKFILE
759 fi
760
[045b2dc]761################## CHROOT ####################
762
[877cc6a]763if [[ "${METHOD}" = "chroot" ]]; then
764(
[045b2dc]765cat << EOF
[877cc6a]766
[c10570d]767all: ck_UID mk_SETUP mk_CROSS mk_SUDO mk_SYSTOOLS create-sbu_du-report mk_BLFS_TOOL
[045b2dc]768 @sudo make do-housekeeping
[936efa8]769 @echo "$VERSION - jhalfs build" > clfs-release && \\
770 sudo mv clfs-release \$(MOUNT_PT)/etc
[045b2dc]771 @\$(call echo_finished,$VERSION)
[a160d86]772
[045b2dc]773ck_UID:
774 @if [ \`id -u\` = "0" ]; then \\
775 echo "+--------------------------------------------------+"; \\
776 echo "|You cannot run this makefile from the root account|"; \\
777 echo "+--------------------------------------------------+"; \\
778 exit 1; \\
779 fi
780
781#---------------AS ROOT
782mk_SETUP:
783 @\$(call echo_SU_request)
[a2133cb]784 @sudo make SHELL=/bin/bash SETUP
[045b2dc]785 @touch \$@
786
787#---------------AS LUSER
788mk_CROSS: mk_SETUP
789 @\$(call echo_PHASE,Cross and Temporary Tools)
[a2133cb]790 @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make SHELL=/bin/bash AS_LUSER" )
[045b2dc]791 @sudo make restore-luser-env
792 @touch \$@
793
794mk_SUDO: mk_CROSS
[a2133cb]795 @sudo make SHELL=/bin/bash SUDO
[045b2dc]796 @touch \$@
797#
798# The convoluted piece of code below is necessary to provide 'make' with a valid shell in the
799# chroot environment. (Unless someone knows a different way)
800# Manually create the /bin directory and provide link to the /tools dir.
801# Also change the original symlink creation to include (f)orce to prevent failure due to
802# pre-existing links.
803
804#---------------CHROOT JAIL
805mk_SYSTOOLS: mk_SUDO
806 @if [ ! -e \$(MOUNT_PT)/bin ]; then \\
807 mkdir \$(MOUNT_PT)/bin; \\
808 cd \$(MOUNT_PT)/bin && \\
809 ln -svf /tools/bin/bash bash; ln -sf bash sh; \\
810 sudo chown -R 0:0 \$(MOUNT_PT)/bin; \\
[877cc6a]811 fi;
[f4d9a48]812 @sudo sed -e 's|^ln -sv |ln -svf |' -i \$(CMDSDIR)/chroot/*-createfiles
[045b2dc]813 @\$(call echo_CHROOT_request)
814 @\$(call echo_PHASE, CHROOT JAIL )
815 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make CHROOT_JAIL")
816 @touch \$@
[877cc6a]817
[1838bc7]818mk_BLFS_TOOL: create-sbu_du-report
819 @\$(call echo_PHASE,Building BLFS-TOOLS)
[c10570d]820 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
821 sudo mkdir -p $BUILDDIR$TRACKING_DIR; \\
822 sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BLFS_TOOL"; \\
[1838bc7]823 fi;
[c10570d]824 @touch \$@
[045b2dc]825
826SETUP: $host_prep
827AS_LUSER: $cross_tools $temptools
828SUDO: $orphan_scripts
[d55a1a1]829CHROOT_JAIL: ${chroottools} $testsuitetools $basicsystem $bootscripttools $bootabletools
[c10570d]830BLFS_TOOL: $blfs_tool
[877cc6a]831
[1838bc7]832
833create-sbu_du-report: mk_SYSTOOLS
834 @\$(call echo_message, Building)
835 @if [ "\$(ADD_REPORT)" = "y" ]; then \\
836 ./create-sbu_du-report.sh logs $VERSION; \\
837 \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
838 fi;
839 @touch \$@
840
[7d9a82d]841do-housekeeping:
[4524fb2]842 @-umount \$(MOUNT_PT)/dev/pts
843 @-umount \$(MOUNT_PT)/dev/shm
844 @-umount \$(MOUNT_PT)/dev
845 @-umount \$(MOUNT_PT)/sys
846 @-umount \$(MOUNT_PT)/proc
[045b2dc]847 @-rm /tools /cross-tools
[6ad5a2f]848 @-if [ ! -f luser-exist ]; then \\
849 userdel \$(LUSER); \\
850 rm -rf /home/\$(LUSER); \\
[7d9a82d]851 fi;
852
[877cc6a]853EOF
854) >> $MKFILE
[045b2dc]855
[877cc6a]856fi
857
[045b2dc]858################### BOOT #####################
[877cc6a]859
860if [[ "${METHOD}" = "boot" ]]; then
861(
[045b2dc]862cat << EOF
[877cc6a]863
[045b2dc]864all: ck_UID mk_SETUP mk_CROSS mk_SUDO
865 @sudo make restore-luser-env
866 @sudo make do-housekeeping
[877cc6a]867 @\$(call echo_boot_finished,$VERSION)
868
[c10570d]869makesys: mk_FINAL mk_BLFS_TOOL
[936efa8]870 @echo "$VERSION - jhalfs build" > /etc/clfs-release
[877cc6a]871 @\$(call echo_finished,$VERSION)
872
873
[045b2dc]874ck_UID:
875 @if [ \`id -u\` = "0" ]; then \\
876 echo "+--------------------------------------------------+"; \\
877 echo "|You cannot run this makefile from the root account|"; \\
878 echo "|However, if this is the boot environment |"; \\
879 echo "| the command you are looking for is |"; \\
880 echo "| make makesys |"; \\
881 echo "| to finish off the build |"; \\
882 echo "+--------------------------------------------------+"; \\
883 exit 1; \\
884 fi
[877cc6a]885
[045b2dc]886#---------------AS ROOT
[877cc6a]887
[045b2dc]888mk_SETUP:
889 @\$(call echo_SU_request)
[d55a1a1]890 @sudo make SHELL=/bin/bash SETUP
[045b2dc]891 @touch \$@
892
893#---------------AS LUSER
[a160d86]894
[045b2dc]895mk_CROSS: mk_SETUP
896 @\$(call echo_PHASE,Cross Tool)
[a2133cb]897 @(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make SHELL=/bin/bash AS_LUSER" )
[045b2dc]898 @touch \$@
899
[c10570d]900mk_SUDO: mk_CROSS
[a2133cb]901 @sudo make SHELL=/bin/bash SUDO
[045b2dc]902 @touch \$@
903
904#---------------AS ROOT
905
906mk_FINAL:
907 @\$(call echo_PHASE,Final System)
[d55a1a1]908 @( source /root/.bash_profile && make AS_ROOT )
[045b2dc]909 @touch \$@
910
[c10570d]911mk_BLFS_TOOL: mk_FINAL
912 @\$(call echo_PHASE,Building BLFS-TOOLS)
913 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
914 mkdir -p $TRACKING_DIR; \\
[d55a1a1]915 ( make BLFS_TOOL ); \\
[c10570d]916 fi
917 @touch \$@
918
[045b2dc]919SETUP: $host_prep
[d55a1a1]920AS_LUSER: $cross_tools $temptools ${boottools}
[045b2dc]921SUDO: $orphan_scripts
922AS_ROOT: $testsuitetools $basicsystem $bootscripttools $bootabletools
[c10570d]923BLFS_TOOL: $blfs_tool
[045b2dc]924
925do-housekeeping:
926 @-rm /tools /cross-tools
927 @-if [ ! -f luser-exist ]; then \\
[6ad5a2f]928 userdel \$(LUSER); \\
929 rm -rf /home/\$(LUSER); \\
[877cc6a]930 fi;
931
[045b2dc]932EOF
933) >> $MKFILE
934fi
935
936(
937 cat << EOF
938
[6ad5a2f]939restore-luser-env:
[877cc6a]940 @\$(call echo_message, Building)
[6ad5a2f]941 @if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
[045b2dc]942 mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
[877cc6a]943 fi;
[6ad5a2f]944 @if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
[045b2dc]945 mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
[877cc6a]946 fi;
[6ad5a2f]947 @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
[93f38e7]948 touch \$@ && \\
949 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
950 echo --------------------------------------------------------------------------------\$(WHITE)
[877cc6a]951
[045b2dc]952########################################################
953
[7d9a82d]954
[877cc6a]955EOF
956) >> $MKFILE
957
958 # Bring over the items from the Makefile.tmp
959 cat $MKFILE.tmp >> $MKFILE
960 rm $MKFILE.tmp
961
[045b2dc]962 echo "Creating Makefile... ${BOLD}DONE${OFF}"
[877cc6a]963}
Note: See TracBrowser for help on using the repository browser.