source: CLFS/master.sh@ 6caa5b8

ablfs-more legacy trunk
Last change on this file since 6caa5b8 was 2e1c1c3, checked in by Pierre Labastie <pierre@…>, 7 years ago

Remove spaces at the end of lines

  • Property mode set to 100644
File size: 43.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 && \\
[5f154f1]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 ;;
[d601cfc]381 *fstab) [[ -z "${FSTAB}" ]] ||
[85506da]382 [[ ${FSTAB} == $BUILDDIR/sources/fstab ]] ||
383 cp ${FSTAB} $BUILDDIR/sources/fstab ;;
[045b2dc]384 *kernel) # if there is no kernel config file do not build the kernel
[85506da]385 [[ -z $BOOT_CONFIG ]] && continue
[045b2dc]386 # Copy the config file to /sources with a standardized name
[85506da]387 [[ ${BOOT_CONFIG} == $BUILDDIR/sources/bootkernel-config ]] ||
[045b2dc]388 cp $BOOT_CONFIG $BUILDDIR/sources/bootkernel-config
389 ;;
[877cc6a]390 esac
391 #
392 # First append each name of the script files to a list (this will become
[179ae85]393 # the names of the targets in the Makefile). Those names differ depending
394 # on the version of the book. What makes the difference between those
395 # versions is the presence of "how-to-view" in the boot chapter.
396 if [ -f boot/*how-to-view ]; then
397 case "${this_script}" in
398 *changingowner)
399 orphan_scripts="${orphan_scripts} ${this_script}"
400 ;;
401 *creatingdirs)
402 orphan_scripts="${orphan_scripts} ${this_script}"
403 ;;
404 *createfiles)
405 orphan_scripts="${orphan_scripts} ${this_script}"
406 ;;
407 *devices)
408 orphan_scripts="${orphan_scripts} ${this_script}"
409 ;;
410 *flags)
411 orphan_scripts="${orphan_scripts} ${this_script}"
412 ;;
413 *fstab)
414 orphan_scripts="${orphan_scripts} ${this_script}"
415 ;;
416 *pwdgroup)
417 orphan_scripts="${orphan_scripts} ${this_script}"
418 ;;
419 *settingenvironment)
420 orphan_scripts="${orphan_scripts} ${this_script}"
421 ;;
422 *)
423 boottools="$boottools $this_script"
424 ;;
425 esac
426 else
427 case "${this_script}" in
428 *changingowner)
429 orphan_scripts="${orphan_scripts} ${this_script}"
430 ;;
431 *devices)
432 orphan_scripts="${orphan_scripts} ${this_script}"
433 ;;
434 *)
435 boottools="$boottools $this_script"
436 ;;
437 esac
438 fi
[045b2dc]439 #
440 # Grab the name of the target, strip id number and misc words.
441 case $this_script in
[179ae85]442 *kernel) name=linux ;;
443 *bootscripts) name="bootscripts-cross-lfs" ;;
444 *boot-scripts) name="boot-scripts-cross-lfs" ;;
445 *udev-rules) name="udev-cross-lfs" ;;
446 *grub-build) name=grub ;;
447 *-aboot-build) name=aboot ;;
448 *yaboot-build) name=yaboot ;;
449 *colo-build) name=colo ;;
450 *silo-build) name=silo ;;
451 *arcload-build) name=arcload ;;
452 *lilo-build) name=lilo ;;
[045b2dc]453 *) name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' ` ;;
454 esac
455 # Identify the unique version naming scheme for the clfs bootscripts..(bad boys)
[a160d86]456 pkg_tarball=$(get_package_tarball_name $name)
[877cc6a]457
458 #--------------------------------------------------------------------#
459 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
460 #--------------------------------------------------------------------#
461 #
462 # Drop in the name of the target on a new line, and the previous target
463 # as a dependency. Also call the echo_message function.
[045b2dc]464 LUSER_wrt_target "${this_script}" "$PREV"
[877cc6a]465 #
[a160d86]466 # If $pkg_tarball isn't empty, we've got a package...
[877cc6a]467 # Insert instructions for unpacking the package and changing directories
468 #
[045b2dc]469 [[ "$pkg_tarball" != "" ]] && LUSER_wrt_unpack "$pkg_tarball"
[ce262a7]470 [[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[877cc6a]471 #
472 # Select a script execution method
[179ae85]473 if [ -f boot/*how-to-view ]; then
474 case $this_script in
475 # The following 8 scripts are defined in the /boot directory but need
476 # to be run as a root user. Set them up here but run them in another
477 # phase
478 *changingowner) wrt_RunAsRoot "${file}" ;;
479 *creatingdirs) wrt_RunAsRoot "${file}" ;;
480 *createfiles) wrt_RunAsRoot "${file}" ;;
481 *devices) wrt_RunAsRoot "${file}" ;;
482 *flags) wrt_RunAsRoot "${file}" ;;
483 *fstab)
484 if [[ -n "$FSTAB" ]]; then
485 LUSER_wrt_CopyFstab
486 else
487 wrt_RunAsRoot "${file}"
488 fi
489 ;;
490 *pwdgroup) wrt_RunAsRoot "${file}" ;;
491 *settingenvironment) wrt_RunAsRoot "${file}" ;;
492 *) LUSER_wrt_RunAsUser "${file}" ;;
493 esac
494 else
495 case $this_script in
496 # The following 2 scripts are defined in the /boot directory but need
497 # to be run as a root user. Set them up here but run them in another
498 # phase
499 *changingowner) wrt_RunAsRoot "${file}" ;;
500 *devices) wrt_RunAsRoot "${file}" ;;
501 *fstab)
[d601cfc]502 if [[ -n "${FSTAB}" ]]; then
[179ae85]503 LUSER_wrt_CopyFstab
504 else
505 LUSER_wrt_RunAsUser "${file}"
506 fi
507 ;;
508 *) LUSER_wrt_RunAsUser "${file}" ;;
509 esac
510 fi
[877cc6a]511 #
[045b2dc]512 # Housekeeping...remove any build directory(ies) except if the package build fails.
513 [[ "$pkg_tarball" != "" ]] && LUSER_RemoveBuildDirs "${name}"
[877cc6a]514 #
515 # Include a touch of the target name so make can check if it's already been made.
[93f38e7]516 wrt_touch
[877cc6a]517 #
518 #--------------------------------------------------------------------#
519 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
520 #--------------------------------------------------------------------#
521 #
522 # Keep the script file name for Makefile dependencies.
523 PREV=$this_script
524
[045b2dc]525 done
[877cc6a]526}
527
528
[045b2dc]529#--------------------------------------#
[d55a1a1]530testsuite_tools_Makefiles() { #
[045b2dc]531#--------------------------------------#
[877cc6a]532
[d55a1a1]533 if [[ "${METHOD}" = "chroot" ]]; then
534 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) testsuite tools ( CHROOT ) ${R_arrow}"
535 else
536 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) testsuite tools ( ROOT ) ${R_arrow}"
[010627d]537 PREV=""
[d55a1a1]538 fi
[877cc6a]539
540 for file in testsuite-tools/* ; do
541 # Keep the script file name
542 this_script=`basename $file`
543
544 # First append each name of the script files to a list (this will become
545 # the names of the targets in the Makefile
546 testsuitetools="$testsuitetools $this_script"
547
548 # Grab the name of the target, strip id number, XXX-script
549 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'\
550 -e 's@-64bit@@' \
551 -e 's@-64@@' \
552 -e 's@64@@' \
553 -e 's@n32@@'`
554
[a160d86]555 pkg_tarball=$(get_package_tarball_name $name)
[877cc6a]556
557 #--------------------------------------------------------------------#
558 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
559 #--------------------------------------------------------------------#
560 #
561 # Drop in the name of the target on a new line, and the previous target
562 # as a dependency. Also call the echo_message function.
[ca6b261]563 CHROOT_wrt_target "${this_script}" "$PREV"
[877cc6a]564 #
[ca6b261]565 CHROOT_Unpack "$pkg_tarball"
[ce262a7]566 [[ "$OPTIMIZE" -ge "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[877cc6a]567 #
[ca6b261]568 CHROOT_wrt_RunAsRoot "${file}"
[877cc6a]569 #
[ca6b261]570 CHROOT_wrt_RemoveBuildDirs "${name}"
[877cc6a]571 #
572 # Include a touch of the target name so make can check if it's already been made.
[93f38e7]573 wrt_touch
[877cc6a]574 #
575 #--------------------------------------------------------------------#
576 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
577 #--------------------------------------------------------------------#
578 #
579 # Keep the script file name for Makefile dependencies.
580 PREV=$this_script
581
582 done
583}
584
585
[045b2dc]586#--------------------------------------#
[d55a1a1]587final_system_Makefiles() { #
[045b2dc]588#--------------------------------------#
[45f82718]589 # Set envars and scripts for iteration targets
590 if [[ -z "$1" ]] ; then
591 local N=""
[d55a1a1]592 # In boot method the makesys phase was initiated in testsuite_tools_makefile
593 [[ "${METHOD}" = "boot" ]] && [[ "$TEST" = 0 ]] && PREV=""
[45f82718]594 else
595 local N=-build_$1
596 local basicsystem=""
597 mkdir final-system$N
598 cp final-system/* final-system$N
599 for script in final-system$N/* ; do
600 # Overwrite existing symlinks, files, and dirs
601 sed -e 's/ln -sv/&f/g' \
602 -e 's/mv -v/&f/g' \
603 -e 's/mkdir -v/&p/g' -i ${script}
[10c8b78]604 # Rename the scripts
605 mv ${script} ${script}$N
[45f82718]606 done
[a5f52ba]607 # Remove Bzip2 binaries before make install (CLFS-1.0 compatibility)
[10c8b78]608 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i final-system$N/*-bzip2$N
[45f82718]609 # Delete *old Readline libraries just after make install
[10c8b78]610 sed -e 's@make install@&\nrm -v /lib/lib{history,readline}*old@' -i final-system$N/*-readline$N
[45f82718]611 fi
612
[d55a1a1]613 if [[ "${METHOD}" = "chroot" ]]; then
614 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) final system$N ( CHROOT ) ${R_arrow}"
615 else
616 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) final system$N ( ROOT ) ${R_arrow}"
617 fi
[877cc6a]618
[45f82718]619 for file in final-system$N/* ; do
[877cc6a]620 # Keep the script file name
621 this_script=`basename $file`
622
[45f82718]623 # Test if the stripping phase must be skipped.
[4384929]624 # Skip also temp-perl for iterative runs
[877cc6a]625 case $this_script in
[401f81e]626 *stripping*) [[ "$STRIP" = "n" ]] && continue ;;
[45f82718]627 *temp-perl*) [[ -n "$N" ]] && continue ;;
[877cc6a]628 esac
629
[4384929]630 # Grab the name of the target, strip id number, XXX-script.
631 # name1 is partially stripped and should be used for logging files.
632 # name is completely stripped and is used for grabbing
633 # the package name.
634 name1=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' \
635 -e 's,'$N',,'`
636 name=`echo $name1 | sed -e 's@temp-@@' \
637 -e 's@-64bit@@' \
638 -e 's@-64@@' \
639 -e 's@64@@' \
640 -e 's@n32@@'`
[877cc6a]641
[45f82718]642 # Find the version of the command files, if it corresponds with the building of
643 # a specific package. We need this here to can skip scripts not needed for
644 # iterations rebuilds
[a160d86]645 pkg_tarball=$(get_package_tarball_name $name)
[9d9ecf7]646
[a160d86]647 if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
[45f82718]648 case "${this_script}" in
649 *stripping*) ;;
650 *) continue ;;
651 esac
652 fi
653
654 # Append each name of the script files to a list (this will become
655 # the names of the targets in the Makefile
[10c8b78]656 basicsystem="$basicsystem ${this_script}"
[45f82718]657
[877cc6a]658 #--------------------------------------------------------------------#
659 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
660 #--------------------------------------------------------------------#
661 #
662 # Drop in the name of the target on a new line, and the previous target
663 # as a dependency. Also call the echo_message function.
[10c8b78]664 CHROOT_wrt_target "${this_script}" "$PREV"
[877cc6a]665
[a160d86]666 # If $pkg_tarball isn't empty, we've got a package...
667 if [ "$pkg_tarball" != "" ] ; then
[f546320]668 # Touch timestamp file if installed files logs will be created.
669 # But only for the firt build when running iterative builds.
670 if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
671 CHROOT_wrt_TouchTimestamp
672 fi
[045b2dc]673 CHROOT_Unpack "$pkg_tarball"
[a229600]674 # If the testsuites must be run, initialize the log file
675 case $name in
[269d81c]676 binutils | gcc | glibc | eglibc | gmp | mpfr | mpc | isl | cloog )
[10c8b78]677 [[ "$TEST" != "0" ]] && CHROOT_wrt_test_log "${this_script}"
[a229600]678 ;;
679 * )
[10c8b78]680 [[ "$TEST" = "2" ]] || [[ "$TEST" = "3" ]] && CHROOT_wrt_test_log "${this_script}"
[a229600]681 ;;
682 esac
683 # If using optimizations, write the instructions
[1b65a84]684 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[877cc6a]685 fi
686 #
[045b2dc]687 CHROOT_wrt_RunAsRoot "${file}"
[877cc6a]688 #
[f546320]689 # Write installed files log and remove the build directory(ies)
690 # except if the package build fails.
691 if [ "$pkg_tarball" != "" ] ; then
692 CHROOT_wrt_RemoveBuildDirs "$name"
693 if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
[4384929]694 CHROOT_wrt_LogNewFiles "$name1"
[f546320]695 fi
696 fi
[877cc6a]697 #
[f546320]698 # Include a touch of the target name so make can check
699 # if it's already been made.
[93f38e7]700 wrt_touch
[877cc6a]701 #
702 #--------------------------------------------------------------------#
703 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
704 #--------------------------------------------------------------------#
705 #
706 # Keep the script file name for Makefile dependencies.
[10c8b78]707 PREV=${this_script}
[45f82718]708 # Set system_build envar for iteration targets
709 system_build=$basicsystem
[877cc6a]710 done # for file in final-system/* ...
711}
712
[045b2dc]713#--------------------------------------#
[d55a1a1]714bootscripts_Makefiles() { #
[045b2dc]715#--------------------------------------#
[d55a1a1]716
[c6ee8ea]717# New versions of the book do not have bootscripts anymore
718# (use systemd configuration files)
719# Define a variable to be used for the right script directory to parse
720 if [ -d bootscripts ]; then
721 config="bootscripts"
722 else
723 config="system-config"
724 fi
725
[d55a1a1]726 if [[ "${METHOD}" = "chroot" ]]; then
[c6ee8ea]727 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) $config ( CHROOT ) ${R_arrow}"
[45f82718]728 else
[c6ee8ea]729 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) $config ( ROOT ) ${R_arrow}"
[45f82718]730 fi
[877cc6a]731
[c6ee8ea]732 for file in $config/* ; do
[877cc6a]733 # Keep the script file name
734 this_script=`basename $file`
735
736 case $this_script in
[d601cfc]737 *udev) continue ;; # This is not a script but a comment, we want udev-rules
[877cc6a]738 *console*) continue ;; # Use the files that came with the bootscripts
[f0de954]739# fstab is now here (for 3.x.y)
[d601cfc]740 *fstab) [[ -z "${FSTAB}" ]] ||
[85506da]741 [[ ${FSTAB} == $BUILDDIR/sources/fstab ]] ||
742 cp ${FSTAB} $BUILDDIR/sources/fstab ;;
[877cc6a]743 *) ;;
744 esac
745
746 # First append each name of the script files to a list (this will become
747 # the names of the targets in the Makefile
748 bootscripttools="$bootscripttools $this_script"
749
[4384929]750 # Grab the name of the target, strip id number, XXX-script.
751 # name1 is partially stripped and should be used for logging files.
752 # name is completely stripped and is used for grabbing
753 # the package name.
754 name1=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
755 name=`echo $name1 | sed -e 's@-64bit@@' \
756 -e 's@-64@@' \
757 -e 's@64@@' \
758 -e 's@n32@@'`
[877cc6a]759 case $name in
[c044e3c]760 *bootscripts*) name=bootscripts-cross-lfs ;;
[877cc6a]761 *udev-rules) name=udev-cross-lfs ;;
762 esac
[c044e3c]763
[a160d86]764 pkg_tarball=$(get_package_tarball_name $name)
[877cc6a]765
766 #--------------------------------------------------------------------#
767 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
768 #--------------------------------------------------------------------#
769 #
770 # Drop in the name of the target on a new line, and the previous target
771 # as a dependency. Also call the echo_message function.
[045b2dc]772 CHROOT_wrt_target "${this_script}" "$PREV"
[877cc6a]773 #
[a160d86]774 # If $pkg_tarball isn't empty, we've got a package...
[877cc6a]775 #
[f546320]776 if [ "$pkg_tarball" != "" ] ; then
777 if [ "${INSTALL_LOG}" = "y" ] ; then
[4384929]778 CHROOT_wrt_TouchTimestamp
[f546320]779 fi
780 CHROOT_Unpack "$pkg_tarball"
781 fi
[877cc6a]782 #
[f0de954]783 case $this_script in
784 *fstab*) if [[ -n "$FSTAB" ]]; then
785 CHROOT_wrt_CopyFstab
786 else
787 CHROOT_wrt_RunAsRoot "${file}"
788 fi
789 ;;
790 *) CHROOT_wrt_RunAsRoot "${file}"
791 ;;
792 esac
[877cc6a]793 #
[f546320]794 # Write installed files log and remove the build directory(ies)
795 # except if the package build fails.
796 if [ "$pkg_tarball" != "" ] ; then
797 CHROOT_wrt_RemoveBuildDirs "$name"
798 if [ "${INSTALL_LOG}" = "y" ] ; then
[4384929]799 CHROOT_wrt_LogNewFiles "$name1"
[f546320]800 fi
801 fi
[877cc6a]802 #
803 # Include a touch of the target name so make can check if it's already been made.
[93f38e7]804 wrt_touch
[877cc6a]805 #
806 #--------------------------------------------------------------------#
807 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
808 #--------------------------------------------------------------------#
809 #
810 # Keep the script file name for Makefile dependencies.
811 PREV=$this_script
812
813 done # for file in bootscripts/* ...
814}
815
[608fbe1]816#--------------------------------------#
817network_Makefiles() { #
818#--------------------------------------#
819
820 if [[ "${METHOD}" = "chroot" ]]; then
821 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) network ( CHROOT ) ${R_arrow}"
822 else
823 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) network ( ROOT ) ${R_arrow}"
824 fi
825
826 for file in network/* ; do
827 # Keep the script file name
828 this_script=`basename $file`
829
830 case $this_script in
[2e1c1c3]831 *choose) continue ;; # This is not a script but a commentary.
[608fbe1]832 *dhcp) continue ;; # Assume static networking.
833 *dhcpcd) continue ;; # Assume static networking.
834 *) ;;
835 esac
836
837 # First append each name of the script files to a list (this will become
838 # the names of the targets in the Makefile
839 networktools="$networktools $this_script"
840
841 # Grab the name of the target, strip id number, XXX-script
[4384929]842 # name1 is partially stripped and should be used for logging files.
843 # name is completely stripped and is used for grabbing
844 # the package name.
845 name1=`echo $this_script | sed -e 's@[0-9]\{3\}-@@'`
846 name=`echo $name1 | sed -e 's@-64bit@@' \
847 -e 's@-64@@' \
848 -e 's@64@@' \
849 -e 's@n32@@'`
[608fbe1]850 case $name in
[b4df9e1]851 network-scripts) name=clfs-network-scripts ;;
[608fbe1]852 esac
853
854 pkg_tarball=$(get_package_tarball_name $name)
855
856 #--------------------------------------------------------------------#
857 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
858 #--------------------------------------------------------------------#
859 #
860 # Drop in the name of the target on a new line, and the previous target
861 # as a dependency. Also call the echo_message function.
862 CHROOT_wrt_target "${this_script}" "$PREV"
863 #
864 # If $pkg_tarball isn't empty, we've got a package...
865 #
866 if [ "$pkg_tarball" != "" ] ; then
867 if [ "${INSTALL_LOG}" = "y" ] ; then
[4384929]868 CHROOT_wrt_TouchTimestamp
[608fbe1]869 fi
870 CHROOT_Unpack "$pkg_tarball"
871 fi
872 #
873 CHROOT_wrt_RunAsRoot "${file}"
874 #
875 # Write installed files log and remove the build directory(ies)
876 # except if the package build fails.
877 if [ "$pkg_tarball" != "" ] ; then
878 CHROOT_wrt_RemoveBuildDirs "$name"
879 if [ "${INSTALL_LOG}" = "y" ] ; then
[4384929]880 CHROOT_wrt_LogNewFiles "$name1"
[608fbe1]881 fi
882 fi
883 #
884 # Include a touch of the target name so make can check if it's already been made.
885 wrt_touch
886 #
887 #--------------------------------------------------------------------#
888 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
889 #--------------------------------------------------------------------#
890 #
891 # Keep the script file name for Makefile dependencies.
892 PREV=$this_script
893
894 done # for file in network/* ...
895}
896
[045b2dc]897#--------------------------------------#
[d55a1a1]898bootable_Makefiles() { #
[045b2dc]899#--------------------------------------#
[877cc6a]900
[d55a1a1]901 if [[ "${METHOD}" = "chroot" ]]; then
902 echo "${tab_}${GREEN}Processing... ${L_arrow}(chroot) make bootable ( CHROOT ) ${R_arrow}"
903 else
904 echo "${tab_}${GREEN}Processing... ${L_arrow}(boot) make bootable ( ROOT ) ${R_arrow}"
905 fi
[877cc6a]906
907
[936efa8]908 for file in bootable/* ; do
[877cc6a]909 # Keep the script file name
910 this_script=`basename $file`
911
912 # A little housekeeping on the scripts
913 case $this_script in
914 *grub | *aboot | *colo | *silo | *arcload | *lilo | *reboot* ) continue ;;
[d601cfc]915 *fstab) [[ -z "${FSTAB}" ]] ||
[85506da]916 [[ ${FSTAB} == $BUILDDIR/sources/fstab ]] ||
917 cp ${FSTAB} $BUILDDIR/sources/fstab ;;
[877cc6a]918 *kernel) # if there is no kernel config file do not build the kernel
919 [[ -z $CONFIG ]] && continue
920 # Copy the config file to /sources with a standardized name
[85506da]921 [[ $CONFIG == $BUILDDIR/sources/kernel-config ]] ||
[877cc6a]922 cp $CONFIG $BUILDDIR/sources/kernel-config
923 ;;
924 esac
925 #
926 # First append each name of the script files to a list (this will become
927 # the names of the targets in the Makefile
928 bootabletools="$bootabletools $this_script"
929 #
930 # Grab the name of the target, strip id number and misc words.
931 name=`echo $this_script | sed -e 's@[0-9]\{3\}-@@' -e 's@-build@@' `
932 case $this_script in
933 *kernel*) name=linux
934 ;;
935 esac
[a160d86]936
937 pkg_tarball=$(get_package_tarball_name $name)
[877cc6a]938
939 #--------------------------------------------------------------------#
940 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
941 #--------------------------------------------------------------------#
942 #
943 # Drop in the name of the target on a new line, and the previous target
944 # as a dependency. Also call the echo_message function.
[045b2dc]945 CHROOT_wrt_target "${this_script}" "$PREV"
[877cc6a]946 #
[a160d86]947 # If $pkg_tarball isn't empty, we've got a package...
[877cc6a]948 # Insert instructions for unpacking the package and changing directories
949 #
[f546320]950 if [ "$pkg_tarball" != "" ] ; then
951 if [ "${INSTALL_LOG}" = "y" ] ; then
[4384929]952 CHROOT_wrt_TouchTimestamp
[f546320]953 fi
954 CHROOT_Unpack "$pkg_tarball"
955 fi
[877cc6a]956 #
957 # Select a script execution method
958 case $this_script in
[045b2dc]959 *fstab*) if [[ -n "$FSTAB" ]]; then
960 CHROOT_wrt_CopyFstab
961 else
962 CHROOT_wrt_RunAsRoot "${file}"
963 fi
964 ;;
965 *) CHROOT_wrt_RunAsRoot "${file}"
966 ;;
[877cc6a]967 esac
968 #
[f546320]969 # Write installed files log and remove the build directory(ies)
970 # except if the package build fails.
971 if [ "$pkg_tarball" != "" ] ; then
972 CHROOT_wrt_RemoveBuildDirs "$name"
973 if [ "${INSTALL_LOG}" = "y" ] ; then
974 CHROOT_wrt_LogNewFiles "$name"
975 fi
976 fi
[877cc6a]977 #
978 # Include a touch of the target name so make can check if it's already been made.
[93f38e7]979 wrt_touch
[877cc6a]980 #
981 #--------------------------------------------------------------------#
982 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
983 #--------------------------------------------------------------------#
984 #
985 # Keep the script file name for Makefile dependencies.
986 PREV=$this_script
987
988 done
989
990}
991
992
[045b2dc]993#--------------------------------------#
994build_Makefile() { # Construct a Makefile from the book scripts
995#--------------------------------------#
996
997 echo "...Creating Makefile... ${BOLD}START${OFF}"
[877cc6a]998
999 cd $JHALFSDIR/${PROGNAME}-commands
[730436a]1000 # Start with clean files
[045b2dc]1001 >$MKFILE
[877cc6a]1002 >$MKFILE.tmp
1003
[d55a1a1]1004 method_cmds=${METHOD}_Makefiles
[045b2dc]1005
1006 host_prep_Makefiles # mk_SETUP (SETUP) $host_prep
[3f83cb0]1007 final_preps_Makefiles # mk_F_PREPS (LUSER) $final_preps
[045b2dc]1008 cross_tools_Makefiles # mk_CROSS (LUSER) $cross_tools
1009 temptools_Makefiles # mk_TEMP (LUSER) $temptools
1010 $method_cmds # mk_SYSTOOLS (CHROOT) $chroottools/$boottools
1011 if [[ ! $TEST = "0" ]]; then
[d55a1a1]1012 testsuite_tools_Makefiles # mk_SYSTOOLS (CHROOT) $testsuitetools
[877cc6a]1013 fi
[d55a1a1]1014 final_system_Makefiles # mk_FINAL (CHROOT) $basicsystem
[045b2dc]1015 # Add the iterations targets, if needed
1016 [[ "$COMPARE" = "y" ]] && wrt_compare_targets
[d55a1a1]1017 bootscripts_Makefiles # mk_BOOTSCRIPT (CHROOT) $bootscripttools
[2e1c1c3]1018 if [ -d network ]; then
[608fbe1]1019 network_Makefiles # If present, process network setup.
1020 fi
[d55a1a1]1021 bootable_Makefiles # mk_BOOTABLE (CHROOT) $bootabletools
[877cc6a]1022
[3e7ceed]1023 # Add the CUSTOM_TOOLS targets, if needed
1024 [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
[c10570d]1025
[877cc6a]1026 # Add a header, some variables and include the function file
1027 # to the top of the real Makefile.
[195ed9f]1028 wrt_Makefile_header
[877cc6a]1029
1030 # Add chroot commands
1031 if [ "$METHOD" = "chroot" ] ; then
[6ad5a2f]1032 CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
[15c9e72]1033 chroot=`cat chroot/???-chroot | \
[6ad5a2f]1034 sed -e "s@chroot@$CHROOT_LOC@" \
[830f28d]1035 -e '/#!\/bin\/bash/d' \
[6ad5a2f]1036 -e '/^export/d' \
1037 -e '/^logout/d' \
1038 -e 's@ \\\@ @g' | \
1039 tr -d '\n' | \
1040 sed -e 's/ */ /g' \
1041 -e 's|\\$|&&|g' \
1042 -e 's|exit||g' \
1043 -e 's|$| -c|' \
[f4d9a48]1044 -e 's|"$${CLFS}"|$(MOUNT_PT)|'\
[f3a7f3b]1045 -e 's|set -e||' \
1046 -e 's|set +h||'`
[877cc6a]1047 echo -e "CHROOT1= $chroot\n" >> $MKFILE
1048 fi
1049
[045b2dc]1050################## CHROOT ####################
1051
[877cc6a]1052if [[ "${METHOD}" = "chroot" ]]; then
1053(
[045b2dc]1054cat << EOF
[877cc6a]1055
[3f83cb0]1056all: ck_UID mk_SETUP mk_F_PREPS mk_SUDO mk_SYSTOOLS create-sbu_du-report mk_CUSTOM_TOOLS mk_BLFS_TOOL
[045b2dc]1057 @sudo make do-housekeeping
[936efa8]1058 @echo "$VERSION - jhalfs build" > clfs-release && \\
[269d81c]1059 sudo mv clfs-release \$(MOUNT_PT)/etc && \\
1060 sudo chown root:root \$(MOUNT_PT)/etc/clfs-release
[045b2dc]1061 @\$(call echo_finished,$VERSION)
[a160d86]1062
[045b2dc]1063ck_UID:
1064 @if [ \`id -u\` = "0" ]; then \\
1065 echo "+--------------------------------------------------+"; \\
1066 echo "|You cannot run this makefile from the root account|"; \\
1067 echo "+--------------------------------------------------+"; \\
1068 exit 1; \\
1069 fi
1070
1071#---------------AS ROOT
1072mk_SETUP:
1073 @\$(call echo_SU_request)
[7a43320]1074 @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
[045b2dc]1075 @touch \$@
1076
1077#---------------AS LUSER
[3f83cb0]1078mk_F_PREPS: mk_SETUP
1079 @\$(call echo_PHASE,Final Preparations Cross and Temporary Tools)
[730436a]1080 @( \$(SU_LUSER) "make -C \$(MOUNT_PT)/\$(SCRIPT_ROOT) BREAKPOINT=\$(BREAKPOINT) AS_LUSER" )
[045b2dc]1081 @sudo make restore-luser-env
1082 @touch \$@
1083
[3f83cb0]1084mk_SUDO: mk_F_PREPS
[7a43320]1085 @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
[045b2dc]1086 @touch \$@
1087
1088#---------------CHROOT JAIL
1089mk_SYSTOOLS: mk_SUDO
1090 @\$(call echo_CHROOT_request)
1091 @\$(call echo_PHASE, CHROOT JAIL )
[6c1b96b]1092 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) PREP_CHROOT_JAIL")
[7a43320]1093 @( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT_JAIL")
[045b2dc]1094 @touch \$@
[877cc6a]1095
[269d81c]1096mk_BLFS_TOOL: create-sbu_du-report
1097 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
1098 \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
1099 (sudo \$(CHROOT1) "make -C $BLFS_ROOT/work"); \\
1100 fi;
1101 @touch \$@
1102
1103mk_CUSTOM_TOOLS: mk_BLFS_TOOL
[3e7ceed]1104 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
[79da297]1105 \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
[3e7ceed]1106 sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
[7a43320]1107 (sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
[3e7ceed]1108 fi;
1109 @touch \$@
1110
[6c1b96b]1111SETUP: $host_prep
[3f83cb0]1112AS_LUSER: $final_preps $cross_tools $temptools
[6c1b96b]1113SUDO: $orphan_scripts
1114PREP_CHROOT_JAIL: SHELL=/tools/bin/bash
1115PREP_CHROOT_JAIL: ${chroottools}
1116CHROOT_JAIL: SHELL=/tools/bin/bash
1117CHROOT_JAIL: $testsuitetools $basicsystem $bootscripttools $bootabletools
1118CUSTOM_TOOLS: $custom_list
[877cc6a]1119
[1838bc7]1120
1121create-sbu_du-report: mk_SYSTOOLS
1122 @\$(call echo_message, Building)
1123 @if [ "\$(ADD_REPORT)" = "y" ]; then \\
[c57747d]1124 ./create-sbu_du-report.sh logs $VERSION $(date --iso-8601); \\
[1838bc7]1125 \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
1126 fi;
1127 @touch \$@
1128
[7d9a82d]1129do-housekeeping:
[59bb076]1130 @-umount \$(MOUNT_PT)/sys
1131 @-umount \$(MOUNT_PT)/proc
1132 @-if mountpoint -q \$(MOUNT_PT)/run; then \\
1133 umount \$(MOUNT_PT)/run; \\
1134 elif [ -h \$(MOUNT_PT)/dev/shm ]; then \\
[269d81c]1135 link=\$\$(readlink \$(MOUNT_PT)/dev/shm); \\
1136 umount \$(MOUNT_PT)/\$\$link; \\
1137 unset link; \\
1138 else \\
1139 umount \$(MOUNT_PT)/dev/shm; \\
1140 fi
[59bb076]1141 @-umount \$(MOUNT_PT)/dev/pts
[4524fb2]1142 @-umount \$(MOUNT_PT)/dev
[045b2dc]1143 @-rm /tools /cross-tools
[6ad5a2f]1144 @-if [ ! -f luser-exist ]; then \\
1145 userdel \$(LUSER); \\
[962793a]1146 rm -rf \$(LUSER_HOME); \\
[7d9a82d]1147 fi;
[877cc6a]1148EOF
1149) >> $MKFILE
[045b2dc]1150
[877cc6a]1151fi
1152
[045b2dc]1153################### BOOT #####################
[877cc6a]1154
1155if [[ "${METHOD}" = "boot" ]]; then
1156(
[045b2dc]1157cat << EOF
[877cc6a]1158
[3f83cb0]1159all: ck_UID mk_SETUP mk_F_PREPS mk_SUDO
[045b2dc]1160 @sudo make restore-luser-env
1161 @sudo make do-housekeeping
[877cc6a]1162 @\$(call echo_boot_finished,$VERSION)
1163
[3e7ceed]1164makesys: mk_FINAL mk_CUSTOM_TOOLS mk_BLFS_TOOL
[936efa8]1165 @echo "$VERSION - jhalfs build" > /etc/clfs-release
[877cc6a]1166 @\$(call echo_finished,$VERSION)
1167
1168
[045b2dc]1169ck_UID:
1170 @if [ \`id -u\` = "0" ]; then \\
1171 echo "+--------------------------------------------------+"; \\
1172 echo "|You cannot run this makefile from the root account|"; \\
1173 echo "|However, if this is the boot environment |"; \\
1174 echo "| the command you are looking for is |"; \\
1175 echo "| make makesys |"; \\
[730436a]1176 echo "| to complete the build |"; \\
[045b2dc]1177 echo "+--------------------------------------------------+"; \\
1178 exit 1; \\
1179 fi
[877cc6a]1180
[045b2dc]1181#---------------AS ROOT
[877cc6a]1182
[045b2dc]1183mk_SETUP:
1184 @\$(call echo_SU_request)
[7a43320]1185 @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
[045b2dc]1186 @touch \$@
1187
1188#---------------AS LUSER
[a160d86]1189
[3f83cb0]1190mk_F_PREPS: mk_SETUP
1191 @\$(call echo_PHASE,Final Preparations and Cross Tools)
[730436a]1192 @( \$(SU_LUSER) "make -C \$(MOUNT_PT)/\$(SCRIPT_ROOT) BREAKPOINT=\$(BREAKPOINT) AS_LUSER" )
[045b2dc]1193 @touch \$@
1194
[3f83cb0]1195mk_SUDO: mk_F_PREPS
[7a43320]1196 @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
[045b2dc]1197 @touch \$@
1198
1199#---------------AS ROOT
1200
1201mk_FINAL:
1202 @\$(call echo_PHASE,Final System)
[7a43320]1203 @( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) AS_ROOT )
[045b2dc]1204 @touch \$@
1205
[269d81c]1206mk_BLFS_TOOL: mk_FINAL
[e18f80a]1207 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
1208 \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
1209 ( make -C $BLFS_ROOT/work ); \\
1210 fi;
1211 @touch \$@
[269d81c]1212
1213mk_CUSTOM_TOOLS: mk_BLFS_TOOL
[3e7ceed]1214 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
[79da297]1215 \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
[3bc6078]1216 mkdir -p ${TRACKING_DIR}; \\
[7a43320]1217 ( source /root/.bash_profile && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS ); \\
[3e7ceed]1218 fi;
1219 @touch \$@
1220
1221SETUP: $host_prep
[3f83cb0]1222AS_LUSER: $final_preps $cross_tools $temptools ${boottools}
[3e7ceed]1223SUDO: $orphan_scripts
[aec4483]1224AS_ROOT: SHELL=/tools/bin/bash
[3e7ceed]1225AS_ROOT: $testsuitetools $basicsystem $bootscripttools $bootabletools
1226CUSTOM_TOOLS: $custom_list
[045b2dc]1227
1228do-housekeeping:
1229 @-rm /tools /cross-tools
1230 @-if [ ! -f luser-exist ]; then \\
[6ad5a2f]1231 userdel \$(LUSER); \\
[962793a]1232 rm -rf \$(LUSER_HOME); \\
[877cc6a]1233 fi;
1234
[045b2dc]1235EOF
1236) >> $MKFILE
1237fi
1238
1239(
1240 cat << EOF
1241
[6ad5a2f]1242restore-luser-env:
[877cc6a]1243 @\$(call echo_message, Building)
[962793a]1244 @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
1245 mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
[877cc6a]1246 fi;
[962793a]1247 @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
1248 mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
[877cc6a]1249 fi;
[962793a]1250 @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash* && \\
[93f38e7]1251 touch \$@ && \\
1252 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
1253 echo --------------------------------------------------------------------------------\$(WHITE)
[877cc6a]1254
[045b2dc]1255########################################################
1256
[7d9a82d]1257
[877cc6a]1258EOF
1259) >> $MKFILE
1260
1261 # Bring over the items from the Makefile.tmp
1262 cat $MKFILE.tmp >> $MKFILE
1263 rm $MKFILE.tmp
1264
[045b2dc]1265 echo "Creating Makefile... ${BOLD}DONE${OFF}"
[877cc6a]1266}
Note: See TracBrowser for help on using the repository browser.