From eaebe94940758b40839209822c8158aff95a2855 Mon Sep 17 00:00:00 2001 From: JaKooLit Date: Wed, 5 Feb 2025 23:27:32 +0900 Subject: [PATCH] new package removal function --- install-scripts/01-hypr-pkgs.sh | 12 ++++++++++-- install-scripts/Global_functions.sh | 18 +++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/install-scripts/01-hypr-pkgs.sh b/install-scripts/01-hypr-pkgs.sh index 06431f6..0ebe8bc 100755 --- a/install-scripts/01-hypr-pkgs.sh +++ b/install-scripts/01-hypr-pkgs.sh @@ -87,11 +87,19 @@ source "$(dirname "$(readlink -f "$0")")/Global_functions.sh" LOG="Install-Logs/install-$(date +%d-%H%M%S)_hypr-pkgs.log" # 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 - uninstall_package "$PKG" "$LOG" + uninstall_package "$PKG" 2>&1 | tee -a "$LOG" + if [ $? -ne 0 ]; then + overall_failed=1 + fi 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} diff --git a/install-scripts/Global_functions.sh b/install-scripts/Global_functions.sh index 0d4f5bf..a649889 100755 --- a/install-scripts/Global_functions.sh +++ b/install-scripts/Global_functions.sh @@ -94,15 +94,23 @@ re_install_package() { fi } - -# Function for uninstalling packages +# Function for removing packages uninstall_package() { + local pkg="$1" + + # Checking if package is installed 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 echo -e "\e[1A\e[K${OK} ${MAGENTA}$1${RESET} was uninstalled." 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 + else + echo -e "${INFO} Package $pkg not installed, skipping." fi -} + return 0 +} \ No newline at end of file