Merge branch 'end-4:main' into main

This commit is contained in:
Perdixky
2025-12-04 16:47:56 +08:00
committed by GitHub
29 changed files with 622 additions and 156 deletions
+5
View File
@@ -43,6 +43,11 @@ if ! command -v pacman >/dev/null 2>&1; then
exit 1
fi
# Keep makepkg from resetting sudo credentials
if [[ -z "${PACMAN_AUTH:-}" ]]; then
export PACMAN_AUTH="sudo"
fi
showfun remove_deprecated_dependencies
v remove_deprecated_dependencies
+44
View File
@@ -80,6 +80,50 @@ function prevent_sudo_or_root(){
root) echo -e "${STY_RED}[$0]: This script is NOT to be executed with sudo or as root. Aborting...${STY_RST}";exit 1;;
esac
}
# Initialize sudo session and keep it alive in background
# Store PID in a global variable that can be accessed by trap
declare -g SUDO_KEEPALIVE_PID=""
function sudo_init_keepalive(){
# Check if sudo is available
if ! command -v sudo >/dev/null 2>&1; then
return 0
fi
# Skip if already initialized
if [[ -n "$SUDO_KEEPALIVE_PID" ]] && kill -0 "$SUDO_KEEPALIVE_PID" 2>/dev/null; then
return 0
fi
# Prompt for sudo password once at the beginning
echo -e "${STY_CYAN}[$0]: Requesting sudo privileges for installation...${STY_RST}"
if ! sudo -v; then
echo -e "${STY_RED}[$0]: Failed to obtain sudo privileges. Aborting...${STY_RST}"
exit 1
fi
# Start background process to keep sudo session alive
# This updates the sudo timestamp every 60 seconds
(
while true; do
sleep 60
sudo -v 2>/dev/null || exit 0
done
) &
SUDO_KEEPALIVE_PID=$!
echo -e "${STY_GREEN}[$0]: Sudo session initialized and will be kept alive (PID: $SUDO_KEEPALIVE_PID)${STY_RST}"
}
# Stop the sudo keepalive background process
function sudo_stop_keepalive(){
if [[ -n "$SUDO_KEEPALIVE_PID" ]] && kill -0 "$SUDO_KEEPALIVE_PID" 2>/dev/null; then
kill "$SUDO_KEEPALIVE_PID" 2>/dev/null
wait "$SUDO_KEEPALIVE_PID" 2>/dev/null
SUDO_KEEPALIVE_PID=""
fi
}
function git_auto_unshallow(){
# We need this function for latest_commit_hash to work properly
if [[ -f "$(git rev-parse --git-dir)/shallow" ]]; then