Lines 6-15
inherit config
Link Here
|
6 |
|
6 |
|
7 |
DESCRIPTION="Manage the system default wxWidgets profile" |
7 |
DESCRIPTION="Manage the system default wxWidgets profile" |
8 |
MAINTAINER="wxwidgets@gentoo.org" |
8 |
MAINTAINER="wxwidgets@gentoo.org" |
9 |
VERSION="20140423" |
9 |
VERSION="20150329" |
10 |
|
10 |
|
11 |
WXCONFFILE="${EROOT}"/var/lib/wxwidgets/current |
11 |
WXCONFFILE="${EROOT}"/var/lib/wxwidgets/current |
12 |
WXCONFDIR="${EROOT}"/usr/lib/wx/config |
12 |
WXCONFDIR_64="${EROOT}"/usr/lib/wx/config |
|
|
13 |
WXCONFDIR_32="${EROOT}"/usr/lib32/wx/config |
13 |
|
14 |
|
14 |
find_targets() { |
15 |
find_targets() { |
15 |
local conf |
16 |
local conf |
Lines 18-84
find_targets() {
Link Here
|
18 |
done |
19 |
done |
19 |
} |
20 |
} |
20 |
|
21 |
|
21 |
set_config() { |
|
|
22 |
local target="${1}" targets |
23 |
|
24 |
if is_number "${target}"; then |
25 |
targets=( $(find_targets) ) |
26 |
[[ ${1} -ge 1 && ${1} -le ${#targets[@]} ]] \ |
27 |
|| die -q "Number out of range: ${1}" |
28 |
target=${targets[$(( ${target} - 1 ))]} |
29 |
fi |
30 |
# we shouldn't change the profile to "none" if there are available configs |
31 |
# this can happen if WXCONFFILE got deleted somehow |
32 |
if [[ ${target} == "none" ]]; then |
33 |
targets=( $(find_targets) ) |
34 |
[[ ${#targets[@]} -ge 1 ]] && target=${targets[0]} |
35 |
fi |
36 |
|
37 |
if [[ ! ${target} == "none" && ! -e ${WXCONFDIR}/${target} ]]; then |
38 |
die -q "\"${1}\" doesn't appear to be a valid profile name" |
39 |
fi |
40 |
|
41 |
echo |
42 |
echo "Setting wxWidgets profile to ${target}" |
43 |
echo |
44 |
store_config ${WXCONFFILE} WXCONFIG ${target} |
45 |
|
46 |
if [[ ! ${target} == "none" ]]; then |
47 |
# expose the slot number of the selected target for various uses |
48 |
local wxslot=${target##*-} |
49 |
fi |
50 |
|
51 |
# symlink bakefile presets to current slot (Bug #209150) |
52 |
local f |
53 |
pushd "${EROOT}"/usr/share/bakefile/presets/ &> /dev/null |
54 |
for f in .bkl _presets.py _unix.bkl _win32.bkl _xrc.bkl; do |
55 |
if [[ -e wx${f} || -L wx${f} ]]; then |
56 |
rm -f wx${f} || die -q "Error removing wx${f}" |
57 |
fi |
58 |
if [[ ! ${target} == "none" ]]; then |
59 |
if [[ -e wx${wxslot/./}${f} ]]; then |
60 |
ln -sf wx${wxslot/./}${f} wx${f} \ |
61 |
|| die -q "Error symlinking wx${wxslot/./}${f}" |
62 |
fi |
63 |
fi |
64 |
done |
65 |
popd &> /dev/null |
66 |
} |
67 |
|
68 |
### show action ### |
22 |
### show action ### |
69 |
|
23 |
|
70 |
describe_show() { |
24 |
describe_show() { |
71 |
echo "Show the currently selected profile" |
25 |
echo "Show the currently selected profile" |
72 |
} |
26 |
} |
73 |
|
27 |
|
|
|
28 |
doshow_helper() { |
29 |
write_list_start "Current ${multiarch}wxWidgets profile:" |
30 |
if [[ -e ${WXCONFFILE} ]]; then |
31 |
write_kv_list_entry "$(load_config ${WXCONFFILE} WXCONFIG${WXCONF_SUFFIX})" "" |
32 |
else |
33 |
write_kv_list_entry "(none)" "" |
34 |
fi |
35 |
} |
36 |
|
74 |
do_show() { |
37 |
do_show() { |
75 |
[[ ${#@} -gt 0 ]] && die -q "Too many parameters" |
38 |
[[ ${#@} -gt 0 ]] && die -q "Too many parameters" |
76 |
|
39 |
|
77 |
write_list_start "Current wxWidgets profile:" |
40 |
if [[ -d "${WXCONFDIR_32}" ]]; then |
78 |
if [[ -e ${WXCONFFILE} ]]; then |
41 |
WXCONFDIR=${WXCONFDIR_64} multiarch="64bit " doshow_helper |
79 |
write_kv_list_entry "$(load_config ${WXCONFFILE} WXCONFIG)" "" |
42 |
WXCONFDIR=${WXCONFDIR_32} WXCONF_SUFFIX=_32 multiarch="32bit " doshow_helper |
80 |
else |
43 |
else |
81 |
write_kv_list_entry "(none)" "" |
44 |
WXCONFDIR=${WXCONFDIR_64} doshow_helper |
82 |
fi |
45 |
fi |
83 |
} |
46 |
} |
84 |
|
47 |
|
Lines 88-107
describe_list() {
Link Here
|
88 |
echo "List available profiles" |
51 |
echo "List available profiles" |
89 |
} |
52 |
} |
90 |
|
53 |
|
91 |
do_list() { |
54 |
dolist_helper() { |
92 |
local i targets currconf |
55 |
local i targets currconf |
93 |
targets=( $(find_targets) ) |
56 |
targets=( $(find_targets) ) |
94 |
[[ -e ${WXCONFFILE} ]] && currconf=$(load_config ${WXCONFFILE} WXCONFIG) |
57 |
[[ -e ${WXCONFFILE} ]] && currconf=$(load_config ${WXCONFFILE} WXCONFIG${WXCONF_SUFFIX}) |
95 |
|
58 |
|
96 |
for (( i = 0; i < ${#targets[@]}; i++ )); do |
59 |
for (( i = 0; i < ${#targets[@]}; i++ )); do |
97 |
# highlight current version |
60 |
# highlight current version |
98 |
[[ ${targets[i]} = ${currconf} ]] \ |
61 |
[[ ${targets[i]} = ${currconf} ]] \ |
99 |
&& targets[i]=$(highlight_marker "${targets[i]}") |
62 |
&& targets[i]=$(highlight_marker "${targets[i]}") |
100 |
done |
63 |
done |
101 |
write_list_start "Available wxWidgets profiles:" |
64 |
write_list_start "Available ${multiarch}wxWidgets profiles:" |
102 |
write_numbered_list -m "(none found)" "${targets[@]}" |
65 |
write_numbered_list -m "(none found)" "${targets[@]}" |
103 |
} |
66 |
} |
104 |
|
67 |
|
|
|
68 |
do_list() { |
69 |
if [[ -d "${WXCONFDIR_32}" ]]; then |
70 |
WXCONFDIR=${WXCONFDIR_64} multiarch="64bit " dolist_helper |
71 |
WXCONFDIR=${WXCONFDIR_32} WXCONF_SUFFIX=_32 multiarch="32bit " dolist_helper |
72 |
else |
73 |
WXCONFDIR=${WXCONFDIR_64} dolist_helper |
74 |
fi |
75 |
} |
76 |
|
105 |
### set action ### |
77 |
### set action ### |
106 |
|
78 |
|
107 |
describe_set() { |
79 |
describe_set() { |
Lines 109-139
describe_set() {
Link Here
|
109 |
} |
81 |
} |
110 |
|
82 |
|
111 |
describe_set_options() { |
83 |
describe_set_options() { |
|
|
84 |
echo "32bit, 64bit : (optional) Apply changes to 32 bit or 64 bit multilib only" |
112 |
echo "<target> : Profile name or number (from 'list')" |
85 |
echo "<target> : Profile name or number (from 'list')" |
113 |
} |
86 |
} |
114 |
|
87 |
|
115 |
describe_set_parameters() { |
88 |
describe_set_parameters() { |
116 |
echo "<target>" |
89 |
echo "[32bit|64bit] <target>" |
|
|
90 |
} |
91 |
|
92 |
doset_helper() { |
93 |
local target="${1}" targets |
94 |
|
95 |
if is_number "${target}"; then |
96 |
targets=( $(find_targets) ) |
97 |
[[ ${1} -ge 1 && ${1} -le ${#targets[@]} ]] \ |
98 |
|| die -q "Number out of range: ${1}" |
99 |
target=${targets[$(( ${target} - 1 ))]} |
100 |
fi |
101 |
# we shouldn't change the profile to "none" if there are available configs |
102 |
# this can happen if WXCONFFILE got deleted somehow |
103 |
if [[ ${target} == "none" ]]; then |
104 |
targets=( $(find_targets) ) |
105 |
[[ ${#targets[@]} -ge 1 ]] && target=${targets[0]} |
106 |
fi |
107 |
|
108 |
if [[ ! ${target} == "none" && ! -e ${WXCONFDIR}/${target} ]]; then |
109 |
die -q "\"${1}\" doesn't appear to be a valid profile name" |
110 |
fi |
111 |
|
112 |
echo |
113 |
echo "Setting ${multiarch}wxWidgets profile to ${target}" |
114 |
echo |
115 |
store_config ${WXCONFFILE} WXCONFIG${WXCONF_SUFFIX} ${target} |
116 |
|
117 |
if [[ ! ${target} == "none" ]]; then |
118 |
# expose the slot number of the selected target for various uses |
119 |
local wxslot=${target##*-} |
120 |
fi |
121 |
|
122 |
if [[ -z "${multiarch}" || "${multiarch}" == "64bit" ]]; then |
123 |
# symlink bakefile presets to current slot (Bug #209150) |
124 |
local f |
125 |
pushd "${EROOT}"/usr/share/bakefile/presets/ &> /dev/null |
126 |
for f in .bkl _presets.py _unix.bkl _win32.bkl _xrc.bkl; do |
127 |
if [[ -e wx${f} || -L wx${f} ]]; then |
128 |
rm -f wx${f} || die -q "Error removing wx${f}" |
129 |
fi |
130 |
if [[ ! ${target} == "none" ]]; then |
131 |
if [[ -e wx${wxslot/./}${f} ]]; then |
132 |
ln -sf wx${wxslot/./}${f} wx${f} \ |
133 |
|| die -q "Error symlinking wx${wxslot/./}${f}" |
134 |
fi |
135 |
fi |
136 |
done |
137 |
popd &> /dev/null |
138 |
fi |
117 |
} |
139 |
} |
118 |
|
140 |
|
119 |
do_set() { |
141 |
do_set() { |
120 |
[[ ! ${#@} -eq 1 ]] \ |
142 |
[[ ${#@} -eq 0 ]] \ |
121 |
&& die -q "You must specify a profile name or number" |
143 |
&& die -q "You must specify a profile name or number" |
122 |
|
144 |
|
123 |
[[ ! -w "${EROOT}"/var/lib/ ]] \ |
145 |
[[ ! -w "${EROOT}"/var/lib/ ]] \ |
124 |
&& die -q "You need write permission to /var/lib to perform this action." |
146 |
&& die -q "You need write permission to /var/lib to perform this action." |
125 |
|
147 |
|
126 |
set_config "${1}" |
148 |
if [[ $1 == "64bit" ]]; then |
|
|
149 |
if [[ -d "${WXCONFDIR_64}" ]]; then |
150 |
WXCONFDIR=${WXCONFDIR_64} multiarch="$1 " doset_helper $2 |
151 |
fi |
152 |
elif [[ $1 == "32bit" ]]; then |
153 |
if [[ -d "${WXCONFDIR_32}" ]]; then |
154 |
WXCONFDIR=${WXCONFDIR_32} WXCONF_SUFFIX=_32 multiarch="$1 " doset_helper $2 |
155 |
else |
156 |
write_warning_msg "The 32bit parameter is intended for multilib systems only" |
157 |
fi |
158 |
else |
159 |
if [[ -d "${WXCONFDIR_32}" ]]; then |
160 |
WXCONFDIR=${WXCONFDIR_64} multiarch="64bit " doset_helper $1 |
161 |
WXCONFDIR=${WXCONFDIR_32} WXCONF_SUFFIX=_32 multiarch="32bit " doset_helper $1 |
162 |
else |
163 |
WXCONFDIR=${WXCONFDIR_64} doset_helper $1 |
164 |
fi |
165 |
fi |
127 |
} |
166 |
} |
128 |
|
167 |
|
|
|
168 |
### update action ### |
169 |
|
129 |
describe_update() { |
170 |
describe_update() { |
130 |
echo "Check current profile and update it if invalid (internal use only)" |
171 |
echo "Check current profile and update it if invalid (internal use only)" |
131 |
} |
172 |
} |
132 |
|
173 |
|
133 |
do_update() { |
174 |
doupdate_helper() { |
134 |
[[ ! -e ${WXCONFFILE} ]] && do_set none |
175 |
currconf=$(load_config ${WXCONFFILE} WXCONFIG${WXCONF_SUFFIX}) |
135 |
|
|
|
136 |
currconf=$(load_config ${WXCONFFILE} WXCONFIG) |
137 |
|
176 |
|
138 |
# if current config is valid leave it alone |
177 |
# if current config is valid leave it alone |
139 |
[[ -e ${WXCONFDIR}/${currconf} ]] && return 0 |
178 |
[[ -e ${WXCONFDIR}/${currconf} ]] && return 0 |
Lines 242-253
do_update() {
Link Here
|
242 |
|
281 |
|
243 |
if [[ ${currconf} != "none" && ${foundconf} != "none" ]]; then |
282 |
if [[ ${currconf} != "none" && ${foundconf} != "none" ]]; then |
244 |
echo |
283 |
echo |
245 |
write_warning_msg "Your currently selected wxWidgets profile: ( ${currconf} )" |
284 |
write_warning_msg "Your currently selected ${multiarch}wxWidgets profile: ( ${currconf} )" |
246 |
write_warning_msg "is no longer available." |
285 |
write_warning_msg "is no longer available." |
247 |
write_warning_msg |
286 |
write_warning_msg |
248 |
write_warning_msg "The closest matching profile: ( ${foundconf} )" |
287 |
write_warning_msg "The closest matching profile: ( ${foundconf} )" |
249 |
write_warning_msg "will be activated in its place." |
288 |
write_warning_msg "will be activated in its place." |
250 |
fi |
289 |
fi |
251 |
|
290 |
|
252 |
do_set ${foundconf} |
291 |
doset_helper ${foundconf} |
|
|
292 |
} |
293 |
|
294 |
do_update() { |
295 |
[[ ! -e ${WXCONFFILE} ]] && do_set none |
296 |
|
297 |
if [[ -d "${WXCONFDIR_32}" ]]; then |
298 |
WXCONFDIR=${WXCONFDIR_64} multiarch="64bit " doupdate_helper |
299 |
WXCONFDIR=${WXCONFDIR_32} WXCONF_SUFFIX=_32 multiarch="32bit " doupdate_helper |
300 |
else |
301 |
WXCONFDIR=${WXCONFDIR_64} doupdate_helper |
302 |
fi |
253 |
} |
303 |
} |
254 |
- |
304 |
|