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