# Copyright 1999-2008 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit config output DESCRIPTION="Manage the /etc/pango/pango.modules file" MAINTAINER="gnome@gentoo.org" VERSION=0.1 # Partially based on env.eselect MIME_WHITELIST="text/plain text/x-makefile" is_envfile() { local mime envfile=${1} # Make sure it is a file and no backup file [[ -f ${envfile} ]] || return 1 [[ -n ${envfile##*~} ]] || return 1 [[ ${envfile##*.} != bak ]] || return 1 mime=$(file -i ${envfile} | cut -d ' ' -f 2 | sed -e 's/;$//') if ! has ${mime} ${MIME_WHITELIST} ; then echo "Skipping non-text file ${envfile}." return 1 fi return 0 } update_pango_modules() { local dirsuffix=${1} local pango_modules=/etc/pango${dirsuffix}/pango.modules local -a envfiles modulespath envfiles=( /etc/env.d/pango${dirsuffix}/* ) for envfile in ${envfiles[@]} ; do if [[ -d ${envfile} ]]; then update_pango_modules ${envfile#/etc/env.d/pango} continue fi is_envfile ${envfile} || continue modulespath[${#modulespath[@]}]="$(load_config ${envfile} ModulesPath)" done if [[ -z ${modulespath[@]} ]]; then if [[ -f ${pango_modules} ]]; then echo "Removing ${pango_modules}..." rm ${pango_modules} fi return fi local tmprc="$(mktemp /tmp/pangorc.XXXXXX)" [[ -n ${tmprc} ]] || die "Could not create temporary file" cat <<-EOF >${tmprc} [Pango] ModulesPath=$(IFS=:; echo "${modulespath[*]}") EOF local querymodules if [[ $(uname -m) == x86_64 && ${dirsuffix} == /i?86-* ]]; then querymodules=pango-querymodules32 else querymodules=pango-querymodules fi if [[ -z $(type -P ${querymodules}) ]]; then write_warning_msg "${querymodules} not found, removing ${pango_modules}" rm ${pango_modules} return fi mkdir -p ${pango_modules%/*} echo "Regenerating ${pango_modules}..." PANGO_RC_FILE=${tmprc} ${querymodules} >${pango_modules} rm -f ${tmprc} } ### update action describe_update() { echo "Update /etc/pango/pango.modules from all scripts in /etc/env.d/pango/" } do_update() { [[ ${ROOT:-/} != / ]] && die 'Sorry, ${ROOT} != / is not supported' update_pango_modules } # vim: ft=eselect