From e06a6cf64cc8dee786ae728624afbff758939809 Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Wed, 9 Jul 2025 08:54:06 -0700 Subject: [PATCH] Allow dib build to remove firmware in a structure. In some cases, a vendor may do many things and we only need to remove a specific subset of firmware blobs. An example is Mellanox and their Spectrum series of switch controllers. In change id Ic8ecf289f1e03e5ee7f36cc6ded707a25cb138c8 we added a command to attempt to remove a huge amount of firmware blobs from multiple revisions of spectrum series switch controllers (i.e. spectrum, spectrum2, spectrum3). Where as the prior pattern of the removal script was to just remove whole folders, becuase there was a historical pattern of clean delineation. Anyhow, now we'll check to see if there is a slash in the path, and only then allow for the glob expansion to take place which was in the original logic of the removal code when it was first submitted, but where we were also concerned someone would override the list and accidently remove all firmware blobs. In this case, we also check to ensure its not an empty string. Change-Id: Iab766228cac801d29457e8bee5a05834f1a0f04a Signed-off-by: Julia Kreger --- .../post-install.d/99-remove-extra-packages | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dib/ironic-python-agent-ramdisk/post-install.d/99-remove-extra-packages b/dib/ironic-python-agent-ramdisk/post-install.d/99-remove-extra-packages index 5ee4375..1ee3420 100755 --- a/dib/ironic-python-agent-ramdisk/post-install.d/99-remove-extra-packages +++ b/dib/ironic-python-agent-ramdisk/post-install.d/99-remove-extra-packages @@ -15,7 +15,15 @@ for folder in $KNOWN_FIRMWARE_PATH; do for item in ${IPA_REMOVE_FIRMWARE//,/ }; do # Attempt removal of item, but don't error # if it is not present already. - rm -rf $folder$item || true + if [[ "$item" != "" ]] && [[ "$item" =~ "/" ]]; then + # We're deleting targetted contents in a folder, + # and not an entire folder. Since we're checking for an + # an empty string, we should be fine letting it do the + # expansion. + rm -r -f $folder$item* + else + rm -rf $folder$item || true + fi done done