summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bracht Laumann Jespersen <t@laumann.xyz>2022-04-06 11:10:33 +0200
committerPatrice Clement <monsieurp@gentoo.org>2022-05-30 14:56:59 +0200
commitf8ce1e8a6616d04efb2e9c734026e46eaa48c66a (patch)
treecc391cc6ffab2431cc965febfcf971e5f0e52aa4 /eclass/vim-doc.eclass
parentsci-electronics/NanoVNA-QT: initial import, version 20200507 (diff)
downloadgentoo-f8ce1e8a6616d04efb2e9c734026e46eaa48c66a.tar.gz
gentoo-f8ce1e8a6616d04efb2e9c734026e46eaa48c66a.tar.bz2
gentoo-f8ce1e8a6616d04efb2e9c734026e46eaa48c66a.zip
vim-doc.eclass: support EAPI 8
* Added "|| die" statements * Create links only if they don't exist yet * `readlink` -> `readlink -f` * Quoted variables Signed-off-by: Thomas Bracht Laumann Jespersen <t@laumann.xyz> Signed-off-by: Anna Vyalkova <cyber+gentoo@sysrq.in> Closes: https://github.com/gentoo/gentoo/pull/24941 Signed-off-by: Patrice Clement <monsieurp@gentoo.org>
Diffstat (limited to 'eclass/vim-doc.eclass')
-rw-r--r--eclass/vim-doc.eclass66
1 files changed, 39 insertions, 27 deletions
diff --git a/eclass/vim-doc.eclass b/eclass/vim-doc.eclass
index ba9d00f4f5e8..f0c5c6edc6f3 100644
--- a/eclass/vim-doc.eclass
+++ b/eclass/vim-doc.eclass
@@ -1,10 +1,10 @@
-# Copyright 1999-2021 Gentoo Authors
+# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: vim-doc.eclass
# @MAINTAINER:
# vim@gentoo.org
-# @SUPPORTED_EAPIS: 6 7
+# @SUPPORTED_EAPIS: 6 7 8
# @BLURB: Eclass for vim{,-plugin}.eclass to update documentation tags.
# @DESCRIPTION:
# This eclass is used by vim.eclass and vim-plugin.eclass to update
@@ -16,26 +16,25 @@
# DEPEND in vim-plugin or by whatever version of vim is being
# installed by the eclass.
-case ${EAPI:-0} in
- [67]) ;;
+case ${EAPI} in
+ 6|7|8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
-if [[ -z ${_VIM_DOC_ECLASS} ]] ; then
-_VIM_DOC_ECLASS=1
+if [[ ! ${_VIM_DOC_ECLASS} ]] ; then
update_vim_helptags() {
- local vimfiles vim d s
+ local vimfiles helpfile files vim d
# This is where vim plugins are installed
vimfiles="${EROOT}"/usr/share/vim/vimfiles
- if [[ $PN != vim-core ]]; then
+ if [[ ${PN} != vim-core ]]; then
# Find a suitable vim binary for updating tags :helptags
vim=$(type -P vim 2>/dev/null)
- [[ -z "$vim" ]] && vim=$(type -P gvim 2>/dev/null)
- [[ -z "$vim" ]] && vim=$(type -P kvim 2>/dev/null)
- if [[ -z "$vim" ]]; then
+ [[ -z "${vim}" ]] && vim=$(type -P gvim 2>/dev/null)
+ [[ -z "${vim}" ]] && vim=$(type -P kvim 2>/dev/null)
+ if [[ -z "${vim}" ]]; then
ewarn "No suitable vim binary to rebuild documentation tags"
fi
fi
@@ -43,44 +42,57 @@ update_vim_helptags() {
# Make vim not try to connect to X. See :help gui-x11-start
# in vim for how this evil trickery works.
if [[ -n "${vim}" ]] ; then
- ln -s "${vim}" "${T}/tagvim"
+ ln -s "${vim}" "${T}/tagvim" || die
vim="${T}/tagvim"
fi
# Install the documentation symlinks into the versioned vim
# directory and run :helptags
for d in "${EROOT%/}"/usr/share/vim/vim[0-9]*; do
- [[ -d "$d/doc" ]] || continue # catch a failed glob
+ [[ -d "${d}/doc" ]] || continue # catch a failed glob
- # Remove links, and possibly remove stale dirs
- find $d/doc -name \*.txt -type l | while read s; do
- [[ $(readlink "$s") = $vimfiles/* ]] && rm -f "$s"
+ # 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
+ rm "${helpfile}" || die
+ fi
done
- if [[ -f "$d/doc/tags" && $(find "$d" | wc -l | tr -d ' ') = 3 ]]; then
+
+ # Remove stale dirs, if possible
+ readarray -d '' files < <(find "${d}" -print0 || die "cannot traverse ${d}")
+ if [[ -f "${d}/doc/tags" && ${#files[@]} -eq 3 ]]; then
# /usr/share/vim/vim61
# /usr/share/vim/vim61/doc
# /usr/share/vim/vim61/doc/tags
- einfo "Removing $d"
- rm -r "$d"
+ einfo "Removing ${d}"
+ rm -r "${d}" || die
continue
fi
# Re-create / install new links
- if [[ -d $vimfiles/doc ]]; then
- ln -s $vimfiles/doc/*.txt $d/doc 2>/dev/null
+ 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
+ fi
+ done
fi
# Update tags; need a vim binary for this
- if [[ -n "$vim" ]]; then
- einfo "Updating documentation tags in $d"
- DISPLAY= $vim -u NONE -U NONE -T xterm -X -n -f \
+ if [[ -n "${vim}" ]]; then
+ einfo "Updating documentation tags in ${d}"
+ DISPLAY= "${vim}" -u NONE -U NONE -T xterm -X -n -f \
'+set nobackup nomore' \
- "+helptags $d/doc" \
- '+qa!' </dev/null &>/dev/null
+ "+helptags ${d}/doc" \
+ '+qa!' </dev/null &>/dev/null || die
fi
done
- [[ -n "${vim}" && -f "${vim}" ]] && rm "${vim}"
+ if [[ -n "${vim}" && -f "${vim}" ]]; then
+ rm "${vim}" || die
+ fi
}
+_VIM_DOC_ECLASS=1
fi