From e661a18c511d629abbcf6a250358f920771185da Mon Sep 17 00:00:00 2001 From: Jay Faulkner Date: Wed, 13 Nov 2024 09:26:42 -0800 Subject: [PATCH] Reapply "Make sure dnf won't autoremove packages that we explicitly installed" The revert of this caused CI failures for Ironic in the Ironic-Python-Agent builds. This reverts commit 4f2613d815d86f5412ef2a67a464dfe3f7dc16ee. Change-Id: I0963d3decefb62680f720bdc3dddd19ecb3bdfd4 --- diskimage_builder/elements/yum/bin/install-packages | 7 +++++++ .../elements/yum/pre-install.d/00-dnf-update | 12 ++++++++++++ 2 files changed, 19 insertions(+) create mode 100755 diskimage_builder/elements/yum/pre-install.d/00-dnf-update diff --git a/diskimage_builder/elements/yum/bin/install-packages b/diskimage_builder/elements/yum/bin/install-packages index 8b65c7c40..1c0a0219a 100755 --- a/diskimage_builder/elements/yum/bin/install-packages +++ b/diskimage_builder/elements/yum/bin/install-packages @@ -135,6 +135,13 @@ if [ -n "$WHITELIST" ]; then # [1] https://bugzilla.redhat.com/show_bug.cgi?id=965567 set -o xtrace ${YUM} -v -y $ACTION $EXTRA_ARGS $PKGS + + if [ "$ACTION" == "install" ]; then + if [ ${YUM} == "dnf" ]; then + # Make sure dnf won't autoremove these packages + dnf mark install $PKGS + fi + fi $_xtrace # probably not the right place for this; but python-pip package on diff --git a/diskimage_builder/elements/yum/pre-install.d/00-dnf-update b/diskimage_builder/elements/yum/pre-install.d/00-dnf-update new file mode 100755 index 000000000..30560a50f --- /dev/null +++ b/diskimage_builder/elements/yum/pre-install.d/00-dnf-update @@ -0,0 +1,12 @@ +#!/bin/bash + +if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + +if [[ $DISTRO_NAME == "fedora" && $DIB_RELEASE -eq 22 ]]; then + # we need dnf mark command from dnf 1.1.1, which is pretty recent + dnf --refresh update -y dnf +fi