diff --git a/adapters/gnome-layer.sh b/adapters/gnome-layer.sh index 29cc26d..2009803 100644 --- a/adapters/gnome-layer.sh +++ b/adapters/gnome-layer.sh @@ -69,7 +69,17 @@ arch-chroot "$stage" pacman -S --needed --noconfirm -- "${desktop_packages[@]}" core_replacements=() replace_core_package() { arch-chroot "$stage" pacman -Q "$2" > "/job/evidence/replacement-$1.txt" + # A kernel's generated initramfs lives in its module directory but is not owned + # by the package, so removing the package alone would leave a stale second + # kernel behind and every later `basename /usr/lib/modules/*` would see two. + # Record the module trees that the replaced package actually installed, then + # drop them with the package; the layer adapter allows exactly that removal. + mapfile -t replaced_trees < <(arch-chroot "$stage" pacman -Ql "$1" | + awk '$2 ~ /^\/?usr\/lib\/modules\/[^/]+\/vmlinuz$/ {sub(/\/vmlinuz$/, "", $2); sub(/^\//, "", $2); print $2}') arch-chroot "$stage" pacman -R --noconfirm -- "$1" >> "/job/evidence/replacement-$1.txt" 2>&1 + for tree in ${replaced_trees[@]+"${replaced_trees[@]}"}; do + rm -rf "$stage/$tree" + done core_replacements+=("$1:$2") } @@PACKAGE_REPLACEMENTS@@