@cryptotaxi247 / netdata-1 / commits / cb0942600

Fix non-interactive options for apt-get and zypper. (#15288)

Bastien committed Jul 20, 2023 at 23:05 UTC cb0942600a17f3d4f17285839a0903005c2f42b9
2 files changed +43 -24
packaging/installer/kickstart.sh
+22 -11
@@ -1330,7 +1330,7 @@ check_special_native_deps() {
1330 progress "EPEL is available, attempting to install so that required dependencies are available."
1331
1332 # shellcheck disable=SC2086
1333 - if ! run_as_root env ${env} ${pm_cmd} install ${pkg_install_opts} epel-release; then
1333 + if ! run_as_root env ${env} ${pm_cmd} ${install_subcmd} ${pkg_install_opts} epel-release; then
1334 warning "Failed to install EPEL, even though it is required to install native packages on this system."
1335 return 1
1336 fi
@@ -1350,12 +1350,16 @@ common_rpm_opts() {
1350 }
1351
1352 common_dnf_opts() {
1353 + if [ "${INTERACTIVE}" = "0" ]; then
1354 + interactive_opts="-y"
1355 + fi
1356 if command -v dnf > /dev/null; then
1357 pm_cmd="dnf"
1358 repo_subcmd="makecache"
1359 else
1360 pm_cmd="yum"
1361 fi
1362 + install_subcmd="install"
1363 pkg_install_opts="${interactive_opts}"
1364 repo_update_opts="${interactive_opts}"
1365 uninstall_subcmd="remove"
@@ -1390,16 +1394,18 @@ try_package_install() {
1394 release=""
1395 fi
1396
1393 - if [ "${INTERACTIVE}" = "0" ]; then
1394 - interactive_opts="-y"
1395 - env="DEBIAN_FRONTEND=noninteractive"
1396 - else
1397 - interactive_opts=""
1398 - env=""
1399 - fi
1397 + interactive_opts=""
1398 + env=""
1399
1400 case "${DISTRO_COMPAT_NAME}" in
1401 debian|ubuntu)
1402 + if [ "${INTERACTIVE}" = "0" ]; then
1403 + install_subcmd="-o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold install"
1404 + interactive_opts="-y"
1405 + env="DEBIAN_FRONTEND=noninteractive"
1406 + else
1407 + install_subcmd="install"
1408 + fi
1409 needs_early_refresh=1
1410 pm_cmd="apt-get"
1411 repo_subcmd="update"
@@ -1427,6 +1433,11 @@ try_package_install() {
1433 repo_prefix="${DISTRO_COMPAT_NAME}/${SYSVERSION}"
1434 ;;
1435 opensuse)
1436 + if [ "${INTERACTIVE}" = "0" ]; then
1437 + install_subcmd="--non-interactive --no-gpg-checks install"
1438 + else
1439 + install_subcmd="--no-gpg-checks install"
1440 + fi
1441 common_rpm_opts
1442 pm_cmd="zypper"
1443 repo_subcmd="--gpg-auto-import-keys refresh"
@@ -1497,7 +1508,7 @@ try_package_install() {
1508 fi
1509
1510 # shellcheck disable=SC2086
1500 - if ! run_as_root env ${env} ${pm_cmd} install ${pkg_install_opts} "${tmpdir}/${repoconfig_file}"; then
1511 + if ! run_as_root env ${env} ${pm_cmd} ${install_subcmd} ${pkg_install_opts} "${tmpdir}/${repoconfig_file}"; then
1512 warning "Failed to install repository configuration package."
1513 return 2
1514 fi
@@ -1546,7 +1557,7 @@ try_package_install() {
1557 fi
1558
1559 # shellcheck disable=SC2086
1549 - if ! run_as_root env ${env} ${pm_cmd} install ${pkg_install_opts} "netdata${NATIVE_VERSION}"; then
1560 + if ! run_as_root env ${env} ${pm_cmd} ${install_subcmd} ${pkg_install_opts} "netdata${NATIVE_VERSION}"; then
1561 warning "Failed to install Netdata package."
1562 if [ -z "${NO_CLEANUP}" ]; then
1563 progress "Attempting to uninstall repository configuration package."
@@ -1559,7 +1570,7 @@ try_package_install() {
1570 if [ -n "${explicitly_install_native_plugins}" ]; then
1571 progress "Installing external plugins."
1572 # shellcheck disable=SC2086
1562 - if ! run_as_root env ${env} ${pm_cmd} install ${DEFAULT_PLUGIN_PACKAGES}; then
1573 + if ! run_as_root env ${env} ${pm_cmd} ${install_subcmd} ${DEFAULT_PLUGIN_PACKAGES}; then
1574 warning "Failed to install external plugin packages. Some collectors may not be available."
1575 fi
1576 fi
packaging/installer/netdata-updater.sh
+21 -13
@@ -744,42 +744,50 @@ update_binpkg() {
744 esac
745 fi
746
747 - if [ "${INTERACTIVE}" = "0" ]; then
748 - interactive_opts="-y"
749 - env="DEBIAN_FRONTEND=noninteractive"
750 - else
751 - interactive_opts=""
752 - env=""
753 - fi
747 + interactive_opts=""
748 + env=""
749
750 case "${DISTRO_COMPAT_NAME}" in
751 debian|ubuntu)
752 + if [ "${INTERACTIVE}" = "0" ]; then
753 + upgrade_subcmd="-o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold --only-upgrade install"
754 + interactive_opts="-y"
755 + env="DEBIAN_FRONTEND=noninteractive"
756 + else
757 + upgrade_subcmd="--only-upgrade install"
758 + fi
759 pm_cmd="apt-get"
760 repo_subcmd="update"
759 - upgrade_cmd="--only-upgrade install"
761 pkg_install_opts="${interactive_opts}"
762 repo_update_opts="${interactive_opts}"
763 pkg_installed_check="dpkg -s"
764 INSTALL_TYPE="binpkg-deb"
765 ;;
766 centos|fedora|ol|amzn)
767 + if [ "${INTERACTIVE}" = "0" ]; then
768 + interactive_opts="-y"
769 + fi
770 if command -v dnf > /dev/null; then
771 pm_cmd="dnf"
772 repo_subcmd="makecache"
773 else
774 pm_cmd="yum"
775 fi
772 - upgrade_cmd="upgrade"
776 + upgrade_subcmd="upgrade"
777 pkg_install_opts="${interactive_opts}"
778 repo_update_opts="${interactive_opts}"
779 pkg_installed_check="rpm -q"
780 INSTALL_TYPE="binpkg-rpm"
781 ;;
782 opensuse)
783 + if [ "${INTERACTIVE}" = "0" ]; then
784 + upgrade_subcmd="--non-interactive update"
785 + else
786 + upgrade_subcmd="update"
787 + fi
788 pm_cmd="zypper"
789 repo_subcmd="--gpg-auto-import-keys refresh"
781 - upgrade_cmd="update"
782 - pkg_install_opts="${interactive_opts}"
790 + pkg_install_opts=""
791 repo_update_opts=""
792 pkg_installed_check="rpm -q"
793 INSTALL_TYPE="binpkg-rpm"
@@ -798,7 +806,7 @@ update_binpkg() {
806 for repopkg in netdata-repo netdata-repo-edge; do
807 if ${pkg_installed_check} ${repopkg} > /dev/null 2>&1; then
808 # shellcheck disable=SC2086
801 - env ${env} ${pm_cmd} ${upgrade_cmd} ${pkg_install_opts} ${repopkg} >&3 2>&3 || fatal "Failed to update Netdata repository config." U000D
809 + env ${env} ${pm_cmd} ${upgrade_subcmd} ${pkg_install_opts} ${repopkg} >&3 2>&3 || fatal "Failed to update Netdata repository config." U000D
810 # shellcheck disable=SC2086
811 if [ -n "${repo_subcmd}" ]; then
812 env ${env} ${pm_cmd} ${repo_subcmd} ${repo_update_opts} >&3 2>&3 || fatal "Failed to update repository metadata." U000E
@@ -807,7 +815,7 @@ update_binpkg() {
815 done
816
817 # shellcheck disable=SC2086
810 - env ${env} ${pm_cmd} ${upgrade_cmd} ${pkg_install_opts} netdata >&3 2>&3 || fatal "Failed to update Netdata package." U000F
818 + env ${env} ${pm_cmd} ${upgrade_subcmd} ${pkg_install_opts} netdata >&3 2>&3 || fatal "Failed to update Netdata package." U000F
819 [ -n "${logfile}" ] && rm "${logfile}" && logfile=
820 return 0
821 }