[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 ;;
|
---|
[33a4e41] | 61 | *strippingagain) [[ "${STRIP}" = "n" ]] && continue ;;
|
---|
[c1060c9] | 62 | *stripping) [[ "${STRIP}" = "n" ]] && continue ;;
|
---|
[3da8c49] | 63 | *linux-headers*) [[ -n "$N" ]] && continue ;;
|
---|
[ebe1ba6] | 64 | 8*grub) (( nb_chaps == 5 )) && continue ;;
|
---|
| 65 | 10*grub) continue ;;
|
---|
| 66 | *fstab) [[ -z "${FSTAB}" ]] ||
|
---|
| 67 | [[ ${FSTAB} == $BUILDDIR/sources/fstab ]] ||
|
---|
| 68 | cp ${FSTAB} $BUILDDIR/sources/fstab ;;
|
---|
| 69 | *kernel) [[ -z ${CONFIG} ]] && continue
|
---|
| 70 | [[ ${CONFIG} == $BUILDDIR/sources/kernel-config ]] ||
|
---|
| 71 | cp ${CONFIG} $BUILDDIR/sources/kernel-config ;;
|
---|
[903eefd] | 72 | esac
|
---|
[3da8c49] | 73 | # Grab the name of the target
|
---|
[088130f] | 74 | # This is only used to check the name in "opt_override" or "BLACKIST"
|
---|
[3da8c49] | 75 | name=`echo ${this_script} | sed -e 's@[0-9]\{3,4\}-@@' \
|
---|
| 76 | -e 's@-pass[0-9]\{1\}@@' \
|
---|
| 77 | -e 's@-libstdc++@@' \
|
---|
[706e5bf] | 78 | -e 's,'$N',,' \
|
---|
| 79 | -e 's@-32@@'`
|
---|
[3da8c49] | 80 |
|
---|
| 81 | # Find the name of the tarball and the version of the package
|
---|
| 82 | # If it doesn't exist, we skip it in iterations rebuilds (except stripping
|
---|
| 83 | # and revisedchroot, where .a and .la files are removed).
|
---|
| 84 | pkg_tarball=$(sed -n 's/tar -xf \(.*\)/\1/p' $file)
|
---|
| 85 | pkg_version=$(sed -n 's/VERSION=\(.*\)/\1/p' $file)
|
---|
| 86 |
|
---|
| 87 | if [[ "$pkg_tarball" = "" ]] && [[ -n "$N" ]] ; then
|
---|
| 88 | case "${this_script}" in
|
---|
[756863b] | 89 | *stripping*|*cleanup*|*revised*) ;;
|
---|
[3da8c49] | 90 | *) continue ;;
|
---|
| 91 | esac
|
---|
| 92 | fi
|
---|
[877cc6a] | 93 |
|
---|
[ebe1ba6] | 94 | # Append the name of the script to a list. The name of the
|
---|
| 95 | # list is contained in the variable Makefile_target. We adjust this
|
---|
| 96 | # variable at various points. Note that it is initialized to "SETUP"
|
---|
| 97 | # in the main function, before calling this function for the first time.
|
---|
| 98 | case "${this_script}" in
|
---|
| 99 | *settingenvironment) Makefile_target=LUSER_TGT ;;
|
---|
| 100 | *changingowner ) Makefile_target=SUDO_TGT ;;
|
---|
| 101 | *creatingdirs ) Makefile_target=CHROOT_TGT ;;
|
---|
| 102 | *bootscripts ) Makefile_target=BOOT_TGT ;; # case of sysv book
|
---|
| 103 | *network ) Makefile_target=BOOT_TGT ;; # case of systemd book
|
---|
| 104 | esac
|
---|
| 105 | eval $Makefile_target=\"\$$Makefile_target ${this_script}\"
|
---|
| 106 |
|
---|
[903eefd] | 107 | #--------------------------------------------------------------------#
|
---|
| 108 | # >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<< #
|
---|
| 109 | #--------------------------------------------------------------------#
|
---|
| 110 |
|
---|
| 111 | # Drop in the name of the target on a new line, and the previous target
|
---|
| 112 | # as a dependency. Also call the echo_message function.
|
---|
[ebe1ba6] | 113 | case $Makefile_target in
|
---|
| 114 | CHROOT_TGT) CHROOT_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
|
---|
| 115 | *) LUSER_wrt_target "${this_script}" "$PREV" "$pkg_version" ;;
|
---|
| 116 | esac
|
---|
| 117 |
|
---|
| 118 | # If $pkg_tarball isn't empty, we've got a package...
|
---|
| 119 | if [ "$pkg_tarball" != "" ] ; then
|
---|
| 120 | # Touch timestamp file if installed files logs shall be created.
|
---|
[3da8c49] | 121 | # But only for the final install chapter and not when rebuilding it
|
---|
| 122 | if [ "${INSTALL_LOG}" = "y" ] &&
|
---|
| 123 | (( 1+nb_chaps <= $1 )) &&
|
---|
| 124 | [ "x$N" = x ] ; then
|
---|
[ebe1ba6] | 125 | CHROOT_wrt_TouchTimestamp
|
---|
| 126 | fi
|
---|
| 127 | # Always initialize the test log file, since the test instructions may
|
---|
| 128 | # be "uncommented" by the user
|
---|
| 129 | case $Makefile_target in
|
---|
| 130 | CHROOT_TGT) CHROOT_wrt_test_log "${this_script}" "$pkg_version" ;;
|
---|
| 131 | LUSER_TGT ) LUSER_wrt_test_log "${this_script}" "$pkg_version" ;;
|
---|
| 132 | esac
|
---|
[903eefd] | 133 |
|
---|
[ebe1ba6] | 134 | # If using optimizations, write the instructions
|
---|
| 135 | case "${OPTIMIZE}$1${nb_chaps}${this_script}${REALSBU}" in
|
---|
| 136 | 0* | *binutils-pass1y | 15* | 167* | 177*) ;;
|
---|
[b33c6ee] | 137 | *kernel*) wrt_makeflags "$name" ;; # No CFLAGS for kernel
|
---|
[ebe1ba6] | 138 | *) wrt_optimize "$name" && wrt_makeflags "$name" ;;
|
---|
| 139 | esac
|
---|
| 140 | fi
|
---|
| 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 |
|
---|
[877cc6a] | 236 | cd $JHALFSDIR/${PROGNAME}-commands
|
---|
| 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 |
|
---|
[13c475b] | 292 | # Store virtual kernel file systems commands:
|
---|
| 293 | devices=`cat ../kernfs-scripts/devices.sh | \
|
---|
| 294 | sed -e 's|^| |' \
|
---|
| 295 | -e 's|mount|sudo &|' \
|
---|
| 296 | -e 's|mkdir|sudo &|' \
|
---|
| 297 | -e 's|\\$|&&|g' \
|
---|
[a659e46] | 298 | -e 's|\$|; \\\\|' \
|
---|
| 299 | -e 's|then|& :|' \
|
---|
[13c475b] | 300 | -e 's|\$\$LFS|$(MOUNT_PT)|g'`
|
---|
| 301 | teardown=`cat ../kernfs-scripts/teardown.sh | \
|
---|
| 302 | sed -e 's|^| |' \
|
---|
[47dfc81] | 303 | -e 's|umount|-sudo &|' \
|
---|
[13c475b] | 304 | -e 's|\$LFS|$(MOUNT_PT)|'`
|
---|
| 305 | teardownat=`cat ../kernfs-scripts/teardown.sh | \
|
---|
| 306 | sed -e 's|^| |' \
|
---|
| 307 | -e 's|umount|@-sudo &|' \
|
---|
| 308 | -e 's|\$LFS|$(MOUNT_PT)|'`
|
---|
[877cc6a] | 309 | # Drop in the main target 'all:' and the chapter targets with each sub-target
|
---|
| 310 | # as a dependency.
|
---|
| 311 | (
|
---|
| 312 | cat << EOF
|
---|
[045b2dc] | 313 |
|
---|
[9728b23] | 314 | 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] | 315 | $teardownat
|
---|
[045b2dc] | 316 | @sudo make do_housekeeping
|
---|
[e1fc855] | 317 | @echo $VERSION > lfs-release && \\
|
---|
[9096853] | 318 | sudo mv lfs-release \$(MOUNT_PT)/etc && \\
|
---|
| 319 | sudo chown root:root \$(MOUNT_PT)/etc/lfs-release
|
---|
[e1fc855] | 320 | @/bin/echo -e -n \\
|
---|
| 321 | DISTRIB_ID=\\"Linux From Scratch\\"\\\\n\\
|
---|
| 322 | DISTRIB_RELEASE=\\"$VERSION\\"\\\\n\\
|
---|
| 323 | DISTRIB_CODENAME=\\"$(whoami)-jhalfs\\"\\\\n\\
|
---|
| 324 | DISTRIB_DESCRIPTION=\\"Linux From Scratch\\"\\\\n\\
|
---|
| 325 | > lsb-release && \\
|
---|
| 326 | sudo mv lsb-release \$(MOUNT_PT)/etc && \\
|
---|
| 327 | sudo chown root:root \$(MOUNT_PT)/etc/lsb-release
|
---|
[56c1fff] | 328 | @/bin/echo -e -n \\
|
---|
| 329 | NAME=\\"Linux From Scratch\\"\\\\n\\
|
---|
| 330 | VERSION=\\"$VERSION\\"\\\\n\\
|
---|
| 331 | ID=lfs\\\\n\\
|
---|
| 332 | PRETTY_NAME=\\"Linux From Scratch $VERSION\\"\\\\n\\
|
---|
| 333 | VERSION_CODENAME=\\"$(whoami)-jhalfs\\"\\\\n\\
|
---|
| 334 | > os-release && \\
|
---|
| 335 | sudo mv os-release \$(MOUNT_PT)/etc && \\
|
---|
| 336 | sudo chown root:root \$(MOUNT_PT)/etc/os-release
|
---|
[877cc6a] | 337 | @\$(call echo_finished,$VERSION)
|
---|
| 338 |
|
---|
[045b2dc] | 339 | ck_UID:
|
---|
| 340 | @if [ \`id -u\` = "0" ]; then \\
|
---|
| 341 | echo "--------------------------------------------------"; \\
|
---|
| 342 | echo "You cannot run this makefile from the root account"; \\
|
---|
| 343 | echo "--------------------------------------------------"; \\
|
---|
| 344 | exit 1; \\
|
---|
| 345 | fi
|
---|
| 346 |
|
---|
[9728b23] | 347 | ck_terminal:
|
---|
[7e0a1b8] | 348 | @stty size | ( read L C; \\
|
---|
| 349 | if (( L < 24 )) || (( C < 80 )) ; then \\
|
---|
[9728b23] | 350 | echo "--------------------------------------------------"; \\
|
---|
[7e0a1b8] | 351 | echo "Terminal too small: \$\$C columns x \$\$L lines";\\
|
---|
[9728b23] | 352 | echo "Minimum: 80 columns x 24 lines";\\
|
---|
| 353 | echo "--------------------------------------------------"; \\
|
---|
| 354 | exit 1; \\
|
---|
[7e0a1b8] | 355 | fi )
|
---|
[9728b23] | 356 |
|
---|
[045b2dc] | 357 | mk_SETUP:
|
---|
| 358 | @\$(call echo_SU_request)
|
---|
[dd7e0f67] | 359 | @sudo make save-luser
|
---|
[dbcdfd7] | 360 | @sudo make BREAKPOINT=\$(BREAKPOINT) SETUP
|
---|
[045b2dc] | 361 | @touch \$@
|
---|
| 362 |
|
---|
| 363 | mk_LUSER: mk_SETUP
|
---|
| 364 | @\$(call echo_SULUSER_request)
|
---|
[903eefd] | 365 | @\$(SU_LUSER) "make -C \$(MOUNT_PT)/\$(SCRIPT_ROOT) BREAKPOINT=\$(BREAKPOINT) LUSER"
|
---|
| 366 | @sudo make restore-luser
|
---|
[045b2dc] | 367 | @touch \$@
|
---|
| 368 |
|
---|
| 369 | mk_SUDO: mk_LUSER
|
---|
[a73ed74] | 370 | @sudo rm -f envars
|
---|
[dbcdfd7] | 371 | @sudo make BREAKPOINT=\$(BREAKPOINT) SUDO
|
---|
[1330ebc] | 372 | @touch \$@
|
---|
| 373 |
|
---|
[045b2dc] | 374 | mk_CHROOT: mk_SUDO
|
---|
| 375 | @\$(call echo_CHROOT_request)
|
---|
[d68eb1b] | 376 | @( sudo \$(CHROOT1) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CHROOT")
|
---|
[045b2dc] | 377 | @touch \$@
|
---|
[877cc6a] | 378 |
|
---|
[045b2dc] | 379 | mk_BOOT: mk_CHROOT
|
---|
| 380 | @\$(call echo_CHROOT_request)
|
---|
[d68eb1b] | 381 | @( sudo \$(CHROOT2) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) BOOT")
|
---|
[045b2dc] | 382 | @touch \$@
|
---|
[877cc6a] | 383 |
|
---|
[ac9bdc7] | 384 | mk_BLFS_TOOL: create-sbu_du-report
|
---|
| 385 | @if [ "\$(ADD_BLFS_TOOLS)" = "y" ]; then \\
|
---|
| 386 | \$(call sh_echo_PHASE,Building BLFS_TOOL); \\
|
---|
[d68eb1b] | 387 | (sudo \$(CHROOT2) -c "make -C $BLFS_ROOT/work"); \\
|
---|
[ac9bdc7] | 388 | fi;
|
---|
| 389 | @touch \$@
|
---|
| 390 |
|
---|
| 391 | mk_CUSTOM_TOOLS: mk_BLFS_TOOL
|
---|
[3e7ceed] | 392 | @if [ "\$(ADD_CUSTOM_TOOLS)" = "y" ]; then \\
|
---|
[3bc6078] | 393 | \$(call sh_echo_PHASE,Building CUSTOM_TOOLS); \\
|
---|
[3e7ceed] | 394 | sudo mkdir -p ${BUILDDIR}${TRACKING_DIR}; \\
|
---|
[d68eb1b] | 395 | (sudo \$(CHROOT2) -c "cd \$(SCRIPT_ROOT) && make BREAKPOINT=\$(BREAKPOINT) CUSTOM_TOOLS"); \\
|
---|
[3e7ceed] | 396 | fi;
|
---|
| 397 | @touch \$@
|
---|
| 398 |
|
---|
[f60a8b7] | 399 | devices: ck_UID
|
---|
[13c475b] | 400 | $devices
|
---|
[d39252b] | 401 | EOF
|
---|
| 402 | ) >> $MKFILE
|
---|
| 403 | if [ "$INITSYS" = systemd ]; then
|
---|
| 404 | (
|
---|
| 405 | cat << EOF
|
---|
| 406 | sudo mkdir -pv \$(MOUNT_PT)/run/systemd/resolve
|
---|
[426c618] | 407 | sudo cp -v /etc/resolv.conf \$(MOUNT_PT)/run/systemd/resolve
|
---|
[d39252b] | 408 | EOF
|
---|
| 409 | ) >> $MKFILE
|
---|
| 410 | fi
|
---|
| 411 | (
|
---|
| 412 | cat << EOF
|
---|
[13c475b] | 413 |
|
---|
[2e1c1c3] | 414 | teardown:
|
---|
[13c475b] | 415 | $teardown
|
---|
[d39252b] | 416 |
|
---|
| 417 | chroot1: devices
|
---|
| 418 | sudo \$(CHROOT1)
|
---|
| 419 | \$(MAKE) teardown
|
---|
[7c17066] | 420 |
|
---|
| 421 | chroot: devices
|
---|
[d68eb1b] | 422 | sudo \$(CHROOT2)
|
---|
[7c17066] | 423 | \$(MAKE) teardown
|
---|
[877cc6a] | 424 |
|
---|
[ebe1ba6] | 425 | SETUP: $SETUP_TGT
|
---|
| 426 | LUSER: $LUSER_TGT
|
---|
| 427 | SUDO: $SUDO_TGT
|
---|
[13c475b] | 428 | EOF
|
---|
| 429 | ) >> $MKFILE
|
---|
| 430 | if [ "$INITSYS" = systemd ]; then
|
---|
| 431 | (
|
---|
| 432 | cat << EOF
|
---|
[c6506aea] | 433 | mkdir -pv \$(MOUNT_PT)/run/systemd/resolve
|
---|
| 434 | cp -v /etc/resolv.conf \$(MOUNT_PT)/run/systemd/resolve
|
---|
[13c475b] | 435 |
|
---|
| 436 | EOF
|
---|
| 437 | ) >> $MKFILE
|
---|
| 438 | fi
|
---|
| 439 | (
|
---|
| 440 | cat << EOF
|
---|
[a73ed74] | 441 | CHROOT: SHELL=\$(filter %bash,\$(CHROOT1))
|
---|
[ebe1ba6] | 442 | CHROOT: $CHROOT_TGT
|
---|
| 443 | BOOT: $BOOT_TGT
|
---|
[3e7ceed] | 444 | CUSTOM_TOOLS: $custom_list
|
---|
[fe24ca6] | 445 |
|
---|
[1838bc7] | 446 | create-sbu_du-report: mk_BOOT
|
---|
| 447 | @\$(call echo_message, Building)
|
---|
| 448 | @if [ "\$(ADD_REPORT)" = "y" ]; then \\
|
---|
[c57747d] | 449 | sudo ./create-sbu_du-report.sh logs $VERSION $(date --iso-8601); \\
|
---|
[1838bc7] | 450 | \$(call echo_report,$VERSION-SBU_DU-$(date --iso-8601).report); \\
|
---|
[903eefd] | 451 | fi
|
---|
[1838bc7] | 452 | @touch \$@
|
---|
[045b2dc] | 453 |
|
---|
[903eefd] | 454 | save-luser:
|
---|
[877cc6a] | 455 | @\$(call echo_message, Building)
|
---|
[49e2745] | 456 | @LUSER_ID=\$\$(grep '^\$(LUSER):' /etc/passwd | cut -d: -f3); \\
|
---|
[dd7e0f67] | 457 | if [ -n "\$\$LUSER_ID" ]; then \\
|
---|
[903eefd] | 458 | if [ ! -d \$(LUSER_HOME).XXX ]; then \\
|
---|
| 459 | mv \$(LUSER_HOME){,.XXX}; \\
|
---|
| 460 | mkdir \$(LUSER_HOME); \\
|
---|
| 461 | chown \$(LUSER):\$(LGROUP) \$(LUSER_HOME); \\
|
---|
| 462 | fi; \\
|
---|
[dd7e0f67] | 463 | echo "\$\$LUSER_ID" > luser-id; \\
|
---|
| 464 | echo User \$(LUSER) exists with ID \$\$LUSER_ID; \\
|
---|
[903eefd] | 465 | else \\
|
---|
[49e2745] | 466 | rm -f luser-id; \\
|
---|
[dd7e0f67] | 467 | echo User \$(LUSER) does not exist; \\
|
---|
| 468 | echo It will be created with book instructions.; \\
|
---|
[903eefd] | 469 | fi
|
---|
[dbcdfd7] | 470 | @\$(call housekeeping)
|
---|
[a858a78] | 471 |
|
---|
[903eefd] | 472 | restore-luser:
|
---|
| 473 | @\$(call echo_message, Building)
|
---|
| 474 | @if [ -f luser-id ]; then \\
|
---|
| 475 | rm -rf \$(LUSER_HOME); \\
|
---|
| 476 | mv \$(LUSER_HOME){.XXX,}; \\
|
---|
| 477 | rm luser-id; \\
|
---|
| 478 | else \\
|
---|
[6ad5a2f] | 479 | userdel \$(LUSER); \\
|
---|
[903eefd] | 480 | groupdel \$(LGROUP); \\
|
---|
[962793a] | 481 | rm -rf \$(LUSER_HOME); \\
|
---|
[903eefd] | 482 | fi
|
---|
| 483 | @\$(call housekeeping)
|
---|
| 484 |
|
---|
| 485 | do_housekeeping:
|
---|
[706e5bf] | 486 | @-rm -f /tools
|
---|
[a858a78] | 487 |
|
---|
[877cc6a] | 488 | EOF
|
---|
| 489 | ) >> $MKFILE
|
---|
| 490 |
|
---|
| 491 | # Bring over the items from the Makefile.tmp
|
---|
| 492 | cat $MKFILE.tmp >> $MKFILE
|
---|
| 493 | rm $MKFILE.tmp
|
---|
[c7c5a53] | 494 | echo "Creating Makefile... ${BOLD}DONE${OFF}"
|
---|
| 495 | }
|
---|