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