diff options
author | Mikle Kolyada <zlogene@gentoo.org> | 2020-01-21 12:19:22 +0300 |
---|---|---|
committer | Mikle Kolyada <zlogene@gentoo.org> | 2020-02-09 13:25:16 +0300 |
commit | 606c68a31bd9a243f28d0bbca2daf202bb40bb3a (patch) | |
tree | 0ce1b5dd06ccbd5ce5a5b52a8a1363bf8dd36ed2 /eclass | |
parent | latex-package: kill POSIX and old EAPI (diff) | |
download | gentoo-606c68a31bd9a243f28d0bbca2daf202bb40bb3a.tar.gz gentoo-606c68a31bd9a243f28d0bbca2daf202bb40bb3a.tar.bz2 gentoo-606c68a31bd9a243f28d0bbca2daf202bb40bb3a.zip |
texlive-module.eclass: kill POSIXism
Reviewed-by: David Saifert <soap@gentoo.org>
Reviewed-by: Michał Górny <mgorny@gentoo.org>
Signed-off-by: Mikle Kolyada <zlogene@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/texlive-module.eclass | 176 |
1 files changed, 104 insertions, 72 deletions
diff --git a/eclass/texlive-module.eclass b/eclass/texlive-module.eclass index 52b26cdca4dc..3f31f35e1abb 100644 --- a/eclass/texlive-module.eclass +++ b/eclass/texlive-module.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2019 Gentoo Authors +# Copyright 1999-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: texlive-module.eclass @@ -68,13 +68,13 @@ # Information to display about the package. # e.g. for enabling/disabling a feature -case "${EAPI:-0}" in - 0|1|2|3|4|5|6) - die "EAPI='${EAPI}' is not supported anymore" - ;; - *) - inherit texlive-common - ;; +if [[ -z ${_TEXLIVE_MODULE_ECLASS} ]]; then +_TEXLIVE_MODULE_ECLASS=1 + +case ${EAPI:-0} in + [0-6]) die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}" ;; + 7) inherit texlive-common ;; + *) die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" ;; esac HOMEPAGE="http://www.tug.org/texlive/" @@ -97,14 +97,14 @@ for i in ${TEXLIVE_MODULE_CONTENTS}; do done # Forge doc SRC_URI -[ -n "${TEXLIVE_MODULE_DOC_CONTENTS}" ] && SRC_URI="${SRC_URI} doc? (" +[[ -n ${TEXLIVE_MODULE_DOC_CONTENTS} ]] && SRC_URI="${SRC_URI} doc? (" for i in ${TEXLIVE_MODULE_DOC_CONTENTS}; do SRC_URI="${SRC_URI} mirror://gentoo/texlive-module-${i}-${PV}.${PKGEXT}" done -[ -n "${TEXLIVE_MODULE_DOC_CONTENTS}" ] && SRC_URI="${SRC_URI} )" +[[ -n ${TEXLIVE_MODULE_DOC_CONTENTS} ]] && SRC_URI="${SRC_URI} )" # Forge source SRC_URI -if [ -n "${TEXLIVE_MODULE_SRC_CONTENTS}" ] ; then +if [[ -n ${TEXLIVE_MODULE_SRC_CONTENTS} ]] ; then SRC_URI="${SRC_URI} source? (" for i in ${TEXLIVE_MODULE_SRC_CONTENTS}; do SRC_URI="${SRC_URI} mirror://gentoo/texlive-module-${i}-${PV}.${PKGEXT}" @@ -122,7 +122,7 @@ IUSE="${IUSE} doc" # A space separated list of Tex engines that can be made optional. # e.g. "luatex luajittex" -if [ -n "${TEXLIVE_MODULE_OPTIONAL_ENGINE}" ] ; then +if [[ -n ${TEXLIVE_MODULE_OPTIONAL_ENGINE} ]] ; then for engine in ${TEXLIVE_MODULE_OPTIONAL_ENGINE} ; do IUSE="${IUSE} +${engine}" done @@ -140,10 +140,12 @@ RELOC_TARGET=texmf-dist texlive-module_src_unpack() { unpack ${A} - grep RELOC tlpkg/tlpobj/* | awk '{print $2}' | sed 's#^RELOC/##' > "${T}/reloclist" - { for i in $(<"${T}/reloclist"); do dirname $i; done; } | uniq > "${T}/dirlist" + grep RELOC tlpkg/tlpobj/* | awk '{print $2}' | sed 's#^RELOC/##' > "${T}/reloclist" || die + { for i in $(<"${T}/reloclist"); do dirname ${i}; done; } | uniq > "${T}/dirlist" for i in $(<"${T}/dirlist"); do - [ -d "${RELOC_TARGET}/${i}" ] || mkdir -p "${RELOC_TARGET}/${i}" + if [[ ! -d ${RELOC_TARGET}/${i} ]]; then + mkdir -p "${RELOC_TARGET}/${i}" || die + fi done for i in $(<"${T}/reloclist"); do mv "${i}" "${RELOC_TARGET}"/$(dirname "${i}") || die "failed to relocate ${i} to ${RELOC_TARGET}/$(dirname ${i})" @@ -161,14 +163,14 @@ texlive-module_add_format() { local name engine mode patterns options eval $@ einfo "Appending to format.${PN}.cnf for $@" - [ -d texmf-dist/fmtutil ] || mkdir -p texmf-dist/fmtutil - [ -f texmf-dist/fmtutil/format.${PN}.cnf ] || { echo "# Generated for ${PN} by texlive-module.eclass" > texmf-dist/fmtutil/format.${PN}.cnf; } - [ -n "${TEXLIVE_MODULE_OPTIONAL_ENGINE}" ] && has ${engine} ${TEXLIVE_MODULE_OPTIONAL_ENGINE} && use !${engine} && mode="disabled" - if [ "${mode}" = "disabled" ]; then - printf "#! " >> texmf-dist/fmtutil/format.${PN}.cnf + [[ -d texmf-dist/fmtutil ]] || mkdir -p texmf-dist/fmtutil || die + [[ -f texmf-dist/fmtutil/format.${PN}.cnf ]] || { echo "# Generated for ${PN} by texlive-module.eclass" > texmf-dist/fmtutil/format.${PN}.cnf; } + [[ -n ${TEXLIVE_MODULE_OPTIONAL_ENGINE} ]] && has ${engine} ${TEXLIVE_MODULE_OPTIONAL_ENGINE} && use !${engine} && mode="disabled" + if [[ ${mode} = disabled ]]; then + printf "#! " >> texmf-dist/fmtutil/format.${PN}.cnf || die fi - [ -z "${patterns}" ] && patterns="-" - printf "${name}\t${engine}\t${patterns}\t${options}\n" >> texmf-dist/fmtutil/format.${PN}.cnf + [[ -z ${patterns} ]] && patterns="-" + printf "${name}\t${engine}\t${patterns}\t${options}\n" >> texmf-dist/fmtutil/format.${PN}.cnf || die } # @FUNCTION: texlive-module_make_language_def_lines @@ -180,13 +182,13 @@ texlive-module_make_language_def_lines() { local lefthyphenmin righthyphenmin synonyms name file file_patterns file_exceptions luaspecial eval $@ einfo "Generating language.def entry for $@" - [ -z "$lefthyphenmin" ] && lefthyphenmin="2" - [ -z "$righthyphenmin" ] && righthyphenmin="3" - echo "\\addlanguage{$name}{$file}{}{$lefthyphenmin}{$righthyphenmin}" >> "${S}/language.${PN}.def" - if [ -n "$synonyms" ] ; then + [[ -z ${lefthyphenmin} ]] && lefthyphenmin="2" + [[ -z ${righthyphenmin} ]] && righthyphenmin="3" + echo "\\addlanguage{$name}{$file}{}{$lefthyphenmin}{$righthyphenmin}" >> "${S}/language.${PN}.def" || die + if [[ -n ${synonyms} ]]; then for i in $(echo $synonyms | tr ',' ' ') ; do einfo "Generating language.def synonym $i for $@" - echo "\\addlanguage{$i}{$file}{}{$lefthyphenmin}{$righthyphenmin}" >> "${S}/language.${PN}.def" + echo "\\addlanguage{$i}{$file}{}{$lefthyphenmin}{$righthyphenmin}" >> "${S}/language.${PN}.def" || die done fi } @@ -200,11 +202,11 @@ texlive-module_make_language_dat_lines() { local lefthyphenmin righthyphenmin synonyms name file file_patterns file_exceptions luaspecial eval $@ einfo "Generating language.dat entry for $@" - echo "$name $file" >> "${S}/language.${PN}.dat" - if [ -n "$synonyms" ] ; then - for i in $(echo $synonyms | tr ',' ' ') ; do - einfo "Generating language.dat synonym $i for $@" - echo "=$i" >> "${S}/language.${PN}.dat" + echo "$name $file" >> "${S}/language.${PN}.dat" || die + if [[ -n ${synonyms} ]]; then + for i in $(echo ${synonyms} | tr ',' ' ') ; do + einfo "Generating language.dat synonym ${i} for $@" + echo "=${i}" >> "${S}/language.${PN}.dat" || die done fi } @@ -217,7 +219,7 @@ texlive-module_make_language_dat_lines() { texlive-module_synonyms_to_language_lua_line() { local prev="" for i in $(echo $@ | tr ',' ' ') ; do - printf "${prev} '%s'" $i + printf "${prev} '%s'" ${i} prev="," done } @@ -233,17 +235,27 @@ texlive-module_make_language_lua_lines() { local lefthyphenmin righthyphenmin synonyms name file file_patterns file_exceptions luaspecial local dest="${S}/language.${PN}.dat.lua" eval $@ - [ -z "$lefthyphenmin" ] && lefthyphenmin="2" - [ -z "$righthyphenmin" ] && righthyphenmin="3" + [[ -z ${lefthyphenmin} ]] && lefthyphenmin="2" + [[ -z ${righthyphenmin} ]] && righthyphenmin="3" einfo "Generating language.dat.lua entry for $@" - printf "\t['%s'] = {\n" "$name" >> "$dest" - printf "\t\tloader = '%s',\n" "$file" >> "$dest" - printf "\t\tlefthyphenmin = %s,\n\t\trighthyphenmin = %s,\n" "$lefthyphenmin" "$righthyphenmin" >> "$dest" - printf "\t\tsynonyms = {%s },\n" "$(texlive-module_synonyms_to_language_lua_line "$synonyms")" >> "$dest" - [ -n "$file_patterns" ] && printf "\t\tpatterns = '%s',\n" "$file_patterns" >> "$dest" - [ -n "$file_exceptions" ] && printf "\t\thyphenation = '%s',\n" "$file_exceptions" >> "$dest" - [ -n "$luaspecial" ] && printf "\t\tspecial = '%s',\n" "$luaspecial" >> "$dest" - printf "\t},\n" >> "$dest" + printf "\t['%s'] = {\n" "${name}" >> "${dest}" || die + printf "\t\tloader = '%s',\n" "${file}" >> "${dest}" || die + printf "\t\tlefthyphenmin = %s,\n\t\trighthyphenmin = %s,\n" "${lefthyphenmin}" "${righthyphenmin}" >> "${dest}" || die + printf "\t\tsynonyms = {%s },\n" "$(texlive-module_synonyms_to_language_lua_line "${synonyms}")" >> "${dest}" || die + + if [[ -n ${file_patterns} ]]; then + printf "\t\tpatterns = '%s',\n" "${file_patterns}" >> "${dest}" || die + fi + + if [[ -n ${file_exceptions} ]]; then + printf "\t\thyphenation = '%s',\n" "${file_exceptions}" >> "${dest}" || die + fi + + if [[ -n ${luaspecial} ]]; then + printf "\t\tspecial = '%s',\n" "$luaspecial" >> "${dest}" || die + fi + + printf "\t},\n" >> "${dest}" || die } # @FUNCTION: texlive-module_src_compile @@ -263,7 +275,7 @@ texlive-module_src_compile() { # later for i in "${S}"/tlpkg/tlpobj/*; do - grep '^execute ' "${i}" | sed -e 's/^execute //' | tr ' \t' '##' >> "${T}/jobs" + grep '^execute ' "${i}" | sed -e 's/^execute //' | tr ' \t' '##' >> "${T}/jobs" || die done for i in $(<"${T}/jobs"); @@ -271,7 +283,7 @@ texlive-module_src_compile() { j="$(echo $i | tr '#' ' ')" command=${j%% *} parameter=${j#* } - case "${command}" in + case ${command} in addMap) echo "Map ${parameter}" >> "${S}/${PN}.cfg";; addMixedMap) @@ -283,14 +295,14 @@ texlive-module_src_compile() { addDvipdfmMap) echo "f ${parameter}" >> "${S}/${PN}-config";; AddHyphen) - texlive-module_make_language_def_lines "$parameter" - texlive-module_make_language_dat_lines "$parameter" - texlive-module_make_language_lua_lines "$parameter" + texlive-module_make_language_def_lines ${parameter} + texlive-module_make_language_dat_lines ${parameter} + texlive-module_make_language_lua_lines ${parameter} ;; AddFormat) - texlive-module_add_format "$parameter";; + texlive-module_add_format ${parameter};; BuildFormat) - einfo "Format $parameter already built.";; + einfo "Format ${parameter} already built.";; BuildLanguageDat) einfo "Language file $parameter already generated.";; *) @@ -304,10 +316,14 @@ texlive-module_src_compile() { # Build format files for i in texmf-dist/fmtutil/format*.cnf; do - if [ -f "${i}" ]; then + if [[ -f ${i} ]]; then einfo "Building format ${i}" - [ -d texmf-var ] || mkdir texmf-var - [ -d texmf-var/web2c ] || mkdir texmf-var/web2c + if [[ ! -d texmf-var ]]; then + mkdir texmf-var || die + fi + if [[ ! -d texmf-var/web2c ]]; then + mkdir texmf-var/web2c || die + fi VARTEXFONTS="${T}/fonts" TEXMFHOME="${S}/texmf:${S}/texmf-dist:${S}/texmf-var"\ env -u TEXINPUTS $fmt_call --cnffile "${i}" --fmtdir "${S}/texmf-var/web2c" --all\ || die "failed to build format ${i}" @@ -326,50 +342,64 @@ texlive-module_src_compile() { texlive-module_src_install() { for i in texmf-dist/fmtutil/format*.cnf; do - [ -f "${i}" ] && etexlinks "${i}" + [[ -f ${i} ]] && etexlinks "${i}" done dodir /usr/share - if use doc; then - [ -d texmf-doc ] && cp -pR texmf-doc "${ED}/usr/share/" + if use doc && [[ -d texmf-doc ]]; then + cp -pR texmf-doc "${ED}/usr/share/" || die else - [ -d texmf/doc ] && rm -rf texmf/doc - [ -d texmf-dist/doc ] && rm -rf texmf-dist/doc + if [[ -d texmf-dist/doc ]]; then + rm -rf texmf-dist/doc || die + fi + + if [[ -d texmf/doc ]]; then + rm -rf texmf/doc || die + fi + fi + + if [[ -d texmf ]]; then + cp -pR texmf "${ED}/usr/share/" || die + fi + + if [[ -d texmf-dist ]]; then + cp -pR texmf-dist "${ED}/usr/share/" || die fi - [ -d texmf ] && cp -pR texmf "${ED}/usr/share/" - [ -d texmf-dist ] && cp -pR texmf-dist "${ED}/usr/share/" - [ -d tlpkg ] && use source && cp -pR tlpkg "${ED}/usr/share/" + if [[ -d tlpkg ]] && use source; then + cp -pR tlpkg "${ED}/usr/share/" || die + fi insinto /var/lib/texmf - [ -d texmf-var ] && doins -r texmf-var/* + + [[ -d texmf-var ]] && doins -r texmf-var/. insinto /etc/texmf/updmap.d - [ -f "${S}/${PN}.cfg" ] && doins "${S}/${PN}.cfg" + [[ -f ${S}/${PN}.cfg ]] && doins "${S}/${PN}.cfg" insinto /etc/texmf/dvips.d - [ -f "${S}/${PN}-config.ps" ] && doins "${S}/${PN}-config.ps" + [[ -f ${S}/${PN}-config.ps ]] && doins "${S}/${PN}-config.ps" insinto /etc/texmf/dvipdfm/config - [ -f "${S}/${PN}-config" ] && doins "${S}/${PN}-config" + [[ -f ${S}/${PN}-config ]] && doins "${S}/${PN}-config" - if [ -f "${S}/language.${PN}.def" ] ; then + if [[ -f ${S}/language.${PN}.def ]] ; then insinto /etc/texmf/language.def.d doins "${S}/language.${PN}.def" fi - if [ -f "${S}/language.${PN}.dat" ] ; then + if [[ -f ${S}/language.${PN}.dat ]] ; then insinto /etc/texmf/language.dat.d doins "${S}/language.${PN}.dat" fi - if [ -f "${S}/language.${PN}.dat.lua" ] ; then + if [[ -f ${S}/language.${PN}.dat.lua ]] ; then insinto /etc/texmf/language.dat.lua.d doins "${S}/language.${PN}.dat.lua" fi - [ -n "${TEXLIVE_MODULE_BINSCRIPTS}" ] && dobin_texmf_scripts ${TEXLIVE_MODULE_BINSCRIPTS} - if [ -n "${TEXLIVE_MODULE_BINLINKS}" ] ; then + [[ -n ${TEXLIVE_MODULE_BINSCRIPTS} ]] && dobin_texmf_scripts ${TEXLIVE_MODULE_BINSCRIPTS} + if [[ -n ${TEXLIVE_MODULE_BINLINKS} ]] ; then for i in ${TEXLIVE_MODULE_BINLINKS} ; do - [ -f "${ED}/usr/bin/${i%:*}" ] || die "Trying to install an invalid BINLINK. This should not happen. Please file a bug." + [[ -f ${ED}/usr/bin/${i%:*} ]] || die "Trying to install an invalid BINLINK. This should not happen. Please file a bug." dosym ${i%:*} /usr/bin/${i#*:} done fi @@ -386,7 +416,7 @@ texlive-module_src_install() { texlive-module_pkg_postinst() { etexmf-update - [ -n "${TL_MODULE_INFORMATION}" ] && elog "${TL_MODULE_INFORMATION}" + [[ -n ${TL_MODULE_INFORMATION} ]] && elog "${TL_MODULE_INFORMATION}" } # @FUNCTION: texlive-module_pkg_postrm @@ -400,3 +430,5 @@ texlive-module_pkg_postrm() { } EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_postinst pkg_postrm + +fi |