[91ff6a9] | 1 | #!/bin/bash
|
---|
[877cc6a] | 2 |
|
---|
| 3 | ###################################
|
---|
| 4 | ### FUNCTIONS ###
|
---|
| 5 | ###################################
|
---|
| 6 |
|
---|
| 7 |
|
---|
[045b2dc] | 8 | #############################################################
|
---|
| 9 |
|
---|
| 10 |
|
---|
[ebe1ba6] | 11 | #-------------------------#
|
---|
| 12 | chapter_targets() { #
|
---|
| 13 | #-------------------------#
|
---|
| 14 | # $1 is the chapter number. Pad it with 0 to the left to obtain a 2-digit
|
---|
| 15 | # number:
|
---|
| 16 | printf -v dir chapter%02d $1
|
---|
| 17 |
|
---|
[3da8c49] | 18 | # $2 contains the build number if rebuilding for ICA
|
---|
| 19 | if [[ -z "$2" ]] ; then
|
---|
| 20 | local N=""
|
---|
| 21 | else
|
---|
| 22 | local N=-build_$2
|
---|
| 23 | local CHROOT_TGT=""
|
---|
| 24 | mkdir ${dir}$N
|
---|
| 25 | cp ${dir}/* ${dir}$N
|
---|
| 26 | for script in ${dir}$N/* ; do
|
---|
| 27 | # Overwrite existing symlinks, files, and dirs
|
---|
| 28 | sed -e 's/ln *-sv/&f/g' \
|
---|
| 29 | -e 's/mv *-v/&f/g' \
|
---|
| 30 | -e 's/mkdir *-v/&p/g' -i ${script}
|
---|
| 31 | # Rename the scripts
|
---|
| 32 | mv ${script} ${script}$N
|
---|
| 33 | done
|
---|
| 34 | # Remove Bzip2 binaries before make install (LFS-6.2 compatibility)
|
---|
| 35 | sed -e 's@make install@rm -vf /usr/bin/bz*\n&@' -i ${dir}$N/*-bzip2$N
|
---|
| 36 | # Remove openssl-<version> from /usr/share/doc (LFS-9.x), because
|
---|
| 37 | # otherwise the mv command creates an openssl directory.
|
---|
| 38 | sed -e 's@mv -v@rm -rfv /usr/share/doc/openssl-*\n&@' \
|
---|
| 39 | -i ${dir}$N/*-openssl$N
|
---|
| 40 | fi
|
---|
| 41 |
|
---|
| 42 | echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter $1$N${R_arrow}"
|
---|
[877cc6a] | 43 |
|
---|
[3da8c49] | 44 | for file in ${dir}$N/* ; do
|
---|
[903eefd] | 45 | # Keep the script file name
|
---|
| 46 | this_script=`basename $file`
|
---|
[877cc6a] | 47 |
|
---|
[ebe1ba6] | 48 | # Some scripts need peculiar actions:
|
---|
| 49 | # - Stripping at the end of system build: lfs.xsl does not generate
|
---|
| 50 | # correct commands if the user does not want to strip, so skip it
|
---|
| 51 | # in this case
|
---|
[3da8c49] | 52 | # - do not reinstall linux-headers when rebuilding
|
---|
[ebe1ba6] | 53 | # - grub config: must be done manually; skip it
|
---|
| 54 | # - handle fstab and .config. Skip kernel if .config not supplied
|
---|
[903eefd] | 55 | case "${this_script}" in
|
---|
[84d0d39] | 56 | *stripping*) [[ "${STRIP}" = "n" ]] && continue ;;
|
---|
[3da8c49] | 57 | *linux-headers*) [[ -n "$N" ]] && continue ;;
|
---|
[ebe1ba6] | 58 | 8*grub) (( nb_chaps == 5 )) && continue ;;
|
---|
| 59 | 10*grub) continue ;;
|
---|
| 60 | *fstab) [[ -z "${FSTAB}" ]] ||
|
---|
| 61 | [[ ${FSTAB} == $BUILDDIR/sources/fstab ]] ||
|
---|
| 62 | cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
| 63 | *kernel) [[ -z ${CONFIG} ]] && continue
|
---|
| 64 | [[ ${CONFIG} == $BUILDDIR/sources/kernel-config ]] ||
|
---|
| 65 | cp ${CONFIG} $BUILDDIR/sources/kernel-config ;;
|
---|
[903eefd] | 66 | esac
|
---|
[3da8c49] | 67 | # Grab the name of the target
|
---|
[93814d1] | 68 | # This is only used to check the name in "opt_override" or "BLACKLIST"
|
---|
[3da8c49] | 69 | name=`echo ${this_script} | sed -e 's@[0-9]\{3,4\}-@@' \
|
---|
| 70 | -e 's@-pass[0-9]\{1\}@@' \
|
---|
| 71 | -e 's@-libstdc++@@' \
|
---|
[706e5bf] | 72 | -e 's,'$N',,' \
|
---|
| 73 | -e 's@-32@@'`
|
---|
[3da8c49] | 74 |
|
---|
| 75 | # Find the name of the tarball and the version of the package
|
---|
| 76 | # If it doesn't exist, we skip it in iterations rebuilds (except stripping
|
---|
| 77 | # and revisedchroot, where .a and .la files are removed).
|
---|
| 78 | pkg_tarball=$(sed -n 's/tar -xf \(.*\)/\1/p' $file)
|
---|
| 79 | pkg_version=$(sed -n 's/VERSION=\(.*\)/\1/p' $file)
|
---|
| 80 |
|
---|
| 81 | if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
|
---|
| 82 | case "${this_script}" in
|
---|
[756863b] | 83 | *stripping*|*cleanup*|*revised*) ;;
|
---|
[3da8c49] | 84 | *) continue ;;
|
---|
| 85 | esac
|
---|
| 86 | fi
|
---|
[877cc6a] | 87 |
|
---|
[ebe1ba6] | 88 | # Append the name of the script to a list. The name of the
|
---|
| 89 | # list is contained in the variable Makefile_target. We adjust this
|
---|
| 90 | # variable at various points. Note that it is initialized to "SETUP"
|
---|
| 91 | # in the main function, before calling this function for the first time.
|
---|
| 92 | case "${this_script}" in
|
---|
| 93 | *settingenvironment) Makefile_target=LUSER_TGT ;;
|
---|
| 94 | *changingowner ) Makefile_target=SUDO_TGT ;;
|
---|
| 95 | *creatingdirs ) Makefile_target=CHROOT_TGT ;;
|
---|
| 96 | *bootscripts ) Makefile_target=BOOT_TGT ;; # case of sysv book
|
---|
| 97 | *network ) Makefile_target=BOOT_TGT ;; # case of systemd book
|
---|
| 98 | esac
|
---|
| 99 | eval $Makefile_target=\"\$$Makefile_target ${this_script}\"
|
---|
| 100 |
|
---|
[903eefd] | 101 | #--------------------------------------------------------------------#
|
---|
| 102 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 103 | #--------------------------------------------------------------------#
|
---|
| 104 |
|
---|
| 105 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 106 | # as a dependency. Also call the echo_message function.
|
---|
[ebe1ba6] | 107 | case $Makefile_target in
|
---|
| 108 | CHROOT_TGT) CHROOT_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
|
---|
| 109 | *) LUSER_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
|
---|
| 110 | esac
|
---|
| 111 |
|
---|
| 112 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
| 113 | if [ "$pkg_tarball" != "" ] ; then
|
---|
| 114 | # Touch timestamp file if installed files logs shall be created.
|
---|
[3da8c49] | 115 | # But only for the final install chapter and not when rebuilding it
|
---|
| 116 | if [ "${INSTALL_LOG}" = "y" ] &&
|
---|
| 117 | (( 1+nb_chaps <= $1 )) &&
|
---|
| 118 | [ "x$N" = x ] ; then
|
---|
[ebe1ba6] | 119 | CHROOT_wrt_TouchTimestamp
|
---|
| 120 | fi
|
---|
| 121 | # Always initialize the test log file, since the test instructions may
|
---|
| 122 | # be "uncommented" by the user
|
---|
| 123 | case $Makefile_target in
|
---|
| 124 | CHROOT_TGT) CHROOT_wrt_test_log "${this_script}" "$pkg_version" ;;
|
---|
| 125 | LUSER_TGT ) LUSER_wrt_test_log "${this_script}" "$pkg_version" ;;
|
---|
| 126 | esac
|
---|
[903eefd] | 127 |
|
---|
[ebe1ba6] | 128 | # If using optimizations, write the instructions
|
---|
| 129 | case "${OPTIMIZE}$1${nb_chaps}${this_script}${REALSBU}" in
|
---|
[63190e6] | 130 | 0* | *binutils-pass1y | 15* | 167* | 177*) ;;
|
---|
| 131 | *kernel*) ;; # No CFLAGS for kernel
|
---|
| 132 | *) wrt_optimize "$name" ;;
|
---|
| 133 | esac
|
---|
[04a608b] | 134 | # There is no need to tweak MAKEFLAGS anymore, this is done
|
---|
| 135 | # by lfs.xsl. But still, NINJAJOBS needs to be set if
|
---|
| 136 | # N_PARALLEL is defined.
|
---|
| 137 | if [ -n "N_PARALLEL" ]; then
|
---|
| 138 | wrt_makeflags "$name" "$JH_MAKEFLAGS" "$N_PARALLEL"
|
---|
| 139 | fi
|
---|
| 140 | fi # end of package specific instructions
|
---|
[ebe1ba6] | 141 |
|
---|
| 142 | # Some scriptlet have a special treatment; otherwise standard
|
---|
[903eefd] | 143 | case "${this_script}" in
|
---|
| 144 | *addinguser)
|
---|
| 145 | (
|
---|
[088130f] | 146 | # /var/lib may already exist and be owned by root if blfs tools
|
---|
| 147 | # have been installed.
|
---|
[903eefd] | 148 | cat << EOF
|
---|
| 149 | @if [ -f luser-id ]; then \\
|
---|
| 150 | function useradd() { true; }; \\
|
---|
| 151 | function groupadd() { true; }; \\
|
---|
| 152 | export -f useradd groupadd; \\
|
---|
| 153 | fi; \\
|
---|
| 154 | export LFS=\$(MOUNT_PT) && \\
|
---|
| 155 | \$(CMDSDIR)/`dirname $file`/\$@ >> \$(LOGDIR)/\$@ 2>&1; \\
|
---|
| 156 | \$(PRT_DU) >>logs/\$@
|
---|
| 157 | @chown \$(LUSER):\$(LGROUP) envars
|
---|
[5562bf1] | 158 | @if [ -d "\$(MOUNT_PT)/var/lib" ]; then \\
|
---|
| 159 | chown \$(LUSER):\$(LGROUP) \$(MOUNT_PT)/var/lib; \\
|
---|
| 160 | fi
|
---|
[903eefd] | 161 | @chmod -R a+wt $JHALFSDIR
|
---|
| 162 | @chmod a+wt \$(SRCSDIR)
|
---|
[877cc6a] | 163 | EOF
|
---|
[903eefd] | 164 | ) >> $MKFILE.tmp
|
---|
| 165 | ;;
|
---|
[ebe1ba6] | 166 | *settingenvironment)
|
---|
| 167 | (
|
---|
| 168 | cat << EOF
|
---|
| 169 | @cd && \\
|
---|
| 170 | function source() { true; } && \\
|
---|
| 171 | export -f source && \\
|
---|
| 172 | \$(CMDSDIR)/`dirname $file`/\$@ >> \$(LOGDIR)/\$@ 2>&1 && \\
|
---|
| 173 | sed 's|/mnt/lfs|\$(MOUNT_PT)|' -i .bashrc && \\
|
---|
| 174 | echo source $JHALFSDIR/envars >> .bashrc
|
---|
| 175 | @\$(PRT_DU) >>logs/\$@
|
---|
| 176 | EOF
|
---|
| 177 | ) >> $MKFILE.tmp
|
---|
| 178 | ;;
|
---|
| 179 | *fstab) if [[ -n "$FSTAB" ]]; then
|
---|
| 180 | CHROOT_wrt_CopyFstab
|
---|
| 181 | else
|
---|
| 182 | CHROOT_wrt_RunAsRoot "$file"
|
---|
| 183 | fi
|
---|
| 184 | ;;
|
---|
| 185 |
|
---|
[0a0753d] | 186 | *)
|
---|
[ebe1ba6] | 187 | # Insert date and disk usage at the top of the log file, the script
|
---|
| 188 | # run and date and disk usage again at the bottom of the log file.
|
---|
| 189 | case "${Makefile_target}" in
|
---|
| 190 | SETUP_TGT | SUDO_TGT) wrt_RunAsRoot "$file" "$pkg_version" ;;
|
---|
| 191 | LUSER_TGT) LUSER_wrt_RunAsUser "$file" "$pkg_version" ;;
|
---|
| 192 | CHROOT_TGT | BOOT_TGT) CHROOT_wrt_RunAsRoot "$file" "$pkg_version" ;;
|
---|
| 193 | esac
|
---|
| 194 | ;;
|
---|
[903eefd] | 195 | esac
|
---|
[045b2dc] | 196 |
|
---|
[ebe1ba6] | 197 | # Write installed files log and remove the build directory(ies)
|
---|
| 198 | # except if the package build fails.
|
---|
| 199 | if [ "$pkg_tarball" != "" ] ; then
|
---|
[3da8c49] | 200 | if [ "${INSTALL_LOG}" = "y" ] &&
|
---|
| 201 | (( 1+nb_chaps <= $1 )) &&
|
---|
| 202 | [ "x${N}" = "x" ] ; then
|
---|
[706e5bf] | 203 | CHROOT_wrt_LogNewFiles "${this_script}"
|
---|
[ebe1ba6] | 204 | fi
|
---|
| 205 | fi
|
---|
| 206 |
|
---|
[903eefd] | 207 | # Include a touch of the target name so make can check
|
---|
| 208 | # if it's already been made.
|
---|
| 209 | wrt_touch
|
---|
| 210 | #
|
---|
| 211 | #--------------------------------------------------------------------#
|
---|
| 212 | # >>>>>>>> END OF Makefile ENTRY <<<<<<<< #
|
---|
| 213 | #--------------------------------------------------------------------#
|
---|
| 214 |
|
---|
| 215 | # Keep the script file name for Makefile dependencies.
|
---|
| 216 | PREV=${this_script}
|
---|
[3da8c49] | 217 | # Set "system_build" var for iteration targets
|
---|
| 218 | if [ -z "$N" ] && (( 1+nb_chaps == $1 )); then
|
---|
| 219 | system_build="$system_build $this_script"
|
---|
| 220 | fi
|
---|
| 221 |
|
---|
[ebe1ba6] | 222 | done # end for file in $dir/*
|
---|
[3da8c49] | 223 | # Set "system_build" when rebuilding: note the CHROOT_TGT is local
|
---|
| 224 | # in that case.
|
---|
| 225 | if [ -n "$N" ]; then
|
---|
| 226 | system_build="$CHROOT_TGT"
|
---|
| 227 | fi
|
---|
[877cc6a] | 228 | }
|
---|
| 229 |
|
---|
| 230 | #----------------------------#
|
---|
[045b2dc] | 231 | build_Makefile() { #
|
---|
[877cc6a] | 232 | #----------------------------#
|
---|
[045b2dc] | 233 |
|
---|
[c7c5a53] | 234 | echo "Creating Makefile... ${BOLD}START${OFF}"
|
---|
[045b2dc] | 235 |
|
---|
[2bd2fb8] | 236 | cd "$JHALFSDIR/$COMMANDS"
|
---|
[877cc6a] | 237 |
|
---|
[ebe1ba6] | 238 | # Start with empty files
|
---|
[045b2dc] | 239 | >$MKFILE
|
---|
[ebe1ba6] | 240 | >$MKFILE.tmp
|
---|
| 241 |
|
---|
| 242 | # Ensure the first dependency is empty
|
---|
| 243 | unset PREV
|
---|
[877cc6a] | 244 |
|
---|
[ebe1ba6] | 245 | # We begin with the SETUP target; successive targets will be assigned in
|
---|
| 246 | # the chapter_targets function.
|
---|
| 247 | Makefile_target=SETUP_TGT
|
---|
| 248 |
|
---|
| 249 | # We need to know the chapter numbering, which depends on the version
|
---|
| 250 | # of the book. Use the number of subdirs to know which version we have
|
---|
[6f74ca1] | 251 | chaps=($(echo chapter*))
|
---|
[ebe1ba6] | 252 | nb_chaps=${#chaps[*]} # 5 if classical version, 7 if new version
|
---|
| 253 | # DEBUG
|
---|
| 254 | # echo chaps: ${chaps[*]}
|
---|
| 255 | # echo nb_chaps: $nb_chaps
|
---|
| 256 | # end DEBUG
|
---|
| 257 |
|
---|
| 258 | # Make a temporary file with all script targets
|
---|
| 259 | for (( i = 4; i < nb_chaps+4; i++ )); do
|
---|
| 260 | chapter_targets $i
|
---|
| 261 | if (( i == nb_chaps )); then : # we have finished temporary tools
|
---|
| 262 | # Add the save target, if needed
|
---|
| 263 | [[ "$SAVE_CH5" = "y" ]] && wrt_save_target $Makefile_target
|
---|
| 264 | fi
|
---|
[3da8c49] | 265 | if (( i == 1+nb_chaps )); then : # we have finished final system
|
---|
| 266 | # Add the iterations targets, if needed
|
---|
| 267 | [[ "$COMPARE" = "y" ]] && wrt_compare_targets $i
|
---|
| 268 | fi
|
---|
[ebe1ba6] | 269 | done
|
---|
[3e7ceed] | 270 | # Add the CUSTOM_TOOLS targets, if needed
|
---|
| 271 | [[ "$CUSTOM_TOOLS" = "y" ]] && wrt_CustomTools_target
|
---|
[877cc6a] | 272 |
|
---|
| 273 | # Add a header, some variables and include the function file
|
---|
| 274 | # to the top of the real Makefile.
|
---|
[195ed9f] | 275 | wrt_Makefile_header
|
---|
[877cc6a] | 276 |
|
---|
| 277 | # Add chroot commands
|
---|
[6ad5a2f] | 278 | CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
|
---|
[877cc6a] | 279 | i=1
|
---|
[d68eb1b] | 280 | for file in ../chroot-scripts/*chroot* ; do
|
---|
[6ad5a2f] | 281 | chroot=`cat $file | \
|
---|
[abc8b27] | 282 | perl -pe 's|\\\\\n||g' | \
|
---|
| 283 | tr -s [:space:] | \
|
---|
| 284 | grep chroot | \
|
---|
| 285 | sed -e "s|chroot|$CHROOT_LOC|" \
|
---|
[6ad5a2f] | 286 | -e 's|\\$|&&|g' \
|
---|
[abc8b27] | 287 | -e 's|"$$LFS"|$(MOUNT_PT)|'`
|
---|
[877cc6a] | 288 | echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
---|
| 289 | i=`expr $i + 1`
|
---|
| 290 | done
|
---|
| 291 |
|
---|
[cacc6c5] | 292 | # If CPUSET is defined and not equal to "all", then we define a first target
|
---|
| 293 | # that calls a script which re-enters make calling target all
|
---|
| 294 | if [ -n "$CPUSET" ] && [ "$CPUSET" != all ]; then
|
---|
| 295 | (
|
---|
| 296 | cat << EOF
|
---|
| 297 |
|
---|
| 298 | all-with-cpuset:
|
---|
[09ac7fc] | 299 | @CPUSPEC="\$(CPUSET)" ./run-in-cgroup.sh \$(MAKE) all
|
---|
[cacc6c5] | 300 | EOF
|
---|
| 301 | ) >> $MKFILE
|
---|
| 302 | fi
|
---|
[877cc6a] | 303 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
[fd90f80] | 304 | # as a dependency. Also prevent running targets in parallel.
|
---|
[877cc6a] | 305 | (
|
---|
| 306 | cat << EOF
|
---|
[045b2dc] | 307 |
|
---|
[fd90f80] | 308 | .NOTPARALLEL:
|
---|
| 309 |
|
---|
[9728b23] | 310 | all: ck_UID ck_terminal mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT create-sbu_du-report mk_BLFS_TOOL mk_CUSTOM_TOOLS
|
---|
[3722d31] | 311 | @sudo env LFS=\$(MOUNT_PT) kernfs-scripts/teardown.sh
|
---|
[262e174] | 312 | EOF
|
---|
| 313 | ) >> $MKFILE
|
---|
| 314 | # With systemd, the commands in chapter 9 do not create a
|
---|
| 315 | # valid /etc/resolv.conf, so that if blfs_tools are installed, and
|
---|
| 316 | # make-ca is run, it cannot connect. In this case, resolv.conf
|
---|
| 317 | # from the host has been copied, and we need to remove it now.
|
---|
| 318 | if [ "$INITSYS" = systemd ]; then
|
---|
| 319 | (
|
---|
| 320 | cat << EOF
|
---|
| 321 | @sudo rm -v \$(MOUNT_PT)/etc/resolv.conf
|
---|
| 322 | EOF
|
---|
| 323 | ) >> $MKFILE
|
---|
| 324 | fi
|
---|
| 325 | (
|
---|
| 326 | cat << EOF
|
---|
[045b2dc] | 327 | @sudo make do_housekeeping
|
---|
[e1fc855] | 328 | @echo $VERSION > lfs-release && \\
|
---|
[9096853] | 329 | sudo mv lfs-release \$(MOUNT_PT)/etc && \\
|
---|
| 330 | sudo chown root:root \$(MOUNT_PT)/etc/lfs-release
|
---|
[e1fc855] | 331 | @/bin/echo -e -n \\
|
---|
| 332 | DISTRIB_ID=\\"Linux From Scratch\\"\\\\n\\
|
---|
| 333 | DISTRIB_RELEASE=\\"$VERSION\\"\\\\n\\
|
---|
| 334 | DISTRIB_CODENAME=\\"$(whoami)-jhalfs\\"\\\\n\\
|
---|
| 335 | DISTRIB_DESCRIPTION=\\"Linux From Scratch\\"\\\\n\\
|
---|
| 336 | > lsb-release && \\
|
---|
| 337 | sudo mv lsb-release \$(MOUNT_PT)/etc && \\
|
---|
| 338 | sudo chown root:root \$(MOUNT_PT)/etc/lsb-release
|
---|
[56c1fff] | 339 | @/bin/echo -e -n \\
|
---|
| 340 | NAME=\\"Linux From Scratch\\"\\\\n\\
|
---|
| 341 | VERSION=\\"$VERSION\\"\\\\n\\
|
---|
| 342 | ID=lfs\\\\n\\
|
---|
| 343 | PRETTY_NAME=\\"Linux From Scratch $VERSION\\"\\\\n\\
|
---|
| 344 | VERSION_CODENAME=\\"$(whoami)-jhalfs\\"\\\\n\\
|
---|
| 345 | > os-release && \\
|
---|
| 346 | sudo mv os-release \$(MOUNT_PT)/etc && \\
|
---|
| 347 | sudo chown root:root \$(MOUNT_PT)/etc/os-release
|
---|
[877cc6a] | 348 | @\$(call echo_finished,$VERSION)
|
---|
| 349 |
|
---|
[045b2dc] | 350 | ck_UID:
|
---|
| 351 | @if [ \`id -u\` = "0" ]; then \\
|
---|
| 352 | echo "--------------------------------------------------"; \\
|
---|
| 353 | echo "You cannot run this makefile from the root account"; \\
|
---|
| 354 | echo "--------------------------------------------------"; \\
|
---|
| 355 | exit 1; \\
|
---|
| 356 | fi
|
---|
| 357 |
|
---|
[9728b23] | 358 | ck_terminal:
|
---|
[7e0a1b8] | 359 | @stty size | ( read L C; \\
|
---|
| 360 | if (( L < 24 )) || (( C < 80 )) ; then \\
|
---|
[9728b23] | 361 | echo "--------------------------------------------------"; \\
|
---|
[7e0a1b8] | 362 | echo "Terminal too small: \$\$C columns x \$\$L lines";\\
|
---|
[9728b23] | 363 | echo "Minimum: 80 columns x 24 lines";\\
|
---|
| 364 | echo "--------------------------------------------------"; \\
|
---|
| 365 | exit 1; \\
|
---|
[7e0a1b8] | 366 | fi )
|
---|
[9728b23] | 367 |
|
---|
[045b2dc] | 368 | mk_SETUP:
|
---|
| 369 | @\$(call echo_SU_request)
|
---|
[dd7e0f67] | 370 | @sudo make save-luser
|
---|
[dbcdfd7] | 371 | @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
|
---|
[045b2dc] | 372 | @touch \$@
|
---|
| 373 |
|
---|
| 374 | mk_LUSER: mk_SETUP
|
---|
| 375 | @\$(call echo_SULUSER_request)
|
---|
[903eefd] | 376 | @\$(SU_LUSER) "make -C \$(MOUNT_PT)/\$(SCRIPT_ROOT) BREAKPOINT=\$(BREAKPOINT) LUSER"
|
---|
| 377 | @sudo make restore-luser
|
---|
[045b2dc] | 378 | @touch \$@
|
---|
| 379 |
|
---|
| 380 | mk_SUDO: mk_LUSER
|
---|
[a73ed74] | 381 | @sudo rm -f envars
|
---|
[dbcdfd7] | 382 | @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
|
---|
[1330ebc] | 383 | @touch \$@
|
---|
| 384 |
|
---|
[200cc01] | 385 | mk_CHROOT: mk_SUDO devices
|
---|
[045b2dc] | 386 | @\$(call echo_CHROOT_request)
|
---|
[d68eb1b] | 387 | @( sudo \$(CHROOT1) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT")
|
---|
[045b2dc] | 388 | @touch \$@
|
---|
[877cc6a] | 389 |
|
---|
[200cc01] | 390 | mk_BOOT: mk_CHROOT devices
|
---|
[045b2dc] | 391 | @\$(call echo_CHROOT_request)
|
---|
[20051e0] | 392 | @( sudo \$(CHROOT1) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
|
---|
[045b2dc] | 393 | @touch \$@
|
---|
[877cc6a] | 394 |
|
---|
[200cc01] | 395 | mk_BLFS_TOOL: create-sbu_du-report devices
|
---|
[ac9bdc7] | 396 | @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
---|
| 397 | \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
|
---|
[20051e0] | 398 | (sudo \$(CHROOT1) -c "make -C $BLFS_ROOT/work"); \\
|
---|
[ac9bdc7] | 399 | fi;
|
---|
| 400 | @touch \$@
|
---|
| 401 |
|
---|
[200cc01] | 402 | mk_CUSTOM_TOOLS: mk_BLFS_TOOL devices
|
---|
[3e7ceed] | 403 | @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
|
---|
[3bc6078] | 404 | \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
|
---|
[3e7ceed] | 405 | sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
|
---|
[20051e0] | 406 | (sudo \$(CHROOT1) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
|
---|
[3e7ceed] | 407 | fi;
|
---|
| 408 | @touch \$@
|
---|
| 409 |
|
---|
[f60a8b7] | 410 | devices: ck_UID
|
---|
[3722d31] | 411 | sudo env LFS=\$(MOUNT_PT) kernfs-scripts/devices.sh
|
---|
[d39252b] | 412 | EOF
|
---|
| 413 | ) >> $MKFILE
|
---|
[262e174] | 414 | # With systemd, the commands in chapter 9 do not create a
|
---|
| 415 | # valid /etc/resolv.conf, so that if we want to enter chroot,
|
---|
| 416 | # and systemd has not yet been run (otherwise /etc/resolv.conf
|
---|
| 417 | # exists), we just copy resolv.conf from the host.
|
---|
[d39252b] | 418 | if [ "$INITSYS" = systemd ]; then
|
---|
| 419 | (
|
---|
| 420 | cat << EOF
|
---|
[262e174] | 421 | if ! [ -e \$(MOUNT_PT)/etc/resolv.conf ]; then \\
|
---|
| 422 | sudo cp -v /etc/resolv.conf \$(MOUNT_PT)/etc; \\
|
---|
| 423 | sudo touch \$(MOUNT_PT)/etc/.host-resolvconf; \\
|
---|
| 424 | fi
|
---|
[d39252b] | 425 | EOF
|
---|
| 426 | ) >> $MKFILE
|
---|
| 427 | fi
|
---|
| 428 | (
|
---|
| 429 | cat << EOF
|
---|
[13c475b] | 430 |
|
---|
[2e1c1c3] | 431 | teardown:
|
---|
[3722d31] | 432 | sudo env LFS=\$(MOUNT_PT) kernfs-scripts/teardown.sh
|
---|
[262e174] | 433 | EOF
|
---|
| 434 | ) >> $MKFILE
|
---|
| 435 | # With systemd, the commands in chapter 9 do not create a
|
---|
| 436 | # valid /etc/resolv.conf, so that if we want to enter chroot,
|
---|
| 437 | # and systemd has not yet been run (otherwise /etc/resolv.conf
|
---|
| 438 | # exists), we just copy resolv.conf from the host.
|
---|
| 439 | # We need to remove it now, if it has been created.
|
---|
| 440 | if [ "$INITSYS" = systemd ]; then
|
---|
| 441 | (
|
---|
| 442 | cat << EOF
|
---|
| 443 | if [ -e \$(MOUNT_PT)/etc/.host-resolvconf ]; then \\
|
---|
| 444 | sudo rm -v \$(MOUNT_PT)/etc/resolv.conf; \\
|
---|
| 445 | sudo rm -v \$(MOUNT_PT)/etc/.host-resolvconf; \\
|
---|
| 446 | fi
|
---|
| 447 | EOF
|
---|
| 448 | ) >> $MKFILE
|
---|
| 449 | fi
|
---|
| 450 | (
|
---|
| 451 | cat << EOF
|
---|
[d39252b] | 452 |
|
---|
| 453 | chroot1: devices
|
---|
[c552eab] | 454 | -sudo \$(CHROOT1)
|
---|
[d39252b] | 455 | \$(MAKE) teardown
|
---|
[7c17066] | 456 |
|
---|
| 457 | chroot: devices
|
---|
[c552eab] | 458 | -sudo \$(CHROOT1)
|
---|
[7c17066] | 459 | \$(MAKE) teardown
|
---|
[877cc6a] | 460 |
|
---|
[ebe1ba6] | 461 | SETUP: $SETUP_TGT
|
---|
| 462 | LUSER: $LUSER_TGT
|
---|
| 463 | SUDO: $SUDO_TGT
|
---|
[13c475b] | 464 | EOF
|
---|
| 465 | ) >> $MKFILE
|
---|
[262e174] | 466 | # With systemd, the commands in chapter 9 do not create a
|
---|
| 467 | # valid /etc/resolv.conf, so that if blfs_tools are installed, and
|
---|
| 468 | # make-ca is run, it cannot connect. We just copy resolv.conf
|
---|
| 469 | # from the host. We'll remove it at the end.
|
---|
[13c475b] | 470 | if [ "$INITSYS" = systemd ]; then
|
---|
| 471 | (
|
---|
| 472 | cat << EOF
|
---|
[262e174] | 473 | @cp -v /etc/resolv.conf \$(MOUNT_PT)/etc
|
---|
[13c475b] | 474 |
|
---|
| 475 | EOF
|
---|
| 476 | ) >> $MKFILE
|
---|
| 477 | fi
|
---|
| 478 | (
|
---|
| 479 | cat << EOF
|
---|
[a73ed74] | 480 | CHROOT: SHELL=\$(filter %bash,\$(CHROOT1))
|
---|
[ebe1ba6] | 481 | CHROOT: $CHROOT_TGT
|
---|
| 482 | BOOT: $BOOT_TGT
|
---|
[3e7ceed] | 483 | CUSTOM_TOOLS: $custom_list
|
---|
[fe24ca6] | 484 |
|
---|
[1838bc7] | 485 | create-sbu_du-report: mk_BOOT
|
---|
| 486 | @\$(call echo_message, Building)
|
---|
| 487 | @if [ "\$(ADD_REPORT)" = "y" ]; then \\
|
---|
[c57747d] | 488 | sudo ./create-sbu_du-report.sh logs $VERSION $(date --iso-8601); \\
|
---|
[1838bc7] | 489 | \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
|
---|
[903eefd] | 490 | fi
|
---|
[1838bc7] | 491 | @touch \$@
|
---|
[045b2dc] | 492 |
|
---|
[903eefd] | 493 | save-luser:
|
---|
[877cc6a] | 494 | @\$(call echo_message, Building)
|
---|
[49e2745] | 495 | @LUSER_ID=\$\$(grep '^\$(LUSER):' /etc/passwd | cut -d: -f3); \\
|
---|
[dd7e0f67] | 496 | if [ -n "\$\$LUSER_ID" ]; then \\
|
---|
[903eefd] | 497 | if [ ! -d \$(LUSER_HOME).XXX ]; then \\
|
---|
| 498 | mv \$(LUSER_HOME){,.XXX}; \\
|
---|
| 499 | mkdir \$(LUSER_HOME); \\
|
---|
| 500 | chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME); \\
|
---|
| 501 | fi; \\
|
---|
[dd7e0f67] | 502 | echo "\$\$LUSER_ID" > luser-id; \\
|
---|
| 503 | echo User \$(LUSER) exists with ID \$\$LUSER_ID; \\
|
---|
[903eefd] | 504 | else \\
|
---|
[49e2745] | 505 | rm -f luser-id; \\
|
---|
[dd7e0f67] | 506 | echo User \$(LUSER) does not exist; \\
|
---|
| 507 | echo It will be created with book instructions.; \\
|
---|
[903eefd] | 508 | fi
|
---|
[dbcdfd7] | 509 | @\$(call housekeeping)
|
---|
[a858a78] | 510 |
|
---|
[903eefd] | 511 | restore-luser:
|
---|
| 512 | @\$(call echo_message, Building)
|
---|
| 513 | @if [ -f luser-id ]; then \\
|
---|
| 514 | rm -rf \$(LUSER_HOME); \\
|
---|
| 515 | mv \$(LUSER_HOME){.XXX,}; \\
|
---|
| 516 | rm luser-id; \\
|
---|
| 517 | else \\
|
---|
[6ad5a2f] | 518 | userdel \$(LUSER); \\
|
---|
[903eefd] | 519 | groupdel \$(LGROUP); \\
|
---|
[962793a] | 520 | rm -rf \$(LUSER_HOME); \\
|
---|
[903eefd] | 521 | fi
|
---|
| 522 | @\$(call housekeeping)
|
---|
| 523 |
|
---|
| 524 | do_housekeeping:
|
---|
[706e5bf] | 525 | @-rm -f /tools
|
---|
[a858a78] | 526 |
|
---|
[877cc6a] | 527 | EOF
|
---|
| 528 | ) >> $MKFILE
|
---|
| 529 |
|
---|
| 530 | # Bring over the items from the Makefile.tmp
|
---|
| 531 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 532 | rm $MKFILE.tmp
|
---|
[c7c5a53] | 533 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
| 534 | }
|
---|