zfsbootmenu/install-helpers.sh: preserve relative symlinks #618
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When installing symlinks into their initramfs images, both dracut and mkinitcpio attempt to canonicalize symlink targets, copying the resolved target into place and making a new symlink that points to there. This means that, even when building a local image, symlinks like
poweroff
andzbm
will point copies of scripts in/usr/lib/zfsbootmenu/bin
rather than the versions already installed into/usr/bin
. For container builds or those built from custom installations that override$zfsbootmenu_module_root
, the target paths get even weirder in the initramfs image. It's also problematic, because people doing testing may attempt to modify things like/usr/bin/zfsbootmenu
in situ and be surprised when they runzbm
and get a different copy of the script than the one they modified.I've made a simple helper that tries to do the right thing with symlink as we use them. When installing a file, if it is a symlink and resides in
$zfsbootmenu_module_root
, then the relative link will be replicated in the initramfs image. This seems to work as intended for the handful of symlinks that we install.In the original implementation, I required that the symlink point to a file in the same location and did not attempt to install the target, instead relying on a
zbm_install_file
call for the actual target to add the file separately. In the fixup commit, I instead attempt to install the target in a location where the symlink will find it. I'm open to suggestions on how to improve this target installation, and am also willing to just drop the fixup commit.