From 69efadbccf10da6e65c7d459c5cfea38375824b6 Mon Sep 17 00:00:00 2001 From: nE0sIghT Date: Sun, 29 Mar 2015 21:18:56 +0300 Subject: [PATCH] wxwidgets.eselect: multilib support --- modules/wxwidgets.eselect | 181 +++++++++++++++++++++++++++++----------------- 1 file changed, 116 insertions(+), 65 deletions(-) diff --git a/modules/wxwidgets.eselect b/modules/wxwidgets.eselect index 55d49d2..04ad16b 100644 --- a/modules/wxwidgets.eselect +++ b/modules/wxwidgets.eselect @@ -6,10 +6,11 @@ inherit config DESCRIPTION="Manage the system default wxWidgets profile" MAINTAINER="wxwidgets@gentoo.org" -VERSION="20140423" +VERSION="20150329" WXCONFFILE="${EROOT}"/var/lib/wxwidgets/current -WXCONFDIR="${EROOT}"/usr/lib/wx/config +WXCONFDIR_64="${EROOT}"/usr/lib/wx/config +WXCONFDIR_32="${EROOT}"/usr/lib32/wx/config find_targets() { local conf @@ -18,67 +19,29 @@ find_targets() { done } -set_config() { - local target="${1}" targets - - 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 - # we shouldn't change the profile to "none" if there are available configs - # this can happen if WXCONFFILE got deleted somehow - if [[ ${target} == "none" ]]; then - targets=( $(find_targets) ) - [[ ${#targets[@]} -ge 1 ]] && target=${targets[0]} - fi - - if [[ ! ${target} == "none" && ! -e ${WXCONFDIR}/${target} ]]; then - 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=${target##*-} - fi - - # symlink bakefile presets to current slot (Bug #209150) - local f - pushd "${EROOT}"/usr/share/bakefile/presets/ &> /dev/null - for f in .bkl _presets.py _unix.bkl _win32.bkl _xrc.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 - if [[ -e wx${wxslot/./}${f} ]]; then - ln -sf wx${wxslot/./}${f} wx${f} \ - || die -q "Error symlinking wx${wxslot/./}${f}" - fi - fi - done - popd &> /dev/null -} - ### show action ### describe_show() { echo "Show the currently selected profile" } +doshow_helper() { + write_list_start "Current ${multiarch}wxWidgets profile:" + if [[ -e ${WXCONFFILE} ]]; then + write_kv_list_entry "$(load_config ${WXCONFFILE} WXCONFIG${WXCONF_SUFFIX})" "" + else + write_kv_list_entry "(none)" "" + fi +} + 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)" "" + if [[ -d "${WXCONFDIR_32}" ]]; then + WXCONFDIR=${WXCONFDIR_64} multiarch="64bit " doshow_helper + WXCONFDIR=${WXCONFDIR_32} WXCONF_SUFFIX=_32 multiarch="32bit " doshow_helper else - write_kv_list_entry "(none)" "" + WXCONFDIR=${WXCONFDIR_64} doshow_helper fi } @@ -88,20 +51,29 @@ describe_list() { echo "List available profiles" } -do_list() { +dolist_helper() { local i targets currconf targets=( $(find_targets) ) - [[ -e ${WXCONFFILE} ]] && currconf=$(load_config ${WXCONFFILE} WXCONFIG) + [[ -e ${WXCONFFILE} ]] && currconf=$(load_config ${WXCONFFILE} WXCONFIG${WXCONF_SUFFIX}) 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_list_start "Available ${multiarch}wxWidgets profiles:" write_numbered_list -m "(none found)" "${targets[@]}" } +do_list() { + if [[ -d "${WXCONFDIR_32}" ]]; then + WXCONFDIR=${WXCONFDIR_64} multiarch="64bit " dolist_helper + WXCONFDIR=${WXCONFDIR_32} WXCONF_SUFFIX=_32 multiarch="32bit " dolist_helper + else + WXCONFDIR=${WXCONFDIR_64} dolist_helper + fi +} + ### set action ### describe_set() { @@ -109,31 +81,98 @@ describe_set() { } describe_set_options() { + echo "32bit, 64bit : (optional) Apply changes to 32 bit or 64 bit multilib only" echo " : Profile name or number (from 'list')" } describe_set_parameters() { - echo "" + echo "[32bit|64bit] " +} + +doset_helper() { + local target="${1}" targets + + 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 + # we shouldn't change the profile to "none" if there are available configs + # this can happen if WXCONFFILE got deleted somehow + if [[ ${target} == "none" ]]; then + targets=( $(find_targets) ) + [[ ${#targets[@]} -ge 1 ]] && target=${targets[0]} + fi + + if [[ ! ${target} == "none" && ! -e ${WXCONFDIR}/${target} ]]; then + die -q "\"${1}\" doesn't appear to be a valid profile name" + fi + + echo + echo "Setting ${multiarch}wxWidgets profile to ${target}" + echo + store_config ${WXCONFFILE} WXCONFIG${WXCONF_SUFFIX} ${target} + + if [[ ! ${target} == "none" ]]; then + # expose the slot number of the selected target for various uses + local wxslot=${target##*-} + fi + + if [[ -z "${multiarch}" || "${multiarch}" == "64bit" ]]; then + # symlink bakefile presets to current slot (Bug #209150) + local f + pushd "${EROOT}"/usr/share/bakefile/presets/ &> /dev/null + for f in .bkl _presets.py _unix.bkl _win32.bkl _xrc.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 + if [[ -e wx${wxslot/./}${f} ]]; then + ln -sf wx${wxslot/./}${f} wx${f} \ + || die -q "Error symlinking wx${wxslot/./}${f}" + fi + fi + done + popd &> /dev/null + fi } do_set() { - [[ ! ${#@} -eq 1 ]] \ + [[ ${#@} -eq 0 ]] \ && die -q "You must specify a profile name or number" [[ ! -w "${EROOT}"/var/lib/ ]] \ && die -q "You need write permission to /var/lib to perform this action." - set_config "${1}" + if [[ $1 == "64bit" ]]; then + if [[ -d "${WXCONFDIR_64}" ]]; then + WXCONFDIR=${WXCONFDIR_64} multiarch="$1 " doset_helper $2 + fi + elif [[ $1 == "32bit" ]]; then + if [[ -d "${WXCONFDIR_32}" ]]; then + WXCONFDIR=${WXCONFDIR_32} WXCONF_SUFFIX=_32 multiarch="$1 " doset_helper $2 + else + write_warning_msg "The 32bit parameter is intended for multilib systems only" + fi + else + if [[ -d "${WXCONFDIR_32}" ]]; then + WXCONFDIR=${WXCONFDIR_64} multiarch="64bit " doset_helper $1 + WXCONFDIR=${WXCONFDIR_32} WXCONF_SUFFIX=_32 multiarch="32bit " doset_helper $1 + else + WXCONFDIR=${WXCONFDIR_64} doset_helper $1 + fi + fi } +### update action ### + 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) +doupdate_helper() { + currconf=$(load_config ${WXCONFFILE} WXCONFIG${WXCONF_SUFFIX}) # if current config is valid leave it alone [[ -e ${WXCONFDIR}/${currconf} ]] && return 0 @@ -242,12 +281,24 @@ do_update() { if [[ ${currconf} != "none" && ${foundconf} != "none" ]]; then echo - write_warning_msg "Your currently selected wxWidgets profile: ( ${currconf} )" + write_warning_msg "Your currently selected ${multiarch}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." fi - do_set ${foundconf} + doset_helper ${foundconf} +} + +do_update() { + [[ ! -e ${WXCONFFILE} ]] && do_set none + + if [[ -d "${WXCONFDIR_32}" ]]; then + WXCONFDIR=${WXCONFDIR_64} multiarch="64bit " doupdate_helper + WXCONFDIR=${WXCONFDIR_32} WXCONF_SUFFIX=_32 multiarch="32bit " doupdate_helper + else + WXCONFDIR=${WXCONFDIR_64} doupdate_helper + fi } + -- 2.3.6