public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/eselect:extern commit in: modules/
Date: Sun,  4 Jan 2015 10:00:20 +0000 (UTC)	[thread overview]
Message-ID: <1418079448.2ffcd1ddd6ff4a65a01133b2ed46597a6d4863e8.mgorny@gentoo> (raw)

commit:     2ffcd1ddd6ff4a65a01133b2ed46597a6d4863e8
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sun Dec  7 23:48:58 2014 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Dec  8 22:57:28 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/eselect.git;a=commit;h=2ffcd1dd

opengl: rewrite not to play with symlinks

Rewrite eselect-opengl to manipulate configuration files only. Properly
configuring the dynamic linker and xorg server, we can avoid doing
anything with libGL.so and related files, and guarantee that everything
is built against xorg-x11 implementation.

---
 modules/opengl.eselect | 201 +++++++++----------------------------------------
 1 file changed, 37 insertions(+), 164 deletions(-)

diff --git a/modules/opengl.eselect b/modules/opengl.eselect
index 3f59a19..40b448e 100644
--- a/modules/opengl.eselect
+++ b/modules/opengl.eselect
@@ -17,10 +17,11 @@ DESCRIPTION="Manage the OpenGL implementation used by your system"
 MAINTAINER="x11@gentoo.org"
 SVN_DATE='$Date$'
 VERSION=$(svn_date_to_version "${SVN_DATE}" )
-EBUILD_VERSION="1.2.1"
+EBUILD_VERSION="1.3.0"
 
 # Our data
-ENV_FILE="${EROOT}/etc/env.d/03opengl"
+ENV_FILE="${EROOT}/etc/env.d/000opengl"
+XORGD_FILE="${EROOT}/etc/X11/xorg.conf.d/20opengl.conf"
 PREFIX="${EROOT}/usr"
 DST_PREFIX="${EROOT}/usr"
 unset IGNORE_MISSING
@@ -42,7 +43,7 @@ get_current_implementation() {
 }
 
 get_implementations() {
-	local ret
+	local -a ret
 	local libdir
 	local dir
 	local dir_name
@@ -52,124 +53,32 @@ get_implementations() {
 		for dir in "${PREFIX}/${libdir}"/opengl/* ; do
 			dir_name=$(basename "${dir}")
 			[[ -d ${dir} && ${dir_name} != "global" ]] || continue
-			has ${dir_name} ${ret} && continue
-			ret=${ret:+${ret} }${dir_name}
+			has ${dir_name} "${ret[@]}" && continue
+			ret+=( "${dir_name}" )
 		done
 	done
 
-	echo ${ret}
-}
-
-# 1: file
-# 2: workdir
-upgrade_file() {
-	local file=$1
-	local filename
-	local workdir=$2
-	local linkfile=$(relative_name ${file} "${workdir}")
-
-	[[ -f ${file} ]] || return
-	filename=$(basename "${file}")
-
-	if [[ -f ${filename} || ( -L ${filename} && ! -e ${filename} ) ]] ; then
-		rm -f "${filename}"* || die -q "Failed to delete ${workdir}/${filename}"
-	fi
-
-	#echo "DEBUG: ln -s \"${linkfile}\" \"${filename}\""
-	if [[ "x${REMOVE_ONLY}" == "xfalse" ]]; then
-		ln -s "${linkfile}" "${filename}" || die -q "Failed to create symlink ${workdir}/${filename}"
-	fi
-}
-
-setup_soname_symlinks() {
-	local file=$1
-	local target=$2
-	local soname
-	local scanner
-
-	# if we have .so or dylib we need to make its soname symlinked
-	# in order to be easy to find and faster to grab
-	if [[ ${file} == *.so || ${file} == *.dylib ]] ; then
-		[[ ${file} == *.so ]] && scanner=scanelf || scanner="scanmacho"
-		soname=$(${scanner} -qBF '%S#p' "${file}" | head -n1)
-		[[ ${file} == *.so ]] && soname="${file%/*}"/${soname}
-		upgrade_file "${soname}" "${target}"
-	fi
-}
-
-setup_lib_symlinks() {
-	local profile_libdir=$1
-	local target=$2
-	local file
-
-	mkdir -p "${target}" || die "Failed to create ${target}"
-
-	pushd "${target}" &> /dev/null
-		# Note that lafiles are removed here and never enabled again
-		for file in libGL{,core}.la ; do
-			rm -f "${file}"* || die -q "Failed to delete ${file}"
-		done
-
-		for file in "${profile_libdir}"/lib{EGL,GL*,OpenVG}{,core}.{so,dylib,a}; do
-			upgrade_file "${file}" "${target}"
-			setup_soname_symlinks "${file}" "${target}"
-		done
-	popd &> /dev/null
-}
-
-setup_extensions_symlinks() {
-	local src=$1
-	local target=$2
-
-	if [[ -e ${src} ]] ; then
-		mkdir -p "${target}" || die "Failed to create ${target}"
-		pushd "${target}" &> /dev/null
-			# First remove old cruft symlinks
-			for file in lib{wfb,glx,dri,dri2}.{so,dylib,a}; do
-				rm -f "${file}" || die -q "Failed to delete ${targetdir}/${file}"
-			done
-
-			# regenerate symlinks
-			for file in "${src}"/*.{so,dylib,a}; do
-				upgrade_file "${file}" "${target}"
-				setup_soname_symlinks "${file}" "${target}"
-			done
-		popd &> /dev/null
-	fi
+	has xorg-x11 "${ret[@]}" || ret+=( xorg-x11 )
+	echo "${ret[*]}"
 }
 
-setup_includes_symlinks() {
-	local target=$1
-	local files=$2
-	local file
-	local mdir=$3
-	local sdir
-
-	shift 2
-	mkdir -p "${target}" || die "Failed to create ${target}"
-	pushd "${target}" &> /dev/null
-		for file in ${files}; do
-			for sdir in "$@"; do
-				if [[ -e ${sdir}/${file} ]]; then
-					upgrade_file "${sdir}/${file}" "${target}"
-					break
-				fi
-			done
-		done
-		test -d ${mdir} && for file in ${mdir}/*.h; do
-			upgrade_file "${file}" "${target}"
-		done
-	popd &> /dev/null
+# takes list of paths
+# outputs the file contents to stderr
+write_xorg_confd() {
+	local dir
+	echo 'Section "Files"'
+	for dir; do
+		echo "	ModulePath \"${dir}\""
+	done
+	echo 'EndSection'
 }
 
 set_new_implementation() {
 	local gl_implem=$1
 	local avail_implems=$(get_implementations)
 	local libdir
-	local moduledir
-	local gl_dir
-	local gl_local
-	local -A gl_header
+	local ldpath
+	local -a xorgmodpath
 
 	# Set a sane umask... bug #83115
 	umask 022
@@ -178,7 +87,7 @@ set_new_implementation() {
 		die -q "Invalid opengl implementation selected."
 	fi
 
-	if [[ -z ${IGNORE_MISSING+1} ]]; then
+	if [[ -z ${IGNORE_MISSING+1} && ${gl_implem} != xorg-x11 ]]; then
 		local found_libgl
 		for libdir in $(list_libdirs); do
 			[[ ${ROOT} != / ]] && libdir=${libdir#${EROOT}}
@@ -199,6 +108,9 @@ set_new_implementation() {
 	if [[ -f ${ENV_FILE} ]] ; then
 		rm -f "${ENV_FILE}" || die -q "Failed to remove ${ENV_FILE}"
 	fi
+	if [[ -f ${XORGD_FILE} ]] ; then
+		rm -f "${XORGD_FILE}" || die -q "Failed to remove ${ENV_FILE}"
+	fi
 
 	for libdir in $(list_libdirs); do
 		# Set libdir correctly to EROOT
@@ -208,70 +120,31 @@ set_new_implementation() {
 		# is a real lib dir, not a symlink
 		[[ -d ${PREFIX}/${libdir}/opengl && ! -h ${PREFIX}/${libdir} ]] || continue
 
-		# Set moduledir
-		# only xorg module is used now can change to case when we add other
-		# implementations.
-		moduledir="xorg/modules"
-
 		# Check if opengl implementation directory exists
 		# and use xorg-x11 as fallback (mesa)
 		# If even mesa is not around then simply die
-		if [[ -d "${PREFIX}/${libdir}/opengl/${gl_implem}" ]] ; then
-			gl_local="${gl_implem}"
-			REMOVE_ONLY="false" # global variable
-		else
-			# we are moving to implementation that does not have any support
-			# for specified libdir (ie 32bit libs for mesa) so we should
-			# remove the current symlinks and continue like nothing happened.
-			REMOVE_ONLY="true" # global variable
-			gl_local=$(get_current_implementation)
-			if ! has ${gl_local} ${avail_implems}; then
-				# skipping the libdir cause there was no profile actually
-				# selected before
-				continue 2
+		if [[ -d ${PREFIX}/${libdir}/opengl/${gl_implem} ]] ; then
+			# we need this relative to ROOT
+			ldpath=${ldpath:+${ldpath}:}${PREFIX#${ROOT}}/${libdir}/opengl/${gl_implem}/lib
+			if [[ -d ${PREFIX}/${libdir}/opengl/${gl_implem}/extensions ]]; then
+				xorgmodpath+=(
+					"${PREFIX#${ROOT}}/${libdir}/opengl/${gl_implem}"
+				)
 			fi
 		fi
-
-		setup_lib_symlinks \
-			"${PREFIX}/${libdir}/opengl/${gl_local}/lib" \
-			"${DST_PREFIX}/${libdir}"
-
-		# check if the implementation has TLS libs around
-		# and install those if around
-		[[ -e ${PREFIX}/${libdir}/opengl/${gl_local}/lib/tls ]] && \
-			setup_lib_symlinks \
-				"${PREFIX}/${libdir}/opengl/${gl_local}/lib/tls" \
-				"${DST_PREFIX}/${libdir}/tls"
-
-		setup_extensions_symlinks \
-			"${PREFIX}/${libdir}/opengl/${gl_local}/extensions" \
-			"${DST_PREFIX}/${libdir}/${moduledir}/extensions"
-
-		gl_header[GL]="gl.h glx.h glxtokens.h glext.h glxext.h glxmd.h glxproto.h"
-		gl_header[GLES]="egl.h gl_extensions.h glext.h gl.h glplatform.h"
-		gl_header[GLES2]="gl2ext.h gl2.h gl2platform.h"
-		gl_header[GLES3]="gl3ext.h gl3.h gl3platform.h"
-		gl_header[EGL]="eglext.h egl.h eglplatform.h"
-		gl_header[KHR]="khrplatform.h"
-		gl_header[VG]="openvg.h vgext.h vgplatform.h vgu.h"
-		for gl_dir in {EGL,GL,GLES,GLES2,GLES3,KHR,VG}; do
-			setup_includes_symlinks \
-			"${DST_PREFIX}/include/${gl_dir}" \
-				"${gl_header[${gl_dir}]}" \
-			"${PREFIX}/${libdir}/opengl/${gl_implem}/include/${gl_dir}/" \
-			"${PREFIX}/${libdir}/opengl/global/include/${gl_dir}" \
-			"${PREFIX}/${libdir}/opengl/xorg-x11/include/${gl_dir}/"
-		done
-		# Setup the $LDPATH
-		if [[ "x${REMOVE_ONLY}" == "xfalse" ]]; then
-			# we need this relative to ROOT
-			ldpath="${ldpath:+${ldpath}:}${PREFIX#${ROOT}}/${libdir}/opengl/${gl_local}/lib"
+		# We need the global module path too
+		if [[ -d ${PREFIX}/${libdir}/xorg/modules ]]; then
+			xorgmodpath+=(
+				"${PREFIX#${ROOT}}/${libdir}/xorg/modules"
+			)
 		fi
 	done
 
 	store_config ${ENV_FILE} LDPATH "${ldpath}"
 	store_config ${ENV_FILE} OPENGL_PROFILE "${gl_implem}"
 
+	write_xorg_confd "${xorgmodpath[@]}" >${XORGD_FILE}
+
 	do_action env update &> /dev/null
 
 	echo " done"


             reply	other threads:[~2015-01-04 10:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-04 10:00 Michał Górny [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-05-09  2:22 [gentoo-commits] proj/eselect:extern commit in: modules/ Patrick McLean
2018-08-30 16:48 Ulrich Müller
2018-03-10 10:22 Ulrich Müller
2018-03-10 10:22 Ulrich Müller
2018-03-10 10:22 Ulrich Müller
2015-02-26  6:52 Ben de Groot
2015-01-04 10:00 Michał Górny
2015-01-04 10:00 Michał Górny
2013-12-30  7:49 Ryan Hill
2013-11-17  8:34 Ryan Hill
2013-09-20 20:34 Ulrich Mueller
2013-03-11  7:06 Ulrich Mueller
2013-03-11  2:16 Christoph Junghans
2013-03-11  2:16 Christoph Junghans
2013-03-11  2:16 Christoph Junghans
2013-01-05 15:35 Ulrich Mueller
2012-06-21 12:26 Luca Barbato

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1418079448.2ffcd1ddd6ff4a65a01133b2ed46597a6d4863e8.mgorny@gentoo \
    --to=mgorny@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox