diff options
Diffstat (limited to 'x11-base/opengl-update/files/opengl-update-3.0.0.eselect')
-rw-r--r-- | x11-base/opengl-update/files/opengl-update-3.0.0.eselect | 357 |
1 files changed, 357 insertions, 0 deletions
diff --git a/x11-base/opengl-update/files/opengl-update-3.0.0.eselect b/x11-base/opengl-update/files/opengl-update-3.0.0.eselect new file mode 100644 index 000000000000..661a4bec77d6 --- /dev/null +++ b/x11-base/opengl-update/files/opengl-update-3.0.0.eselect @@ -0,0 +1,357 @@ +# Copyright 1999-2004 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/x11-base/opengl-update/files/opengl-update-3.0.0.eselect,v 1.1 2005/08/13 07:42:36 eradicator Exp $ +# Author: Martin Schlemmer <azarah@gentoo.org> +# Further modifications by Donnie Berkholz <spyderous@gentoo.org> +# Further modifications based off submissions to bug #54984 <cyfred@gentoo.org> +# Further modifications by Jeremy Huddleston <eradicator@gentoo.org> +# Made into eselect module by Jeremy Huddleston <eradicator@gentoo.org> + +# Eselect data +DESCRIPTION="Manage the OpenGL implementation used by your system" +MAINTAINER="x11-drivers@gentoo.org" +VERSION="3.0.0" + +# Our data +ENV_D="${ROOT}/etc/env.d/03opengl" +PREFIX="${ROOT}/usr" +DST_PREFIX="${ROOT}/usr" +USE_PROFILE_HEADERS="no" + +hasq() { + local x + + local me=${1} + shift + + for x in "${@}"; do + if [[ "${x}" == "${me}" ]]; then + return 0 + fi + done + return 1 +} + +check_user() { + if [[ $(id -u) -ne 0 ]]; then + die -q "${0}: Must be run as root." + fi +} + +check_version() { + if portageq has_version / 'x11-base/xorg-x11'; then + if ! portageq has_version / '>=x11-base/xorg-x11-6.8.0-r4'; then + die -q "This version requires >=x11-base/xorg-x11-6.8.0-r4" + fi + fi +} + +get_current_implem() { + local implem + if [[ -f ${ENV_D} ]]; then + source ${ENV_D} + if [[ -n "${OPENGL_PROFILE}" ]]; then + implem="${OPENGL_PROFILE}" + elif [[ -n "${LDPATH}" ]]; then + implem="${LDPATH%%:*}" + implem="${implem##*opengl/}" + implem="${implem%/lib*}" + fi + unset LDPATH + unset OPENGL_PROFILE + fi + + echo ${implem} +} + +get_implementations() { + local implems + for dir in ${PREFIX}/lib{,32,64}/opengl/*; do + if [[ -d "${dir}" && ${dir##*/} != "global" ]] && ! hasq ${dir##*/} ${implems}; then + implems=${implems:+${implems} }${dir##*/} + fi + done + + echo ${implems} +} + +set-new-implementation() { + local GL_IMPLEM=${1} + local GL_LOCAL + + check_version + check_user + + # Set a sane umask... bug #83115 + umask 022 + + if ! hasq ${GL_IMPLEM} ${AVAIL_IMPLEMS}; then + eerror "Invalid profile selected." + exit 1 + fi + + echo -n "Switching to ${GL_IMPLEM} OpenGL interface..." + rm -f ${ENV_D} &> /dev/null + + LIBDIRS="lib32 lib lib64" + for LIBDIR in ${LIBDIRS}; do + # Special case handling of lib32 because it can be a symlink to + # emul libs + if [[ "${LIBDIR}" = "lib32" ]]; then + [[ -d "${PREFIX}/${LIBDIR}/opengl" ]] || continue + else + [[ -d "${PREFIX}/${LIBDIR}/opengl" && ! -h "${PREFIX}/${LIBDIR}" ]] || continue + fi + + # Fallback on xorg-x11 if we don't have this implementation for this LIBDIR. + if [[ ! -d ${PREFIX}/${LIBDIR}/opengl/"${GL_IMPLEM}" ]]; then + GL_LOCAL="xorg-x11" + else + GL_LOCAL="${GL_IMPLEM}" + fi + + mkdir -p ${DST_PREFIX}/${LIBDIR} + pushd ${DST_PREFIX}/${LIBDIR} &> /dev/null + # First remove old symlinks + for file in libGL{,core}.{a,so,la} ; do + [[ -h ${file} ]] && rm -f ${file} + done + + # Note that we don't do .so*, just .so on purpose. The + # loader knows to look in the profile dir, and the + # linked just needs the .so + for file in ${PREFIX}/${LIBDIR}/opengl/${GL_LOCAL}/lib/libGL{,core}.{so,a,la}; do + [[ -f "${file}" ]] || continue + [[ -f "${file##*/}" ]] && rm -f ${file##*/} + + # Fix libtool archives (#48297) + if [[ "${file%.la}" != "${file}" ]]; then + sed "s:${PREFIX}/[^/]*/opengl/[^/]*/lib:${DST_PREFIX}/${LIBDIR}:g" ${file} > ${file##*/} + else + ln -s ${file} + fi + done + popd &> /dev/null + + if [[ -e "${PREFIX}/${LIBDIR}/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls" ]]; then + mkdir -p ${DST_PREFIX}/${LIBDIR}/tls + pushd ${DST_PREFIX}/${LIBDIR}/tls &> /dev/null + # First remove old symlinks + for file in libGL{,core}.{a,so,la} ; do + [[ -h ${file} ]] && rm -f ${file} + done + + for file in ${PREFIX}/${LIBDIR}/opengl/${GL_LOCAL}/lib/tls/libGL{,core}.{so,a,la}; do + [[ -f "${file}" ]] || continue + [[ -f "${file##*/}" ]] && rm -f ${file##*/} + + # Fix libtool archives (#48297) + if [ "${file%.la}" != "${file}" ]; then + sed "s:${PREFIX}/[^/]*/opengl/[^/]*/lib:${DST_PREFIX}/${LIBDIR}:g" ${file} > ${file##*/} + else + ln -s ${file} + fi + done + popd &> /dev/null + fi + + local MODULEDIR + if [[ -e "${DST_PREFIX}/${LIBDIR}/xorg/modules" ]]; then + MODULEDIR="xorg/modules" + else + MODULEDIR="modules" + fi + + if [[ -e "${PREFIX}/${LIBDIR}/opengl/${GL_LOCAL}/extensions" ]]; then + mkdir -p ${DST_PREFIX}/${LIBDIR}/${MODULEDIR}/extensions + pushd ${DST_PREFIX}/${LIBDIR}/${MODULEDIR}/extensions &> /dev/null + # First remove old symlinks + for file in libglx.so libglx.a; do + [[ -h ${file} ]] && rm -f ${file} + done + + for file in ${PREFIX}/${LIBDIR}/opengl/${GL_LOCAL}/extensions/*.{so,a,la}; do + [[ -f "${file}" ]] || continue + [[ -f "${file##*/}" ]] && rm -f ${file##*/} + + # Fix libtool archives (#48297) + if [[ "${file%.la}" != "${file}" ]]; then + sed "s:${PREFIX}/[^/]*/opengl/[^/]*/lib:${DST_PREFIX}/${LIBDIR}:g" ${file} > ${file##*/} + else + ln -s ${file} + fi + done + popd &> /dev/null + fi + + # Setup the includes + mkdir -p ${DST_PREFIX}/include/GL + pushd ${DST_PREFIX}/include/GL &> /dev/null + for file in gl.h glx.h glxtokens.h glext.h glxext.h glxmd.h glxproto.h; do + # IMPORTANT + # It is preferable currently to use the standard glext.h file + # however if an OpenGL provider must use a self produced glext.h + # then it should be installed to ${GL_IMPLEM}/include and the user + # can add the --impl-headers option to select it. + + if [[ ${USE_PROFILE_HEADERS} == "yes" ]] ; then + # Check the profile first. + if [[ -e ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${file} ]]; then + [[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} + ln -s ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${file} + fi + fi + + if [[ -e ${PREFIX}/${LIBDIR}/opengl/global/include/${file} ]]; then + [[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} + ln -s ${PREFIX}/${LIBDIR}/opengl/global/include/${file} + elif [[ -e ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${file} ]]; then + [[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} + ln -s ${PREFIX}/${LIBDIR}/opengl/${GL_IMPLEM}/include/${file} + elif [[ -e ${PREFIX}/${LIBDIR}/opengl/xorg-x11/include/${file} ]]; then + [[ -f "${file}" || ( -L "${file}" && ! -e "${file}" ) ]] && rm -f ${file} + ln -s ${PREFIX}/${LIBDIR}/opengl/xorg-x11/include/${file} + fi + done + popd &> /dev/null + + # Setup the $LDPATH + ldpath="${ldpath:+${ldpath}:}${PREFIX}/${LIBDIR}/opengl/${GL_LOCAL}/lib" + + done + + echo "LDPATH=\"${ldpath}\"" > ${ENV_D} + echo "OPENGL_PROFILE=\"${GL_IMPLEM}\"" >> ${ENV_D} + + env-update >& /dev/null + + echo " done" +} + +### show action ### +describe_show() { + echo "Print the current OpenGL implementation." +} + +do_show() { + local CURRENT_GL_IMPLEM=$(get_current_implem) + if [[ -n "${CURRENT_GL_IMPLEM}" ]]; then + echo ${CURRENT_GL_IMPLEM} + return 0 + else + echo "(none)" + return 2 + fi +} + +### list action ### +describe_list() { + echo "List the availible OpenGL implementations." +} + +do_list() { + targets=( $(get_implementations) ) + write_list_start "Availible OpenGL implementations:" + if [[ -n ${targets[@]} ]] ; then + local i + for (( i = 0 ; i < ${#targets[@]} ; i = i + 1 )) ; do + [[ ${targets[${i}]} == $(get_current_implem) ]] && \ + targets[${i}]="${targets[${i}]} $(highlight '*' )" + done + write_numbered_list "${targets[@]}" + else + write_kv_list_entry "(none found)" "" + fi +} + +### set action ### +describe_set() { + echo "Select the OpenGL implementation. (see set --help)" +} + +do_set() { + local ACTION="error" + local CURRENT_GL_IMPLEM=$(get_current_implem) + local AVAIL_IMPLEMS=$(get_implementations) + + while [[ ${#} -gt 0 ]]; do + local opt=${1} + shift + case ${opt} in + --use-old) + if [[ -n "${CURRENT_GL_IMPLEM}" ]] && hasq ${CURRENT_GL_IMPLEM} ${AVAIL_IMPLEMS}; then + ACTION="old-implementation" + fi + ;; + --prefix=*) + PREFIX=${ROOT}${opt#*=} + AVAIL_IMPLEMS=$(get_implementations) + ;; + --dst-prefix=*) + DST_PREFIX=${ROOT}${opt#*=} + ;; + --impl-headers) + USE_PROFILE_HEADERS="yes" + ;; + --help|-h|-?) + ACION="usage" + ;; + *) + if [[ "${ACTION}" != "old-implementation" ]]; then + ACTION="set-implementation" + fi + + if is_number ${opt} ; then + targets=( $(get_implementations) ) + NEW_GL_IMPLEM=${targets[$(( ${opt} - 1 ))]} + if [[ -z "${NEW_GL_IMPLEM}" ]] ; then + die -q "Unrecognized option: ${opt}" + fi + elif hasq ${opt} ${AVAIL_IMPLEMS}; then + NEW_GL_IMPLEM="${opt}" + else + die -q "Unrecognized option: ${opt}" + fi + ;; + esac + done + + case ${ACTION} in + old-implementation) + set-new-implementation ${CURRENT_GL_IMPLEM} + return $? + ;; + set-implementation) + if [[ -n "${NEW_GL_IMPLEM}" ]]; then + set-new-implementation ${NEW_GL_IMPLEM} + return $? + else + print_set_usage + return 1 + fi + ;; + usage) + print_set_usage + return 0 + ;; + *) + print_set_usage + return 1 + ;; + esac + +} + +print_set_usage() { +cat << FOO +Usage: eselect opengl set [<options>] <GL implementation> + Set the opengl implementation. + Valid options: + --use-old: If an implementation is already set, use that one. + --prefix=<val>: Set the source prefix (default: /usr) + --dst-prefix=<val>: Set the destination prefix (default: /usr) + --impl-headers: Use headers provided by this implementation to + override golbal ones provided by opengl-update. + This was default in <opengl-update-2.2 +FOO +} |