summaryrefslogtreecommitdiffstats
path: root/packaging
diff options
context:
space:
mode:
authorBastien <b.ogier@protonmail.com>2023-07-20 23:05:26 +0200
committerGitHub <noreply@github.com>2023-07-20 21:05:26 +0000
commitcb0942600a17f3d4f17285839a0903005c2f42b9 (patch)
tree1a85c564b5992c5e59768271c1eed72e1f059e6e /packaging
parentd36fb28d73cac93412b15a0e23df08fd18b28879 (diff)
Fix non-interactive options for apt-get and zypper. (#15288)
Diffstat (limited to 'packaging')
-rwxr-xr-xpackaging/installer/kickstart.sh33
-rwxr-xr-xpackaging/installer/netdata-updater.sh34
2 files changed, 43 insertions, 24 deletions
diff --git a/packaging/installer/kickstart.sh b/packaging/installer/kickstart.sh
index 31930f9d49..8ddcd86e07 100755
--- a/packaging/installer/kickstart.sh
+++ b/packaging/installer/kickstart.sh
@@ -1330,7 +1330,7 @@ check_special_native_deps() {
progress "EPEL is available, attempting to install so that required dependencies are available."
# shellcheck disable=SC2086
- if ! run_as_root env ${env} ${pm_cmd} install ${pkg_install_opts} epel-release; then
+ if ! run_as_root env ${env} ${pm_cmd} ${install_subcmd} ${pkg_install_opts} epel-release; then
warning "Failed to install EPEL, even though it is required to install native packages on this system."
return 1
fi
@@ -1350,12 +1350,16 @@ common_rpm_opts() {
}
common_dnf_opts() {
+ if [ "${INTERACTIVE}" = "0" ]; then
+ interactive_opts="-y"
+ fi
if command -v dnf > /dev/null; then
pm_cmd="dnf"
repo_subcmd="makecache"
else
pm_cmd="yum"
fi
+ install_subcmd="install"
pkg_install_opts="${interactive_opts}"
repo_update_opts="${interactive_opts}"
uninstall_subcmd="remove"
@@ -1390,16 +1394,18 @@ try_package_install() {
release=""
fi
- if [ "${INTERACTIVE}" = "0" ]; then
- interactive_opts="-y"
- env="DEBIAN_FRONTEND=noninteractive"
- else
- interactive_opts=""
- env=""
- fi
+ interactive_opts=""
+ env=""
case "${DISTRO_COMPAT_NAME}" in
debian|ubuntu)
+ if [ "${INTERACTIVE}" = "0" ]; then
+ install_subcmd="-o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold install"
+ interactive_opts="-y"
+ env="DEBIAN_FRONTEND=noninteractive"
+ else
+ install_subcmd="install"
+ fi
needs_early_refresh=1
pm_cmd="apt-get"
repo_subcmd="update"
@@ -1427,6 +1433,11 @@ try_package_install() {
repo_prefix="${DISTRO_COMPAT_NAME}/${SYSVERSION}"
;;
opensuse)
+ if [ "${INTERACTIVE}" = "0" ]; then
+ install_subcmd="--non-interactive --no-gpg-checks install"
+ else
+ install_subcmd="--no-gpg-checks install"
+ fi
common_rpm_opts
pm_cmd="zypper"
repo_subcmd="--gpg-auto-import-keys refresh"
@@ -1497,7 +1508,7 @@ try_package_install() {
fi
# shellcheck disable=SC2086
- if ! run_as_root env ${env} ${pm_cmd} install ${pkg_install_opts} "${tmpdir}/${repoconfig_file}"; then
+ if ! run_as_root env ${env} ${pm_cmd} ${install_subcmd} ${pkg_install_opts} "${tmpdir}/${repoconfig_file}"; then
warning "Failed to install repository configuration package."
return 2
fi
@@ -1546,7 +1557,7 @@ try_package_install() {
fi
# shellcheck disable=SC2086
- if ! run_as_root env ${env} ${pm_cmd} install ${pkg_install_opts} "netdata${NATIVE_VERSION}"; then
+ if ! run_as_root env ${env} ${pm_cmd} ${install_subcmd} ${pkg_install_opts} "netdata${NATIVE_VERSION}"; then
warning "Failed to install Netdata package."
if [ -z "${NO_CLEANUP}" ]; then
progress "Attempting to uninstall repository configuration package."
@@ -1559,7 +1570,7 @@ try_package_install() {
if [ -n "${explicitly_install_native_plugins}" ]; then
progress "Installing external plugins."
# shellcheck disable=SC2086
- if ! run_as_root env ${env} ${pm_cmd} install ${DEFAULT_PLUGIN_PACKAGES}; then
+ if ! run_as_root env ${env} ${pm_cmd} ${install_subcmd} ${DEFAULT_PLUGIN_PACKAGES}; then
warning "Failed to install external plugin packages. Some collectors may not be available."
fi
fi
diff --git a/packaging/installer/netdata-updater.sh b/packaging/installer/netdata-updater.sh
index 8e06923e4b..d05e2e4d9f 100755
--- a/packaging/installer/netdata-updater.sh
+++ b/packaging/installer/netdata-updater.sh
@@ -744,42 +744,50 @@ update_binpkg() {
esac
fi
- if [ "${INTERACTIVE}" = "0" ]; then
- interactive_opts="-y"
- env="DEBIAN_FRONTEND=noninteractive"
- else
- interactive_opts=""
- env=""
- fi
+ interactive_opts=""
+ env=""
case "${DISTRO_COMPAT_NAME}" in
debian|ubuntu)
+ if [ "${INTERACTIVE}" = "0" ]; then
+ upgrade_subcmd="-o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold --only-upgrade install"
+ interactive_opts="-y"
+ env="DEBIAN_FRONTEND=noninteractive"
+ else
+ upgrade_subcmd="--only-upgrade install"
+ fi
pm_cmd="apt-get"
repo_subcmd="update"
- upgrade_cmd="--only-upgrade install"
pkg_install_opts="${interactive_opts}"
repo_update_opts="${interactive_opts}"
pkg_installed_check="dpkg -s"
INSTALL_TYPE="binpkg-deb"
;;
centos|fedora|ol|amzn)
+ if [ "${INTERACTIVE}" = "0" ]; then
+ interactive_opts="-y"
+ fi
if command -v dnf > /dev/null; then
pm_cmd="dnf"
repo_subcmd="makecache"
else
pm_cmd="yum"
fi
- upgrade_cmd="upgrade"
+ upgrade_subcmd="upgrade"
pkg_install_opts="${interactive_opts}"
repo_update_opts="${interactive_opts}"
pkg_installed_check="rpm -q"
INSTALL_TYPE="binpkg-rpm"
;;
opensuse)
+ if [ "${INTERACTIVE}" = "0" ]; then
+ upgrade_subcmd="--non-interactive update"
+ else
+ upgrade_subcmd="update"
+ fi
pm_cmd="zypper"
repo_subcmd="--gpg-auto-import-keys refresh"
- upgrade_cmd="update"
- pkg_install_opts="${interactive_opts}"
+ pkg_install_opts=""
repo_update_opts=""
pkg_installed_check="rpm -q"
INSTALL_TYPE="binpkg-rpm"
@@ -798,7 +806,7 @@ update_binpkg() {
for repopkg in netdata-repo netdata-repo-edge; do
if ${pkg_installed_check} ${repopkg} > /dev/null 2>&1; then
# shellcheck disable=SC2086
- env ${env} ${pm_cmd} ${upgrade_cmd} ${pkg_install_opts} ${repopkg} >&3 2>&3 || fatal "Failed to update Netdata repository config." U000D
+ env ${env} ${pm_cmd} ${upgrade_subcmd} ${pkg_install_opts} ${repopkg} >&3 2>&3 || fatal "Failed to update Netdata repository config." U000D
# shellcheck disable=SC2086
if [ -n "${repo_subcmd}" ]; then
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() {
done
# shellcheck disable=SC2086
- env ${env} ${pm_cmd} ${upgrade_cmd} ${pkg_install_opts} netdata >&3 2>&3 || fatal "Failed to update Netdata package." U000F
+ env ${env} ${pm_cmd} ${upgrade_subcmd} ${pkg_install_opts} netdata >&3 2>&3 || fatal "Failed to update Netdata package." U000F
[ -n "${logfile}" ] && rm "${logfile}" && logfile=
return 0
}