summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Michael <fedora.dm0@gmail.com>2021-07-01 20:42:33 +0100
committerSam James <sam@gentoo.org>2022-04-03 01:27:54 +0100
commitf57b6d44c764b18c1bf9c8ceb0574aa7103f760d (patch)
tree52f21826452b46dfb91e4bf7f2b2c8710feb205f
parentImport 1.1 (diff)
downloadeselect-fontconfig-master.tar.gz
eselect-fontconfig-master.tar.bz2
eselect-fontconfig-master.zip
Use relative symlinksHEAD20220403master
This eselect module writes its links with absolute paths which include ${EROOT} prefixes. This results in broken links when using the file system mounted at ${ROOT} natively. The main fix is using the --relative argument to ln, which has been available for about a decade in coreutils. (If that's not portable enough, I'd recommend dropping the ES_FONTCONFIG_DIRS variable so paths are predictable. It doesn't appear to be documented anywhere anyway.) The file also updates syntax a bit to simplify it and adhere to modern Gentoo style conventions. I dropped its behavior of overriding system files if a file with the same name is in the current working directory, since it seems dangerous. That behavior could still be used by prefixing files with the "./" path (but I'd prefer to drop support for specifying directories as well so it only accepts the file names/indices as they are printed). [sam: reformatted/gitified git message from Bugzilla comment] Closes: https://bugs.gentoo.org/799758 Signed-off-by: David Michael <fedora.dm0@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r--fontconfig.eselect106
1 files changed, 40 insertions, 66 deletions
diff --git a/fontconfig.eselect b/fontconfig.eselect
index cb3e25a..d7f90f0 100644
--- a/fontconfig.eselect
+++ b/fontconfig.eselect
@@ -1,36 +1,26 @@
# -*-eselect-*- vim: ft=eselect
-# Copyright 1999-2009 Gentoo Foundation
+# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
-# $Id: fontconfig.eselect 728 2009-11-14 21:08:28Z dirtyepic $
-DESCRIPTION="Manage fontconfig /etc/fonts/conf.d/ symlinks"
+DESCRIPTION="Manage fontconfig /etc/fonts/conf.d symlinks"
AUTHOR="cardoe@gentoo.org"
MAINTAINER="fonts@gentoo.org"
-SVN_DATE='$Date: 2009-11-14 15:08:28 -0600 (Sat, 14 Nov 2009) $'
-VERSION=$(svn_date_to_version "${SVN_DATE}")
+VERSION=20220403
find_targets() {
- local targets bc x i=0
- bcdirs[i]="${EROOT}/etc/fonts/conf.avail/*.conf"
+ local bc bcdirs=()
- if [[ -n "${ES_FONTCONFIG_DIRS}" ]] ; then
- for x in ${ES_FONTCONFIG_DIRS} ; do
- bcdirs[$((++i))]="${x}/*"
- done
- fi
-
- for bc in ${bcdirs[@]} ; do
- [[ -e ${bc} && ${bc} != *~ ]] && targets="${targets}\n$(basename ${bc})"
+ for bc in /etc/fonts/conf.avail ${ES_FONTCONFIG_DIRS}; do
+ bcdirs+=("${EROOT}${bc}/*.conf")
done
- echo -ne ${targets} | sort -u
+ for bc in ${bcdirs[@]}; do
+ [[ -e ${bc} ]] && echo "${bc##*/}"
+ done | sort -u
}
is_enabled() {
- bcdir="${EROOT}/etc/fonts/conf.d"
-
- [[ -e ${bcdir}/${1} ]] || return 1
- return 0
+ [[ -e ${EROOT}/etc/fonts/conf.d/${1} ]]
}
### list action ###
@@ -40,18 +30,15 @@ describe_list() {
}
do_list() {
- local n
- targets=( $(find_targets) )
+ local n targets=($(find_targets))
write_list_start \
"Available fontconfig .conf files ($(highlight '*') is enabled):"
for (( n = 0; n < ${#targets[@]}; ++n )); do
- is_enabled ${targets[n]} \
- && targets[n]=$(highlight_marker "${targets[n]}")
+ is_enabled "${targets[n]}" &&
+ targets[n]=$(highlight_marker "${targets[n]}")
done
write_numbered_list -m "(none found)" "${targets[@]}"
-
- return 0
}
### enable action ###
@@ -69,30 +56,30 @@ describe_enable_options() {
}
do_enable() {
- local bc bcdir="${EROOT}/etc/fonts/conf.d"
+ local bc bcdir="${EROOT}/etc/fonts/conf.d" x
[[ -z ${1} ]] && die -q "You didn't specify any .conf files to enable"
# create directory if necessary
- if [[ ! -d ${bcdir} && -w $(dirname ${bcdir}) ]] ; then
+ if [[ ! -d ${bcdir} && -w ${bcdir%/*} ]] ; then
mkdir ${bcdir} || die -q "Failed to create ${bcdir}"
elif [[ ! -d ${bcdir} ]] ; then
die -q "You don't have permission to create ${bcdir}"
fi
# make sure we have proper permissions
- [[ -w ${bcdir} ]] || \
+ [[ -w ${bcdir} ]] ||
die -q "You don't have permission to write to ${bcdir}"
- targets=( $(find_targets) )
+ local targets=($(find_targets))
- for bc in $@ ; do
+ for bc; do
local file target=${bc}
- is_number "${target}" && \
- target=${targets[$(( ${target} - 1 ))]}
+ is_number "${target}" &&
+ target=${targets[${target} - 1]}
- [[ -z "${target}" ]] && \
+ [[ -z ${target} ]] &&
die -q "Target \"${bc}\" doesn't appear to be valid!"
bc=${target}
@@ -101,52 +88,39 @@ do_enable() {
[[ ${bc} == --* ]] && continue
# what form is the argument in?
- case "${bc}" in
+ case ${bc} in
# absolute path
/*)
- file="${EROOT}/${bc}"
+ file="${EROOT}${bc}"
;;
# relative path
*/*)
- file="${EROOT}/${PWD}/${bc}"
+ file="${EROOT}${PWD}/${bc}"
;;
# no path
*)
- # CWD
- if [[ -f ${bc} ]] ; then
- file="${EROOT}/${PWD}/${bc}"
- # assume /etc/fonts/conf.avail
- elif [[ -f ${EROOT}/etc/fonts/conf.avail/${bc} ]]
- then
- file="${EROOT}/etc/fonts/conf.avail/${bc}"
- else
- if [[ -n "${ES_FONTCONFIG_DIRS}" ]] ; then
- for x in ${ES_FONTCONFIG_DIRS} ; do
- [[ -f ${x}/${bc} ]] && file="${x}/${bc}"
- done
- fi
-
- [[ -e ${file} ]] || \
- file="${EROOT}/etc/fonts/conf.avail/${bc}"
- fi
+ [[ -n ${ES_FONTCONFIG_DIRS} ]] &&
+ for x in ${ES_FONTCONFIG_DIRS}; do
+ [[ -f ${EROOT}${x}/${bc} ]] && file="${EROOT}${x}/${bc}" && break
+ done || file="${EROOT}/etc/fonts/conf.avail/${bc}"
;;
esac
# does it exist?
- if [[ ! -e ${file} ]] ; then
+ if [[ ! -e ${file} ]]; then
write_error_msg "${file} doesn't exist"
continue
fi
# already installed?
- if [[ -e ${bcdir}/$(basename ${bc}) ]] ; then
- write_error_msg "$(basename ${bc}) is already installed"
+ if [[ -e ${bcdir}/${bc##*/} ]]; then
+ write_error_msg "${bc##*/} is already installed"
continue
fi
# finally, create the symlink
- ln -s "${file}" "${bcdir}" || \
- die -q "Failed to create symlink from '${file}' to '${bcdir}'"
+ ln -rs "${file}" "${bcdir}" ||
+ die -q "Failed to create symlink from \"${file}\" to \"${bcdir}\""
done
}
@@ -170,15 +144,15 @@ do_disable() {
[[ -z ${1} ]] && die -q "You didn't specify any .conf files to disable"
- targets=( $(find_targets) )
+ local targets=($(find_targets))
- for bc in $@ ; do
+ for bc; do
local file target=${bc}
- is_number "${target}" && \
- target=${targets[$(( ${target} - 1 ))]}
+ is_number "${target}" &&
+ target=${targets[${target} - 1]}
- [[ -z "${target}" ]] && \
+ [[ -z ${target} ]] &&
die -q "Target \"${bc}\" doesn't appear to be valid!"
bc=${target}
@@ -188,13 +162,13 @@ do_disable() {
[[ ${bc} == --* ]] && continue
# is in installed?
- if [[ ! -e ${file} ]] ; then
+ if [[ ! -e ${file} ]]; then
write_error_msg "${bc} is not installed"
continue
fi
# remove it if we have permissions
- if [[ -w $(dirname ${file}) ]] ; then
+ if [[ -w ${file%/*} ]]; then
rm "${file}" || die -q "Failed to remove ${file}"
else
die -q "You don't have permission to remove ${file}"