1 |
ulm 15/03/31 16:48:42 |
2 |
|
3 |
Added: fontconfig.eselect-1.0 |
4 |
Log: |
5 |
Move package from app-admin to app-eselect category. |
6 |
|
7 |
(Portage version: 2.2.18/cvs/Linux x86_64, RepoMan options: --force, signed Manifest commit with key 9433907D693FB5B8!) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 app-eselect/eselect-fontconfig/files/fontconfig.eselect-1.0 |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-fontconfig/files/fontconfig.eselect-1.0?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-fontconfig/files/fontconfig.eselect-1.0?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: fontconfig.eselect-1.0 |
16 |
=================================================================== |
17 |
# Copyright 1999-2015 Gentoo Foundation |
18 |
# Distributed under the terms of the GNU General Public License v2 |
19 |
# $Header: /var/cvsroot/gentoo-x86/app-eselect/eselect-fontconfig/files/fontconfig.eselect-1.0,v 1.1 2015/03/31 16:48:42 ulm Exp $ |
20 |
|
21 |
DESCRIPTION="Manage fontconfig /etc/fonts/conf.d/ symlinks" |
22 |
MAINTAINER="fonts@g.o" |
23 |
VERSION="1.0" |
24 |
|
25 |
find_targets() { |
26 |
local targets bc x i=0 |
27 |
bcdirs[i]="${ROOT}/etc/fonts/conf.avail/*.conf" |
28 |
|
29 |
if [[ -n "${ES_FONTCONFIG_DIRS}" ]] ; then |
30 |
for x in ${ES_FONTCONFIG_DIRS} ; do |
31 |
bcdirs[$((++i))]="${x}/*" |
32 |
done |
33 |
fi |
34 |
|
35 |
for bc in ${bcdirs[@]} ; do |
36 |
[[ -e ${bc} && ${bc} != *~ ]] && targets="${targets}\n$(basename ${bc})" |
37 |
done |
38 |
|
39 |
echo -ne ${targets} | sort -u |
40 |
} |
41 |
|
42 |
is_enabled() { |
43 |
bcdir="${ROOT}/etc/fonts/conf.d" |
44 |
|
45 |
[[ -e ${bcdir}/${1} ]] || return 1 |
46 |
return 0 |
47 |
} |
48 |
|
49 |
### list action ### |
50 |
|
51 |
describe_list() { |
52 |
echo "List available fontconfig .conf files" |
53 |
} |
54 |
|
55 |
do_list() { |
56 |
local opts |
57 |
targets=( $(find_targets) ) |
58 |
write_list_start "Available fontconfig .conf files ( $(highlight '*') is enabled ):" |
59 |
|
60 |
if [[ -n "${targets[@]}" ]] ; then |
61 |
for (( n = 0 ; n < ${#targets[@]} ; ++n )) ; do |
62 |
is_enabled ${opts:-} ${targets[${n}]} && \ |
63 |
targets[${n}]="${targets[${n}]} $(highlight '*')" |
64 |
done |
65 |
write_numbered_list "${targets[@]}" |
66 |
else |
67 |
write_kv_list_entry "(none found)" "" |
68 |
fi |
69 |
|
70 |
return 0 |
71 |
} |
72 |
|
73 |
### enable action ### |
74 |
|
75 |
describe_enable() { |
76 |
echo "Enable specified fontconfig .conf file(s)" |
77 |
} |
78 |
|
79 |
describe_enable_parameters() { |
80 |
echo "<target>" |
81 |
} |
82 |
|
83 |
describe_enable_options() { |
84 |
echo "<target> : Target name or number (from 'list' action)" |
85 |
} |
86 |
|
87 |
do_enable() { |
88 |
local bc bcdir="${ROOT}/etc/fonts/conf.d" |
89 |
|
90 |
[[ -z ${1} ]] && die -q "You didn't specify any .conf files to enable" |
91 |
|
92 |
# create directory if necessary |
93 |
if [[ ! -d ${bcdir} && -w $(dirname ${bcdir}) ]] ; then |
94 |
mkdir ${bcdir} || die -q "Failed to create ${bcdir}" |
95 |
elif [[ ! -d ${bcdir} ]] ; then |
96 |
die -q "You don't have permission to create ${bcdir}" |
97 |
fi |
98 |
|
99 |
# make sure we have proper permissions |
100 |
[[ -w ${bcdir} ]] || \ |
101 |
die -q "You don't have permission to write to ${bcdir}" |
102 |
|
103 |
targets=( $(find_targets) ) |
104 |
|
105 |
for bc in $@ ; do |
106 |
local file target=${bc} |
107 |
|
108 |
is_number "${target}" && \ |
109 |
target=${targets[$(( ${target} - 1 ))]} |
110 |
|
111 |
[[ -z "${target}" ]] && \ |
112 |
die -q "Target \"${bc}\" doesn't appear to be valid!" |
113 |
|
114 |
bc=${target} |
115 |
|
116 |
# ignore any unrecognized options |
117 |
[[ ${bc} == --* ]] && continue |
118 |
|
119 |
# what form is the argument in? |
120 |
case "${bc}" in |
121 |
# absolute path |
122 |
/*) |
123 |
file="${ROOT}/${bc}" |
124 |
;; |
125 |
# relative path |
126 |
*/*) |
127 |
file="${ROOT}/${PWD}/${bc}" |
128 |
;; |
129 |
# no path |
130 |
*) |
131 |
# CWD |
132 |
if [[ -f ${bc} ]] ; then |
133 |
file="${ROOT}/${PWD}/${bc}" |
134 |
# assume /etc/fonts/conf.avail |
135 |
elif [[ -f ${ROOT}/etc/fonts/conf.avail/${bc} ]] |
136 |
then |
137 |
file="${ROOT}/etc/fonts/conf.avail/${bc}" |
138 |
else |
139 |
if [[ -n "${ES_FONTCONFIG_DIRS}" ]] ; then |
140 |
for x in ${ES_FONTCONFIG_DIRS} ; do |
141 |
[[ -f ${x}/${bc} ]] && file="${x}/${bc}" |
142 |
done |
143 |
fi |
144 |
|
145 |
[[ -e ${file} ]] || \ |
146 |
file="${ROOT}/etc/fonts/conf.avail/${bc}" |
147 |
fi |
148 |
;; |
149 |
esac |
150 |
|
151 |
# does it exist? |
152 |
if [[ ! -e ${file} ]] ; then |
153 |
write_error_msg "${file} doesn't exist" |
154 |
continue |
155 |
fi |
156 |
|
157 |
# already installed? |
158 |
if [[ -e ${bcdir}/$(basename ${bc}) ]] ; then |
159 |
write_error_msg "$(basename ${bc}) is already installed" |
160 |
continue |
161 |
fi |
162 |
|
163 |
# finally, create the symlink |
164 |
ln -s "${file}" "${bcdir}" || \ |
165 |
die -q "Failed to create symlink from '${file}' to '${bcdir}'" |
166 |
done |
167 |
} |
168 |
|
169 |
### disable action ### |
170 |
|
171 |
describe_disable() { |
172 |
echo "Disable specified fontconfig .conf file(s)" |
173 |
} |
174 |
|
175 |
describe_disable_parameters() { |
176 |
echo "<target>" |
177 |
} |
178 |
|
179 |
describe_disable_options() { |
180 |
echo "<target> : Target name or number (from 'list' action)" |
181 |
} |
182 |
|
183 |
|
184 |
do_disable() { |
185 |
local bc bcdir="${ROOT}/etc/fonts/conf.d" |
186 |
|
187 |
[[ -z ${1} ]] && die -q "You didn't specify any .conf files to disable" |
188 |
|
189 |
targets=( $(find_targets) ) |
190 |
|
191 |
for bc in $@ ; do |
192 |
local file target=${bc} |
193 |
|
194 |
is_number "${target}" && \ |
195 |
target=${targets[$(( ${target} - 1 ))]} |
196 |
|
197 |
[[ -z "${target}" ]] && \ |
198 |
die -q "Target \"${bc}\" doesn't appear to be valid!" |
199 |
|
200 |
bc=${target} |
201 |
file="${bcdir}/${bc}" |
202 |
|
203 |
# ignore any unrecognized options |
204 |
[[ ${bc} == --* ]] && continue |
205 |
|
206 |
# is in installed? |
207 |
if [[ ! -e ${file} ]] ; then |
208 |
write_error_msg "${bc} is not installed" |
209 |
continue |
210 |
fi |
211 |
|
212 |
# remove it if we have permissions |
213 |
if [[ -w $(dirname ${file}) ]] ; then |
214 |
rm "${file}" || die -q "Failed to remove ${file}" |
215 |
else |
216 |
die -q "You don't have permission to remove ${file}" |
217 |
fi |
218 |
done |
219 |
} |
220 |
|
221 |
# vim: set ft=eselect : |