source: LFS/master.sh@ 22bb166

ablfs-more legacy trunk
Last change on this file since 22bb166 was ebe1ba6, checked in by Pierre Labastie <pierre@…>, 4 years ago

Adapt for the cross 2 branch. Note that ICA is broken now. Keeping some old
code to use for fixing ICA, but committing now so that testing can begin!

  • Property mode set to 100644
File size: 26.2 KB
Line 
1#!/bin/bash
2
3# $Id$
4
5###################################
6### FUNCTIONS ###
7###################################
8
9
10#############################################################
11
12
13#-------------------------#
14chapter_targets() { #
15#-------------------------#
16# $1 is the chapter number. Pad it with 0 to the left to obtain a 2-digit
17# number:
18 printf -v dir chapter%02d $1
19
20 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter $1${R_arrow}"
21
22 for file in $dir/* ; do
23 # Keep the script file name
24 this_script=`basename $file`
25
26 # Some scripts need peculiar actions:
27 # - glibc chap 5: ix locales creation when running chapter05 testsuites
28 # - Stripping at the end of system build: lfs.xsl does not generate
29 # correct commands if the user does not want to strip, so skip it
30 # in this case
31 # - grub config: must be done manually; skip it
32 # - handle fstab and .config. Skip kernel if .config not supplied
33 case "${this_script}" in
34 5*glibc) [[ "${TEST}" = "3" ]] && \
35 sed -i 's@/usr/lib/locale@/tools/lib/locale@' $file ;;
36 *strippingagain) [[ "${STRIP}" = "n" ]] && continue ;;
37 8*grub) (( nb_chaps == 5 )) && continue ;;
38 10*grub) continue ;;
39 *fstab) [[ -z "${FSTAB}" ]] ||
40 [[ ${FSTAB} == $BUILDDIR/sources/fstab ]] ||
41 cp ${FSTAB} $BUILDDIR/sources/fstab ;;
42 *kernel) [[ -z ${CONFIG} ]] && continue
43 [[ ${CONFIG} == $BUILDDIR/sources/kernel-config ]] ||
44 cp ${CONFIG} $BUILDDIR/sources/kernel-config ;;
45 esac
46
47 # Append the name of the script to a list. The name of the
48 # list is contained in the variable Makefile_target. We adjust this
49 # variable at various points. Note that it is initialized to "SETUP"
50 # in the main function, before calling this function for the first time.
51 case "${this_script}" in
52 *settingenvironment) Makefile_target=LUSER_TGT ;;
53 *changingowner ) Makefile_target=SUDO_TGT ;;
54 *creatingdirs ) Makefile_target=CHROOT_TGT ;;
55 *bootscripts ) Makefile_target=BOOT_TGT ;; # case of sysv book
56 *network ) Makefile_target=BOOT_TGT ;; # case of systemd book
57 esac
58 eval $Makefile_target=\"\$$Makefile_target ${this_script}\"
59
60 # Grab the name of the target
61 name=`echo ${this_script} | sed -e 's@[0-9]\{3,4\}-@@' \
62 -e 's@-pass[0-9]\{1\}@@' \
63 -e 's@-libstdc++@@'`
64
65 #--------------------------------------------------------------------#
66 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
67 #--------------------------------------------------------------------#
68 #
69 # Find the name of the tarball and the version of the package
70 pkg_tarball=$(sed -n 's/tar -xf \(.*\)/\1/p' $file)
71 pkg_version=$(sed -n 's/VERSION=\(.*\)/\1/p' $file)
72
73 # Drop in the name of the target on a new line, and the previous target
74 # as a dependency. Also call the echo_message function.
75 case $Makefile_target in
76 CHROOT_TGT) CHROOT_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
77 *) LUSER_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
78 esac
79
80 # If $pkg_tarball isn't empty, we've got a package...
81 if [ "$pkg_tarball" != "" ] ; then
82 # Touch timestamp file if installed files logs shall be created.
83 # But only for the final install chapter
84 if [ "${INSTALL_LOG}" = "y" ] && (( 1+nb_chaps <= $1 )) ; then
85 CHROOT_wrt_TouchTimestamp
86 fi
87 # Always initialize the test log file, since the test instructions may
88 # be "uncommented" by the user
89 case $Makefile_target in
90 CHROOT_TGT) CHROOT_wrt_test_log "${this_script}" "$pkg_version" ;;
91 LUSER_TGT ) LUSER_wrt_test_log "${this_script}" "$pkg_version" ;;
92 esac
93
94 # If using optimizations, write the instructions
95 case "${OPTIMIZE}$1${nb_chaps}${this_script}${REALSBU}" in
96 0* | *binutils-pass1y | 15* | 167* | 177*) ;;
97 *kernel) wrt_makeflags "$name" ;; # No CFLAGS for kernel
98 *) wrt_optimize "$name" && wrt_makeflags "$name" ;;
99 esac
100 fi
101
102# Some scriptlet have a special treatment; otherwise standard
103 case "${this_script}" in
104 *addinguser)
105(
106cat << EOF
107 @if [ -f luser-id ]; then \\
108 function useradd() { true; }; \\
109 function groupadd() { true; }; \\
110 export -f useradd groupadd; \\
111 fi; \\
112 export LFS=\$(MOUNT_PT) && \\
113 \$(CMDSDIR)/`dirname $file`/\$@ >> \$(LOGDIR)/\$@ 2>&1; \\
114 \$(PRT_DU) >>logs/\$@
115 @chown \$(LUSER):\$(LGROUP) envars
116 @chmod -R a+wt $JHALFSDIR
117 @chmod a+wt \$(SRCSDIR)
118EOF
119) >> $MKFILE.tmp
120 ;;
121 *settingenvironment)
122(
123cat << EOF
124 @cd && \\
125 function source() { true; } && \\
126 export -f source && \\
127 \$(CMDSDIR)/`dirname $file`/\$@ >> \$(LOGDIR)/\$@ 2>&1 && \\
128 sed 's|/mnt/lfs|\$(MOUNT_PT)|' -i .bashrc && \\
129 echo source $JHALFSDIR/envars >> .bashrc
130 @\$(PRT_DU) >>logs/\$@
131EOF
132) >> $MKFILE.tmp
133 ;;
134 *fstab) if [[ -n "$FSTAB" ]]; then
135 CHROOT_wrt_CopyFstab
136 else
137 CHROOT_wrt_RunAsRoot "$file"
138 fi
139 ;;
140
141 *)
142 # Insert date and disk usage at the top of the log file, the script
143 # run and date and disk usage again at the bottom of the log file.
144 case "${Makefile_target}" in
145 SETUP_TGT | SUDO_TGT) wrt_RunAsRoot "$file" "$pkg_version" ;;
146 LUSER_TGT) LUSER_wrt_RunAsUser "$file" "$pkg_version" ;;
147 CHROOT_TGT | BOOT_TGT) CHROOT_wrt_RunAsRoot "$file" "$pkg_version" ;;
148 esac
149 ;;
150 esac
151
152 # Write installed files log and remove the build directory(ies)
153 # except if the package build fails.
154 if [ "$pkg_tarball" != "" ] ; then
155 if [ "${INSTALL_LOG}" = "y" ] && (( 1+nb_chaps <= $1 )) ; then
156 CHROOT_wrt_LogNewFiles "$name"
157 fi
158 fi
159
160 # Include a touch of the target name so make can check
161 # if it's already been made.
162 wrt_touch
163 #
164 #--------------------------------------------------------------------#
165 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
166 #--------------------------------------------------------------------#
167
168 # Keep the script file name for Makefile dependencies.
169 PREV=${this_script}
170 done # end for file in $dir/*
171}
172
173# NOT USED -- NOT USED
174#----------------------------#
175chapter5_Makefiles() {
176#----------------------------#
177 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5 ( LUSER ) ${R_arrow}"
178
179# Initialize the Makefile target: it'll change during chapter
180# For vanilla lfs, the "changingowner" script should be run as root. So
181# it belongs to the "SUDO" target, with list in the "runasroot" variable.
182# For new lfs, changingowner and kernfs are in "runasroot", then the following,
183# starting at creatingdirs, are in the "CHROOT" target, in variable "chapter6".
184# Makefile_target records the variable, not really the target!
185# We use a case statement on that variable, because instructions in the
186# Makefile change according to the phase of the build (LUSER, SUDO, CHROOT).
187 Makefile_target=chapter5
188
189# Start loop
190 for file in chapter05/* ; do
191 # Keep the script file name
192 this_script=`basename $file`
193
194 # Append each name of the script files to a list that Makefile_target
195 # points to. But before that, change Makefile_target at the first script
196 # of each target.
197 case "${this_script}" in
198 *changingowner) Makefile_target=runasroot ;;
199 *creatingdirs ) Makefile_target=chapter6 ;; # only run for new lfs
200 esac
201 eval $Makefile_target=\"\$$Makefile_target ${this_script}\"
202
203 # Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc
204 # and binutils in chapter 5)
205 name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@' \
206 -e 's@-pass[0-9]\{1\}@@' \
207 -e 's@-libstdc++@@'`
208
209 #--------------------------------------------------------------------#
210 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
211 #--------------------------------------------------------------------#
212 #
213 # Find the name of the tarball and the version of the package
214 pkg_tarball=$(sed -n 's/tar -xf \(.*\)/\1/p' $file)
215 pkg_version=$(sed -n 's/VERSION=\(.*\)/\1/p' $file)
216
217 # Drop in the name of the target on a new line, and the previous target
218 # as a dependency. Also call the echo_message function.
219 case $Makefile_target in
220 chapter6) CHROOT_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
221 *) LUSER_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
222 esac
223
224 # If $pkg_tarball isn't empty, we've got a package...
225 if [ "$pkg_tarball" != "" ] ; then
226 # Always initialize the log file, since the test instructions may be
227 # "uncommented" by the user
228 case $Makefile_target in
229 chapter6) CHROOT_wrt_test_log "${this_script}" "$pkg_version" ;;
230 *) LUSER_wrt_test_log "${this_script}" "$pkg_version" ;;
231 esac
232
233 # If using optimizations, write the instructions
234 case "${OPTIMIZE}${this_script}${REALSBU}" in
235 *binutils-pass1y) ;;
236 2*) wrt_optimize "$name" && wrt_makeflags "$name" ;;
237 *) ;;
238 esac
239 fi
240
241 # Insert date and disk usage at the top of the log file, the script run
242 # and date and disk usage again at the bottom of the log file.
243 # The changingowner script must be run as root.
244 case "${Makefile_target}" in
245 runasroot) wrt_RunAsRoot "$file" "$pkg_version" ;;
246 chapter5) LUSER_wrt_RunAsUser "$file" "$pkg_version" ;;
247 chapter6) CHROOT_wrt_RunAsRoot "$file" "$pkg_version" ;;
248 esac
249
250 # Include a touch of the target name so make can check
251 # if it's already been made.
252 wrt_touch
253 #
254 #--------------------------------------------------------------------#
255 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
256 #--------------------------------------------------------------------#
257
258 # Keep the script file name for Makefile dependencies.
259 PREV=${this_script}
260 done # end for file in chapter05/*
261}
262
263# NOT USED -- NOT USED keep for ICA code
264#----------------------------#
265chapter6_Makefiles() {
266#----------------------------#
267
268 # Set envars and scripts for iteration targets
269 if [[ -z "$1" ]] ; then
270 local N=""
271 else
272 local N=-build_$1
273 local chapter6=""
274 mkdir chapter06$N
275 cp chapter06/* chapter06$N
276 for script in chapter06$N/* ; do
277 # Overwrite existing symlinks, files, and dirs
278 sed -e 's/ln *-sv/&f/g' \
279 -e 's/mv *-v/&f/g' \
280 -e 's/mkdir *-v/&p/g' -i ${script}
281 # Suppress the mod of "test-installation.pl" because now
282 # the library path points to /usr/lib
283 if [[ ${script} =~ glibc ]]; then
284 sed '/DL=/,/unset DL/d' -i ${script}
285 fi
286 # Rename the scripts
287 mv ${script} ${script}$N
288 done
289 # Remove Bzip2 binaries before make install (LFS-6.2 compatibility)
290 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2$N
291 # Remove openssl-<version> from /usr/share/doc (LFS-9.x), because
292 # otherwise the mv command creates an openssl directory.
293 sed -e 's@mv -v@rm -rfv /usr/share/doc/openssl-*\n&@' \
294 -i chapter06$N/*-openssl$N
295 fi
296
297 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N ( CHROOT ) ${R_arrow}"
298
299# Initialize the Makefile target. In vanilla lfs, kernfs should be run as root,
300# then the others are run in chroot. If in new lfs, we should start in chroot.
301# this will be changed later because man-pages is the first script in
302# chapter 6. Note that this Makefile_target business is not really needed here
303# but we do it to have a similar structure to chapter 5 (we may merge all
304# those functions at some point).
305 case "$N" in
306 -build*) Makefile_target=chapter6 ;;
307 *) Makefile_target=runasroot ;;
308 esac
309
310# Start loop
311 for file in chapter06$N/* ; do
312 # Keep the script file name
313 this_script=`basename $file`
314
315 # Skip the "stripping" scripts if the user does not want to strip.
316 # Skip also linux-headers in iterative builds.
317 case "${this_script}" in
318 *stripping*) [[ "${STRIP}" = "n" ]] && continue ;;
319 *linux-headers*) [[ -n "$N" ]] && continue ;;
320 esac
321
322 # Grab the name of the target.
323 name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@' -e 's,'$N',,'`
324
325 # Find the tarball corresponding to our script.
326 # If it doesn't exist, we skip it in iterations rebuilds (except stripping
327 # and revisedchroot, where .a and .la files are removed).
328 pkg_tarball=$(sed -n 's/tar -xf \(.*\)/\1/p' $file)
329 pkg_version=$(sed -n 's/VERSION=\(.*\)/\1/p' $file)
330
331 if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
332 case "${this_script}" in
333 *stripping*|*revised*) ;;
334 *) continue ;;
335 esac
336 fi
337
338 # Append each name of the script files to a list (this will become
339 # the names of the targets in the Makefile)
340 # The kernfs script must be run as part of SUDO target.
341 case "${this_script}" in
342 *creatingdirs) Makefile_target=chapter6 ;;
343 *man-pages ) Makefile_target=chapter6 ;;
344 esac
345 eval $Makefile_target=\"\$$Makefile_target ${this_script}\"
346
347 #--------------------------------------------------------------------#
348 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
349 #--------------------------------------------------------------------#
350 #
351 # Drop in the name of the target on a new line, and the previous target
352 # as a dependency. Also call the echo_message function.
353 # In the mount of kernel filesystems we need to set LFS
354 # and not to use chroot.
355 case "${Makefile_target}" in
356 runasroot) LUSER_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
357 *) CHROOT_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
358 esac
359
360 # If $pkg_tarball isn't empty, we've got a package...
361 # Insert instructions for unpacking the package and changing directories
362 if [ "$pkg_tarball" != "" ] ; then
363 # Touch timestamp file if installed files logs will be created.
364 # But only for the firt build when running iterative builds.
365 if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
366 CHROOT_wrt_TouchTimestamp
367 fi
368 # Always initialize the log file, so that the user may reinstate a
369 # commented out test
370 CHROOT_wrt_test_log "${this_script}" "$pkg_version"
371 # If using optimizations, write the instructions
372 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
373 fi
374
375 # In the mount of kernel filesystems we need to set LFS
376 # and not to use chroot.
377 case "${Makefile_target}" in
378 runasroot) wrt_RunAsRoot "$file" "$pkg_version" ;;
379 *) CHROOT_wrt_RunAsRoot "$file" "$pkg_version" ;;
380 esac
381
382 # Write installed files log and remove the build directory(ies)
383 # except if the package build fails.
384 if [ "$pkg_tarball" != "" ] ; then
385 if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
386 CHROOT_wrt_LogNewFiles "$name"
387 fi
388 fi
389
390 # Include a touch of the target name so make can check
391 # if it's already been made.
392 wrt_touch
393 #
394 #--------------------------------------------------------------------#
395 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
396 #--------------------------------------------------------------------#
397
398 # Keep the script file name for Makefile dependencies.
399 PREV=${this_script}
400 # Set system_build envar for iteration targets
401 if [ -z "$N" ]; then
402 system_build="$system_build $this_script"
403 fi
404 done # end for file in chapter06/*
405 if [ -n "$N" ]; then
406 system_build="$chapter6"
407 fi
408}
409# NOT USED -- NOT USED
410#----------------------------#
411chapter78_Makefiles() {
412#----------------------------#
413 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7/8 ( BOOT ) ${R_arrow}"
414
415 for file in chapter0{7,8}/* ; do
416 # Keep the script file name
417 this_script=`basename $file`
418
419 # Grub must be configured manually.
420 # Handle fstab creation.
421 # If no .config file is supplied, the kernel build is skipped
422 case ${this_script} in
423 *grub) continue ;;
424 *fstab) [[ -z "${FSTAB}" ]] ||
425 [[ ${FSTAB} == $BUILDDIR/sources/fstab ]] ||
426 cp ${FSTAB} $BUILDDIR/sources/fstab ;;
427 *kernel) [[ -z ${CONFIG} ]] && continue
428 [[ ${CONFIG} == $BUILDDIR/sources/kernel-config ]] ||
429 cp ${CONFIG} $BUILDDIR/sources/kernel-config ;;
430 esac
431
432 # First append each name of the script files to a list (this will become
433 # the names of the targets in the Makefile
434 chapter78="$chapter78 ${this_script}"
435
436 #--------------------------------------------------------------------#
437 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
438 #--------------------------------------------------------------------#
439 #
440 # Drop in the name of the target on a new line, and the previous target
441 # as a dependency. Also call the echo_message function.
442 CHROOT_wrt_target "${this_script}" "$PREV"
443
444 # Find the bootscripts or networkscripts (for systemd)
445 # and kernel package names
446 case "${this_script}" in
447 *bootscripts)
448 name="lfs-bootscripts"
449 if [ "${INSTALL_LOG}" = "y" ] ; then
450 CHROOT_wrt_TouchTimestamp
451 fi
452 ;;
453 *network-scripts)
454 name="lfs-network-scripts"
455 if [ "${INSTALL_LOG}" = "y" ] ; then
456 CHROOT_wrt_TouchTimestamp
457 fi
458 ;;
459 *kernel)
460 name="linux"
461 if [ "${INSTALL_LOG}" = "y" ] ; then
462 CHROOT_wrt_TouchTimestamp
463 fi
464 # If using optimizations, use MAKEFLAGS (unless blacklisted)
465 # no setting of CFLAGS and friends.
466 [[ "$OPTIMIZE" != "0" ]] && wrt_makeflags "$name"
467 ;;
468 esac
469
470 # Check if we have a real /etc/fstab file
471 case "${this_script}" in
472 *fstab) if [[ -n "$FSTAB" ]]; then
473 CHROOT_wrt_CopyFstab
474 else
475 CHROOT_wrt_RunAsRoot "$file"
476 fi
477 ;;
478 *) CHROOT_wrt_RunAsRoot "$file"
479 ;;
480 esac
481
482 case "${this_script}" in
483 *bootscripts|*network-scripts|*kernel)
484 if [ "${INSTALL_LOG}" = "y" ] ; then
485 CHROOT_wrt_LogNewFiles "$name"
486 fi ;;
487 esac
488 # Include a touch of the target name so make can check
489 # if it's already been made.
490 wrt_touch
491 #
492 #--------------------------------------------------------------------#
493 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
494 #--------------------------------------------------------------------#
495
496 # Keep the script file name for Makefile dependencies.
497 PREV=${this_script}
498 done # for file in chapter0{7,8}/*
499
500}
501
502#----------------------------#
503build_Makefile() { #
504#----------------------------#
505
506 echo "Creating Makefile... ${BOLD}START${OFF}"
507
508 cd $JHALFSDIR/${PROGNAME}-commands
509
510 # Start with empty files
511 >$MKFILE
512 >$MKFILE.tmp
513
514 # Ensure the first dependency is empty
515 unset PREV
516
517 # We begin with the SETUP target; successive targets will be assigned in
518 # the chapter_targets function.
519 Makefile_target=SETUP_TGT
520
521 # We need to know the chapter numbering, which depends on the version
522 # of the book. Use the number of subdirs to know which version we have
523 chaps=($(echo *))
524 nb_chaps=${#chaps[*]} # 5 if classical version, 7 if new version
525# DEBUG
526# echo chaps: ${chaps[*]}
527# echo nb_chaps: $nb_chaps
528# end DEBUG
529
530 # Make a temporary file with all script targets
531 for (( i = 4; i < nb_chaps+4; i++ )); do
532 chapter_targets $i
533 if (( i == nb_chaps )); then : # we have finished temporary tools
534 # Add the save target, if needed
535 [[ "$SAVE_CH5" = "y" ]] && wrt_save_target $Makefile_target
536 fi
537 # TODO Add the iterations targets, if needed
538 # [[ "$COMPARE" = "y" ]] && wrt_compare_targets
539 done
540 # Add the CUSTOM_TOOLS targets, if needed
541 [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
542
543 # Add a header, some variables and include the function file
544 # to the top of the real Makefile.
545 wrt_Makefile_header
546
547 # Add chroot commands
548 CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
549 i=1
550 for file in ../chroot-scripts/*chroot* ; do
551 chroot=`cat $file | \
552 perl -pe 's|\\\\\n||g' | \
553 tr -s [:space:] | \
554 grep chroot | \
555 sed -e "s|chroot|$CHROOT_LOC|" \
556 -e 's|\\$|&&|g' \
557 -e 's|"$$LFS"|$(MOUNT_PT)|'`
558 echo -e "CHROOT$i= $chroot\n" >> $MKFILE
559 i=`expr $i + 1`
560 done
561
562 # Store virtual kernel file systems commands:
563 devices=`cat ../kernfs-scripts/devices.sh | \
564 sed -e 's|^| |' \
565 -e 's|mount|sudo &|' \
566 -e 's|mkdir|sudo &|' \
567 -e 's|\\$|&&|g' \
568 -e 's|\$|; \\\\|' \
569 -e 's|then|& :|' \
570 -e 's|\$\$LFS|$(MOUNT_PT)|g'`
571 teardown=`cat ../kernfs-scripts/teardown.sh | \
572 sed -e 's|^| |' \
573 -e 's|umount|sudo &|' \
574 -e 's|\$LFS|$(MOUNT_PT)|'`
575 teardownat=`cat ../kernfs-scripts/teardown.sh | \
576 sed -e 's|^| |' \
577 -e 's|umount|@-sudo &|' \
578 -e 's|\$LFS|$(MOUNT_PT)|'`
579 # Drop in the main target 'all:' and the chapter targets with each sub-target
580 # as a dependency.
581(
582 cat << EOF
583
584all: ck_UID ck_terminal mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT create-sbu_du-report mk_BLFS_TOOL mk_CUSTOM_TOOLS
585$teardownat
586 @sudo make do_housekeeping
587EOF
588) >> $MKFILE
589if [ "$INITSYS" = systemd ]; then
590(
591 cat << EOF
592 @/bin/echo -e -n \\
593 NAME=\\"Linux From Scratch\\"\\\\n\\
594 VERSION=\\"$VERSION\\"\\\\n\\
595 ID=lfs\\\\n\\
596 PRETTY_NAME=\\"Linux From Scratch $VERSION\\"\\\\n\\
597 VERSION_CODENAME=\\"$(whoami)-jhalfs\\"\\\\n\\
598 > os-release && \\
599 sudo mv os-release \$(MOUNT_PT)/etc && \\
600 sudo chown root:root \$(MOUNT_PT)/etc/os-release
601EOF
602) >> $MKFILE
603fi
604(
605 cat << EOF
606 @echo $VERSION > lfs-release && \\
607 sudo mv lfs-release \$(MOUNT_PT)/etc && \\
608 sudo chown root:root \$(MOUNT_PT)/etc/lfs-release
609 @/bin/echo -e -n \\
610 DISTRIB_ID=\\"Linux From Scratch\\"\\\\n\\
611 DISTRIB_RELEASE=\\"$VERSION\\"\\\\n\\
612 DISTRIB_CODENAME=\\"$(whoami)-jhalfs\\"\\\\n\\
613 DISTRIB_DESCRIPTION=\\"Linux From Scratch\\"\\\\n\\
614 > lsb-release && \\
615 sudo mv lsb-release \$(MOUNT_PT)/etc && \\
616 sudo chown root:root \$(MOUNT_PT)/etc/lsb-release
617 @\$(call echo_finished,$VERSION)
618
619ck_UID:
620 @if [ \`id -u\` = "0" ]; then \\
621 echo "--------------------------------------------------"; \\
622 echo "You cannot run this makefile from the root account"; \\
623 echo "--------------------------------------------------"; \\
624 exit 1; \\
625 fi
626
627ck_terminal:
628 @stty size | ( read L C; \\
629 if (( L < 24 )) || (( C < 80 )) ; then \\
630 echo "--------------------------------------------------"; \\
631 echo "Terminal too small: \$\$C columns x \$\$L lines";\\
632 echo "Minimum: 80 columns x 24 lines";\\
633 echo "--------------------------------------------------"; \\
634 exit 1; \\
635 fi )
636
637mk_SETUP:
638 @\$(call echo_SU_request)
639 @sudo make save-luser
640 @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
641 @touch \$@
642
643mk_LUSER: mk_SETUP
644 @\$(call echo_SULUSER_request)
645 @\$(SU_LUSER) "make -C \$(MOUNT_PT)/\$(SCRIPT_ROOT) BREAKPOINT=\$(BREAKPOINT) LUSER"
646 @sudo make restore-luser
647 @touch \$@
648
649mk_SUDO: mk_LUSER
650 @sudo rm -f envars
651 @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
652 @touch \$@
653
654mk_CHROOT: mk_SUDO
655 @\$(call echo_CHROOT_request)
656 @( sudo \$(CHROOT1) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT")
657 @touch \$@
658
659mk_BOOT: mk_CHROOT
660 @\$(call echo_CHROOT_request)
661 @( sudo \$(CHROOT2) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
662 @touch \$@
663
664mk_BLFS_TOOL: create-sbu_du-report
665 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
666 \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
667 (sudo \$(CHROOT2) -c "make -C $BLFS_ROOT/work"); \\
668 fi;
669 @touch \$@
670
671mk_CUSTOM_TOOLS: mk_BLFS_TOOL
672 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
673 \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
674 sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
675 (sudo \$(CHROOT2) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
676 fi;
677 @touch \$@
678
679devices: ck_UID
680$devices
681EOF
682) >> $MKFILE
683if [ "$INITSYS" = systemd ]; then
684(
685 cat << EOF
686 sudo mkdir -pv \$(MOUNT_PT)/run/systemd/resolve
687 sudo cp -v /etc/resolv.conf \$(MOUNT_PT)/run/systemd/resolve
688EOF
689) >> $MKFILE
690fi
691(
692 cat << EOF
693
694teardown:
695$teardown
696
697chroot1: devices
698 sudo \$(CHROOT1)
699 \$(MAKE) teardown
700
701chroot: devices
702 sudo \$(CHROOT2)
703 \$(MAKE) teardown
704
705SETUP: $SETUP_TGT
706LUSER: $LUSER_TGT
707SUDO: $SUDO_TGT
708EOF
709) >> $MKFILE
710if [ "$INITSYS" = systemd ]; then
711(
712 cat << EOF
713 mkdir -pv \$(MOUNT_PT)/run/systemd/resolve
714 cp -v /etc/resolv.conf \$(MOUNT_PT)/run/systemd/resolve
715
716EOF
717) >> $MKFILE
718fi
719(
720 cat << EOF
721CHROOT: SHELL=\$(filter %bash,\$(CHROOT1))
722CHROOT: $CHROOT_TGT
723BOOT: $BOOT_TGT
724CUSTOM_TOOLS: $custom_list
725
726create-sbu_du-report: mk_BOOT
727 @\$(call echo_message, Building)
728 @if [ "\$(ADD_REPORT)" = "y" ]; then \\
729 sudo ./create-sbu_du-report.sh logs $VERSION $(date --iso-8601); \\
730 \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
731 fi
732 @touch \$@
733
734save-luser:
735 @\$(call echo_message, Building)
736 @LUSER_ID=\$\$(grep '^\$(LUSER):' /etc/passwd | cut -d: -f3); \\
737 if [ -n "\$\$LUSER_ID" ]; then \\
738 if [ ! -d \$(LUSER_HOME).XXX ]; then \\
739 mv \$(LUSER_HOME){,.XXX}; \\
740 mkdir \$(LUSER_HOME); \\
741 chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME); \\
742 fi; \\
743 echo "\$\$LUSER_ID" > luser-id; \\
744 echo User \$(LUSER) exists with ID \$\$LUSER_ID; \\
745 else \\
746 rm -f luser-id; \\
747 echo User \$(LUSER) does not exist; \\
748 echo It will be created with book instructions.; \\
749 fi
750 @\$(call housekeeping)
751
752restore-luser:
753 @\$(call echo_message, Building)
754 @if [ -f luser-id ]; then \\
755 rm -rf \$(LUSER_HOME); \\
756 mv \$(LUSER_HOME){.XXX,}; \\
757 rm luser-id; \\
758 else \\
759 userdel \$(LUSER); \\
760 groupdel \$(LGROUP); \\
761 rm -rf \$(LUSER_HOME); \\
762 fi
763 @\$(call housekeeping)
764
765do_housekeeping:
766 @-rm /tools
767
768EOF
769) >> $MKFILE
770
771 # Bring over the items from the Makefile.tmp
772 cat $MKFILE.tmp >> $MKFILE
773 rm $MKFILE.tmp
774 echo "Creating Makefile... ${BOLD}DONE${OFF}"
775}
Note: See TracBrowser for help on using the repository browser.