Add diagnostic logging methods
This commit is contained in:
parent
ce6e652408
commit
ee92ac8f50
1 changed files with 23 additions and 9 deletions
32
buildtool.sh
32
buildtool.sh
|
@ -15,6 +15,7 @@ export "BUILDTOOL_PACKAGES=base-devel git rustup"
|
|||
export "BUILDTOOL_BUILDCMDLINE=nice -20 env MAKEFLAGS=-j$(nproc)"
|
||||
## OOOOoooo colors! (not true color tho)
|
||||
export "BUILDTOOL_COLOR_SPECIAL=\e[0;35m"
|
||||
export "BUILDTOOL_COLOR_DIAG=\e[0;36m"
|
||||
export "BUILDTOOL_COLOR_WARN=\e[0;33m"
|
||||
export "BUILDTOOL_COLOR_ERROR=\e[0;31m"
|
||||
export "BUILDTOOL_COLOR_RESET=\e[0m"
|
||||
|
@ -28,6 +29,16 @@ function empty() {
|
|||
function special() {
|
||||
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)
|
||||
function infoh() {
|
||||
echo -e "${BUILDTOOL_COLOR_RESET}[INFO] ${*}"
|
||||
|
@ -62,10 +73,9 @@ special " _/ |___/\\__|_| |_| |_| |_|\\_\\___|_| |_| |_|\\___|_| \\___
|
|||
special "|__/ |_|"
|
||||
empty
|
||||
|
||||
# Print debug info warning
|
||||
if [ -n "${BUILDTOOL_DEBUG}" ]; then
|
||||
warnh "Debug mode is enabled"
|
||||
fi
|
||||
# Print environment configuration
|
||||
debugh "\$BUILDTOOL_DEBUG is set, debug mode is enabled"
|
||||
debugh "\$BUILDTOOL_LOCALDIR is set, will build kernel package from current working directory"
|
||||
|
||||
# Checks
|
||||
## Check for Arch Linux
|
||||
|
@ -304,8 +314,10 @@ function ask_clonedir_conflictresolution() {
|
|||
warnh "Skipped conflict resolution (\$BUILDTOOL_LOCALDIR is set)"
|
||||
export "BUILDTOOL_CLONEDIR_CONFLICT=r"
|
||||
if [ -a "${BUILDTOOL_CLONEDIR}/src" ]; then
|
||||
debugh "src/ directory present, appending \"--noextract\""
|
||||
export "BUILDTOOL_MAKEPKG_REUSE= --noextract"
|
||||
elif [ -a "${BUILDTOOL_CLONEDIR}/pkg" ]; then
|
||||
debugh "pkg/ directory present, appending \"--force\""
|
||||
export "BUILDTOOL_MAKEPKG_REUSE=${BUILDTOOL_MAKEPKG_REUSE} --force"
|
||||
fi
|
||||
return
|
||||
|
@ -323,8 +335,10 @@ function ask_clonedir_conflictresolution() {
|
|||
;;
|
||||
"r"|"R")
|
||||
if [ -a "${BUILDTOOL_CLONEDIR}/src" ]; then
|
||||
debugh "src/ directory present, appending \"--noextract\""
|
||||
export "BUILDTOOL_MAKEPKG_REUSE= --noextract"
|
||||
elif [ -a "${BUILDTOOL_CLONEDIR}/pkg" ]; then
|
||||
debugh "pkg/ directory present, appending \"--force\""
|
||||
export "BUILDTOOL_MAKEPKG_REUSE=${BUILDTOOL_MAKEPKG_REUSE} --force"
|
||||
fi
|
||||
;;
|
||||
|
@ -387,12 +401,12 @@ cd "${BUILDTOOL_CLONEDIR}"
|
|||
|
||||
# Print debug information
|
||||
if [ -n "${BUILDTOOL_DEBUG}" ]; then
|
||||
infoh "Printing debug information"
|
||||
echo "+++ env +++"
|
||||
debugh "Printing debug information"
|
||||
debuge "Environment variables:"
|
||||
env|grep "BUILDTOOL_"|sort
|
||||
echo "+++ env +++"
|
||||
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"
|
||||
echo "cwd: $(pwd)"
|
||||
debugh "More debug information:"
|
||||
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"
|
||||
debuge "Cwd=$(pwd)"
|
||||
fi
|
||||
|
||||
# Build package
|
||||
|
|
Reference in a new issue