/[gentoo-x86]/eclass/font.eclass
Gentoo

Diff of /eclass/font.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.50 Revision 1.51
1# Copyright 1999-2010 Gentoo Foundation 1# Copyright 1999-2010 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/font.eclass,v 1.50 2010/05/15 05:25:32 dirtyepic Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/font.eclass,v 1.51 2010/07/09 03:44:19 dirtyepic Exp $
4 4
5# @ECLASS: font.eclass 5# @ECLASS: font.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# fonts@gentoo.org 7# fonts@gentoo.org
8# @BLURB: Eclass to make font installation uniform 8# @BLURB: Eclass to make font installation uniform
84# @FUNCTION: font_cleanup_dirs 84# @FUNCTION: font_cleanup_dirs
85# @DESCRIPTION: 85# @DESCRIPTION:
86# Remove font directories containing only generated files. 86# Remove font directories containing only generated files.
87font_cleanup_dirs() { 87font_cleanup_dirs() {
88 local genfiles="encodings.dir fonts.alias fonts.cache-1 fonts.dir fonts.scale" 88 local genfiles="encodings.dir fonts.alias fonts.cache-1 fonts.dir fonts.scale"
89 # fonts.alias isn't generated but it's a special case (see below).
89 local d f g generated candidate otherfile 90 local d f g generated candidate otherfile
90 91
91 ebegin "Purging empty font directories" 92 ebegin "Cleaning up font directories"
92 find -L "${EROOT}"usr/share/fonts/ -type d -print0 | while read -d $'\0' d; do 93 find -L "${EROOT}"usr/share/fonts/ -type d -print0 | while read -d $'\0' d; do
93 candidate=false 94 candidate=false
94 otherfile=false 95 otherfile=false
95 for f in "${d}"/*; do 96 for f in "${d}"/*; do
96 generated=false 97 generated=false
98 # make sure this is a file and not a subdir
97 [[ -e ${f} || -L ${f} ]] || continue 99 [[ -e ${f} || -L ${f} ]] || continue
98 for g in ${genfiles}; do 100 for g in ${genfiles}; do
99 if [[ ${f##*/} == ${g} ]]; then 101 if [[ ${f##*/} == ${g} ]]; then
102 # this is a generated file
100 generated=true 103 generated=true
101 break 104 break
102 fi 105 fi
103 done 106 done
107 # if the file is a generated file then we know this is a font dir (as
108 # opposed to something like encodings or util) and a candidate for
109 # removal. if it's not generated then it's an "otherfile".
104 ${generated} && candidate=true || otherfile=true 110 ${generated} && candidate=true || otherfile=true
111 # if the directory is both a candidate for removal and contains at
112 # least one "otherfile" then don't remove it.
105 [[ ${candidate} == ${otherfile} ]] && break # both are true, keep the dir 113 [[ ${candidate} == ${otherfile} ]] && break
106 done 114 done
115 # if we only have generated files, purge the directory.
107 if [[ ${candidate} == true && ${otherfile} == false ]]; then 116 if [[ ${candidate} == true && ${otherfile} == false ]]; then
108 ebegin "Removing ${d}" 117 # we don't want to remove fonts.alias files that were installed by
109 rm -rf "${d}" 118 # media-fonts/font-alias. any other fonts.alias files will have
110 eend $? 119 # already been unmerged with their packages.
120 for g in ${genfiles}; do
121 [[ ${g} != fonts.alias && ( -e ${d}/${g} || -L ${d}/${g} ) ]] \
122 && rm "${d}"/${g}
123 done
124 # if there's nothing left remove the directory
125 find "${d}" -maxdepth 0 -type d -empty -exec rmdir '{}' \;
111 fi 126 fi
112 done 127 done
113 eend 0 128 eend 0
114} 129}
115 130

Legend:
Removed from v.1.50  
changed lines
  Added in v.1.51

  ViewVC Help
Powered by ViewVC 1.1.20