source: CLFS/master.sh@ 45f0437

new_features
Last change on this file since 45f0437 was bc5aee2, checked in by Pierre Labastie <pierre@…>, 9 years ago

Merge trunk r3851

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