source: CLFS/master.sh@ ff9938f

2.4 ablfs-more legacy new_features trunk
Last change on this file since ff9938f was c6ee8ea, checked in by Pierre Labastie <pierre@…>, 10 years ago

Adaptation to the new layout for CLFS systemd.
From a patch by W. Harrington

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