source: LFS/master.sh@ 6caa5b8

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

Check terminal size before starting build

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