source: LFS/master.sh@ 5637b53

ablfs-more legacy trunk
Last change on this file since 5637b53 was 5a8939e, checked in by Pierre Labastie <pierre@…>, 7 years ago

Really comment out test instructions+always define TESTLOG since the user
may "uncomment" some tests

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