Skip to content

Commit

Permalink
50-dracut.install: add exit condition for pre-existing image
Browse files Browse the repository at this point in the history
essentially mirrors what the upstream systemd equivalent also does

Signed-off-by: Nowa Ammerlaan <[email protected]>
  • Loading branch information
Nowa-Ammerlaan committed Feb 19, 2025
1 parent f2692ef commit 2fe4b0b
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions hooks/50-dracut.install
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

ver=${1}
img=${2}
initrd="${INSTALLKERNEL_STAGING_AREA}/initrd"
uki="${INSTALLKERNEL_STAGING_AREA}/uki.efi"
tmp="${INSTALLKERNEL_STAGING_AREA}/dracut-tmp"
initrd="${INSTALLKERNEL_STAGING_AREA:-$(dirname "${img}")}/initrd"
uki="${INSTALLKERNEL_STAGING_AREA:-$(dirname "${img}")}/uki.efi"
tmp="${INSTALLKERNEL_STAGING_AREA:-$(dirname "${img}")}/dracut-tmp"

# familiar helpers, we intentionally don't use Gentoo functions.sh
die() {
Expand Down Expand Up @@ -53,10 +53,24 @@ main() {
einfo "Using dracut as the initramfs and UKI generator..."
initramfs_gen_args+=( --uefi )
out="${uki}"
if [[ -f $(dirname "${img}")/uki.efi ]]; then
einfo "There is an UKI image at the same place as the kernel, skipping generating a new one"
cp --reflink=auto "$(dirname "${img}")/uki.efi" "${uki}" || die
chown root:root "${uki}" || die
chmod 0600 "${uki}" || die
exit 0
fi
elif [[ ${INSTALLKERNEL_INITRD_GENERATOR} == dracut ]]; then
einfo "Using dracut as the initramfs generator..."
initramfs_gen_args+=( --no-uefi )
out="${initrd}"
if [[ -f $(dirname "${img}")/initrd ]]; then
einfo "There is an initramfs image at the same place as the kernel, skipping generating a new one"
cp --reflink=auto "$(dirname "${img}")/initrd" "${initrd}" || die
chown root:root "${initrd}" || die
chmod 0600 "${initrd}" || die
exit 0
fi
else
einfo "No install.conf preference set, falling back to dracut.conf..."
out="${tmp}"
Expand Down

0 comments on commit 2fe4b0b

Please sign in to comment.