[PATCH] vim-doc.eclass: Support installing in alternative ROOT
Esteve Varela Colominas <[email protected]> Thu, 11 Jun 2026 11:13:34 +0200
| Newsgroups | gmane.linux.gentoo.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, I've been dealing with bug #917047[1] for a while, and I want to try to push for a solution. To this end, I've created github PR 46276[2], and previously sent an email, but I didn't get a response, so this is the second attempt, hope I'm doing it right 😅. The patch is appended to this email. I hope this change can be considered! [1]: https://bugs.gentoo.org/917047 [2]: https://github.com/gentoo/gentoo/pull/46276 From 8fa9a1934211b460d7e29542207a8bd0dd23ba27 Mon Sep 17 00:00:00 2001 From: Esteve Varela Colominas <[email protected]> Date: Sun, 17 May 2026 23:16:53 +0200 Subject: [PATCH] vim-doc.eclass: Support installing in alternative ROOT When a vim-doc package is installed into an alternative ROOT, symlinks will be created that include a full path to this root. This prevents the symlinks from functioning in a running system. Furthermore, when the running system attempts to reinstall any vim-doc package, it will throw an error when it tries to create a symlink in place of one that is stale. To improve this situation, a few changes are made: - Use relative symlinks, which helps the symlinks resolve no matter where the ROOT system is mounted. This isn't strictly necessary, as the symlink target path could simply be created by stripping the leading ROOT component, but I think it's good practice to move to relative symlinks where possible. - Using relative symlinks requires the removal of existing links (which aids in removing stale directories) to resolve a full path to the symlink. This also helps deal with existing installs which will still have symlinks with a full path. - Stale symlinks pass the [[ ! -e ]] check, but cause an error when the "ln" command is used on them. This will basically never happen anymore with the above fixes, but I think it makes sense to override any symlinks which may exist with the packaged version, to ensure consistency. The occurrence is logged. Closes: https://bugs.gentoo.org/922614 Signed-off-by: Esteve Varela Colominas <[email protected]> --- eclass/vim-doc.eclass | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/eclass/vim-doc.eclass b/eclass/vim-doc.eclass index ad595c5a67c67..04e9011baf06e 100644 --- a/eclass/vim-doc.eclass +++ b/eclass/vim-doc.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2024 Gentoo Authors +# Copyright 1999-2026 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: vim-doc.eclass @@ -61,7 +61,7 @@ update_vim_helptags() { # Remove links readarray -d '' files < <(find "${d}"/doc -name "*.txt" - type l -print0 || die "cannot traverse ${d}/doc" ) for helpfile in "${files[@]}"; do - if [[ $(readlink -f "${helpfile}") == "$ {vimfiles}"/* ]]; then + if [[ $(realpath "$(readlink -f "$ {helpfile}")") == "${vimfiles}"/* ]]; then rm "${helpfile}" || die fi done @@ -80,8 +80,16 @@ update_vim_helptags() { # Re-create / install new links if [[ -d "${vimfiles}"/doc ]]; then for helpfile in "${vimfiles}"/doc/*.txt; do - if [[ ! -e "${d}/doc/$(basename "$ {helpfile}")" ]]; then - ln -s "${helpfile}" "$ {d}/doc" || die + helpfile="$(basename "${helpfile}")" + # Symlinks to packaged files should've already been removed + # above, but if somehow a symlink exists for this file, make + # sure to point it to the new file. + if [[ -h "${d}/doc/${helpfile}" ]]; then + ewarn "Updating symlink ${d}/doc/${helpfile}" + rm "${d}/doc/$ {helpfile}" || die + fi + if [[ ! -e "${d}/doc/${helpfile}" ]]; then + ln -s "../../vimfiles/ doc/${helpfile}" "${d}/doc" || die fi done fi