Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 510708 | Differences between
and this patch

Collapse All | Expand All

(-)a/modules/wxwidgets.eselect (-64 / +115 lines)
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-107 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
74
do_show() {
28
doshow_helper() {
75
	[[ ${#@} -gt 0 ]] && die -q "Too many parameters"
29
	[[ ${#@} -gt 0 ]] && die -q "Too many parameters"
76
30
77
	write_list_start "Current wxWidgets profile:"
31
	write_list_start "Current ${multiarch}wxWidgets profile:"
78
	if [[ -e ${WXCONFFILE} ]]; then
32
	if [[ -e ${WXCONFFILE} ]]; then
79
		write_kv_list_entry "$(load_config ${WXCONFFILE} WXCONFIG)" ""
33
		write_kv_list_entry "$(load_config ${WXCONFFILE} WXCONFIG${WXCONF_SUFFIX})" ""
80
	else
34
	else
81
		write_kv_list_entry "(none)" ""
35
		write_kv_list_entry "(none)" ""
82
	fi
36
	fi
83
}
37
}
84
38
39
do_show() {
40
	if [[ -d "${WXCONFDIR_32}" ]]; then
41
		WXCONFDIR=${WXCONFDIR_64} multiarch="64bit " doshow_helper
42
		WXCONFDIR=${WXCONFDIR_32} WXCONF_SUFFIX=_32 multiarch="32bit " doshow_helper
43
	else
44
		WXCONFDIR=${WXCONFDIR_64} doshow_helper
45
	fi
46
}
47
85
### list action ###
48
### list action ###
86
49
87
describe_list() {
50
describe_list() {
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 249-253 do_update() { Link Here
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}
253
}
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
303
}
304

Return to bug 510708