-# Copyright 1999-2019 Gentoo Authors
+# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: font.eclass
# @MAINTAINER:
# fonts@gentoo.org
-# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7
+# @SUPPORTED_EAPIS: 5 6 7
# @BLURB: Eclass to make font installation uniform
case ${EAPI:-0} in
- 0|1|2|3|4|5|6) inherit eutils ;;
+ [56]) inherit eutils ;;
7) ;;
*) die "EAPI ${EAPI} is not supported by font.eclass." ;;
esac
+if [[ ! ${_FONT_ECLASS} ]]; then
+
EXPORT_FUNCTIONS pkg_setup src_install pkg_postinst pkg_postrm
# @ECLASS-VARIABLE: FONT_SUFFIX
FONT_SUFFIX=${FONT_SUFFIX:-}
# @ECLASS-VARIABLE: FONT_S
-# @REQUIRED
+# @DEFAULT_UNSET
# @DESCRIPTION:
-# Space delimited list of directories containing the fonts.
-FONT_S=${FONT_S:-${S}}
+# Directory containing the fonts. If unset, ${S} is used instead.
+# Can also be an array of several directories.
# @ECLASS-VARIABLE: FONT_PN
# @DESCRIPTION:
-e ${EPREFIX}/usr/share/fonts/encodings \
-e ${EPREFIX}/usr/share/fonts/encodings/large \
"${ED%/}/${FONTDIR}/${1//${S}/}" || eerror "failed to create fonts.dir"
- if [[ -e fonts.alias ]]; then
- doins fonts.alias || die "failed to install fonts.alias" # TODO old EAPI cleanup
- fi
+ [[ -e fonts.alias ]] && doins fonts.alias
fi
}
if [[ -n ${FONT_CONF[@]} ]]; then
insinto /etc/fonts/conf.avail/
for conffile in "${FONT_CONF[@]}"; do
- if [[ -e ${conffile} ]]; then
- doins ${conffile} || die "failed to install conf file" # TODO old EAPI cleanup
- fi
+ [[ -e ${conffile} ]] && doins "${conffile}"
done
fi
}
# @FUNCTION: font_pkg_setup
# @DESCRIPTION:
# The font pkg_setup function.
-# Collision protection and Prefix compat for eapi < 3.
+# Collision protection
font_pkg_setup() {
- # Prefix compat
- case ${EAPI:-0} in
- 0|1|2)
- if ! use prefix; then
- EPREFIX=
- ED=${D}
- EROOT=${ROOT}
- [[ ${EROOT} = */ ]] || EROOT+="/"
- fi
- ;;
- esac
-
# make sure we get no collisions
# setup is not the nicest place, but preinst doesn't cut it
if [[ -e "${EROOT%/}/${FONTDIR}/fonts.cache-1" ]] ; then
font_src_install() {
local dir suffix commondoc
- set -- ${FONT_S:-${S}}
- if [[ $# -gt 1 ]]; then
- # if we have multiple FONT_S elements then we want to recreate the dir
- # structure
+ if [[ $(declare -p FONT_S 2>/dev/null) == "declare -a"* ]]; then
+ # recreate the directory structure if FONT_S is an array
+ for dir in "${FONT_S[@]}"; do
+ pushd "${dir}" > /dev/null || die "pushd ${dir} failed"
+ insinto "${FONTDIR}/${dir#"${S}"}"
+ for suffix in ${FONT_SUFFIX}; do
+ doins *.${suffix}
+ done
+ font_xfont_config "${dir}"
+ popd > /dev/null || die
+ done
+ elif [[ ${FONT_S/[[:space:]]} != "${FONT_S}" ]]; then
+ # backwards compatibility code, can be removed after 2021-02-14
+ eqawarn "Using a space-separated list for FONT_S is deprecated."
+ eqawarn "Use a bash array instead if there are multiple directories."
for dir in ${FONT_S}; do
- pushd "${dir}" > /dev/null
+ pushd "${dir}" > /dev/null || die "pushd ${dir} failed"
insinto "${FONTDIR}/${dir//${S}/}"
for suffix in ${FONT_SUFFIX}; do
- doins *.${suffix} || die "font installation failed" # TODO old EAPI cleanup
+ doins *.${suffix}
done
font_xfont_config "${dir}"
- popd > /dev/null
+ popd > /dev/null || die
done
else
- pushd "${FONT_S}" > /dev/null
+ pushd "${FONT_S:-${S}}" > /dev/null \
+ || die "pushd ${FONT_S:-${S}} failed"
insinto "${FONTDIR}"
for suffix in ${FONT_SUFFIX}; do
- doins *.${suffix} || die "font installation failed" # TODO old EAPI cleanup
+ doins *.${suffix}
done
font_xfont_config
- popd > /dev/null
+ popd > /dev/null || die
fi
font_fontconfig
- [[ -n ${DOCS} ]] && { dodoc ${DOCS} || die "docs installation failed" ; } # TODO old EAPI cleanup
+ einstalldocs
# install common docs
- for commondoc in COPYRIGHT README{,.md,.txt} NEWS AUTHORS BUGS ChangeLog FONTLOG.txt; do
+ for commondoc in COPYRIGHT FONTLOG.txt; do
[[ -s ${commondoc} ]] && dodoc ${commondoc}
done
}
elog "The following fontconfig configuration files have been installed:"
elog
for conffile in "${FONT_CONF[@]}"; do
- if [[ -e "${EROOT%/}"/etc/fonts/conf.avail/${conffile##*/} ]]; then
+ [[ -e "${EROOT%/}"/etc/fonts/conf.avail/${conffile##*/} ]] &&
elog " ${conffile##*/}"
- fi
done
elog
elog "Use \`eselect fontconfig\` to enable/disable them."
font_cleanup_dirs
_update_fontcache
}
+
+_FONT_ECLASS=1
+fi