Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zfsbootmenu/install-helpers.sh: preserve relative symlinks #618

Merged
merged 1 commit into from
Apr 30, 2024
Merged
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
37 changes: 36 additions & 1 deletion zfsbootmenu/install-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,42 @@ create_zbm_profiles() {
ln -s "/root/.bashrc" "${BUILDROOT}/root/.profile"
}

zbm_install_symlink() {
[ -L "${1}" ] || return 1

# shellcheck disable=SC2154
case "${1}" in
"${zfsbootmenu_module_root}"/*) ;;
*) return 1 ;;
esac

local dest src

dest="$(readlink "${1}")" || dest=
[ -n "${dest}" ] || return 1

case "${dest}" in
/*) return 1 ;;
esac

src="${2:-"${1}"}"

# Attempt to install the target of the symlink
local rpath
if rpath="$(realpath -f "${1}")"; then
if [ -e "${rpath}" ] && [ ! -L "${rpath}" ]; then
zbm_install_file "${rpath}" "$(dirname "${src}")/${dest}" || return 1
fi
fi

ln -Ts "${dest}" "${BUILDROOT}/${src}" || return 1
return 0
}

zbm_install_file() {
# All symlinks in the ZBM module root should be relative
zbm_install_symlink "$@" && return 0

case "${ZBM_BUILDSTYLE,,}" in
mkinitcpio)
if ! add_file "${1}" "${2}"; then
Expand Down Expand Up @@ -253,7 +288,7 @@ install_zbm_docs() {

install_zbm_fonts() {

[ -d "${zfsbootmenu_module_root}/fonts" ] || return 1
[ -d "${zfsbootmenu_module_root}/fonts" ] || return 1

# Install into a non-standard path so that the Dracut i18n module doesn't stomp over our custom fonts

Expand Down