source: LFS/master.sh@ 90f5b6d

ablfs-more legacy trunk
Last change on this file since 90f5b6d was d39252b, checked in by Pierre Labastie <pierre@…>, 6 years ago

LFS: Copy /etc/resolv.conf to where it should be during chroot, for
systemd: this allows using the network in chroot.
Also add a chroot1 target, and update the teardown target to what is
in the book.

  • Property mode set to 100644
File size: 20.6 KB
RevLine 
[91ff6a9]1#!/bin/bash
[877cc6a]2
3# $Id$
4
5###################################
6### FUNCTIONS ###
7###################################
8
9
[045b2dc]10#############################################################
11
12
[877cc6a]13#----------------------------#
[045b2dc]14chapter4_Makefiles() { #
[877cc6a]15#----------------------------#
[045b2dc]16 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter4 ( SETUP ) ${R_arrow}"
[877cc6a]17
[962793a]18# If $LUSER_HOME is already present in the host, we asume that the
[877cc6a]19# lfs user and group are also presents in the host, and a backup
20# of their bash init files is made.
21(
22 cat << EOF
23020-creatingtoolsdir:
24 @\$(call echo_message, Building)
[cee9568]25 @mkdir \$(MOUNT_PT)/tools && \\
26 rm -f /tools && \\
[dbcdfd7]27 ln -s \$(MOUNT_PT)/tools /
28 @\$(call housekeeping)
[877cc6a]29
30021-addinguser: 020-creatingtoolsdir
31 @\$(call echo_message, Building)
[1849935]32 @-if [ ! -d \$(LUSER_HOME) ]; then \\
[6ad5a2f]33 groupadd \$(LGROUP); \\
34 useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
[877cc6a]35 else \\
[6ad5a2f]36 touch luser-exist; \\
[877cc6a]37 fi;
[6ad5a2f]38 @chown \$(LUSER) \$(MOUNT_PT)/tools && \\
[ac35c8e]39 chmod -R a+wt \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
[dbcdfd7]40 chmod a+wt \$(SRCSDIR)
41 @\$(call housekeeping)
[877cc6a]42
43022-settingenvironment: 021-addinguser
44 @\$(call echo_message, Building)
[962793a]45 @if [ -f \$(LUSER_HOME)/.bashrc -a ! -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
46 mv \$(LUSER_HOME)/.bashrc \$(LUSER_HOME)/.bashrc.XXX; \\
[877cc6a]47 fi;
[962793a]48 @if [ -f \$(LUSER_HOME)/.bash_profile -a ! -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
49 mv \$(LUSER_HOME)/.bash_profile \$(LUSER_HOME)/.bash_profile.XXX; \\
[877cc6a]50 fi;
[962793a]51 @echo "set +h" > \$(LUSER_HOME)/.bashrc && \\
52 echo "umask 022" >> \$(LUSER_HOME)/.bashrc && \\
53 echo "LFS=\$(MOUNT_PT)" >> \$(LUSER_HOME)/.bashrc && \\
54 echo "LC_ALL=POSIX" >> \$(LUSER_HOME)/.bashrc && \\
[0850553]55 echo "LFS_TGT=`uname -m`-lfs-linux-gnu" >> \$(LUSER_HOME)/.bashrc && \\
[962793a]56 echo "PATH=/tools/bin:/bin:/usr/bin" >> \$(LUSER_HOME)/.bashrc && \\
[0850553]57 echo "export LFS LC_ALL LFS_TGT PATH" >> \$(LUSER_HOME)/.bashrc && \\
[962793a]58 echo "source $JHALFSDIR/envars" >> \$(LUSER_HOME)/.bashrc && \\
59 chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bashrc && \\
[877cc6a]60 touch envars && \\
[dbcdfd7]61 chown \$(LUSER) envars
62 @\$(call housekeeping)
[877cc6a]63EOF
[045b2dc]64) > $MKFILE.tmp
65
66 chapter4=" 020-creatingtoolsdir 021-addinguser 022-settingenvironment"
[877cc6a]67}
68
[045b2dc]69
70
[877cc6a]71#----------------------------#
72chapter5_Makefiles() {
73#----------------------------#
[045b2dc]74 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter5 ( LUSER ) ${R_arrow}"
[877cc6a]75
76 for file in chapter05/* ; do
77 # Keep the script file name
78 this_script=`basename $file`
79
[7831c79]80 # If no testsuites are run, then TCL, Expect, DejaGNU and Check
[de84c00]81 # aren't needed (but building them does not hurt).
[a241c33]82 # Fix also locales creation when running chapter05 testsuites (ugly)
[877cc6a]83 case "${this_script}" in
[de84c00]84# *tcl) [[ "${TEST}" = "0" ]] && continue ;;
85# *expect) [[ "${TEST}" = "0" ]] && continue ;;
86# *dejagnu) [[ "${TEST}" = "0" ]] && continue ;;
87# *check) [[ "${TEST}" = "0" ]] && continue ;;
[dc7fd7b]88# We now do that in LFS.xsl, because stripping.xml contains other cleaning
89# instructions
90# *stripping) [[ "${STRIP}" = "n" ]] && continue ;;
[a241c33]91 *glibc) [[ "${TEST}" = "3" ]] && \
[d46a46e]92 sed -i 's@/usr/lib/locale@/tools/lib/locale@' $file ;;
[877cc6a]93 esac
94
95 # First append each name of the script files to a list (this will become
96 # the names of the targets in the Makefile
[4eba1ea]97 # DO NOT append the changingowner script, it need be run as root.
[045b2dc]98 # A hack is necessary: create script in chap5 BUT run as a dependency for
[4eba1ea]99 # SUDO target
[045b2dc]100 case "${this_script}" in
[4eba1ea]101 *changingowner) runasroot="$runasroot ${this_script}" ;;
[045b2dc]102 *) chapter5="$chapter5 ${this_script}" ;;
103 esac
[877cc6a]104
105 # Grab the name of the target (minus the -pass1 or -pass2 in the case of gcc
106 # and binutils in chapter 5)
[1849935]107 name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@' \
108 -e 's@-pass[0-9]\{1\}@@' \
109 -e 's@-libstdc++@@'`
[877cc6a]110
111 # Set the dependency for the first target.
112 if [ -z $PREV ] ; then PREV=022-settingenvironment ; fi
113
114 #--------------------------------------------------------------------#
115 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
116 #--------------------------------------------------------------------#
117 #
[3cb4ef5b]118 # Find the name of the tarball and the version of the package
119 pkg_tarball=$(get_package_tarball_name $name)
120 pkg_version=$(get_package_version $pkg_tarball)
121
[877cc6a]122 # Drop in the name of the target on a new line, and the previous target
123 # as a dependency. Also call the echo_message function.
[3cb4ef5b]124 LUSER_wrt_target "${this_script}" "$PREV" "$pkg_version"
[b7faa5a]125
[a160d86]126 # If $pkg_tarball isn't empty, we've got a package...
127 if [ "$pkg_tarball" != "" ] ; then
[877cc6a]128 # Insert instructions for unpacking the package and to set the PKGDIR variable.
[045b2dc]129 LUSER_wrt_unpack "$pkg_tarball"
[5a8939e]130 # Always initialize the log file, since the test instructions may be
131 # "uncommented" by the user
132 LUSER_wrt_test_log "${this_script}" "$pkg_version"
[a229600]133 # If using optimizations, write the instructions
[84a3fda]134 case "${OPTIMIZE}${this_script}${REALSBU}" in
135 *binutils-pass1y) ;;
136 2*) wrt_optimize "$name" && wrt_makeflags "$name" ;;
137 *) ;;
138 esac
[877cc6a]139 fi
140
141 # Insert date and disk usage at the top of the log file, the script run
142 # and date and disk usage again at the bottom of the log file.
[a241c33]143 # The changingowner script must be run as root.
144 case "${this_script}" in
[3cb4ef5b]145 *changingowner) wrt_RunAsRoot "$file" "$pkg_version" ;;
146 *) LUSER_wrt_RunAsUser "$file" "$pkg_version" ;;
[a241c33]147 esac
[877cc6a]148
149 # Remove the build directory(ies) except if the package build fails
150 # (so we can review config.cache, config.log, etc.)
[a160d86]151 if [ "$pkg_tarball" != "" ] ; then
[4b54394]152 case "${name}" in
153 *xz-utils) LUSER_RemoveBuildDirs "xz" ;;
154 *) LUSER_RemoveBuildDirs "$name" ;;
155 esac
[877cc6a]156 fi
157
158 # Include a touch of the target name so make can check
159 # if it's already been made.
[e2ef100]160 wrt_touch
[877cc6a]161 #
162 #--------------------------------------------------------------------#
163 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
164 #--------------------------------------------------------------------#
165
166 # Keep the script file name for Makefile dependencies.
167 PREV=${this_script}
168 done # end for file in chapter05/*
169}
170
[045b2dc]171
[877cc6a]172#----------------------------#
173chapter6_Makefiles() {
174#----------------------------#
[045b2dc]175
[45f82718]176 # Set envars and scripts for iteration targets
177 if [[ -z "$1" ]] ; then
178 local N=""
179 else
180 local N=-build_$1
181 local chapter6=""
182 mkdir chapter06$N
183 cp chapter06/* chapter06$N
184 for script in chapter06$N/* ; do
185 # Overwrite existing symlinks, files, and dirs
[93fd2d0]186 sed -e 's/ln *-sv/&f/g' \
187 -e 's/mv *-v/&f/g' \
188 -e 's/mkdir *-v/&p/g' -i ${script}
189 # Suppress the mod of "test-installation.pl" because now
190 # the library path points to /usr/lib
191 if [[ ${script} =~ glibc ]]; then
192 sed '/DL=/,/unset DL/d' -i ${script}
193 fi
[10c8b78]194 # Rename the scripts
195 mv ${script} ${script}$N
[45f82718]196 done
[a5f52ba]197 # Remove Bzip2 binaries before make install (LFS-6.2 compatibility)
198 sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i chapter06$N/*-bzip2$N
[45f82718]199 fi
200
[045b2dc]201 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter6$N ( CHROOT ) ${R_arrow}"
[45f82718]202
203 for file in chapter06$N/* ; do
[877cc6a]204 # Keep the script file name
205 this_script=`basename $file`
206
[d68eb1b]207 # Skip the "stripping" scripts if the user does not want to strip.
[8426d1f]208 # Skip also linux-headers in iterative builds.
[877cc6a]209 case "${this_script}" in
[401f81e]210 *stripping*) [[ "${STRIP}" = "n" ]] && continue ;;
[8426d1f]211 *linux-headers*) [[ -n "$N" ]] && continue ;;
[877cc6a]212 esac
213
[4eba1ea]214 # Grab the name of the target.
[10c8b78]215 name=`echo ${this_script} | sed -e 's@[0-9]\{3\}-@@' -e 's,'$N',,'`
[877cc6a]216
[d68eb1b]217 # Find the tarball corresponding to our script.
218 # If it doesn't, we skip it in iterations rebuilds (except stripping).
[a160d86]219 pkg_tarball=$(get_package_tarball_name $name)
[3cb4ef5b]220 pkg_version=$(get_package_version $pkg_tarball)
[45f82718]221
[a160d86]222 if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
[45f82718]223 case "${this_script}" in
224 *stripping*) ;;
225 *) continue ;;
226 esac
227 fi
228
229 # Append each name of the script files to a list (this will become
230 # the names of the targets in the Makefile)
[4eba1ea]231 # The kernfs script must be run as part of SUDO target.
232 case "${this_script}" in
233 *kernfs) runasroot="$runasroot ${this_script}" ;;
[10c8b78]234 *) chapter6="$chapter6 ${this_script}" ;;
[4eba1ea]235 esac
[45f82718]236
[877cc6a]237 #--------------------------------------------------------------------#
238 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
239 #--------------------------------------------------------------------#
240 #
241 # Drop in the name of the target on a new line, and the previous target
242 # as a dependency. Also call the echo_message function.
[8bea2c8]243 # In the mount of kernel filesystems we need to set LFS
244 # and not to use chroot.
245 case "${this_script}" in
[3cb4ef5b]246 *kernfs) LUSER_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
247 *) CHROOT_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
[8bea2c8]248 esac
[877cc6a]249
[a160d86]250 # If $pkg_tarball isn't empty, we've got a package...
[877cc6a]251 # Insert instructions for unpacking the package and changing directories
[a160d86]252 if [ "$pkg_tarball" != "" ] ; then
[38d2de6]253 # Touch timestamp file if installed files logs will be created.
[81fca31]254 # But only for the firt build when running iterative builds.
255 if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
[93346ee]256 CHROOT_wrt_TouchTimestamp
257 fi
[045b2dc]258 CHROOT_Unpack "$pkg_tarball"
[5a8939e]259 # Always initialize the log file, so that the use may reinstate a
260 # commented out test
261 CHROOT_wrt_test_log "${this_script}" "$pkg_version"
[a229600]262 # If using optimizations, write the instructions
[1b65a84]263 [[ "$OPTIMIZE" != "0" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
[877cc6a]264 fi
265
266 # In the mount of kernel filesystems we need to set LFS
267 # and not to use chroot.
268 case "${this_script}" in
[3cb4ef5b]269 *kernfs) wrt_RunAsRoot "$file" "$pkg_version" ;;
270 *) CHROOT_wrt_RunAsRoot "$file" "$pkg_version" ;;
[877cc6a]271 esac
272
[93346ee]273 # Write installed files log and remove the build directory(ies)
274 # except if the package build fails.
[a160d86]275 if [ "$pkg_tarball" != "" ] ; then
[4b54394]276 case "${name}" in
277 *xz-utils) CHROOT_wrt_RemoveBuildDirs "xz" ;;
278 *) CHROOT_wrt_RemoveBuildDirs "$name" ;;
279 esac
[81fca31]280 if [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
[93346ee]281 CHROOT_wrt_LogNewFiles "$name"
282 fi
[877cc6a]283 fi
284
285 # Include a touch of the target name so make can check
286 # if it's already been made.
[e2ef100]287 wrt_touch
[877cc6a]288 #
289 #--------------------------------------------------------------------#
290 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
291 #--------------------------------------------------------------------#
292
293 # Keep the script file name for Makefile dependencies.
[10c8b78]294 PREV=${this_script}
[45f82718]295 # Set system_build envar for iteration targets
296 system_build=$chapter6
[877cc6a]297 done # end for file in chapter06/*
298}
299
300#----------------------------#
[14eaa9f]301chapter78_Makefiles() {
[877cc6a]302#----------------------------#
[b11c10b]303 echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter7/8 ( BOOT ) ${R_arrow}"
[877cc6a]304
[14eaa9f]305 for file in chapter0{7,8}/* ; do
[877cc6a]306 # Keep the script file name
307 this_script=`basename $file`
308
309 # Grub must be configured manually.
[14eaa9f]310 # Handle fstab creation.
[877cc6a]311 # If no .config file is supplied, the kernel build is skipped
312 case ${this_script} in
313 *grub) continue ;;
[d601cfc]314 *fstab) [[ -z "${FSTAB}" ]] ||
[85506da]315 [[ ${FSTAB} == $BUILDDIR/sources/fstab ]] ||
316 cp ${FSTAB} $BUILDDIR/sources/fstab ;;
[877cc6a]317 *kernel) [[ -z ${CONFIG} ]] && continue
[85506da]318 [[ ${CONFIG} == $BUILDDIR/sources/kernel-config ]] ||
[877cc6a]319 cp ${CONFIG} $BUILDDIR/sources/kernel-config ;;
320 esac
321
322 # First append each name of the script files to a list (this will become
323 # the names of the targets in the Makefile
[14eaa9f]324 chapter78="$chapter78 ${this_script}"
[877cc6a]325
326 #--------------------------------------------------------------------#
327 # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
328 #--------------------------------------------------------------------#
329 #
330 # Drop in the name of the target on a new line, and the previous target
331 # as a dependency. Also call the echo_message function.
[045b2dc]332 CHROOT_wrt_target "${this_script}" "$PREV"
[877cc6a]333
[532ede6]334 # Find the bootscripts or networkscripts (for systemd)
335 # and kernel package names
[877cc6a]336 case "${this_script}" in
337 *bootscripts)
[a160d86]338 name="lfs-bootscripts"
339 pkg_tarball=$(get_package_tarball_name $name)
[93346ee]340 if [ "${INSTALL_LOG}" = "y" ] ; then
341 CHROOT_wrt_TouchTimestamp
342 fi
[81fca31]343 CHROOT_Unpack "$pkg_tarball"
[877cc6a]344 ;;
[532ede6]345 *network-scripts)
346 name="lfs-network-scripts"
347 pkg_tarball=$(get_package_tarball_name $name)
348 if [ "${INSTALL_LOG}" = "y" ] ; then
349 CHROOT_wrt_TouchTimestamp
350 fi
351 CHROOT_Unpack "$pkg_tarball"
352 ;;
[877cc6a]353 *kernel)
[a160d86]354 name="linux"
355 pkg_tarball=$(get_package_tarball_name $name)
[93346ee]356 if [ "${INSTALL_LOG}" = "y" ] ; then
357 CHROOT_wrt_TouchTimestamp
358 fi
[81fca31]359 CHROOT_Unpack "$pkg_tarball"
[93fd2d0]360 # If using optimizations, use MAKEFLAGS (unless blacklisted)
361 # no setting of CFLAGS and friends.
362 [[ "$OPTIMIZE" != "0" ]] && wrt_makeflags "$name"
[877cc6a]363 ;;
364 esac
365
366 # Check if we have a real /etc/fstab file
367 case "${this_script}" in
[d601cfc]368 *fstab) if [[ -n "$FSTAB" ]]; then
[045b2dc]369 CHROOT_wrt_CopyFstab
[877cc6a]370 else
[045b2dc]371 CHROOT_wrt_RunAsRoot "$file"
[877cc6a]372 fi
373 ;;
[045b2dc]374 *) CHROOT_wrt_RunAsRoot "$file"
[877cc6a]375 ;;
376 esac
377
378 case "${this_script}" in
[532ede6]379 *bootscripts) CHROOT_wrt_RemoveBuildDirs "dummy"
380 if [ "${INSTALL_LOG}" = "y" ] ; then
381 CHROOT_wrt_LogNewFiles "$name"
382 fi ;;
383 *network-scripts) CHROOT_wrt_RemoveBuildDirs "dummy"
384 if [ "${INSTALL_LOG}" = "y" ] ; then
385 CHROOT_wrt_LogNewFiles "$name"
386 fi ;;
387 *kernel) CHROOT_wrt_RemoveBuildDirs "dummy"
388 if [ "${INSTALL_LOG}" = "y" ] ; then
389 CHROOT_wrt_LogNewFiles "$name"
390 fi ;;
[877cc6a]391 esac
392
393 # Include a touch of the target name so make can check
394 # if it's already been made.
[e2ef100]395 wrt_touch
[877cc6a]396 #
397 #--------------------------------------------------------------------#
398 # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
399 #--------------------------------------------------------------------#
400
401 # Keep the script file name for Makefile dependencies.
402 PREV=${this_script}
[14eaa9f]403 done # for file in chapter0{7,8}/*
[453bef0]404
[877cc6a]405}
406
407
[045b2dc]408
[877cc6a]409#----------------------------#
[045b2dc]410build_Makefile() { #
[877cc6a]411#----------------------------#
[045b2dc]412
[c7c5a53]413 echo "Creating Makefile... ${BOLD}START${OFF}"
[045b2dc]414
[877cc6a]415 cd $JHALFSDIR/${PROGNAME}-commands
416
417 # Start with a clean Makefile.tmp file
[045b2dc]418 >$MKFILE
[877cc6a]419
420 chapter4_Makefiles
421 chapter5_Makefiles
422 chapter6_Makefiles
[45f82718]423 # Add the iterations targets, if needed
[401f81e]424 [[ "$COMPARE" = "y" ]] && wrt_compare_targets
[14eaa9f]425 chapter78_Makefiles
[3e7ceed]426 # Add the CUSTOM_TOOLS targets, if needed
427 [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
[877cc6a]428
429 # Add a header, some variables and include the function file
430 # to the top of the real Makefile.
[195ed9f]431 wrt_Makefile_header
[877cc6a]432
433 # Add chroot commands
[6ad5a2f]434 CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
[877cc6a]435 i=1
[d68eb1b]436 for file in ../chroot-scripts/*chroot* ; do
[6ad5a2f]437 chroot=`cat $file | \
[abc8b27]438 perl -pe 's|\\\\\n||g' | \
439 tr -s [:space:] | \
440 grep chroot | \
441 sed -e "s|chroot|$CHROOT_LOC|" \
[6ad5a2f]442 -e 's|\\$|&&|g' \
[abc8b27]443 -e 's|"$$LFS"|$(MOUNT_PT)|'`
[877cc6a]444 echo -e "CHROOT$i= $chroot\n" >> $MKFILE
445 i=`expr $i + 1`
446 done
447
448 # Drop in the main target 'all:' and the chapter targets with each sub-target
449 # as a dependency.
450(
451 cat << EOF
[045b2dc]452
[ac9bdc7]453all: ck_UID mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT create-sbu_du-report mk_BLFS_TOOL mk_CUSTOM_TOOLS
[045b2dc]454 @sudo make do_housekeeping
[df97e68]455EOF
456) >> $MKFILE
457if [ "$INITSYS" = systemd ]; then
458(
459 cat << EOF
460 @/bin/echo -e -n \\
461 NAME=\\"Linux From Scratch\\"\\\\n\\
462 VERSION=\\"$VERSION\\"\\\\n\\
463 ID=lfs\\\\n\\
464 PRETTY_NAME=\\"Linux From Scratch $VERSION\\"\\\\n\\
465 VERSION_CODENAME=\\"$(whoami)-jhalfs\\"\\\\n\\
466 > os-release && \\
467 sudo mv os-release \$(MOUNT_PT)/etc && \\
468 sudo chown root:root \$(MOUNT_PT)/etc/os-release
469EOF
470) >> $MKFILE
471fi
472(
473 cat << EOF
[e1fc855]474 @echo $VERSION > lfs-release && \\
[9096853]475 sudo mv lfs-release \$(MOUNT_PT)/etc && \\
476 sudo chown root:root \$(MOUNT_PT)/etc/lfs-release
[e1fc855]477 @/bin/echo -e -n \\
478 DISTRIB_ID=\\"Linux From Scratch\\"\\\\n\\
479 DISTRIB_RELEASE=\\"$VERSION\\"\\\\n\\
480 DISTRIB_CODENAME=\\"$(whoami)-jhalfs\\"\\\\n\\
481 DISTRIB_DESCRIPTION=\\"Linux From Scratch\\"\\\\n\\
482 > lsb-release && \\
483 sudo mv lsb-release \$(MOUNT_PT)/etc && \\
484 sudo chown root:root \$(MOUNT_PT)/etc/lsb-release
[877cc6a]485 @\$(call echo_finished,$VERSION)
486
[045b2dc]487ck_UID:
488 @if [ \`id -u\` = "0" ]; then \\
489 echo "--------------------------------------------------"; \\
490 echo "You cannot run this makefile from the root account"; \\
491 echo "--------------------------------------------------"; \\
492 exit 1; \\
493 fi
494
495mk_SETUP:
496 @\$(call echo_SU_request)
[dbcdfd7]497 @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
[045b2dc]498 @touch \$@
499
500mk_LUSER: mk_SETUP
501 @\$(call echo_SULUSER_request)
[ef32ce5]502 @( \$(SU_LUSER) "make -C \$(MOUNT_PT)/\$(SCRIPT_ROOT) BREAKPOINT=\$(BREAKPOINT) LUSER" )
[045b2dc]503 @sudo make restore-luser-env
504 @touch \$@
505
506mk_SUDO: mk_LUSER
[dbcdfd7]507 @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
[1330ebc]508 @touch \$@
509
[045b2dc]510mk_CHROOT: mk_SUDO
511 @\$(call echo_CHROOT_request)
[d68eb1b]512 @( sudo \$(CHROOT1) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT")
[045b2dc]513 @touch \$@
[877cc6a]514
[045b2dc]515mk_BOOT: mk_CHROOT
516 @\$(call echo_CHROOT_request)
[d68eb1b]517 @( sudo \$(CHROOT2) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
[045b2dc]518 @touch \$@
[877cc6a]519
[ac9bdc7]520mk_BLFS_TOOL: create-sbu_du-report
521 @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
522 \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
[d68eb1b]523 (sudo \$(CHROOT2) -c "make -C $BLFS_ROOT/work"); \\
[ac9bdc7]524 fi;
525 @touch \$@
526
527mk_CUSTOM_TOOLS: mk_BLFS_TOOL
[3e7ceed]528 @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
[3bc6078]529 \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
[3e7ceed]530 sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
[d68eb1b]531 (sudo \$(CHROOT2) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
[3e7ceed]532 fi;
533 @touch \$@
534
[f60a8b7]535devices: ck_UID
536 sudo mount -v --bind /dev \$(MOUNT_PT)/dev
537 sudo mount -vt devpts devpts \$(MOUNT_PT)/dev/pts
538 sudo mount -vt proc proc \$(MOUNT_PT)/proc
539 sudo mount -vt sysfs sysfs \$(MOUNT_PT)/sys
[d954e9c]540 sudo mount -vt tmpfs tmpfs \$(MOUNT_PT)/run
[f60a8b7]541 if [ -h \$(MOUNT_PT)/dev/shm ]; then \\
[d954e9c]542 sudo mkdir -p \$(MOUNT_PT)/\$\$(readlink \$(MOUNT_PT)/dev/shm); \\
[72f2f82]543 fi
[d39252b]544EOF
545) >> $MKFILE
546if [ "$INITSYS" = systemd ]; then
547(
548 cat << EOF
549 sudo mkdir -pv \$(MOUNT_PT)/run/systemd/resolve
550 sudo cp -v /etc/resolv.conf \$(MOUNT_PT)}/run/systemd/resolve
551EOF
552) >> $MKFILE
553fi
554(
555 cat << EOF
[2e1c1c3]556teardown:
[f60a8b7]557 sudo umount -v \$(MOUNT_PT)/dev/pts
558 sudo umount -v \$(MOUNT_PT)/dev
[d39252b]559 sudo umount -v \$(MOUNT_PT)/run
560 sudo umount -v \$(MOUNT_PT)/proc
561 sudo umount -v \$(MOUNT_PT)/sys
562
563chroot1: devices
564 sudo \$(CHROOT1)
565 \$(MAKE) teardown
[7c17066]566
567chroot: devices
[d68eb1b]568 sudo \$(CHROOT2)
[7c17066]569 \$(MAKE) teardown
[877cc6a]570
[3e7ceed]571SETUP: $chapter4
572LUSER: $chapter5
573SUDO: $runasroot
[aec4483]574CHROOT: SHELL=/tools/bin/bash
[3e7ceed]575CHROOT: $chapter6
576BOOT: $chapter78
577CUSTOM_TOOLS: $custom_list
[fe24ca6]578
[045b2dc]579
[1838bc7]580create-sbu_du-report: mk_BOOT
581 @\$(call echo_message, Building)
582 @if [ "\$(ADD_REPORT)" = "y" ]; then \\
[c57747d]583 sudo ./create-sbu_du-report.sh logs $VERSION $(date --iso-8601); \\
[1838bc7]584 \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
585 fi;
586 @touch \$@
[045b2dc]587
[6ad5a2f]588restore-luser-env:
[877cc6a]589 @\$(call echo_message, Building)
[962793a]590 @if [ -f \$(LUSER_HOME)/.bashrc.XXX ]; then \\
591 mv -f \$(LUSER_HOME)/.bashrc.XXX \$(LUSER_HOME)/.bashrc; \\
[877cc6a]592 fi;
[962793a]593 @if [ -f \$(LUSER_HOME)/.bash_profile.XXX ]; then \\
594 mv \$(LUSER_HOME)/.bash_profile.XXX \$(LUSER_HOME)/.bash_profile; \\
[877cc6a]595 fi;
[962793a]596 @chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME)/.bash*
[dbcdfd7]597 @\$(call housekeeping)
[a858a78]598
[7d9a82d]599do_housekeeping:
[4524fb2]600 @-umount \$(MOUNT_PT)/sys
601 @-umount \$(MOUNT_PT)/proc
[d954e9c]602 @-if mountpoint -q \$(MOUNT_PT)/run; then \\
603 umount \$(MOUNT_PT)/run; \\
604 elif [ -h \$(MOUNT_PT)/dev/shm ]; then \\
[72f2f82]605 link=\$\$(readlink \$(MOUNT_PT)/dev/shm); \\
606 umount \$(MOUNT_PT)/\$\$link; \\
607 unset link; \\
608 else \\
609 umount \$(MOUNT_PT)/dev/shm; \\
610 fi
[4524fb2]611 @-umount \$(MOUNT_PT)/dev/pts
612 @-umount \$(MOUNT_PT)/dev
[045b2dc]613 @-rm /tools
[6ad5a2f]614 @-if [ ! -f luser-exist ]; then \\
615 userdel \$(LUSER); \\
[962793a]616 rm -rf \$(LUSER_HOME); \\
[7d9a82d]617 fi;
[a858a78]618
[fe24ca6]619
[877cc6a]620EOF
621) >> $MKFILE
622
623 # Bring over the items from the Makefile.tmp
624 cat $MKFILE.tmp >> $MKFILE
625 rm $MKFILE.tmp
[c7c5a53]626 echo "Creating Makefile... ${BOLD}DONE${OFF}"
627}
Note: See TracBrowser for help on using the repository browser.