source: CLFS/master.sh@ a690d42

ablfs-more legacy trunk
Last change on this file since a690d42 was fd4a798, checked in by Pierre Labastie <pierre.labastie@…>, 3 years ago

Remove $Id$ comments, they are useless with git

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