From dcaadac152528e85e3a645cbe1788cc060f6325b Mon Sep 17 00:00:00 2001 From: Ricardo Pardini Date: Sat, 21 Jan 2023 02:42:18 +0100 Subject: [PATCH] armbian-next: git: disallow forcing impossible shallow/full; warn if it's the case - you gotta wipe the worktree before you change it from full to shallow or vice-versa --- lib/functions/compilation/kernel-git-oras.sh | 37 +++++++++++--------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/lib/functions/compilation/kernel-git-oras.sh b/lib/functions/compilation/kernel-git-oras.sh index 0b651a00e7..b4f67f3fe8 100644 --- a/lib/functions/compilation/kernel-git-oras.sh +++ b/lib/functions/compilation/kernel-git-oras.sh @@ -45,22 +45,6 @@ function kernel_prepare_bare_repo_decide_shallow_or_full() { free_space_mib="$(df -BM --output=avail "${cache_git_bare_dir}" | tail -n 1 | sed 's/M//')" display_alert "Free space on ${cache_git_bare_dir}" "${free_space_mib} MiB" "git" - # simplest, via parameter/env var, something like KERNEL_GIT=shallow or KERNEL_GIT=full to force. - declare forced_decision="${KERNEL_GIT:-"none"}" - case "${forced_decision,,}" in # lowercase - shallow) - display_alert "Forced shallow via" "KERNEL_GIT=shallow" "git" - decision="shallow" - decision_why="forced by KERNEL_GIT=shallow" - ;; - - full) - display_alert "Forced full via" "KERNEL_GIT=full" "git" - decision="full" - decision_why="forced by KERNEL_GIT=full" - ;; - esac - if [[ "${decision}" == "not_yet_decided" ]]; then # First: if ${kernel_work_dir}/.git already exists, use whatever that used before, by reading its .git file. if [[ -f "${kernel_work_dir}/.git" ]]; then @@ -90,6 +74,27 @@ function kernel_prepare_bare_repo_decide_shallow_or_full() { fi fi + # simplest, via parameter/env var, something like KERNEL_GIT=shallow or KERNEL_GIT=full to force. + declare forced_decision="${KERNEL_GIT:-"none"}" + if [[ "${decision}" == "not_yet_decided" ]]; then + case "${forced_decision,,}" in # lowercase + shallow) + display_alert "Forced shallow via" "KERNEL_GIT=shallow" "git" + decision="shallow" + decision_why="forced by KERNEL_GIT=shallow" + ;; + + full) + display_alert "Forced full via" "KERNEL_GIT=full" "git" + decision="full" + decision_why="forced by KERNEL_GIT=full" + ;; + esac + elif [[ "${forced_decision}" != "none" && "${forced_decision}" != "${decision}" ]]; then + display_alert "Can't change Kernel git from '${decision}' to '${forced_decision}'" "${decision_why}" "warn" + countdown_and_continue_if_not_aborted 3 + fi + # @TODO: using shallow for vendor kernels (eg rockchip-rk3588) is a bad idea. It's a mess and will cause fetches to unshallow. # So skip Third if family indicates so, via KERNEL_VENDOR_DO_NOT_SHALLOW=yes in config.