From 652ee39a16a83bc522a6c6fa6c3ae4ad05e63ce6 Mon Sep 17 00:00:00 2001 From: Douglas Schilling Landgraf Date: Sat, 27 Apr 2024 00:53:22 -0400 Subject: [PATCH] setup: add validation for removing PACKAGES_TO_REMOVE We should validate if the packages exists to avoid exit in failed command. Fixes: https://github.com/containers/qm/issues/396 Signed-off-by: Douglas Schilling Landgraf --- setup | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/setup b/setup index ebd380b9..081ed243 100755 --- a/setup +++ b/setup @@ -168,8 +168,10 @@ install() { cmd_dnf_install="dnf -y install --releasever=${VERSION_ID} --installroot ${ROOTFS} ${PACKAGES_TO_INSTALL}" ${cmd_dnf_install} - cmd_dnf_remove="dnf --installroot ${ROOTFS} remove ${PACKAGES_TO_REMOVE} -y" - ${cmd_dnf_remove} + if dnf --installroot "${ROOTFS}" list installed "${PACKAGE_TO_REMOVE}" > /dev/null 2>&1; then + dnf --installroot ${ROOTFS} remove ${PACKAGES_TO_REMOVE} -y + fi + # check if "${ROOTFS}"/etc/yum.repos.d if [ -z "$(find "${ROOTFS}"/etc/yum.repos.d -mindepth 1 -maxdepth 1)" ]; then cat > "${ROOTFS}/etc/yum.repos.d/autosd.repo" << EOF