Gentoo Archives: gentoo-commits

From: "Ryan Hill (dirtyepic)" <dirtyepic@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: font.eclass
Date: Tue, 20 Apr 2010 04:07:03
Message-Id: 20100420040659.A3B752C04A@corvid.gentoo.org
1 dirtyepic 10/04/20 04:06:59
2
3 Modified: font.eclass
4 Log:
5 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.
6
7 Revision Changes Path
8 1.49 eclass/font.eclass
9
10 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/font.eclass?rev=1.49&view=markup
11 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/font.eclass?rev=1.49&content-type=text/plain
12 diff : http://sources.gentoo.org/viewcvs.py/gentoo-x86/eclass/font.eclass?r1=1.48&r2=1.49
13
14 Index: font.eclass
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo-x86/eclass/font.eclass,v
17 retrieving revision 1.48
18 retrieving revision 1.49
19 diff -u -r1.48 -r1.49
20 --- font.eclass 9 Feb 2010 17:15:08 -0000 1.48
21 +++ font.eclass 20 Apr 2010 04:06:59 -0000 1.49
22 @@ -1,6 +1,6 @@
23 # Copyright 1999-2010 Gentoo Foundation
24 # Distributed under the terms of the GNU General Public License v2
25 -# $Header: /var/cvsroot/gentoo-x86/eclass/font.eclass,v 1.48 2010/02/09 17:15:08 scarabeus Exp $
26 +# $Header: /var/cvsroot/gentoo-x86/eclass/font.eclass,v 1.49 2010/04/20 04:06:59 dirtyepic Exp $
27
28 # @ECLASS: font.eclass
29 # @MAINTAINER:
30 @@ -85,6 +85,39 @@
31 fi
32 }
33
34 +# @FUNCTION: font_cleanup_dirs
35 +# @DESCRIPTION:
36 +# Remove any font directories only containing generated files.
37 +# Runs in pkg_postrm.
38 +font_cleanup_dirs() {
39 + local genfiles="encodings.dir fonts.alias fonts.cache-1 fonts.dir fonts.scale"
40 + local d f g generated candidate otherfile
41 +
42 + ebegin "Purging empty font directories"
43 + find -L "${EROOT}"usr/share/fonts/ -type d -print0 | while read -d $'\0' d; do
44 + candidate=false
45 + otherfile=false
46 + for f in "${d}"/*; do
47 + generated=false
48 + [[ -e ${f} || -L ${f} ]] || continue
49 + for g in ${genfiles}; do
50 + if [[ ${f##*/} == ${g} ]]; then
51 + generated=true
52 + break
53 + fi
54 + done
55 + ${generated} && candidate=true || otherfile=true
56 + [[ ${candidate} == ${otherfile} ]] && break # both are true, keep the dir
57 + done
58 + if [[ ${candidate} == true && ${otherfile} == false ]]; then
59 + ebegin "Removing ${d}"
60 + rm -rf "${d}"
61 + eend $?
62 + fi
63 + done
64 + eend 0
65 +}
66 +
67 # @FUNCTION: font_src_install
68 # @DESCRIPTION:
69 # The font src_install function.
70 @@ -172,6 +205,8 @@
71 # The font pkg_postrm function.
72 # Updates global font cache
73 font_pkg_postrm() {
74 + font_cleanup_dirs
75 +
76 # unreadable font files = fontconfig segfaults
77 find "${EROOT}"usr/share/fonts/ -type f '!' -perm 0644 -print0 \
78 | xargs -0 chmod -v 0644 2>/dev/null