Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/boot/dracut/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ installkernel() {
}

check() {
if [[ -x $systemdutildir/systemd ]] && [[ -x /usr/lib/ostree/ostree-prepare-root ]]; then
if [[ -x $systemdutildir/systemd ]] && [[ -x "${dracutsysrootdir-}/usr/lib/ostree/ostree-prepare-root" ]]; then
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The variable $systemdutildir should be quoted to prevent issues if the path contains spaces or other special characters. This is a general shell scripting best practice for robustness.

Suggested change
if [[ -x $systemdutildir/systemd ]] && [[ -x "${dracutsysrootdir-}/usr/lib/ostree/ostree-prepare-root" ]]; then
if [[ -x "$systemdutildir/systemd" ]] && [[ -x "${dracutsysrootdir-}/usr/lib/ostree/ostree-prepare-root" ]]; then

return 255
fi

Expand All @@ -36,14 +36,14 @@ depends() {
}

install() {
dracut_install /usr/lib/ostree/ostree-prepare-root
for r in /usr/lib /etc; do
dracut_install "${dracutsysrootdir-}/usr/lib/ostree/ostree-prepare-root"
for r in "${dracutsysrootdir-}/usr/lib" "${dracutsysrootdir-}/etc"; do
if test -f "$r/ostree/prepare-root.conf"; then
inst_simple "$r/ostree/prepare-root.conf"
fi
done
if test -f "/etc/ostree/initramfs-root-binding.key"; then
inst_simple "/etc/ostree/initramfs-root-binding.key"
if test -f "${dracutsysrootdir-}/etc/ostree/initramfs-root-binding.key"; then
inst_simple "${dracutsysrootdir-}/etc/ostree/initramfs-root-binding.key"
fi
Comment on lines +39 to 47
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The dracut_install and inst_simple functions in standard dracut automatically prepend the $dracutsysrootdir path when locating files. Your change manually prepends this path, which will likely cause an error due to double-prefixing (e.g., /sysroot/sysroot/...).

While the test -f checks do need the prefix, the dracut installation functions should be called with paths relative to the sysroot. If you are using a patched version of dracut in Yocto that changes this behavior, please clarify. Otherwise, the logic should be adjusted.

Here's a suggested correction that should work with standard dracut:

Suggested change
dracut_install "${dracutsysrootdir-}/usr/lib/ostree/ostree-prepare-root"
for r in "${dracutsysrootdir-}/usr/lib" "${dracutsysrootdir-}/etc"; do
if test -f "$r/ostree/prepare-root.conf"; then
inst_simple "$r/ostree/prepare-root.conf"
fi
done
if test -f "/etc/ostree/initramfs-root-binding.key"; then
inst_simple "/etc/ostree/initramfs-root-binding.key"
if test -f "${dracutsysrootdir-}/etc/ostree/initramfs-root-binding.key"; then
inst_simple "${dracutsysrootdir-}/etc/ostree/initramfs-root-binding.key"
fi
dracut_install /usr/lib/ostree/ostree-prepare-root
for r in /usr/lib /etc; do
if test -f "${dracutsysrootdir-}$r/ostree/prepare-root.conf"; then
inst_simple "$r/ostree/prepare-root.conf"
fi
done
if test -f "${dracutsysrootdir-}/etc/ostree/initramfs-root-binding.key"; then
inst_simple "/etc/ostree/initramfs-root-binding.key"
fi

inst_simple "${systemdsystemunitdir}/ostree-prepare-root.service"
mkdir -p "${initdir}${systemdsystemconfdir}/initrd-root-fs.target.wants"
Expand Down
Loading