From 5777497f52c3c87da870e9282bf21e30ffcf5133 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Sun, 8 Jun 2025 21:25:43 +0200 Subject: [PATCH] Separate package manager detection and cache update functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- advanced/Scripts/update.sh | 1 - automated install/basic-install.sh | 9 +++++---- test/test_any_automated_install.py | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/advanced/Scripts/update.sh b/advanced/Scripts/update.sh index d9412f8a..51c1b1a1 100755 --- a/advanced/Scripts/update.sh +++ b/advanced/Scripts/update.sh @@ -114,7 +114,6 @@ main() { # Install packages used by this installation script (necessary if users have removed e.g. git from their systems) - check_fresh_install package_manager_detect build_dependency_package install_dependent_packages diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index cbad9eac..99b11d5c 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -254,10 +254,6 @@ package_manager_detect() { PKG_COUNT="${PKG_MANAGER} -s -o Debug::NoLocking=true upgrade | grep -c ^Inst || true" # The command we will use to remove packages (used in the uninstaller) PKG_REMOVE="${PKG_MANAGER} -y remove --purge" - # Update package cache only on fresh installs - if [[ "${fresh_install}" == true ]]; then - update_package_cache || exit 1 - fi # If apt-get is not found, check for rpm. elif is_command rpm; then @@ -2208,6 +2204,11 @@ main() { # Check for supported package managers so that we may install dependencies package_manager_detect + # Update package cache only on fresh installs and apt based systems + if [[ "${fresh_install}" == true ]] && is_command apt-get; then + update_package_cache || exit 1 + fi + # Notify user of package availability notify_package_updates_available diff --git a/test/test_any_automated_install.py b/test/test_any_automated_install.py index eb1f72e4..cf4b454d 100644 --- a/test/test_any_automated_install.py +++ b/test/test_any_automated_install.py @@ -471,6 +471,7 @@ def test_package_manager_has_pihole_deps(host): """ source /opt/pihole/basic-install.sh package_manager_detect + update_package_cache build_dependency_package install_dependent_packages """ @@ -487,6 +488,7 @@ def test_meta_package_uninstall(host): """ source /opt/pihole/basic-install.sh package_manager_detect + update_package_cache build_dependency_package install_dependent_packages """