From e5ca38496c833727b46cb10e3705279088afa03e Mon Sep 17 00:00:00 2001
From: Donnie Berkholz <dberkholz@gentoo.org>
Date: Wed, 10 Aug 2005 06:39:34 +0000
Subject: Bump to deal with modular X. Do this by only checking for a high
 enough xorg-x11 version if xorg-x11's installed. Package-Manager:
 portage-2.0.51.22-r2

---
 x11-base/opengl-update/ChangeLog                   |   9 +-
 x11-base/opengl-update/Manifest                    |  13 +-
 .../opengl-update/files/digest-opengl-update-2.2.2 |   2 +
 x11-base/opengl-update/files/opengl-update-2.2.2   | 375 +++++++++++++++++++++
 x11-base/opengl-update/opengl-update-2.2.2.ebuild  |  89 +++++
 5 files changed, 482 insertions(+), 6 deletions(-)
 create mode 100644 x11-base/opengl-update/files/digest-opengl-update-2.2.2
 create mode 100755 x11-base/opengl-update/files/opengl-update-2.2.2
 create mode 100644 x11-base/opengl-update/opengl-update-2.2.2.ebuild

(limited to 'x11-base/opengl-update')

diff --git a/x11-base/opengl-update/ChangeLog b/x11-base/opengl-update/ChangeLog
index 53f7c31172a3..5c18ab6b6db5 100644
--- a/x11-base/opengl-update/ChangeLog
+++ b/x11-base/opengl-update/ChangeLog
@@ -1,6 +1,13 @@
 # ChangeLog for x11-base/opengl-update
 # Copyright 2002-2005 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/x11-base/opengl-update/ChangeLog,v 1.98 2005/07/07 22:51:45 geoman Exp $
+# $Header: /var/cvsroot/gentoo-x86/x11-base/opengl-update/ChangeLog,v 1.99 2005/08/10 06:39:34 spyderous Exp $
+
+*opengl-update-2.2.2 (10 Aug 2005)
+
+  10 Aug 2005; Donnie Berkholz <spyderous@gentoo.org>;
+  +files/opengl-update-2.2.2, +opengl-update-2.2.2.ebuild:
+  Bump to deal with modular X. Do this by only checking for a high enough
+  xorg-x11 version if xorg-x11's installed.
 
   07 Jul 2005; Stephen P. Becker <geoman@gentoo.org>
   opengl-update-2.2.1.ebuild:
diff --git a/x11-base/opengl-update/Manifest b/x11-base/opengl-update/Manifest
index 94e2e8cb593e..a33f3690d1fd 100644
--- a/x11-base/opengl-update/Manifest
+++ b/x11-base/opengl-update/Manifest
@@ -1,9 +1,12 @@
-MD5 6cae34c9865539c34b8b126a72572fde opengl-update-2.1.1-r1.ebuild 2327
-MD5 cd3a4b8acf0490934369cbcead0fcf26 opengl-update-2.2.1.ebuild 2670
-MD5 7f869416fa7a0be40c69de268987445d ChangeLog 17933
 MD5 69eeef9cee49974bcaae3cb9ddce8abd metadata.xml 366
-MD5 ca73e0f8c9b114553216930eb0eb601a files/glxext.h-inttypes.patch 677
-MD5 91d9c17541be018d065a7838d7149c86 files/opengl-update-2.1.1 9110
+MD5 cd3a4b8acf0490934369cbcead0fcf26 opengl-update-2.2.1.ebuild 2670
+MD5 3f1fd46674f23700b58fe740b04cc5a7 opengl-update-2.2.2.ebuild 2684
+MD5 6cae34c9865539c34b8b126a72572fde opengl-update-2.1.1-r1.ebuild 2327
+MD5 f7f2b863181b3bd59855d7ebba3b8bcc ChangeLog 18205
 MD5 78f2778d5b41874016deb3135122b189 files/opengl-update-2.2.1 9849
+MD5 91d9c17541be018d065a7838d7149c86 files/opengl-update-2.1.1 9110
 MD5 219a292f64caeaa46b333eecde2197f2 files/digest-opengl-update-2.2.1 116
+MD5 ae5b820a1034139870f7b0867f37be17 files/opengl-update-2.2.2 9702
+MD5 219a292f64caeaa46b333eecde2197f2 files/digest-opengl-update-2.2.2 116
 MD5 bbec0e16e4f45a464cec5b4feeecaa9b files/digest-opengl-update-2.1.1-r1 116
+MD5 ca73e0f8c9b114553216930eb0eb601a files/glxext.h-inttypes.patch 677
diff --git a/x11-base/opengl-update/files/digest-opengl-update-2.2.2 b/x11-base/opengl-update/files/digest-opengl-update-2.2.2
new file mode 100644
index 000000000000..f25de9a2425e
--- /dev/null
+++ b/x11-base/opengl-update/files/digest-opengl-update-2.2.2
@@ -0,0 +1,2 @@
+MD5 aba5f492425adddd083c941735b8e3c1 glext.h-27.bz2 33156
+MD5 3260a509b23a3519b8df335a4e8f5e1d glxext.h-10.bz2 5895
diff --git a/x11-base/opengl-update/files/opengl-update-2.2.2 b/x11-base/opengl-update/files/opengl-update-2.2.2
new file mode 100755
index 000000000000..ddc3512381a3
--- /dev/null
+++ b/x11-base/opengl-update/files/opengl-update-2.2.2
@@ -0,0 +1,375 @@
+#!/bin/bash
+# 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-2.2.2,v 1.1 2005/08/10 06:39:34 spyderous 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>
+
+. /etc/init.d/functions.sh
+
+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
+		eerror "${0}: Must be run as root."
+		exit 1
+	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
+			eerror "This version requires >=x11-base/xorg-x11-6.8.0-r4"
+			exit 1
+		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}
+}
+
+print_version() {
+	echo "opengl-update ${VERSION}"
+}
+
+print_usage() {
+	# Get grammar right in message
+	local IS_ARE IMPLEM_PLURAL
+	if [[ $(echo ${AVAIL_IMPLEMS} | wc -w) -eq 1 ]]; then
+		IS_ARE="is"
+		IMPLEM_PLURAL=""
+	else
+		IS_ARE="are"
+		IMPLEM_PLURAL="s"
+	fi
+
+	print_version
+
+	cat << FOO
+Usage: ${0##*/} [<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.
+
+Usage: ${0##*/} --get-implementation
+       Print the current implementaion
+
+Notes:
+       --impl-headers was default in <opengl-update-2.2.
+
+       This utility switches between OpenGL implementations.  There ${IS_ARE}
+       $(echo ${AVAIL_IMPLEMS} | wc -w) available implementation${IMPLEM_PLURAL}: ${AVAIL_IMPLEMS}
+
+Examples:
+       ${0##*/} xorg-x11
+       This will setup things to use libGL.so from X.org.
+
+       ${0##*/} nvidia
+       This will setup things to use libGL.so from the nVidia drivers.
+
+FOO
+	exit 1
+}
+
+parse_options() {
+	local opt
+	while [[ ${#} -gt 0 ]]; do
+		opt=${1}
+		shift
+		case ${opt} in
+			--use-old)
+				if [[ -n "${ACTION}" ]]; then
+					ACTION="error"
+					eerror "Invalid usage."
+				else
+					if [[ -n "${CURRENT_GL_IMPLEM}" ]] && hasq ${CURRENT_GL_IMPLEM} ${AVAIL_IMPLEMS}; then
+						ACTION="old-implementation"
+					fi
+				fi				
+			;;
+			--get-implementation)
+				if [[ -n "${ACTION}" ]]; then
+					ACTION="error"
+					eerror "Invalid usage."
+				else
+					ACTION="get-implementation"
+				fi				
+			;;
+			--prefix=*)
+				PREFIX=${opt#*=}
+				AVAIL_IMPLEMS=$(get_implementations)
+			;;
+			--dst-prefix=*)
+				DST_PREFIX=${opt#*=}
+			;;
+			--impl-headers)
+				USE_PROFILE_HEADERS="yes"
+			;;
+			--help|-h|-?)
+				ACION="usage"
+			;;
+			--version)
+				ACTION="version"
+			;;
+			*)
+				if hasq ${opt} ${AVAIL_IMPLEMS}; then
+					if [[ "${ACTION}" != "old-implementation" ]]; then
+						if [[ -n "${ACTION}" ]]; then
+							ACTION="error"
+							eerror "Invalid usage."
+						else
+							ACTION="set-implementation"
+							NEW_GL_IMPLEM="${opt}"
+						fi
+					fi				
+				else
+					eerror "Unrecognized option: ${opt}"
+					ACTION="error"
+				fi
+			;;
+		esac
+	done
+}
+
+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
+
+	ebegin "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
+
+			if [[ -e "${PREFIX}/${LIBDIR}/opengl/${GL_LOCAL}/extensions" ]]; then
+				mkdir -p ${DST_PREFIX}/${LIBDIR}/modules/extensions
+				pushd ${DST_PREFIX}/${LIBDIR}/modules/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
+
+	eend 0
+}
+
+## START PROGRAM ##
+
+ENV_D="/etc/env.d/03opengl"
+NEW_GL_IMPLEM=""
+ACTION=""
+PREFIX="/usr"
+DST_PREFIX="/usr"
+AVAIL_IMPLEMS=$(get_implementations)
+CURRENT_GL_IMPLEM=$(get_current_implem)
+USE_PROFILE_HEADERS="no"
+VERSION="2.2.1"
+
+parse_options ${@}
+
+case ${ACTION} in
+	get-implementation)
+		if [[ -n "${CURRENT_GL_IMPLEM}" ]]; then
+			echo ${CURRENT_GL_IMPLEM}
+			exit 0
+		else
+			exit 2
+		fi
+	;;
+	old-implementation)
+		set-new-implementation ${CURRENT_GL_IMPLEM}
+		exit $?
+	;;
+	set-implementation)
+		if [[ -n "${NEW_GL_IMPLEM}" ]]; then
+			set-new-implementation ${NEW_GL_IMPLEM}
+			exit $?
+		else
+			print_usage
+			exit 1
+		fi
+	;;
+	version)
+		print_version
+		exit 0
+	;;
+	usage)
+		print_usage
+		exit 0
+	;;
+	error)
+		print_usage
+		exit 1
+	;;
+	*)
+		print_usage
+		exit 1
+	;;
+esac
diff --git a/x11-base/opengl-update/opengl-update-2.2.2.ebuild b/x11-base/opengl-update/opengl-update-2.2.2.ebuild
new file mode 100644
index 000000000000..4abe155fda18
--- /dev/null
+++ b/x11-base/opengl-update/opengl-update-2.2.2.ebuild
@@ -0,0 +1,89 @@
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/x11-base/opengl-update/opengl-update-2.2.2.ebuild,v 1.1 2005/08/10 06:39:34 spyderous Exp $
+
+inherit multilib toolchain-funcs eutils
+
+DESCRIPTION="Utility to change the OpenGL interface being used"
+HOMEPAGE="http://www.gentoo.org/"
+
+# Source:
+# http://oss.sgi.com/projects/ogl-sample/ABI/glext.h
+# http://oss.sgi.com/projects/ogl-sample/ABI/glxext.h
+
+GLEXT="27"
+GLXEXT="10"
+
+SRC_URI="http://dev.gentoo.org/~eradicator/opengl/glext.h-${GLEXT}.bz2
+	 http://dev.gentoo.org/~eradicator/opengl/glxext.h-${GLXEXT}.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86"
+IUSE=""
+RESTRICT="multilib-pkg-force"
+
+DEPEND="virtual/libc
+	app-arch/bzip2"
+
+S="${WORKDIR}"
+
+src_unpack() {
+	unpack ${A}
+
+	# Bugs #81199, #81472
+	epatch ${FILESDIR}/glxext.h-inttypes.patch
+}
+
+pkg_preinst() {
+	# It needs to be before 04multilib
+	[ -f "${ROOT}/etc/env.d/09opengl" ] && mv ${ROOT}/etc/env.d/09opengl ${ROOT}/etc/env.d/03opengl
+
+	OABI="${ABI}"
+	for ABI in $(get_install_abis); do
+		if [ -e "${ROOT}/usr/$(get_libdir)/opengl/xorg-x11/lib/libMesaGL.so" ]; then
+			einfo "Removing libMesaGL.so from xorg-x11 profile.  See bug #47598."
+			rm -f ${ROOT}/usr/$(get_libdir)/opengl/xorg-x11/lib/libMesaGL.so
+		fi
+		if [ -e "${ROOT}/usr/$(get_libdir)/libMesaGL.so" ]; then
+			einfo "Removing libMesaGL.so from /usr/$(get_libdir).  See bug #47598."
+			rm -f ${ROOT}/usr/$(get_libdir)/libMesaGL.so
+		fi
+
+		for f in ${ROOT}/usr/$(get_libdir)/libGL.so.* ${ROOT}/usr/$(get_libdir)/libGLcore.so.* ${ROOT}/usr/$(get_libdir)/libnvidia-tls* ${ROOT}/usr/$(get_libdir)/tls/libnvidia-tls* ; do
+			[[ -e ${f} ]] && rm -f ${f}
+		done
+	done
+	ABI="${OABI}"
+	unset OABI
+}
+
+pkg_postinst() {
+	local impl="$(opengl-update --get-implementation)"
+	if [[ -n "${impl}" ]] ; then
+		opengl-update "${impl}"
+	fi
+}
+
+src_install() {
+	newsbin ${FILESDIR}/opengl-update-${PV} opengl-update || die
+
+	# MULTILIB-CLEANUP: Fix this when FEATURES=multilib-pkg is in portage
+	local MLTEST=$(type dyn_unpack)
+	if has_multilib_profile && [ "${MLTEST/set_abi}" = "${MLTEST}" ]; then
+		OABI="${ABI}"
+		for ABI in $(get_install_abis); do
+			# Install default glext.h
+			insinto /usr/$(get_libdir)/opengl/global/include
+			newins ${WORKDIR}/glext.h-${GLEXT} glext.h || die
+			newins ${WORKDIR}/glxext.h-${GLXEXT} glxext.h || die
+		done
+		ABI="${OABI}"
+		unset OABI
+	else
+		# Install default glext.h
+		insinto /usr/$(get_libdir)/opengl/global/include
+		newins ${WORKDIR}/glext.h-${GLEXT} glext.h || die
+		newins ${WORKDIR}/glxext.h-${GLXEXT} glxext.h || die
+	fi
+}
-- 
cgit v1.2.3-65-gdbad