[RFC 1/3] Add gles-diversions package similar to glx-diversions

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


There won't probably be any new devices that don't support GLESv2
and all proprietary vendor drivers I encountered provide
libEGL, libGLESv1_CM and libGLESv2. So it's probably ok to simple
handle all three libs together.

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

---
 debian/control                           |   15 ++++
 debian/gles-diversions.dirs              |    3 +
 debian/gles-diversions.lintian-overrides |    4 +
 debian/gles-diversions.postinst          |  103 ++++++++++++++++++++++++++++++
 debian/gles-diversions.postrm            |   63 ++++++++++++++++++
 5 files changed, 188 insertions(+), 0 deletions(-)

diff --git a/debian/control b/debian/control
index ab43bdf..b3d849f 100644
--- a/debian/control
+++ b/debian/control
@@ -144,3 +144,18 @@ Description: allows the selection of FGLRX as GLX provider
  This package does not depend on the corresponding FGLRX libraries.
  In order to install the FGLRX driver and libraries, install the fglrx-glx and
  fglrx-driver packages instead.
+
+Package: gles-diversions
+Architecture: armel i386 amd64
+Multi-Arch: foreign
+Depends:
+ dpkg (>= 1.15),
+ ${misc:Depends}
+Recommends:
+ gles-alternative-mesa,
+Conflicts:
+ libgl1-mesa-swx11,
+Description: prepare for using accelerated OpenGL ES implementations from GPU vendors
+ 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.
diff --git a/debian/gles-diversions.dirs b/debian/gles-diversions.dirs
new file mode 100644
index 0000000..473f5a6
--- /dev/null
+++ b/debian/gles-diversions.dirs
@@ -0,0 +1,3 @@
+usr/lib/mesa-diverted/arm-linux-gnueabi
+usr/lib/mesa-diverted/i386-linux-gnu
+usr/lib/mesa-diverted/x86_64-linux-gnu
diff --git a/debian/gles-diversions.lintian-overrides b/debian/gles-diversions.lintian-overrides
new file mode 100644
index 0000000..7944483
--- /dev/null
+++ b/debian/gles-diversions.lintian-overrides
@@ -0,0 +1,4 @@
+# The diversions are placed here.
+package-contains-empty-directory usr/lib/mesa-diverted/arm-linux-gnueabi/
+package-contains-empty-directory usr/lib/mesa-diverted/i386-linux-gnu/
+package-contains-empty-directory usr/lib/mesa-diverted/x86_64-linux-gnu/
diff --git a/debian/gles-diversions.postinst b/debian/gles-diversions.postinst
new file mode 100644
index 0000000..c74e4ca
--- /dev/null
+++ b/debian/gles-diversions.postinst
@@ -0,0 +1,103 @@
+#!/bin/sh
+set -e
+
+
+TRIPLETS="/ /arm-linux-gnueabi/ /i386-linux-gnu/ /x86_64-linux-gnu/"
+#DIVERT_QUIET="--quiet"
+
+
+add_multiarch_diversion()
+{
+	local file source_dir diversion_dir triplet
+	file="$1"
+	source_dir="$2"
+	diversion_dir="$3"
+
+	for triplet in $TRIPLETS ; do
+		dpkg-divert $DIVERT_QUIET --add --rename --package $DPKG_MAINTSCRIPT_PACKAGE --divert \
+			${diversion_dir}${triplet}${file} \
+			${source_dir}${triplet}${file}
+	done
+}
+
+if [ "$1" = "configure" ]
+then
+
+	# make new diversions
+	add_multiarch_diversion libEGL.so /usr/lib /usr/lib/mesa-diverted
+	add_multiarch_diversion libEGL.so.1 /usr/lib /usr/lib/mesa-diverted
+	add_multiarch_diversion libEGL.so.1.0 /usr/lib /usr/lib/mesa-diverted
+
+	add_multiarch_diversion libGLESv1_CM.so /usr/lib /usr/lib/mesa-diverted
+	add_multiarch_diversion libGLESv1_CM.so.1 /usr/lib /usr/lib/mesa-diverted
+	add_multiarch_diversion libGLESv1_CM.so.1.1.0 /usr/lib /usr/lib/mesa-diverted
+
+	add_multiarch_diversion libGLESv2.so /usr/lib /usr/lib/mesa-diverted
+	add_multiarch_diversion libGLESv2.so.2 /usr/lib /usr/lib/mesa-diverted
+	add_multiarch_diversion libGLESv2.so.2.0.0 /usr/lib /usr/lib/mesa-diverted
+
+fi
+
+
+validate_diverted_symlink()
+{
+	local original diverted target owner filename
+	original="$1"
+	diverted="$2"
+	target="$3"
+	filename="$(basename "$original")"
+
+	# determine ownership of the original file
+	owner="$(LC_ALL=C dpkg-query -S "$original" 2>/dev/null | grep -v '^diversion by' || true)"
+
+	if [ -L "$diverted" ] && [ -z "$owner" ]; then
+		echo "Removing diverted '$filename' symlink owned by no package."
+		rm "$diverted"
+	fi
+
+	if [ -L "$diverted" ] && [ "$(readlink "$diverted")" != "$target" ]; then
+		echo "Removing diverted '$filename' symlink with unexpected target '$target'."
+		rm "$diverted"
+	fi
+
+	if [ ! -L "$diverted" ] && [ -n "$owner" ]; then
+		echo "Restoring diverted '$filename' symlink."
+		ln -s "$target" "$diverted"
+	fi
+}
+
+if [ "$1" = "configure" ]; then
+
+	# do some validation of the diverted libEGL.so and libEGL.so.1
+	for triplet in $TRIPLETS ; do
+		validate_diverted_symlink /usr/lib${triplet}libEGL.so /usr/lib/mesa-diverted${triplet}libEGL.so libEGL.so.1
+		validate_diverted_symlink /usr/lib${triplet}libEGL.so.1 /usr/lib/mesa-diverted${triplet}libEGL.so.1 libEGL.so.1.0
+
+		validate_diverted_symlink /usr/lib${triplet}libGLESv1_CM.so /usr/lib/mesa-diverted${triplet}libGLESv1_CM.so libGLESv1_CM.so.1
+		validate_diverted_symlink /usr/lib${triplet}libGLESv1_CM.so.1 /usr/lib/mesa-diverted${triplet}libGLESv1_CM.so.1 
libGLESv1_CM.so.1.1.0
+
+		validate_diverted_symlink /usr/lib${triplet}libGLESv2.so /usr/lib/mesa-diverted${triplet}libGLESv2.so libGLESv2.so.2
+		validate_diverted_symlink /usr/lib${triplet}libGLESv2.so.2 /usr/lib/mesa-diverted${triplet}libGLESv2.so.2 libGLESv2.so.2.0.0
+	done
+
+fi
+
+
+if [ "$1" = "configure" ]; then
+
+	# activate triggers
+	for triplet in $TRIPLETS ; do
+		dpkg-trigger /usr/lib${triplet}libEGL.so.1
+		dpkg-trigger /usr/lib${triplet}libEGL.so
+		dpkg-trigger /usr/lib${triplet}libGLESv1_CM.so.1
+		dpkg-trigger /usr/lib${triplet}libGLESv1_CM.so
+		dpkg-trigger /usr/lib${triplet}libGLESv2.so.2
+		dpkg-trigger /usr/lib${triplet}libGLESv2.so
+	done
+
+fi
+
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/gles-diversions.postrm b/debian/gles-diversions.postrm
new file mode 100644
index 0000000..52450d8
--- /dev/null
+++ b/debian/gles-diversions.postrm
@@ -0,0 +1,63 @@
+#!/bin/sh
+set -e
+
+
+TRIPLETS="/ /arm-linux-gnueabi/ /i386-linux-gnu/ /x86_64-linux-gnu/"
+#DIVERT_QUIET="--quiet"
+
+
+# Rationale:
+#
+# Remove our diversions at the remove stage, since even if we have
+# configuration files left, we want to put back everything we moved.  Do not
+# try to do this again on purge since remove will have already been called.
+#
+# Leave all of our diversions alone during upgrades or aborted upgrades, since
+# we're staying installed in all cases and the diversions are still correct.
+#
+# It's not clear what to do on disappear, but for now leave everything alone
+# and assume that our overwriting package will have logic to take over the
+# diversions and doesn't want us messing with them.
+
+remove_multiarch_diversion()
+{
+	local file source_dir diversion_dir triplet
+	file="$1"
+	source_dir="$2"
+	diversion_dir="$3"
+
+	for triplet in $TRIPLETS ; do
+		dpkg-divert $DIVERT_QUIET --remove --rename --package $DPKG_MAINTSCRIPT_PACKAGE --divert \
+			${diversion_dir}${triplet}${file} \
+			${source_dir}${triplet}${file}
+	done
+}
+
+case "$1" in
+    remove)
+
+	# restore libs, diverted to /usr/lib/mesa-diverted
+	remove_multiarch_diversion libEGL.so.1.0 /usr/lib /usr/lib/mesa-diverted
+	remove_multiarch_diversion libEGL.so.1 /usr/lib /usr/lib/mesa-diverted
+	remove_multiarch_diversion libEGL.so /usr/lib /usr/lib/mesa-diverted
+
+	remove_multiarch_diversion libGLESv1_CM.so.1.1.0 /usr/lib /usr/lib/mesa-diverted
+	remove_multiarch_diversion libGLESv1_CM.so.1 /usr/lib /usr/lib/mesa-diverted
+	remove_multiarch_diversion libGLESv1_CM.so /usr/lib /usr/lib/mesa-diverted
+
+	remove_multiarch_diversion libGLESv2.so.2.0.0 /usr/lib /usr/lib/mesa-diverted
+	remove_multiarch_diversion libGLESv2.so.2 /usr/lib /usr/lib/mesa-diverted
+	remove_multiarch_diversion libGLESv2.so /usr/lib /usr/lib/mesa-diverted
+
+	for triplet in $TRIPLETS ; do
+		rmdir /usr/lib/mesa-diverted${triplet} 2>/dev/null || true
+	done
+	rmdir /usr/lib/mesa-diverted 2>/dev/null || true
+
+    ;;
+esac
+
+
+#DEBHELPER#
+
+exit 0
-- 
tg: (780b399..) topic/gles-diversions (depends on: master)



More information about the pkg-nvidia-devel mailing list