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