Gentoo Archives: gentoo-commits

From: Patrice Clement <monsieurp@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Mon, 30 May 2022 12:57:15
Message-Id: 1653915419.f8ce1e8a6616d04efb2e9c734026e46eaa48c66a.monsieurp@gentoo
1 commit: f8ce1e8a6616d04efb2e9c734026e46eaa48c66a
2 Author: Thomas Bracht Laumann Jespersen <t <AT> laumann <DOT> xyz>
3 AuthorDate: Wed Apr 6 09:10:33 2022 +0000
4 Commit: Patrice Clement <monsieurp <AT> gentoo <DOT> org>
5 CommitDate: Mon May 30 12:56:59 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f8ce1e8a
7
8 vim-doc.eclass: support EAPI 8
9
10 * Added "|| die" statements
11 * Create links only if they don't exist yet
12 * `readlink` -> `readlink -f`
13 * Quoted variables
14
15 Signed-off-by: Thomas Bracht Laumann Jespersen <t <AT> laumann.xyz>
16 Signed-off-by: Anna Vyalkova <cyber+gentoo <AT> sysrq.in>
17 Closes: https://github.com/gentoo/gentoo/pull/24941
18 Signed-off-by: Patrice Clement <monsieurp <AT> gentoo.org>
19
20 eclass/vim-doc.eclass | 66 ++++++++++++++++++++++++++++++---------------------
21 1 file changed, 39 insertions(+), 27 deletions(-)
22
23 diff --git a/eclass/vim-doc.eclass b/eclass/vim-doc.eclass
24 index ba9d00f4f5e8..f0c5c6edc6f3 100644
25 --- a/eclass/vim-doc.eclass
26 +++ b/eclass/vim-doc.eclass
27 @@ -1,10 +1,10 @@
28 -# Copyright 1999-2021 Gentoo Authors
29 +# Copyright 1999-2022 Gentoo Authors
30 # Distributed under the terms of the GNU General Public License v2
31
32 # @ECLASS: vim-doc.eclass
33 # @MAINTAINER:
34 # vim@g.o
35 -# @SUPPORTED_EAPIS: 6 7
36 +# @SUPPORTED_EAPIS: 6 7 8
37 # @BLURB: Eclass for vim{,-plugin}.eclass to update documentation tags.
38 # @DESCRIPTION:
39 # This eclass is used by vim.eclass and vim-plugin.eclass to update
40 @@ -16,26 +16,25 @@
41 # DEPEND in vim-plugin or by whatever version of vim is being
42 # installed by the eclass.
43
44 -case ${EAPI:-0} in
45 - [67]) ;;
46 +case ${EAPI} in
47 + 6|7|8) ;;
48 *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
49 esac
50
51 -if [[ -z ${_VIM_DOC_ECLASS} ]] ; then
52 -_VIM_DOC_ECLASS=1
53 +if [[ ! ${_VIM_DOC_ECLASS} ]] ; then
54
55 update_vim_helptags() {
56 - local vimfiles vim d s
57 + local vimfiles helpfile files vim d
58
59 # This is where vim plugins are installed
60 vimfiles="${EROOT}"/usr/share/vim/vimfiles
61
62 - if [[ $PN != vim-core ]]; then
63 + if [[ ${PN} != vim-core ]]; then
64 # Find a suitable vim binary for updating tags :helptags
65 vim=$(type -P vim 2>/dev/null)
66 - [[ -z "$vim" ]] && vim=$(type -P gvim 2>/dev/null)
67 - [[ -z "$vim" ]] && vim=$(type -P kvim 2>/dev/null)
68 - if [[ -z "$vim" ]]; then
69 + [[ -z "${vim}" ]] && vim=$(type -P gvim 2>/dev/null)
70 + [[ -z "${vim}" ]] && vim=$(type -P kvim 2>/dev/null)
71 + if [[ -z "${vim}" ]]; then
72 ewarn "No suitable vim binary to rebuild documentation tags"
73 fi
74 fi
75 @@ -43,44 +42,57 @@ update_vim_helptags() {
76 # Make vim not try to connect to X. See :help gui-x11-start
77 # in vim for how this evil trickery works.
78 if [[ -n "${vim}" ]] ; then
79 - ln -s "${vim}" "${T}/tagvim"
80 + ln -s "${vim}" "${T}/tagvim" || die
81 vim="${T}/tagvim"
82 fi
83
84 # Install the documentation symlinks into the versioned vim
85 # directory and run :helptags
86 for d in "${EROOT%/}"/usr/share/vim/vim[0-9]*; do
87 - [[ -d "$d/doc" ]] || continue # catch a failed glob
88 + [[ -d "${d}/doc" ]] || continue # catch a failed glob
89
90 - # Remove links, and possibly remove stale dirs
91 - find $d/doc -name \*.txt -type l | while read s; do
92 - [[ $(readlink "$s") = $vimfiles/* ]] && rm -f "$s"
93 + # Remove links
94 + readarray -d '' files < <(find "${d}"/doc -name "*.txt" -type l -print0 || die "cannot traverse ${d}/doc" )
95 + for helpfile in "${files[@]}"; do
96 + if [[ $(readlink -f "${helpfile}") == "${vimfiles}"/* ]]; then
97 + rm "${helpfile}" || die
98 + fi
99 done
100 - if [[ -f "$d/doc/tags" && $(find "$d" | wc -l | tr -d ' ') = 3 ]]; then
101 +
102 + # Remove stale dirs, if possible
103 + readarray -d '' files < <(find "${d}" -print0 || die "cannot traverse ${d}")
104 + if [[ -f "${d}/doc/tags" && ${#files[@]} -eq 3 ]]; then
105 # /usr/share/vim/vim61
106 # /usr/share/vim/vim61/doc
107 # /usr/share/vim/vim61/doc/tags
108 - einfo "Removing $d"
109 - rm -r "$d"
110 + einfo "Removing ${d}"
111 + rm -r "${d}" || die
112 continue
113 fi
114
115 # Re-create / install new links
116 - if [[ -d $vimfiles/doc ]]; then
117 - ln -s $vimfiles/doc/*.txt $d/doc 2>/dev/null
118 + if [[ -d "${vimfiles}"/doc ]]; then
119 + for helpfile in "${vimfiles}"/doc/*.txt; do
120 + if [[ ! -e "${d}/doc/$(basename "${helpfile}")" ]]; then
121 + ln -s "${helpfile}" "${d}/doc" || die
122 + fi
123 + done
124 fi
125
126 # Update tags; need a vim binary for this
127 - if [[ -n "$vim" ]]; then
128 - einfo "Updating documentation tags in $d"
129 - DISPLAY= $vim -u NONE -U NONE -T xterm -X -n -f \
130 + if [[ -n "${vim}" ]]; then
131 + einfo "Updating documentation tags in ${d}"
132 + DISPLAY= "${vim}" -u NONE -U NONE -T xterm -X -n -f \
133 '+set nobackup nomore' \
134 - "+helptags $d/doc" \
135 - '+qa!' </dev/null &>/dev/null
136 + "+helptags ${d}/doc" \
137 + '+qa!' </dev/null &>/dev/null || die
138 fi
139 done
140
141 - [[ -n "${vim}" && -f "${vim}" ]] && rm "${vim}"
142 + if [[ -n "${vim}" && -f "${vim}" ]]; then
143 + rm "${vim}" || die
144 + fi
145 }
146
147 +_VIM_DOC_ECLASS=1
148 fi