Remove Netdata packages from APT cache when attempting to install. (#16566)
* Remove Netdata packages from APT cache when attempting to install. This should help resolve some issues we have with installing when dealing with unclean caches after dist-upgrades. * Run cached package removal as root. * Update packaging/installer/kickstart.sh Co-authored-by: Ilya Mashchenko <ilya@netdata.cloud> --------- Co-authored-by: Ilya Mashchenko <ilya@netdata.cloud>
Austin S. Hemmelgarn committed
Dec 21, 2023 at 07:11 UTC
95d8a5ffd9dee9a6288550913c8f04b3d591a683
1 file changed
+13
packaging/installer/kickstart.sh
+13
@@ -1357,6 +1357,14 @@ check_special_native_deps() {
1357
fi
1358
}
1359
1360
+cleanup_apt_cache() {
1361
+ cache_dir="/var/cache/apt/archives"
1362
+
1363
+ if [ -d "${cache_dir}" ]; then
1364
+ run_as_root find "${cache_dir}" -type f -name 'netdata*.deb' -delete
1365
+ fi
1366
+}
1367
+
1368
common_rpm_opts() {
1369
pkg_type="rpm"
1370
pkg_suffix=".noarch"
@@ -1423,6 +1431,7 @@ try_package_install() {
1431
install_subcmd="install"
1432
fi
1433
needs_early_refresh=1
1434
+ needs_apt_cache_cleanup=1
1435
pm_cmd="apt-get"
1436
repo_subcmd="update"
1437
pkg_type="deb"
@@ -1521,6 +1530,10 @@ try_package_install() {
1530
warning "${failed_refresh_msg}"
1531
return 2
1532
fi
1533
+
1534
+ if [ -n "${needs_apt_cache_cleanup}" ]; then
1535
+ cleanup_apt_cache
1536
+ fi
1537
fi
1538
1539
# shellcheck disable=SC2086