Gentoo Archives: gentoo-commits

From: Mikle Kolyada <zlogene@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Sun, 09 Feb 2020 10:25:24
Message-Id: 1581243916.606c68a31bd9a243f28d0bbca2daf202bb40bb3a.zlogene@gentoo
1 commit: 606c68a31bd9a243f28d0bbca2daf202bb40bb3a
2 Author: Mikle Kolyada <zlogene <AT> gentoo <DOT> org>
3 AuthorDate: Tue Jan 21 09:19:22 2020 +0000
4 Commit: Mikle Kolyada <zlogene <AT> gentoo <DOT> org>
5 CommitDate: Sun Feb 9 10:25:16 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=606c68a3
7
8 texlive-module.eclass: kill POSIXism
9
10 Reviewed-by: David Saifert <soap <AT> gentoo.org>
11 Reviewed-by: Michał Górny <mgorny <AT> gentoo.org>
12 Signed-off-by: Mikle Kolyada <zlogene <AT> gentoo.org>
13
14 eclass/texlive-module.eclass | 176 +++++++++++++++++++++++++------------------
15 1 file changed, 104 insertions(+), 72 deletions(-)
16
17 diff --git a/eclass/texlive-module.eclass b/eclass/texlive-module.eclass
18 index 52b26cdca4d..3f31f35e1ab 100644
19 --- a/eclass/texlive-module.eclass
20 +++ b/eclass/texlive-module.eclass
21 @@ -1,4 +1,4 @@
22 -# Copyright 1999-2019 Gentoo Authors
23 +# Copyright 1999-2020 Gentoo Authors
24 # Distributed under the terms of the GNU General Public License v2
25
26 # @ECLASS: texlive-module.eclass
27 @@ -68,13 +68,13 @@
28 # Information to display about the package.
29 # e.g. for enabling/disabling a feature
30
31 -case "${EAPI:-0}" in
32 - 0|1|2|3|4|5|6)
33 - die "EAPI='${EAPI}' is not supported anymore"
34 - ;;
35 - *)
36 - inherit texlive-common
37 - ;;
38 +if [[ -z ${_TEXLIVE_MODULE_ECLASS} ]]; then
39 +_TEXLIVE_MODULE_ECLASS=1
40 +
41 +case ${EAPI:-0} in
42 + [0-6]) die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}" ;;
43 + 7) inherit texlive-common ;;
44 + *) die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" ;;
45 esac
46
47 HOMEPAGE="http://www.tug.org/texlive/"
48 @@ -97,14 +97,14 @@ for i in ${TEXLIVE_MODULE_CONTENTS}; do
49 done
50
51 # Forge doc SRC_URI
52 -[ -n "${TEXLIVE_MODULE_DOC_CONTENTS}" ] && SRC_URI="${SRC_URI} doc? ("
53 +[[ -n ${TEXLIVE_MODULE_DOC_CONTENTS} ]] && SRC_URI="${SRC_URI} doc? ("
54 for i in ${TEXLIVE_MODULE_DOC_CONTENTS}; do
55 SRC_URI="${SRC_URI} mirror://gentoo/texlive-module-${i}-${PV}.${PKGEXT}"
56 done
57 -[ -n "${TEXLIVE_MODULE_DOC_CONTENTS}" ] && SRC_URI="${SRC_URI} )"
58 +[[ -n ${TEXLIVE_MODULE_DOC_CONTENTS} ]] && SRC_URI="${SRC_URI} )"
59
60 # Forge source SRC_URI
61 -if [ -n "${TEXLIVE_MODULE_SRC_CONTENTS}" ] ; then
62 +if [[ -n ${TEXLIVE_MODULE_SRC_CONTENTS} ]] ; then
63 SRC_URI="${SRC_URI} source? ("
64 for i in ${TEXLIVE_MODULE_SRC_CONTENTS}; do
65 SRC_URI="${SRC_URI} mirror://gentoo/texlive-module-${i}-${PV}.${PKGEXT}"
66 @@ -122,7 +122,7 @@ IUSE="${IUSE} doc"
67 # A space separated list of Tex engines that can be made optional.
68 # e.g. "luatex luajittex"
69
70 -if [ -n "${TEXLIVE_MODULE_OPTIONAL_ENGINE}" ] ; then
71 +if [[ -n ${TEXLIVE_MODULE_OPTIONAL_ENGINE} ]] ; then
72 for engine in ${TEXLIVE_MODULE_OPTIONAL_ENGINE} ; do
73 IUSE="${IUSE} +${engine}"
74 done
75 @@ -140,10 +140,12 @@ RELOC_TARGET=texmf-dist
76 texlive-module_src_unpack() {
77 unpack ${A}
78
79 - grep RELOC tlpkg/tlpobj/* | awk '{print $2}' | sed 's#^RELOC/##' > "${T}/reloclist"
80 - { for i in $(<"${T}/reloclist"); do dirname $i; done; } | uniq > "${T}/dirlist"
81 + grep RELOC tlpkg/tlpobj/* | awk '{print $2}' | sed 's#^RELOC/##' > "${T}/reloclist" || die
82 + { for i in $(<"${T}/reloclist"); do dirname ${i}; done; } | uniq > "${T}/dirlist"
83 for i in $(<"${T}/dirlist"); do
84 - [ -d "${RELOC_TARGET}/${i}" ] || mkdir -p "${RELOC_TARGET}/${i}"
85 + if [[ ! -d ${RELOC_TARGET}/${i} ]]; then
86 + mkdir -p "${RELOC_TARGET}/${i}" || die
87 + fi
88 done
89 for i in $(<"${T}/reloclist"); do
90 mv "${i}" "${RELOC_TARGET}"/$(dirname "${i}") || die "failed to relocate ${i} to ${RELOC_TARGET}/$(dirname ${i})"
91 @@ -161,14 +163,14 @@ texlive-module_add_format() {
92 local name engine mode patterns options
93 eval $@
94 einfo "Appending to format.${PN}.cnf for $@"
95 - [ -d texmf-dist/fmtutil ] || mkdir -p texmf-dist/fmtutil
96 - [ -f texmf-dist/fmtutil/format.${PN}.cnf ] || { echo "# Generated for ${PN} by texlive-module.eclass" > texmf-dist/fmtutil/format.${PN}.cnf; }
97 - [ -n "${TEXLIVE_MODULE_OPTIONAL_ENGINE}" ] && has ${engine} ${TEXLIVE_MODULE_OPTIONAL_ENGINE} && use !${engine} && mode="disabled"
98 - if [ "${mode}" = "disabled" ]; then
99 - printf "#! " >> texmf-dist/fmtutil/format.${PN}.cnf
100 + [[ -d texmf-dist/fmtutil ]] || mkdir -p texmf-dist/fmtutil || die
101 + [[ -f texmf-dist/fmtutil/format.${PN}.cnf ]] || { echo "# Generated for ${PN} by texlive-module.eclass" > texmf-dist/fmtutil/format.${PN}.cnf; }
102 + [[ -n ${TEXLIVE_MODULE_OPTIONAL_ENGINE} ]] && has ${engine} ${TEXLIVE_MODULE_OPTIONAL_ENGINE} && use !${engine} && mode="disabled"
103 + if [[ ${mode} = disabled ]]; then
104 + printf "#! " >> texmf-dist/fmtutil/format.${PN}.cnf || die
105 fi
106 - [ -z "${patterns}" ] && patterns="-"
107 - printf "${name}\t${engine}\t${patterns}\t${options}\n" >> texmf-dist/fmtutil/format.${PN}.cnf
108 + [[ -z ${patterns} ]] && patterns="-"
109 + printf "${name}\t${engine}\t${patterns}\t${options}\n" >> texmf-dist/fmtutil/format.${PN}.cnf || die
110 }
111
112 # @FUNCTION: texlive-module_make_language_def_lines
113 @@ -180,13 +182,13 @@ texlive-module_make_language_def_lines() {
114 local lefthyphenmin righthyphenmin synonyms name file file_patterns file_exceptions luaspecial
115 eval $@
116 einfo "Generating language.def entry for $@"
117 - [ -z "$lefthyphenmin" ] && lefthyphenmin="2"
118 - [ -z "$righthyphenmin" ] && righthyphenmin="3"
119 - echo "\\addlanguage{$name}{$file}{}{$lefthyphenmin}{$righthyphenmin}" >> "${S}/language.${PN}.def"
120 - if [ -n "$synonyms" ] ; then
121 + [[ -z ${lefthyphenmin} ]] && lefthyphenmin="2"
122 + [[ -z ${righthyphenmin} ]] && righthyphenmin="3"
123 + echo "\\addlanguage{$name}{$file}{}{$lefthyphenmin}{$righthyphenmin}" >> "${S}/language.${PN}.def" || die
124 + if [[ -n ${synonyms} ]]; then
125 for i in $(echo $synonyms | tr ',' ' ') ; do
126 einfo "Generating language.def synonym $i for $@"
127 - echo "\\addlanguage{$i}{$file}{}{$lefthyphenmin}{$righthyphenmin}" >> "${S}/language.${PN}.def"
128 + echo "\\addlanguage{$i}{$file}{}{$lefthyphenmin}{$righthyphenmin}" >> "${S}/language.${PN}.def" || die
129 done
130 fi
131 }
132 @@ -200,11 +202,11 @@ texlive-module_make_language_dat_lines() {
133 local lefthyphenmin righthyphenmin synonyms name file file_patterns file_exceptions luaspecial
134 eval $@
135 einfo "Generating language.dat entry for $@"
136 - echo "$name $file" >> "${S}/language.${PN}.dat"
137 - if [ -n "$synonyms" ] ; then
138 - for i in $(echo $synonyms | tr ',' ' ') ; do
139 - einfo "Generating language.dat synonym $i for $@"
140 - echo "=$i" >> "${S}/language.${PN}.dat"
141 + echo "$name $file" >> "${S}/language.${PN}.dat" || die
142 + if [[ -n ${synonyms} ]]; then
143 + for i in $(echo ${synonyms} | tr ',' ' ') ; do
144 + einfo "Generating language.dat synonym ${i} for $@"
145 + echo "=${i}" >> "${S}/language.${PN}.dat" || die
146 done
147 fi
148 }
149 @@ -217,7 +219,7 @@ texlive-module_make_language_dat_lines() {
150 texlive-module_synonyms_to_language_lua_line() {
151 local prev=""
152 for i in $(echo $@ | tr ',' ' ') ; do
153 - printf "${prev} '%s'" $i
154 + printf "${prev} '%s'" ${i}
155 prev=","
156 done
157 }
158 @@ -233,17 +235,27 @@ texlive-module_make_language_lua_lines() {
159 local lefthyphenmin righthyphenmin synonyms name file file_patterns file_exceptions luaspecial
160 local dest="${S}/language.${PN}.dat.lua"
161 eval $@
162 - [ -z "$lefthyphenmin" ] && lefthyphenmin="2"
163 - [ -z "$righthyphenmin" ] && righthyphenmin="3"
164 + [[ -z ${lefthyphenmin} ]] && lefthyphenmin="2"
165 + [[ -z ${righthyphenmin} ]] && righthyphenmin="3"
166 einfo "Generating language.dat.lua entry for $@"
167 - printf "\t['%s'] = {\n" "$name" >> "$dest"
168 - printf "\t\tloader = '%s',\n" "$file" >> "$dest"
169 - printf "\t\tlefthyphenmin = %s,\n\t\trighthyphenmin = %s,\n" "$lefthyphenmin" "$righthyphenmin" >> "$dest"
170 - printf "\t\tsynonyms = {%s },\n" "$(texlive-module_synonyms_to_language_lua_line "$synonyms")" >> "$dest"
171 - [ -n "$file_patterns" ] && printf "\t\tpatterns = '%s',\n" "$file_patterns" >> "$dest"
172 - [ -n "$file_exceptions" ] && printf "\t\thyphenation = '%s',\n" "$file_exceptions" >> "$dest"
173 - [ -n "$luaspecial" ] && printf "\t\tspecial = '%s',\n" "$luaspecial" >> "$dest"
174 - printf "\t},\n" >> "$dest"
175 + printf "\t['%s'] = {\n" "${name}" >> "${dest}" || die
176 + printf "\t\tloader = '%s',\n" "${file}" >> "${dest}" || die
177 + printf "\t\tlefthyphenmin = %s,\n\t\trighthyphenmin = %s,\n" "${lefthyphenmin}" "${righthyphenmin}" >> "${dest}" || die
178 + printf "\t\tsynonyms = {%s },\n" "$(texlive-module_synonyms_to_language_lua_line "${synonyms}")" >> "${dest}" || die
179 +
180 + if [[ -n ${file_patterns} ]]; then
181 + printf "\t\tpatterns = '%s',\n" "${file_patterns}" >> "${dest}" || die
182 + fi
183 +
184 + if [[ -n ${file_exceptions} ]]; then
185 + printf "\t\thyphenation = '%s',\n" "${file_exceptions}" >> "${dest}" || die
186 + fi
187 +
188 + if [[ -n ${luaspecial} ]]; then
189 + printf "\t\tspecial = '%s',\n" "$luaspecial" >> "${dest}" || die
190 + fi
191 +
192 + printf "\t},\n" >> "${dest}" || die
193 }
194
195 # @FUNCTION: texlive-module_src_compile
196 @@ -263,7 +275,7 @@ texlive-module_src_compile() {
197 # later
198 for i in "${S}"/tlpkg/tlpobj/*;
199 do
200 - grep '^execute ' "${i}" | sed -e 's/^execute //' | tr ' \t' '##' >> "${T}/jobs"
201 + grep '^execute ' "${i}" | sed -e 's/^execute //' | tr ' \t' '##' >> "${T}/jobs" || die
202 done
203
204 for i in $(<"${T}/jobs");
205 @@ -271,7 +283,7 @@ texlive-module_src_compile() {
206 j="$(echo $i | tr '#' ' ')"
207 command=${j%% *}
208 parameter=${j#* }
209 - case "${command}" in
210 + case ${command} in
211 addMap)
212 echo "Map ${parameter}" >> "${S}/${PN}.cfg";;
213 addMixedMap)
214 @@ -283,14 +295,14 @@ texlive-module_src_compile() {
215 addDvipdfmMap)
216 echo "f ${parameter}" >> "${S}/${PN}-config";;
217 AddHyphen)
218 - texlive-module_make_language_def_lines "$parameter"
219 - texlive-module_make_language_dat_lines "$parameter"
220 - texlive-module_make_language_lua_lines "$parameter"
221 + texlive-module_make_language_def_lines ${parameter}
222 + texlive-module_make_language_dat_lines ${parameter}
223 + texlive-module_make_language_lua_lines ${parameter}
224 ;;
225 AddFormat)
226 - texlive-module_add_format "$parameter";;
227 + texlive-module_add_format ${parameter};;
228 BuildFormat)
229 - einfo "Format $parameter already built.";;
230 + einfo "Format ${parameter} already built.";;
231 BuildLanguageDat)
232 einfo "Language file $parameter already generated.";;
233 *)
234 @@ -304,10 +316,14 @@ texlive-module_src_compile() {
235
236 # Build format files
237 for i in texmf-dist/fmtutil/format*.cnf; do
238 - if [ -f "${i}" ]; then
239 + if [[ -f ${i} ]]; then
240 einfo "Building format ${i}"
241 - [ -d texmf-var ] || mkdir texmf-var
242 - [ -d texmf-var/web2c ] || mkdir texmf-var/web2c
243 + if [[ ! -d texmf-var ]]; then
244 + mkdir texmf-var || die
245 + fi
246 + if [[ ! -d texmf-var/web2c ]]; then
247 + mkdir texmf-var/web2c || die
248 + fi
249 VARTEXFONTS="${T}/fonts" TEXMFHOME="${S}/texmf:${S}/texmf-dist:${S}/texmf-var"\
250 env -u TEXINPUTS $fmt_call --cnffile "${i}" --fmtdir "${S}/texmf-var/web2c" --all\
251 || die "failed to build format ${i}"
252 @@ -326,50 +342,64 @@ texlive-module_src_compile() {
253
254 texlive-module_src_install() {
255 for i in texmf-dist/fmtutil/format*.cnf; do
256 - [ -f "${i}" ] && etexlinks "${i}"
257 + [[ -f ${i} ]] && etexlinks "${i}"
258 done
259
260 dodir /usr/share
261 - if use doc; then
262 - [ -d texmf-doc ] && cp -pR texmf-doc "${ED}/usr/share/"
263 + if use doc && [[ -d texmf-doc ]]; then
264 + cp -pR texmf-doc "${ED}/usr/share/" || die
265 else
266 - [ -d texmf/doc ] && rm -rf texmf/doc
267 - [ -d texmf-dist/doc ] && rm -rf texmf-dist/doc
268 + if [[ -d texmf-dist/doc ]]; then
269 + rm -rf texmf-dist/doc || die
270 + fi
271 +
272 + if [[ -d texmf/doc ]]; then
273 + rm -rf texmf/doc || die
274 + fi
275 + fi
276 +
277 + if [[ -d texmf ]]; then
278 + cp -pR texmf "${ED}/usr/share/" || die
279 + fi
280 +
281 + if [[ -d texmf-dist ]]; then
282 + cp -pR texmf-dist "${ED}/usr/share/" || die
283 fi
284
285 - [ -d texmf ] && cp -pR texmf "${ED}/usr/share/"
286 - [ -d texmf-dist ] && cp -pR texmf-dist "${ED}/usr/share/"
287 - [ -d tlpkg ] && use source && cp -pR tlpkg "${ED}/usr/share/"
288 + if [[ -d tlpkg ]] && use source; then
289 + cp -pR tlpkg "${ED}/usr/share/" || die
290 + fi
291
292 insinto /var/lib/texmf
293 - [ -d texmf-var ] && doins -r texmf-var/*
294 +
295 + [[ -d texmf-var ]] && doins -r texmf-var/.
296
297 insinto /etc/texmf/updmap.d
298 - [ -f "${S}/${PN}.cfg" ] && doins "${S}/${PN}.cfg"
299 + [[ -f ${S}/${PN}.cfg ]] && doins "${S}/${PN}.cfg"
300 insinto /etc/texmf/dvips.d
301 - [ -f "${S}/${PN}-config.ps" ] && doins "${S}/${PN}-config.ps"
302 + [[ -f ${S}/${PN}-config.ps ]] && doins "${S}/${PN}-config.ps"
303 insinto /etc/texmf/dvipdfm/config
304 - [ -f "${S}/${PN}-config" ] && doins "${S}/${PN}-config"
305 + [[ -f ${S}/${PN}-config ]] && doins "${S}/${PN}-config"
306
307 - if [ -f "${S}/language.${PN}.def" ] ; then
308 + if [[ -f ${S}/language.${PN}.def ]] ; then
309 insinto /etc/texmf/language.def.d
310 doins "${S}/language.${PN}.def"
311 fi
312
313 - if [ -f "${S}/language.${PN}.dat" ] ; then
314 + if [[ -f ${S}/language.${PN}.dat ]] ; then
315 insinto /etc/texmf/language.dat.d
316 doins "${S}/language.${PN}.dat"
317 fi
318
319 - if [ -f "${S}/language.${PN}.dat.lua" ] ; then
320 + if [[ -f ${S}/language.${PN}.dat.lua ]] ; then
321 insinto /etc/texmf/language.dat.lua.d
322 doins "${S}/language.${PN}.dat.lua"
323 fi
324
325 - [ -n "${TEXLIVE_MODULE_BINSCRIPTS}" ] && dobin_texmf_scripts ${TEXLIVE_MODULE_BINSCRIPTS}
326 - if [ -n "${TEXLIVE_MODULE_BINLINKS}" ] ; then
327 + [[ -n ${TEXLIVE_MODULE_BINSCRIPTS} ]] && dobin_texmf_scripts ${TEXLIVE_MODULE_BINSCRIPTS}
328 + if [[ -n ${TEXLIVE_MODULE_BINLINKS} ]] ; then
329 for i in ${TEXLIVE_MODULE_BINLINKS} ; do
330 - [ -f "${ED}/usr/bin/${i%:*}" ] || die "Trying to install an invalid BINLINK. This should not happen. Please file a bug."
331 + [[ -f ${ED}/usr/bin/${i%:*} ]] || die "Trying to install an invalid BINLINK. This should not happen. Please file a bug."
332 dosym ${i%:*} /usr/bin/${i#*:}
333 done
334 fi
335 @@ -386,7 +416,7 @@ texlive-module_src_install() {
336
337 texlive-module_pkg_postinst() {
338 etexmf-update
339 - [ -n "${TL_MODULE_INFORMATION}" ] && elog "${TL_MODULE_INFORMATION}"
340 + [[ -n ${TL_MODULE_INFORMATION} ]] && elog "${TL_MODULE_INFORMATION}"
341 }
342
343 # @FUNCTION: texlive-module_pkg_postrm
344 @@ -400,3 +430,5 @@ texlive-module_pkg_postrm() {
345 }
346
347 EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_postinst pkg_postrm
348 +
349 +fi