[RFC 2/3] gles-alternative-mesa package

Heiko Stübner heiko at sntech.de
Thu Jul 21 06:46:19 UTC 2011


Handles the original libraries provided by mesa and the .so links

Signed-off-by: Heiko Stuebner <mmind at debian.org>

---
 debian/control                        |   19 ++++++
 debian/gles-alternative-mesa.postinst |  103 +++++++++++++++++++++++++++++++++
 debian/gles-alternative-mesa.prerm    |   17 ++++++
 debian/gles-alternative-mesa.triggers |   61 +++++++++++++++++++
 4 files changed, 200 insertions(+), 0 deletions(-)

diff --git a/debian/control b/debian/control
index b3d849f..37a3798 100644
--- a/debian/control
+++ b/debian/control
@@ -159,3 +159,22 @@ Description: prepare for using accelerated OpenGL ES implementations from GPU ve
  Diverts the free libEGL.so, libGLES1v1_CM.so and libGLESv2.so implementations (MESA)
  preparing the system for plugging in accelerated implementations from GPU vendors via
  alternatives, see the gles-alternative-* packages.
+
+Package: gles-alternative-mesa
+Architecture: armel i386 amd64
+Multi-Arch: foreign
+Depends:
+ gles-diversions (= ${binary:Version}),
+ ${misc:Depends}
+Suggests:
+ libgles1-mesa, libgles2-mesa, libegl1-mesa
+Description: allows the selection of MESA as OpenGL ES provider
+ In setups with several OpenGL ES providers (e.g. the free MESA implementation and
+ proprietary graphics hardware vendor implementations) this metapackage
+ allows one to switch back to MESA.
+ .
+ Use 'update-alternatives --config gles' to select an implementation.
+ .
+ This package does not depend on the corresponding MESA libraries.
+ In order to install the MESA libraries, install the libgles1-mesa, libgles2-mesa
+ and libegl1-mesa packages instead.
diff --git a/debian/gles-alternative-mesa.postinst b/debian/gles-alternative-mesa.postinst
new file mode 100644
index 0000000..d73dd79
--- /dev/null
+++ b/debian/gles-alternative-mesa.postinst
@@ -0,0 +1,103 @@
+#!/bin/sh
+set -e
+
+
+TRIPLETS="/ /arm-linux-gnueabi/ /i386-linux-gnu/ /x86_64-linux-gnu/"
+
+add_slave()
+{
+	local target_link name source_path prefix
+	target_link="$1"
+	name="$2"
+	source_path="$3"
+	prefix="gles--"
+
+	if [ -f "${source_path}" ] && [ -d "$(dirname "${target_link}")" ]; then
+		echo --slave "${target_link}" "${prefix}${name}" "${source_path}"
+	fi
+}
+
+add_multiarch_slave()
+{
+	local target_dir target_sub_dir file source_dir source_sub_dir prefix suffix triplet
+	target_dir="$1"
+	target_sub_dir="$2"
+	file="$3"
+	source_dir="$4"
+	source_sub_dir="$5"
+	prefix="$6"
+
+	for triplet in $TRIPLETS ; do
+		# s|/$||; s|^/|-|;
+		suffix="${triplet%/}"
+		suffix="${suffix:+-${suffix#/}}"
+		add_slave \
+			"${target_dir}${triplet}${target_sub_dir}${file}" \
+			"${prefix}${file}${suffix}" \
+			"${source_dir}${triplet}${source_sub_dir}${file}"
+	done
+}
+
+# A trigger that handles the alternatives for
+# * /usr/lib[/<triplet>]/libEGL.so
+# * /usr/lib[/<triplet>]/libEGL.so.1
+# * /usr/lib[/<triplet>]/libGLESv1_CM.so
+# * /usr/lib[/<triplet>]/libGLESv1_CM.so.1
+# * /usr/lib[/<triplet>]/libGLESv2.so
+# * /usr/lib[/<triplet>]/libGLESv2.so.2
+if [ "$1" = "triggered" ]; then
+
+	# libEGL.so.1, libGLESv1_CM.so.1, libGLESv2.so.2
+	slaves="
+		$(add_multiarch_slave /usr/lib "" libEGL.so.1 /usr/lib/mesa-diverted)
+		$(add_multiarch_slave /usr/lib "" libGLESv1_CM.so.1 /usr/lib/mesa-diverted)
+		$(add_multiarch_slave /usr/lib "" libGLESv2.so.2 /usr/lib/mesa-diverted)
+"
+
+	if echo "$slaves" | grep -q "slave" ; then
+		update-alternatives --install /usr/lib/gles gles /usr/lib/mesa-diverted 5 $slaves
+	else
+		update-alternatives --remove gles /usr/lib/mesa-diverted
+	fi
+
+	# libEGL.so
+	slaves="$(add_multiarch_slave /usr/lib "" libEGL.so /usr/lib/mesa-diverted)"
+
+	if echo "$slaves" | grep -q "slave" ; then
+		update-alternatives --install /usr/lib/mesa-diverted/libEGL.so-master libEGL.so-master /usr/lib/mesa-diverted 9995 $slaves
+	else
+		update-alternatives --remove libEGL.so-master /usr/lib/mesa-diverted
+	fi
+
+	# libGLESv1_CM.so
+	slaves="$(add_multiarch_slave /usr/lib "" libGLESv1_CM.so /usr/lib/mesa-diverted)"
+
+	if echo "$slaves" | grep -q "slave" ; then
+		update-alternatives --install /usr/lib/mesa-diverted/libGLESv1_CM.so-master libGLESv1_CM.so-master /usr/lib/mesa-diverted 9995 
$slaves
+	else
+		update-alternatives --remove libGLESv1_CM.so-master /usr/lib/mesa-diverted
+	fi
+
+	# libGLESv2.so
+	slaves="$(add_multiarch_slave /usr/lib "" libGLESv2.so /usr/lib/mesa-diverted)"
+
+	if echo "$slaves" | grep -q "slave" ; then
+		update-alternatives --install /usr/lib/mesa-diverted/libGLESv2.so-master libGLESv2.so-master /usr/lib/mesa-diverted 9995 $slaves
+	else
+		update-alternatives --remove libGLESv2.so-master /usr/lib/mesa-diverted
+	fi
+
+fi
+
+
+if [ "$1" = "configure" ]; then
+
+	# activate our trigger
+	dpkg-trigger register-gles-alternative-mesa
+
+fi
+
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/gles-alternative-mesa.prerm b/debian/gles-alternative-mesa.prerm
new file mode 100644
index 0000000..658035e
--- /dev/null
+++ b/debian/gles-alternative-mesa.prerm
@@ -0,0 +1,17 @@
+#!/bin/sh
+set -e
+
+
+if [ "$1" = "remove" ] || [ "$1" = "deconfigure" ]; then
+
+	update-alternatives --remove libEGL.so-master /usr/lib/mesa-diverted
+	update-alternatives --remove libGLESv1_CM.so-master /usr/lib/mesa-diverted
+	update-alternatives --remove libGLESv2.so-master /usr/lib/mesa-diverted
+	update-alternatives --remove gles /usr/lib/mesa-diverted
+
+fi
+
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/gles-alternative-mesa.triggers b/debian/gles-alternative-mesa.triggers
new file mode 100644
index 0000000..acbf087
--- /dev/null
+++ b/debian/gles-alternative-mesa.triggers
@@ -0,0 +1,61 @@
+interest register-gles-alternative-mesa
+
+interest /usr/lib/libEGL.so
+interest /usr/lib/arm-linux-gnueabi/libEGL.so
+interest /usr/lib/i386-linux-gnu/libEGL.so
+interest /usr/lib/x86_64-linux-gnu/libEGL.so
+
+interest /usr/lib/mesa-diverted/libEGL.so
+interest /usr/lib/mesa-diverted/arm-linux-gnueabi/libEGL.so
+interest /usr/lib/mesa-diverted/i386-linux-gnu/libEGL.so
+interest /usr/lib/mesa-diverted/x86_64-linux-gnu/libEGL.so
+
+interest /usr/lib/libEGL.so.1
+interest /usr/lib/arm-linux-gnueabi/libEGL.so.1
+interest /usr/lib/i386-linux-gnu/libEGL.so.1
+interest /usr/lib/x86_64-linux-gnu/libEGL.so.1
+
+interest /usr/lib/mesa-diverted/libEGL.so.1
+interest /usr/lib/mesa-diverted/arm-linux-gnueabi/libEGL.so.1
+interest /usr/lib/mesa-diverted/i386-linux-gnu/libEGL.so.1
+interest /usr/lib/mesa-diverted/x86_64-linux-gnu/libEGL.so.1
+
+interest /usr/lib/libGLESv1_CM.so
+interest /usr/lib/arm-linux-gnueabi/libGLESv1_CM.so
+interest /usr/lib/i386-linux-gnu/libGLESv1_CM.so
+interest /usr/lib/x86_64-linux-gnu/libGLESv1_CM.so
+
+interest /usr/lib/mesa-diverted/libGLESv1_CM.so
+interest /usr/lib/mesa-diverted/arm-linux-gnueabi/libGLESv1_CM.so
+interest /usr/lib/mesa-diverted/i386-linux-gnu/libGLESv1_CM.so
+interest /usr/lib/mesa-diverted/x86_64-linux-gnu/libGLESv1_CM.so
+
+interest /usr/lib/libGLESv1_CM.so.1
+interest /usr/lib/arm-linux-gnueabi/libGLESv1_CM.so.1
+interest /usr/lib/i386-linux-gnu/libGLESv1_CM.so.1
+interest /usr/lib/x86_64-linux-gnu/libGLESv1_CM.so.1
+
+interest /usr/lib/mesa-diverted/libGLESv1_CM.so.1
+interest /usr/lib/mesa-diverted/arm-linux-gnueabi/libGLESv1_CM.so.1
+interest /usr/lib/mesa-diverted/i386-linux-gnu/libGLESv1_CM.so.1
+interest /usr/lib/mesa-diverted/x86_64-linux-gnu/libGLESv1_CM.so.1
+
+interest /usr/lib/libGLESv2.so
+interest /usr/lib/arm-linux-gnueabi/libGLESv2.so
+interest /usr/lib/i386-linux-gnu/libGLESv2.so
+interest /usr/lib/x86_64-linux-gnu/libGLESv2.so
+
+interest /usr/lib/mesa-diverted/libGLESv2.so
+interest /usr/lib/mesa-diverted/arm-linux-gnueabi/libGLESv2.so
+interest /usr/lib/mesa-diverted/i386-linux-gnu/libGLESv2.so
+interest /usr/lib/mesa-diverted/x86_64-linux-gnu/libGLESv2.so
+
+interest /usr/lib/libGLESv2.so.2
+interest /usr/lib/arm-linux-gnueabi/libGLESv2.so.2
+interest /usr/lib/i386-linux-gnu/libGLESv2.so.2
+interest /usr/lib/x86_64-linux-gnu/libGLESv2.so.2
+
+interest /usr/lib/mesa-diverted/libGLESv2.so.2
+interest /usr/lib/mesa-diverted/arm-linux-gnueabi/libGLESv2.so.2
+interest /usr/lib/mesa-diverted/i386-linux-gnu/libGLESv2.so.2
+interest /usr/lib/mesa-diverted/x86_64-linux-gnu/libGLESv2.so.2
-- 
tg: (df81887..) topic/gles-alternative-mesa (depends on: master topic/gles-diversions)



More information about the pkg-nvidia-devel mailing list