diff options
author | Ryan Hill <dirtyepic@gentoo.org> | 2009-07-01 03:10:08 +0000 |
---|---|---|
committer | Ryan Hill <dirtyepic@gentoo.org> | 2009-07-01 03:10:08 +0000 |
commit | ec6c7d8a4af17e4122d6d953ac23bd984e10f8e1 (patch) | |
tree | d633c037d0cb8a0bd5565d696985da76095b0e99 | |
download | eselect-wxwidgets-ec6c7d8a4af17e4122d6d953ac23bd984e10f8e1.tar.gz eselect-wxwidgets-ec6c7d8a4af17e4122d6d953ac23bd984e10f8e1.tar.bz2 eselect-wxwidgets-ec6c7d8a4af17e4122d6d953ac23bd984e10f8e1.zip |
Add the wxwdigets module.
svn path=/trunk/; revision=591
Filtered-out-of: https://gitweb.gentoo.org/proj/eselect.git/
Filtered-branch: extern
Filtered-commit: 3af62ddd1dc6dcb7f26283f15dd9c4cd095ea162
-rw-r--r-- | wxwidgets.eselect | 246 |
1 files changed, 246 insertions, 0 deletions
diff --git a/wxwidgets.eselect b/wxwidgets.eselect new file mode 100644 index 0000000..2be0a65 --- /dev/null +++ b/wxwidgets.eselect @@ -0,0 +1,246 @@ +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $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 $ + +inherit config + +DESCRIPTION="Manage the system default wxWidgets profile." +MAINTAINER="dirtyepic@gentoo.org" +VERSION=0.8 + +WXCONFFILE=/var/lib/wxwidgets/current +WXCONFDIR=/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 /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 + # targets is an array containing names of available configs + targets=( $(find_targets) ) + + if [[ -n ${targets[@]} ]]; then + for (( i = 0; i < ${#targets[@]}; i++ )); do + if [[ -e ${WXCONFFILE} ]]; then + # highlight current version + [[ ${targets[${i}]} == $(load_config ${WXCONFFILE} WXCONFIG) ]] \ + && targets[${i}]="$(highlight ${targets[${i}]}) *" + fi + done + write_list_start "Available wxWidgets profiles:" + write_numbered_list "${targets[@]}" + else + write_kv_list_entry "(none found)" "" + fi +} + +### 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 "${ROOT}"/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} +} |