1 |
commit: dcfc5829e7c027057d8e4add3d28c9ece3ac09b5 |
2 |
Author: Mikle Kolyada <zlogene <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Jan 21 09:32:08 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=dcfc5829 |
7 |
|
8 |
texlive-common.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-common.eclass | 78 ++++++++++++++++++++++++-------------------- |
15 |
1 file changed, 42 insertions(+), 36 deletions(-) |
16 |
|
17 |
diff --git a/eclass/texlive-common.eclass b/eclass/texlive-common.eclass |
18 |
index 593e8855871..2618cba2e1a 100644 |
19 |
--- a/eclass/texlive-common.eclass |
20 |
+++ b/eclass/texlive-common.eclass |
21 |
@@ -1,4 +1,4 @@ |
22 |
-# Copyright 1999-2014 Gentoo Foundation |
23 |
+# Copyright 1999-2020 Gentoo Authors |
24 |
# Distributed under the terms of the GNU General Public License v2 |
25 |
|
26 |
# @ECLASS: texlive-common.eclass |
27 |
@@ -12,14 +12,15 @@ |
28 |
# Purpose: Provide various functions used by both texlive-core and texlive |
29 |
# modules. |
30 |
# |
31 |
-# Note that this eclass *must* not assume the presence of any standard tex tool |
32 |
- |
33 |
-case "${EAPI:-0}" in |
34 |
- 0|1|2|3|4|5|6) |
35 |
- die "EAPI='${EAPI}' is not supported anymore" |
36 |
- ;; |
37 |
- *) |
38 |
- ;; |
39 |
+# Note that this eclass *must* not assume the presence of any standard tex too |
40 |
+ |
41 |
+if [[ -z ${_TEXLIVE_COMMON_ECLASS} ]]; then |
42 |
+_TEXLIVE_COMMON_ECLASS=1 |
43 |
+ |
44 |
+case ${EAPI:-0} in |
45 |
+ [0-6]) die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}" ;; |
46 |
+ 7) ;; |
47 |
+ *) die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" ;; |
48 |
esac |
49 |
|
50 |
TEXMF_PATH=/usr/share/texmf |
51 |
@@ -35,17 +36,18 @@ TEXMF_VAR_PATH=/var/lib/texmf |
52 |
|
53 |
texlive-common_handle_config_files() { |
54 |
# Handle config files properly |
55 |
- [ -d "${ED}${TEXMF_PATH}" ] || return |
56 |
- cd "${ED}${TEXMF_PATH}" |
57 |
- for f in $(find . -name '*.cnf' -type f -o -name '*.cfg' -type f | sed -e "s:\./::g") ; do |
58 |
- if [ "${f#*config}" != "${f}" -o "${f#doc}" != "${f}" -o "${f#source}" != "${f}" -o "${f#tex}" != "${f}" ] ; then |
59 |
+ [[ -d ${ED}${TEXMF_PATH} ]] || return |
60 |
+ cd "${ED}${TEXMF_PATH}" || die |
61 |
+ |
62 |
+ while read -r -d '' i; do |
63 |
+ if [[ ${f#*config} != ${f} || ${f#doc} != ${f} || ${f#source} != ${f} || ${f#tex} != ${f} ]] ; then |
64 |
continue |
65 |
fi |
66 |
dodir /etc/texmf/$(dirname ${f}).d |
67 |
einfo "Moving (and symlinking) ${EPREFIX}${TEXMF_PATH}/${f} to ${EPREFIX}/etc/texmf/$(dirname ${f}).d" |
68 |
mv "${ED}/${TEXMF_PATH}/${f}" "${ED}/etc/texmf/$(dirname ${f}).d" || die "mv ${f} failed." |
69 |
dosym /etc/texmf/$(dirname ${f}).d/$(basename ${f}) ${TEXMF_PATH}/${f} |
70 |
- done |
71 |
+ done < <(find -name '*.cnf' -type f -o -name '*.cfg' -type f | sed -e "s:\./::g") |
72 |
} |
73 |
|
74 |
# @FUNCTION: texlive-common_is_file_present_in_texmf |
75 |
@@ -54,10 +56,14 @@ texlive-common_handle_config_files() { |
76 |
# Call it from the directory containing texmf and texmf-dist |
77 |
|
78 |
texlive-common_is_file_present_in_texmf() { |
79 |
- local mark="${T}/$1.found" |
80 |
- [ -d texmf ] && find texmf -name $1 -exec touch "${mark}" \; |
81 |
- [ -d texmf-dist ] && find texmf-dist -name $1 -exec touch "${mark}" \; |
82 |
- [ -f "${mark}" ] |
83 |
+ local mark="${T}/${1}.found" |
84 |
+ if [[ -d texmf ]]; then |
85 |
+ find texmf -name ${1} -exec touch ${mark} {} + || die |
86 |
+ fi |
87 |
+ |
88 |
+ if [[ -d texmf-dist ]]; then |
89 |
+ find texmf-dist -name ${1} -exec touch ${mark} {} + || die |
90 |
+ fi |
91 |
} |
92 |
|
93 |
# @FUNCTION: texlive-common_do_symlinks |
94 |
@@ -73,24 +79,22 @@ texlive-common_is_file_present_in_texmf() { |
95 |
# also do the fmtutil file parsing. |
96 |
|
97 |
texlive-common_do_symlinks() { |
98 |
- while [ $# != 0 ]; do |
99 |
- case $1 in |
100 |
+ while [[ ${#} != 0 ]]; do |
101 |
+ case ${1} in |
102 |
cont-??|metafun|mptopdf) |
103 |
- einfo "Symlink $1 skipped (special case)" |
104 |
+ einfo "Symlink ${1} skipped (special case)" |
105 |
;; |
106 |
mf) |
107 |
- einfo "Symlink $1 -> $2 skipped (texlive-core takes care of it)" |
108 |
+ einfo "Symlink ${1} -> ${2} skipped (texlive-core takes care of it)" |
109 |
;; |
110 |
*) |
111 |
- if [ $1 = $2 ]; |
112 |
- then |
113 |
- einfo "Symlink $1 -> $2 skipped" |
114 |
- elif [ -e "${ED}/usr/bin/$1" -o -L "${ED}/usr/bin/$1" ]; |
115 |
- then |
116 |
- einfo "Symlink $1 skipped (file exists)" |
117 |
+ if [[ ${1} == ${2} ]]; then |
118 |
+ einfo "Symlink ${1} -> ${2} skipped" |
119 |
+ elif [[ -e ${ED}/usr/bin/${1} || -L ${ED}/usr/bin/${1} ]]; then |
120 |
+ einfo "Symlink ${1} skipped (file exists)" |
121 |
else |
122 |
- einfo "Making symlink from $1 to $2" |
123 |
- dosym $2 /usr/bin/$1 |
124 |
+ einfo "Making symlink from ${1} to ${2}" |
125 |
+ dosym ${2} /usr/bin/${1} |
126 |
fi |
127 |
;; |
128 |
esac |
129 |
@@ -123,11 +127,11 @@ etexlinks() { |
130 |
# correctly set for the file that it will point to. |
131 |
|
132 |
dobin_texmf_scripts() { |
133 |
- while [ $# -gt 0 ] ; do |
134 |
+ while [[ ${#} -gt 0 ]] ; do |
135 |
local trg=$(basename ${1} | sed 's,\.[^/]*$,,' | tr '[:upper:]' '[:lower:]') |
136 |
einfo "Installing ${1} as ${trg} bin wrapper" |
137 |
- [ -x "${ED}/usr/share/${1}" ] || die "Trying to install a non existing or non executable symlink to /usr/bin: ${1}" |
138 |
- dosym ../share/${1} /usr/bin/${trg} || die "failed to install ${1} as $trg" |
139 |
+ [[ -x ${ED}/usr/share/${1} ]] || die "Trying to install a non existing or non executable symlink to /usr/bin: ${1}" |
140 |
+ dosym ../share/${1} /usr/bin/${trg} |
141 |
shift |
142 |
done |
143 |
} |
144 |
@@ -140,7 +144,7 @@ dobin_texmf_scripts() { |
145 |
|
146 |
etexmf-update() { |
147 |
if has_version 'app-text/texlive-core' ; then |
148 |
- if [ -z "${ROOT%/}" ] && [ -x "${EPREFIX}"/usr/sbin/texmf-update ] ; then |
149 |
+ if [[ -z ${ROOT} && -x "${EPREFIX}"/usr/sbin/texmf-update ]] ; then |
150 |
"${EPREFIX}"/usr/sbin/texmf-update |
151 |
else |
152 |
ewarn "Cannot run texmf-update for some reason." |
153 |
@@ -158,9 +162,9 @@ etexmf-update() { |
154 |
|
155 |
efmtutil-sys() { |
156 |
if has_version 'app-text/texlive-core' ; then |
157 |
- if [ -z "${ROOT%/}" ] && [ -x "${EPREFIX}"/usr/bin/fmtutil-sys ] ; then |
158 |
+ if [[ -z ${ROOT} && -x "${EPREFIX}"/usr/bin/fmtutil-sys ]] ; then |
159 |
einfo "Rebuilding formats" |
160 |
- "${EPREFIX}"/usr/bin/fmtutil-sys --all &> /dev/null |
161 |
+ "${EPREFIX}"/usr/bin/fmtutil-sys --all &> /dev/null || die |
162 |
else |
163 |
ewarn "Cannot run fmtutil-sys for some reason." |
164 |
ewarn "Your formats might be inconsistent with your installed ${PN} version" |
165 |
@@ -168,3 +172,5 @@ efmtutil-sys() { |
166 |
fi |
167 |
fi |
168 |
} |
169 |
+ |
170 |
+fi |