@cryptotaxi247 / netdata-1 / commits / c318d5631

Handle problematic repo configuration states in kickstart. (#21226)

Austin S. Hemmelgarn committed Oct 30, 2025 at 08:57 UTC c318d5631b3963be4622083e202abe45330eeae1
1 file changed +68 -42
packaging/installer/kickstart.sh
+68 -42
@@ -1551,12 +1551,40 @@ check_special_native_deps() {
1551 fi
1552 }
1553
1554 -cleanup_apt_cache() {
1555 - cache_dir="/var/cache/apt/archives"
1554 +cleanup_apt_state() {
1555 + cache_dir="/var/cache/apt/archives"
1556
1557 - if [ -d "${cache_dir}" ]; then
1558 - run_as_root find "${cache_dir}" -type f -name 'netdata*.deb' -delete
1557 + if [ -d "${cache_dir}" ]; then
1558 + run_as_root find "${cache_dir}" -type f -name 'netdata*.deb' -delete
1559 + fi
1560 +
1561 + for p in netdata-repo netdata-repo-edge; do
1562 + if pkg_installed "${p}" ; then
1563 + warning "Detected already installed repository configuration ${p}, attempting to remove it."
1564 + # shellcheck disable=SC2086
1565 + run_as_root env ${env} ${pm_cmd} ${uninstall_subcmd} ${pkg_install_opts} "${p}"
1566 + fi
1567 + done
1568 +}
1569 +
1570 +cleanup_dnf_state() {
1571 + for p in "" "-edge"; do
1572 + if pkg_installed "netdata-repo${p}"; then
1573 + warning "Detected already installed repository configuration netdata-repo${p}, attempting to remove it."
1574 + run_as_root "${pm_cmd}" clean all --disablerepo "*" --enablerepo "netdata${p}"
1575 + run_as_root "${pm_cmd}" "${uninstall_subcmd}" -y "netdata-repo${p}"
1576 + fi
1577 + done
1578 +}
1579 +
1580 +cleanup_zypper_state() {
1581 + for p in netdata-repo netdata-repo-edge; do
1582 + if pkg_installed "${p}" ; then
1583 + warning "Detected already installed repository configuration ${p}, attempting to remove it."
1584 + # shellcheck disable=SC2086
1585 + run_as_root env ${env} ${pm_cmd} ${uninstall_subcmd} ${pkg_install_opts} "${p}"
1586 fi
1587 + done
1588 }
1589
1590 common_rpm_opts() {
@@ -1573,10 +1601,10 @@ common_dnf_opts() {
1601 fi
1602 if command -v dnf > /dev/null; then
1603 pm_cmd="dnf"
1576 - repo_subcmd="makecache"
1604 else
1605 pm_cmd="yum"
1606 fi
1607 + repo_subcmd="makecache"
1608 install_subcmd="install"
1609 pkg_install_opts="${interactive_opts}"
1610 repo_update_opts="${interactive_opts}"
@@ -1615,6 +1643,10 @@ try_package_install() {
1643 interactive_opts=""
1644 env=""
1645
1646 + if [ -n "${SKIP_DISTRO_DETECTION}" ]; then
1647 + warning "Attempting to use native packages with a distro override. This is not officially supported, but may work in some cases. If your system requires a distro override to use native packages, please open a feature request at ${AGENT_BUG_REPORT_URL} about it so that we can update the installer to auto-detect this."
1648 + fi
1649 +
1650 case "${DISTRO_COMPAT_NAME}" in
1651 debian|ubuntu)
1652 if [ "${INTERACTIVE}" = "0" ]; then
@@ -1625,7 +1657,6 @@ try_package_install() {
1657 install_subcmd="install"
1658 fi
1659 needs_early_refresh=1
1628 - needs_apt_cache_cleanup=1
1660 pm_cmd="apt-get"
1661 repo_subcmd="update"
1662 pkg_type="deb"
@@ -1676,10 +1707,6 @@ try_package_install() {
1707 ;;
1708 esac
1709
1679 - if [ -n "${SKIP_DISTRO_DETECTION}" ]; then
1680 - warning "Attempting to use native packages with a distro override. This is not officially supported, but may work in some cases. If your system requires a distro override to use native packages, please open an feature request at ${AGENT_BUG_REPORT_URL} about it so that we can update the installer to auto-detect this."
1681 - fi
1682 -
1710 if [ -n "${INSTALL_VERSION}" ]; then
1711 if echo "${INSTALL_VERSION}" | grep -q "nightly"; then
1712 new_release="-edge"
@@ -1709,47 +1736,46 @@ try_package_install() {
1736 ;;
1737 esac
1738
1712 - if ! pkg_installed "${repoconfig_name}"; then
1713 - progress "Checking for availability of repository configuration package."
1714 - if ! check_for_remote_file "${ref_check_url}"; then
1715 - NETDATA_ASSUME_REMOTE_FILES_ARE_PRESENT=1
1716 - fi
1717 -
1718 - if ! check_for_remote_file "${repoconfig_url}"; then
1719 - warning "No repository configuration package available for ${DISTRO} ${SYSVERSION}. Cannot install native packages on this system."
1720 - return 2
1721 - fi
1739 + progress "Checking for availability of repository configuration package."
1740 + if ! check_for_remote_file "${ref_check_url}"; then
1741 + NETDATA_ASSUME_REMOTE_FILES_ARE_PRESENT=1
1742 + fi
1743
1723 - if ! download "${repoconfig_url}" "${tmpdir}/${repoconfig_file}"; then
1724 - fatal "Failed to download repository configuration package. ${BADNET_MSG}." F0209
1725 - fi
1744 + if ! check_for_remote_file "${repoconfig_url}"; then
1745 + warning "No repository configuration package available for ${DISTRO} ${SYSVERSION}. Cannot install native packages on this system."
1746 + return 2
1747 + fi
1748
1727 - if [ -n "${needs_early_refresh}" ]; then
1728 - # shellcheck disable=SC2086
1729 - if ! run_as_root env ${env} ${pm_cmd} ${repo_subcmd} ${repo_update_opts}; then
1730 - warning "${failed_refresh_msg}"
1731 - return 2
1732 - fi
1749 + if ! download "${repoconfig_url}" "${tmpdir}/${repoconfig_file}"; then
1750 + fatal "Failed to download repository configuration package. ${BADNET_MSG}." F0209
1751 + fi
1752
1734 - if [ -n "${needs_apt_cache_cleanup}" ]; then
1735 - cleanup_apt_cache
1736 - fi
1737 - fi
1753 + case "${pm_cmd}" in
1754 + apt-get) cleanup_apt_state ;;
1755 + yum|dnf) cleanup_dnf_state ;;
1756 + zypper) cleanup_zypper_state ;;
1757 + *) warning "I don’t know how to clean up package manager state for ${pm_cmd}. Please report this as a bug at ${AGENT_BUG_REPORT_URL}."
1758 + esac
1759
1760 + if [ -n "${needs_early_refresh}" ]; then
1761 # shellcheck disable=SC2086
1740 - if ! run_as_root env ${env} ${pm_cmd} ${install_subcmd} ${pkg_install_opts} "${tmpdir}/${repoconfig_file}"; then
1741 - warning "Failed to install repository configuration package."
1762 + if ! run_as_root env ${env} ${pm_cmd} ${repo_subcmd} ${repo_update_opts}; then
1763 + warning "${failed_refresh_msg}"
1764 return 2
1765 fi
1766 + fi
1767
1745 - if [ -n "${repo_subcmd}" ]; then
1746 - # shellcheck disable=SC2086
1747 - if ! run_as_root env ${env} ${pm_cmd} ${repo_subcmd} ${repo_update_opts}; then
1748 - fatal "${failed_refresh_msg} In most cases, disabling any third-party repositories on the system and re-running the installer with the same options should work. If that does not work, consider using a static build with the --static-only option instead of native packages." F0205
1749 - fi
1768 + # shellcheck disable=SC2086
1769 + if ! run_as_root env ${env} ${pm_cmd} ${install_subcmd} ${pkg_install_opts} "${tmpdir}/${repoconfig_file}"; then
1770 + warning "Failed to install repository configuration package."
1771 + return 2
1772 + fi
1773 +
1774 + if [ -n "${repo_subcmd}" ]; then
1775 + # shellcheck disable=SC2086
1776 + if ! run_as_root env ${env} ${pm_cmd} ${repo_subcmd} ${repo_update_opts}; then
1777 + fatal "${failed_refresh_msg} In most cases, disabling any third-party repositories on the system and re-running the installer with the same options should work. If that does not work, consider using a static build with the --static-only option instead of native packages." F0205
1778 fi
1751 - else
1752 - progress "Repository configuration is already present, attempting to install netdata."
1779 fi
1780
1781 if [ "${ACTION}" = "repositories-only" ]; then