Add diagnostic logging methods

This commit is contained in:
JeremyStar™ 2024-03-11 01:51:29 +01:00
parent ce6e652408
commit ee92ac8f50

View file

@ -15,6 +15,7 @@ export "BUILDTOOL_PACKAGES=base-devel git rustup"
export "BUILDTOOL_BUILDCMDLINE=nice -20 env MAKEFLAGS=-j$(nproc)" export "BUILDTOOL_BUILDCMDLINE=nice -20 env MAKEFLAGS=-j$(nproc)"
## OOOOoooo colors! (not true color tho) ## OOOOoooo colors! (not true color tho)
export "BUILDTOOL_COLOR_SPECIAL=\e[0;35m" export "BUILDTOOL_COLOR_SPECIAL=\e[0;35m"
export "BUILDTOOL_COLOR_DIAG=\e[0;36m"
export "BUILDTOOL_COLOR_WARN=\e[0;33m" export "BUILDTOOL_COLOR_WARN=\e[0;33m"
export "BUILDTOOL_COLOR_ERROR=\e[0;31m" export "BUILDTOOL_COLOR_ERROR=\e[0;31m"
export "BUILDTOOL_COLOR_RESET=\e[0m" export "BUILDTOOL_COLOR_RESET=\e[0m"
@ -28,6 +29,16 @@ function empty() {
function special() { function special() {
echo -e "${BUILDTOOL_COLOR_SPECIAL}${*}${BUILDTOOL_COLOR_RESET}" echo -e "${BUILDTOOL_COLOR_SPECIAL}${*}${BUILDTOOL_COLOR_RESET}"
} }
## Diagnostic (header)
function diagh() {
if [ -z "${BUILDTOOL_DEBUG}" ]; then return; fi
echo -e "${BUILDTOOL_COLOR_DIAG}[DIAG] ${*}${BUILDTOOL_COLOR_RESET}"
}
## Diagnostic (extension)
function diage() {
if [ -z "${BUILDTOOL_DEBUG}" ]; then return; fi
echo -e "${BUILDTOOL_COLOR_DIAG} ${*}${BUILDTOOL_COLOR_RESET}"
}
## Informational (header) ## Informational (header)
function infoh() { function infoh() {
echo -e "${BUILDTOOL_COLOR_RESET}[INFO] ${*}" echo -e "${BUILDTOOL_COLOR_RESET}[INFO] ${*}"
@ -62,10 +73,9 @@ special " _/ |___/\\__|_| |_| |_| |_|\\_\\___|_| |_| |_|\\___|_| \\___
special "|__/ |_|" special "|__/ |_|"
empty empty
# Print debug info warning # Print environment configuration
if [ -n "${BUILDTOOL_DEBUG}" ]; then debugh "\$BUILDTOOL_DEBUG is set, debug mode is enabled"
warnh "Debug mode is enabled" debugh "\$BUILDTOOL_LOCALDIR is set, will build kernel package from current working directory"
fi
# Checks # Checks
## Check for Arch Linux ## Check for Arch Linux
@ -304,8 +314,10 @@ function ask_clonedir_conflictresolution() {
warnh "Skipped conflict resolution (\$BUILDTOOL_LOCALDIR is set)" warnh "Skipped conflict resolution (\$BUILDTOOL_LOCALDIR is set)"
export "BUILDTOOL_CLONEDIR_CONFLICT=r" export "BUILDTOOL_CLONEDIR_CONFLICT=r"
if [ -a "${BUILDTOOL_CLONEDIR}/src" ]; then if [ -a "${BUILDTOOL_CLONEDIR}/src" ]; then
debugh "src/ directory present, appending \"--noextract\""
export "BUILDTOOL_MAKEPKG_REUSE= --noextract" export "BUILDTOOL_MAKEPKG_REUSE= --noextract"
elif [ -a "${BUILDTOOL_CLONEDIR}/pkg" ]; then elif [ -a "${BUILDTOOL_CLONEDIR}/pkg" ]; then
debugh "pkg/ directory present, appending \"--force\""
export "BUILDTOOL_MAKEPKG_REUSE=${BUILDTOOL_MAKEPKG_REUSE} --force" export "BUILDTOOL_MAKEPKG_REUSE=${BUILDTOOL_MAKEPKG_REUSE} --force"
fi fi
return return
@ -323,8 +335,10 @@ function ask_clonedir_conflictresolution() {
;; ;;
"r"|"R") "r"|"R")
if [ -a "${BUILDTOOL_CLONEDIR}/src" ]; then if [ -a "${BUILDTOOL_CLONEDIR}/src" ]; then
debugh "src/ directory present, appending \"--noextract\""
export "BUILDTOOL_MAKEPKG_REUSE= --noextract" export "BUILDTOOL_MAKEPKG_REUSE= --noextract"
elif [ -a "${BUILDTOOL_CLONEDIR}/pkg" ]; then elif [ -a "${BUILDTOOL_CLONEDIR}/pkg" ]; then
debugh "pkg/ directory present, appending \"--force\""
export "BUILDTOOL_MAKEPKG_REUSE=${BUILDTOOL_MAKEPKG_REUSE} --force" export "BUILDTOOL_MAKEPKG_REUSE=${BUILDTOOL_MAKEPKG_REUSE} --force"
fi fi
;; ;;
@ -387,12 +401,12 @@ cd "${BUILDTOOL_CLONEDIR}"
# Print debug information # Print debug information
if [ -n "${BUILDTOOL_DEBUG}" ]; then if [ -n "${BUILDTOOL_DEBUG}" ]; then
infoh "Printing debug information" debugh "Printing debug information"
echo "+++ env +++" debuge "Environment variables:"
env|grep "BUILDTOOL_"|sort env|grep "BUILDTOOL_"|sort
echo "+++ env +++" debugh "More debug information:"
echo "build cmdline: ${BUILDTOOL_BUILDCMDLINE} ${BUILDTOOL_PKGBUILD_XCONFIG} ${BUILDTOOL_PKGBUILD_NCONFIG} ${BUILDTOOL_PKGBUILD_CPFINALCONFIG} ${BUILDTOOL_PKGBUILD_MODPROBEDDB} ${BUILDTOOL_PKGBUILD_SUBARCHITECTURE} ${BUILDTOOL_PKGBUILD_DEBUG} makepkg --syncdeps -p PKGBUILD.buildtool" debuge "Build cmdline=${BUILDTOOL_BUILDCMDLINE} ${BUILDTOOL_PKGBUILD_XCONFIG} ${BUILDTOOL_PKGBUILD_NCONFIG} ${BUILDTOOL_PKGBUILD_CPFINALCONFIG} ${BUILDTOOL_PKGBUILD_MODPROBEDDB} ${BUILDTOOL_PKGBUILD_SUBARCHITECTURE} ${BUILDTOOL_PKGBUILD_DEBUG} makepkg --syncdeps -p PKGBUILD.buildtool"
echo "cwd: $(pwd)" debuge "Cwd=$(pwd)"
fi fi
# Build package # Build package