diff options
author | Ryan Hill <dirtyepic@gentoo.org> | 2010-04-20 04:06:59 +0000 |
---|---|---|
committer | Ryan Hill <dirtyepic@gentoo.org> | 2010-04-20 04:06:59 +0000 |
commit | a936428f0ad131ee7b01910ff50baa32c9c4e879 (patch) | |
tree | e2b89d52723629f6c981091dbdfcf2b3c4fa8d3e /eclass | |
parent | Drop ppc, ppc64 and sparc because of missing keywords in udisks. (diff) | |
download | gentoo-2-a936428f0ad131ee7b01910ff50baa32c9c4e879.tar.gz gentoo-2-a936428f0ad131ee7b01910ff50baa32c9c4e879.tar.bz2 gentoo-2-a936428f0ad131ee7b01910ff50baa32c9c4e879.zip |
Add new function font_cleanup_dirs, called in pkg_postrm, to clean up font directories that only contain generated files (bug #315369). Based on code taken from xorg-2.eclass. Note that due to portage caching pkg_postrm, currently installed font packages will not trigger this code until the second time they are reinstalled.
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/font.eclass | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/eclass/font.eclass b/eclass/font.eclass index 431a318686b9..edf83312eca4 100644 --- a/eclass/font.eclass +++ b/eclass/font.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/font.eclass,v 1.48 2010/02/09 17:15:08 scarabeus Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/font.eclass,v 1.49 2010/04/20 04:06:59 dirtyepic Exp $ # @ECLASS: font.eclass # @MAINTAINER: @@ -85,6 +85,39 @@ font_fontconfig() { fi } +# @FUNCTION: font_cleanup_dirs +# @DESCRIPTION: +# Remove any font directories only containing generated files. +# Runs in pkg_postrm. +font_cleanup_dirs() { + local genfiles="encodings.dir fonts.alias fonts.cache-1 fonts.dir fonts.scale" + local d f g generated candidate otherfile + + ebegin "Purging empty font directories" + find -L "${EROOT}"usr/share/fonts/ -type d -print0 | while read -d $'\0' d; do + candidate=false + otherfile=false + for f in "${d}"/*; do + generated=false + [[ -e ${f} || -L ${f} ]] || continue + for g in ${genfiles}; do + if [[ ${f##*/} == ${g} ]]; then + generated=true + break + fi + done + ${generated} && candidate=true || otherfile=true + [[ ${candidate} == ${otherfile} ]] && break # both are true, keep the dir + done + if [[ ${candidate} == true && ${otherfile} == false ]]; then + ebegin "Removing ${d}" + rm -rf "${d}" + eend $? + fi + done + eend 0 +} + # @FUNCTION: font_src_install # @DESCRIPTION: # The font src_install function. @@ -172,6 +205,8 @@ font_pkg_postinst() { # The font pkg_postrm function. # Updates global font cache font_pkg_postrm() { + font_cleanup_dirs + # unreadable font files = fontconfig segfaults find "${EROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \ | xargs -0 chmod -v 0644 2>/dev/null |