summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorRyan Hill <rhill@gentoo.org>2010-04-20 04:06:59 +0000
committerRyan Hill <rhill@gentoo.org>2010-04-20 04:06:59 +0000
commitc2d811fb1558925d54470c21d18731569ea4024a (patch)
treebbed89bb94514691cdcf7d1b7a3ad69b5e3332d6 /eclass
parentDrop ppc, ppc64 and sparc because of missing keywords in udisks. (diff)
downloadhistorical-c2d811fb1558925d54470c21d18731569ea4024a.tar.gz
historical-c2d811fb1558925d54470c21d18731569ea4024a.tar.bz2
historical-c2d811fb1558925d54470c21d18731569ea4024a.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.eclass37
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