blob: a4452fdd5afa35e667cfc0546cff0248bc4fb505 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
# -*-eselect-*- vim: ft=eselect
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
inherit config
DESCRIPTION="Manage the system default wxWidgets profile."
MAINTAINER="wxwidgets@gentoo.org"
SVN_DATE='$Date$'
VERSION=$(svn_date_to_version "${SVN_DATE}")
WXCONFFILE="${EROOT}"/var/lib/wxwidgets/current
WXCONFDIR="${EROOT}"/usr/lib/wx/config
find_targets() {
local conf
for conf in ${WXCONFDIR}/*; do
[[ -f ${conf} && -x ${conf} ]] && basename ${conf}
done
}
set_config() {
local target="${1}" targets
# selected by number
if is_number "${target}"; then
targets=( $(find_targets) )
[[ ${1} -ge 1 && ${1} -le ${#targets[@]} ]] \
|| die -q "Number out of range: ${1}"
target=${targets[$(( ${target} - 1 ))]}
fi
if [[ ${target} == "none" ]]; then
# none is a special case
:
else
[[ ! -f ${WXCONFDIR}/${target} ]] && \
die -q "\"${1}\" doesn't appear to be a valid profile name"
fi
echo
echo "Setting wxWidgets profile to ${target}"
echo
store_config ${WXCONFFILE} WXCONFIG ${target}
if [[ ! ${target} == "none" ]]; then
# expose the slot number of the selected target for various uses
local wxslot
OIFS=${IFS}
IFS=-
set -- ${target}
wxslot=${4}
IFS=${OIFS}
fi
# symlink bakefile presets to current slot (Bug #209150)
local f
pushd "${EROOT}"/usr/share/bakefile/presets/ &> /dev/null
for f in .bkl _unix.bkl _win32.bkl; do
if [[ -e wx${f} || -L wx${f} ]]; then
rm -f wx${f} || die -q "Error removing wx${f}"
fi
if [[ ! ${target} == "none" ]]; then
ln -sf wx${wxslot/./}${f} wx${f} \
|| die -q "Error symlinking wx${wxslot/./}${f}"
fi
done
popd &> /dev/null
}
### show action ###
describe_show() {
echo "Show the currently selected profile"
}
do_show() {
[[ ${#@} -gt 0 ]] && die -q "Too many parameters"
write_list_start "Current wxWidgets profile:"
if [[ -e ${WXCONFFILE} ]]; then
write_kv_list_entry "$(load_config ${WXCONFFILE} WXCONFIG)" ""
else
write_kv_list_entry "(none)" ""
fi
}
### list action ###
describe_list() {
echo "List available profiles"
}
do_list() {
local i targets currconf
# targets is an array containing names of available configs
targets=( $(find_targets) )
[[ -e ${WXCONFFILE} ]] && currconf=$(load_config ${WXCONFFILE} WXCONFIG)
for (( i = 0; i < ${#targets[@]}; i++ )); do
# highlight current version
[[ ${targets[i]} = ${currconf} ]] \
&& targets[i]=$(highlight_marker "${targets[i]}")
done
write_list_start "Available wxWidgets profiles:"
write_numbered_list -m "(none found)" "${targets[@]}"
}
### set action ###
describe_set() {
echo "Set the system wxWidgets profile"
}
describe_set_options() {
echo "target: profile name or number (gotten from 'list')"
}
describe_set_parameters() {
echo "<target>"
}
do_set() {
[[ ! ${#@} -eq 1 ]] \
&& die -q "You must specify a profile name or number"
[[ -w "${EROOT}"/var/lib ]] \
|| die -q "You need proper write permissions. Please run as root."
set_config "${1}"
}
describe_update() {
echo "Check current profile and update it if invalid (internal use only)"
}
do_update() {
[[ ! -e ${WXCONFFILE} ]] && do_set none
currconf=$(load_config ${WXCONFFILE} WXCONFIG)
# if current config is "none" leave it alone
[[ ${currconf} == none ]] && return 0
# if current config is valid leave it alone
[[ -e ${WXCONFDIR}/${currconf} ]] && return 0
# split the config string into components
OIFS=${IFS}
IFS=-
set -- ${currconf}
IFS=${OIFS}
declare -a wxtoolkit wxchar wxdebug wxver
# put selected components into the first element of the array
wxtoolkit=(${1})
wxchar=(${2})
wxdebug=(${3})
wxver=(${4})
# put available components into next element(s) of array
local component toolkit char debug ver element opt
for component in toolkit char debug ver; do
element=1
case ${component} in
toolkit)
for opt in base gtk2; do
if [[ ${opt} == ${wxtoolkit[0]} ]]; then
continue
else
wxtoolkit[${element}]=${opt}
(( element++ ))
fi
done
;;
char)
for opt in ansi unicode; do
if [[ ${opt} == ${wxchar[0]} ]]; then
continue
else
wxchar[${element}]=${opt}
(( element++ ))
fi
done
;;
debug)
for opt in release debug; do
if [[ ${opt} == ${wxdebug[0]} ]]; then
continue
else
wxdebug[${element}]=${opt}
(( element++ ))
fi
done
;;
ver)
for opt in 2.10 2.8 2.6; do
if [[ ${opt} == ${wxver[0]} ]]; then
continue
else
wxver[${element}]=${opt}
(( element++ ))
fi
done
;;
esac
done
# Now we iterate through the installed wx-configs and find the closest match
# ( debug > char > toolkit > ver )
local d c t v checkconf foundconf
for (( v = 0 ; v < ${#wxver[@]} ; v++ )); do
for (( t = 0 ; t < ${#wxtoolkit[@]} ; t++ )); do
for (( c = 0 ; c < ${#wxchar[@]} ; c++ )); do
for (( d = 0 ; d < ${#wxdebug[@]} ; d++ )); do
checkconf="${wxtoolkit[$t]}-${wxchar[$c]}-${wxdebug[$d]}-${wxver[$v]}"
[[ -e ${WXCONFDIR}/${checkconf} ]] || continue
foundconf=${checkconf}
break 4
done
done
done
done
[[ -z ${foundconf} ]] && foundconf="none"
echo
write_warning_msg "Your currently selected wxWidgets profile: ( ${currconf} )"
write_warning_msg "is no longer available."
write_warning_msg
write_warning_msg "The closest matching profile: ( ${foundconf} )"
write_warning_msg "will be activated in its place."
do_set ${foundconf}
}
|