Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=frugalware-current.git;a=commitdiff;h=eb58a0e23132c8f11a1f0f37cc3a6779bc43c2e6

commit eb58a0e23132c8f11a1f0f37cc3a6779bc43c2e6
Author: James Buren <[email protected]>
Date:   Fri Nov 20 04:36:56 2015 +0100

lib32-0.2-1-x86_64
* add C program to wrap glibc dynamic loader (needed for DRI to work)

diff --git a/source/lib32-extra/lib32/FrugalBuild 
b/source/lib32-extra/lib32/FrugalBuild
index e459794..b7ce5e8 100644
--- a/source/lib32-extra/lib32/FrugalBuild
+++ b/source/lib32-extra/lib32/FrugalBuild
@@ -2,7 +2,7 @@
# Maintainer: James Buren <[email protected]>

pkgname=lib32
-pkgver=0.1
+pkgver=0.2
pkgrel=1
pkgdesc="Configuration and other files required to make lib32 work."
url="http://frugalware.org";
@@ -10,7 +10,8 @@ depends=()
groups=('lib32-extra')
archs=('!i686' 'x86_64')
up2date="$pkgver"
-source=()
+source=('ld-wrapper.c')
+sha1sums=('8bbbcf2edf32a823e24c1cca735b8a8badfb441e')

build() {
# Tells ldconfig how to find 32 bit libraries.
@@ -24,9 +25,11 @@ EOF
# Tells binfmt how to load 32 bit binaries.
Fmkdir /etc/binfmt.d/
cat > "$Fdestdir/etc/binfmt.d/lib32.conf" << EOF
-:lib32:M::\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00\x01\x00\x00\x00::/lib32/ld-linux.so.2:
+:lib32:M::\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00\x01\x00\x00\x00::/lib32/ld-wrapper:
EOF

# Create the 32 bit library directories.
Fmkdir /lib32 /usr/lib32 /usr/local/lib32
+
+       gcc -Wall -Wextra $CFLAGS ld-wrapper.c -o "$Fdestdir/lib32/ld-wrapper" 
|| Fdie
}
diff --git a/source/lib32-extra/lib32/ld-wrapper.c 
b/source/lib32-extra/lib32/ld-wrapper.c
new file mode 100644
index 0000000..62eaba6
--- /dev/null
+++ b/source/lib32-extra/lib32/ld-wrapper.c
@@ -0,0 +1,35 @@
+#include <stdlib.h>
+#include <unistd.h>
+
+typedef struct {
+       char *key;
+       char *value;
+} table_pair_t;
+
+static void prepare_environment(void) {
+       static const table_pair_t table[] = {
+               { "LIBGL_DRIVERS_PATH", "/usr/lib32/dri" },
+               {                 NULL,             NULL }
+       };
+       size_t i;
+
+       for( i = 0 ; table[i].key != NULL ; ++i ) {
+               setenv(table[i].key, table[i].value, 1);
+       }
+}
+
+static void launch_binary(char **argv) {
+       static const char ld[] = "/lib32/ld-linux.so.2";
+
+       execv(ld, argv);
+}
+
+int main(int argc, char **argv) {
+       (void) argc;
+
+       prepare_environment();
+
+       launch_binary(&argv[1]);
+
+       return 1;
+}
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to