new package removal function

This commit is contained in:
JaKooLit 2025-02-05 23:27:32 +09:00
parent 0bdd2fb29e
commit eaebe94940
2 changed files with 23 additions and 7 deletions

View File

@ -87,11 +87,19 @@ source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"
LOG="Install-Logs/install-$(date +%d-%H%M%S)_hypr-pkgs.log" LOG="Install-Logs/install-$(date +%d-%H%M%S)_hypr-pkgs.log"
# Remove conflicting packages # Remove conflicting packages
printf "\n%s - ${SKY_BLUE}removing some packages${RESET} inorder for dots to work properly \n" "${NOTE}" overall_failed=0
printf "\n%s - Removing some packages as it causes conflicts with KooL's Hyprland Dots \n" "${NOTE}"
for PKG in "${uninstall[@]}"; do for PKG in "${uninstall[@]}"; do
uninstall_package "$PKG" "$LOG" uninstall_package "$PKG" 2>&1 | tee -a "$LOG"
if [ $? -ne 0 ]; then
overall_failed=1
fi
done done
if [ $overall_failed -ne 0 ]; then
echo -e "${ERROR} Some packages failed to uninstall. Please check the log."
fi
printf "\n%.0s" {1..1} printf "\n%.0s" {1..1}

View File

@ -94,15 +94,23 @@ re_install_package() {
fi fi
} }
# Function for removing packages
# Function for uninstalling packages
uninstall_package() { uninstall_package() {
local pkg="$1"
# Checking if package is installed
if sudo dpkg -l | grep -q -w "^ii $1" ; then if sudo dpkg -l | grep -q -w "^ii $1" ; then
sudo apt autoremove -y "$1" >> "$LOG" 2>&1 echo -e "${NOTE} Uninstalling $pkg ..."
sudo apt autoremove -y "$1" >> "$LOG" 2>&1 | grep -v "error: target not found"
if ! dpkg -l | grep -q -w "^ii $1" ; then if ! dpkg -l | grep -q -w "^ii $1" ; then
echo -e "\e[1A\e[K${OK} ${MAGENTA}$1${RESET} was uninstalled." echo -e "\e[1A\e[K${OK} ${MAGENTA}$1${RESET} was uninstalled."
else else
echo -e "\e[1A\e[K${ERROR} $1 failed to uninstall. Please check the uninstall.log." echo -e "\e[1A\e[K${ERROR} $pkg failed to uninstall. Please check the log."
return 1
fi fi
else
echo -e "${INFO} Package $pkg not installed, skipping."
fi fi
} return 0
}