From 7639862e514a427534d9ef2cc366af76d2ae75d5 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Sun, 10 Mar 2024 21:26:37 +0100 Subject: [PATCH] Add clone dir conflict resolution --- buildtool.sh | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/buildtool.sh b/buildtool.sh index bf9168d..3883fda 100755 --- a/buildtool.sh +++ b/buildtool.sh @@ -13,12 +13,13 @@ echo "" # Variables export "BUILDTOOL_REPOSITORY=https://git.staropensource.de/JeremyStarTM/kernel-optimized.git" export "BUILDTOOL_PACKAGES=base-devel git rustup" -export "BUILDTOOL_CLONEDIR=jstm-kernel-optimized" export "BUILDTOOL_BUILDCMDLINE=nice -20 env MAKEFLAGS=-j$(nproc)" +export "BUILDTOOL_CLONEDIR=jstm-kernel-optimized" # Checks ## Check for Arch Linux ( + # shellcheck disable=SC1091 source "/etc/os-release" if [ "${NAME}" != "Arch Linux" ] || [ "${PRETTY_NAME}" != "Arch Linux" ] || [ "${ID}" != "arch" ]; then if [ "${BUILDTOOL_COMPILE_NONARCH}" != "true" ]; then @@ -241,6 +242,29 @@ function ask_debug() { ask_debug esac } +## Ask for clone directory conflict resolution (includes check) +function ask_clonedir_conflictresolution() { + if [ ! -d "${BUILDTOOL_CLONEDIR}" ]; then + return + elif [ -a "${BUILDTOOL_CLONEDIR}" ] && [ ! -d "${BUILDTOOL_CLONEDIR}" ]; then + echo ":: Warning: Something that isn't a directory exists at location \"${BUILDTOOL_CLONEDIR}\"" + fi + read -rp ":: Warning: \"${BUILDTOOL_CLONEDIR}\" already exists. What should be done to resolve the conflict [A(bort)/r(ecompile)/f(resh)]? " BUILDTOOL_CLONEDIR_CONFLICT + case "${BUILDTOOL_CLONEDIR_CONFLICT}" in + "a"|"A"|"") + echo ":: Error: Conflict resolution failed." + exit 1 + ;; + "r"|"R") ;; + "f"|"F") + echo ":: Removing existing \$BUILDTOOL_CLONEDIR directory" + #rm -rf "${BUILDTOOL_CLONEDIR}" + ;; + *) + echo "Invalid answer. Please answer with Y, N or I." + ask_debug + esac +} ask_mold ask_cpupower ask_tmpfs @@ -250,6 +274,7 @@ ask_cpfinalconfig ask_modprobeddb ask_subarchitecture ask_debug +ask_clonedir_conflictresolution # Pre-building ## Install dependencies