mirror of
https://github.com/flatcar/scripts.git
synced 2026-02-15 20:52:34 +01:00
app-admin/eselect-fontconfig: import from portage
Just copying the ebuilds from portage/ so hopefully no functional changes. BUG=chromium-os:26016 TEST=`cbuildbot arm-generic-full` works TEST=build_packages+build_image for x86-alex boots Change-Id: I07b248cf25c2adfdcc8b4b9d5e828c838af1c979 Reviewed-on: https://gerrit.chromium.org/gerrit/15427 Reviewed-by: Matt Tennant <mtennant@chromium.org> Commit-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
parent
4ff289ea16
commit
0a388d240d
@ -0,0 +1,21 @@
|
||||
# Copyright 1999-2007 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header: /var/cvsroot/gentoo-x86/app-admin/eselect-fontconfig/eselect-fontconfig-1.0.ebuild,v 1.18 2007/12/29 11:40:34 vapier Exp $
|
||||
|
||||
DESCRIPTION="An eselect module to manage /etc/fonts/conf.d symlinks."
|
||||
HOMEPAGE="http://www.gentoo.org"
|
||||
SRC_URI=""
|
||||
|
||||
LICENSE="GPL-2"
|
||||
SLOT="0"
|
||||
KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc ~sparc-fbsd x86 ~x86-fbsd"
|
||||
IUSE=""
|
||||
|
||||
DEPEND=""
|
||||
RDEPEND="app-admin/eselect
|
||||
>=media-libs/fontconfig-2.4"
|
||||
|
||||
src_install() {
|
||||
insinto /usr/share/eselect/modules
|
||||
newins "${FILESDIR}/fontconfig.eselect-${PV}" fontconfig.eselect || die
|
||||
}
|
||||
@ -0,0 +1,205 @@
|
||||
# Copyright 1999-2007 Gentoo Foundation
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
# $Header: /var/cvsroot/gentoo-x86/app-admin/eselect-fontconfig/files/fontconfig.eselect-1.0,v 1.1 2007/07/28 02:50:13 dirtyepic Exp $
|
||||
|
||||
DESCRIPTION="Manage fontconfig /etc/fonts/conf.d/ symlinks"
|
||||
MAINTAINER="fonts@gentoo.org"
|
||||
VERSION="1.0"
|
||||
|
||||
find_targets() {
|
||||
local targets bc x i=0
|
||||
bcdirs[i]="${ROOT}/etc/fonts/conf.avail/*.conf"
|
||||
|
||||
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})"
|
||||
done
|
||||
|
||||
echo -ne ${targets} | sort -u
|
||||
}
|
||||
|
||||
is_enabled() {
|
||||
bcdir="${ROOT}/etc/fonts/conf.d"
|
||||
|
||||
[[ -e ${bcdir}/${1} ]] || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
### list action ###
|
||||
|
||||
describe_list() {
|
||||
echo "List available fontconfig .conf files"
|
||||
}
|
||||
|
||||
do_list() {
|
||||
local opts
|
||||
targets=( $(find_targets) )
|
||||
write_list_start "Available fontconfig .conf files ( $(highlight '*') is enabled ):"
|
||||
|
||||
if [[ -n "${targets[@]}" ]] ; then
|
||||
for (( n = 0 ; n < ${#targets[@]} ; ++n )) ; do
|
||||
is_enabled ${opts:-} ${targets[${n}]} && \
|
||||
targets[${n}]="${targets[${n}]} $(highlight '*')"
|
||||
done
|
||||
write_numbered_list "${targets[@]}"
|
||||
else
|
||||
write_kv_list_entry "(none found)" ""
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
### enable action ###
|
||||
|
||||
describe_enable() {
|
||||
echo "Enable specified fontconfig .conf file(s)"
|
||||
}
|
||||
|
||||
describe_enable_parameters() {
|
||||
echo "<target>"
|
||||
}
|
||||
|
||||
describe_enable_options() {
|
||||
echo "<target> : Target name or number (from 'list' action)"
|
||||
}
|
||||
|
||||
do_enable() {
|
||||
local bc bcdir="${ROOT}/etc/fonts/conf.d"
|
||||
|
||||
[[ -z ${1} ]] && die -q "You didn't specify any .conf files to enable"
|
||||
|
||||
# create directory if necessary
|
||||
if [[ ! -d ${bcdir} && -w $(dirname ${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} ]] || \
|
||||
die -q "You don't have permission to write to ${bcdir}"
|
||||
|
||||
targets=( $(find_targets) )
|
||||
|
||||
for bc in $@ ; do
|
||||
local file target=${bc}
|
||||
|
||||
is_number "${target}" && \
|
||||
target=${targets[$(( ${target} - 1 ))]}
|
||||
|
||||
[[ -z "${target}" ]] && \
|
||||
die -q "Target \"${bc}\" doesn't appear to be valid!"
|
||||
|
||||
bc=${target}
|
||||
|
||||
# ignore any unrecognized options
|
||||
[[ ${bc} == --* ]] && continue
|
||||
|
||||
# what form is the argument in?
|
||||
case "${bc}" in
|
||||
# absolute path
|
||||
/*)
|
||||
file="${ROOT}/${bc}"
|
||||
;;
|
||||
# relative path
|
||||
*/*)
|
||||
file="${ROOT}/${PWD}/${bc}"
|
||||
;;
|
||||
# no path
|
||||
*)
|
||||
# CWD
|
||||
if [[ -f ${bc} ]] ; then
|
||||
file="${ROOT}/${PWD}/${bc}"
|
||||
# assume /etc/fonts/conf.avail
|
||||
elif [[ -f ${ROOT}/etc/fonts/conf.avail/${bc} ]]
|
||||
then
|
||||
file="${ROOT}/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="${ROOT}/etc/fonts/conf.avail/${bc}"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# does it exist?
|
||||
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"
|
||||
continue
|
||||
fi
|
||||
|
||||
# finally, create the symlink
|
||||
ln -s "${file}" "${bcdir}" || \
|
||||
die -q "Failed to create symlink from '${file}' to '${bcdir}'"
|
||||
done
|
||||
}
|
||||
|
||||
### disable action ###
|
||||
|
||||
describe_disable() {
|
||||
echo "Disable specified fontconfig .conf file(s)"
|
||||
}
|
||||
|
||||
describe_disable_parameters() {
|
||||
echo "<target>"
|
||||
}
|
||||
|
||||
describe_disable_options() {
|
||||
echo "<target> : Target name or number (from 'list' action)"
|
||||
}
|
||||
|
||||
|
||||
do_disable() {
|
||||
local bc bcdir="${ROOT}/etc/fonts/conf.d"
|
||||
|
||||
[[ -z ${1} ]] && die -q "You didn't specify any .conf files to disable"
|
||||
|
||||
targets=( $(find_targets) )
|
||||
|
||||
for bc in $@ ; do
|
||||
local file target=${bc}
|
||||
|
||||
is_number "${target}" && \
|
||||
target=${targets[$(( ${target} - 1 ))]}
|
||||
|
||||
[[ -z "${target}" ]] && \
|
||||
die -q "Target \"${bc}\" doesn't appear to be valid!"
|
||||
|
||||
bc=${target}
|
||||
file="${bcdir}/${bc}"
|
||||
|
||||
# ignore any unrecognized options
|
||||
[[ ${bc} == --* ]] && continue
|
||||
|
||||
# is in installed?
|
||||
if [[ ! -e ${file} ]] ; then
|
||||
write_error_msg "${bc} is not installed"
|
||||
continue
|
||||
fi
|
||||
|
||||
# remove it if we have permissions
|
||||
if [[ -w $(dirname ${file}) ]] ; then
|
||||
rm "${file}" || die -q "Failed to remove ${file}"
|
||||
else
|
||||
die -q "You don't have permission to remove ${file}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# vim: set ft=eselect :
|
||||
Loading…
x
Reference in New Issue
Block a user