]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
Fake output of uname(3) on different host arches.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 11 Dec 2011 02:34:29 +0000 (03:34 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 11 Dec 2011 02:34:29 +0000 (03:34 +0100)
po/pakfire.pot
python/pakfire/builder.py
tools/fake-environ/Makefile [new file with mode: 0644]
tools/fake-environ/uname.c [new file with mode: 0644]

index ec67bf4c64c9be332d81229d93c66c1755956264..0e84beaf93a213f31154e028a088e8114ad6c26f 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-12-11 02:41+0100\n"
+"POT-Creation-Date: 2011-12-11 03:33+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -132,72 +132,72 @@ msgstr ""
 msgid "Extracting"
 msgstr ""
 
-#: ../python/pakfire/builder.py:575
+#: ../python/pakfire/builder.py:582
 msgid "You cannot run a build when no package was given."
 msgstr ""
 
-#: ../python/pakfire/builder.py:580
+#: ../python/pakfire/builder.py:587
 #, python-format
 msgid "Could not find makefile in build root: %s"
 msgstr ""
 
-#: ../python/pakfire/builder.py:594
+#: ../python/pakfire/builder.py:601
 msgid "The build command failed. See logfile for details."
 msgstr ""
 
 #. Walk through the whole tree and collect all files
 #. that are on the same disk (not crossing mountpoints).
-#: ../python/pakfire/builder.py:652
+#: ../python/pakfire/builder.py:659
 msgid "Creating filelist..."
 msgstr ""
 
 #. Create a nice progressbar.
-#: ../python/pakfire/builder.py:671
+#: ../python/pakfire/builder.py:678
 msgid "Compressing files..."
 msgstr ""
 
-#: ../python/pakfire/builder.py:690
+#: ../python/pakfire/builder.py:697
 #, python-format
 msgid "Cache file was successfully created at %s."
 msgstr ""
 
-#: ../python/pakfire/builder.py:691
+#: ../python/pakfire/builder.py:698
 #, python-format
 msgid "  Containing %(files)s files, it has a size of %(size)s."
 msgstr ""
 
 #. Make a nice progress bar as always.
-#: ../python/pakfire/builder.py:702
+#: ../python/pakfire/builder.py:709
 msgid "Extracting files..."
 msgstr ""
 
 #. Update all packages.
-#: ../python/pakfire/builder.py:722
+#: ../python/pakfire/builder.py:729
 msgid "Updating packages from cache..."
 msgstr ""
 
 #. Package the result.
 #. Make all these little package from the build environment.
-#: ../python/pakfire/builder.py:838
+#: ../python/pakfire/builder.py:845
 msgid "Creating packages:"
 msgstr ""
 
 #. Execute the buildscript of this stage.
-#: ../python/pakfire/builder.py:858
+#: ../python/pakfire/builder.py:865
 #, python-format
 msgid "Running stage %s:"
 msgstr ""
 
-#: ../python/pakfire/builder.py:876
+#: ../python/pakfire/builder.py:883
 #, python-format
 msgid "Could not remove static libraries: %s"
 msgstr ""
 
-#: ../python/pakfire/builder.py:882
+#: ../python/pakfire/builder.py:889
 msgid "Compressing man pages did not complete successfully."
 msgstr ""
 
-#: ../python/pakfire/builder.py:902
+#: ../python/pakfire/builder.py:909
 msgid "Extracting debuginfo did not complete with success. Aborting build."
 msgstr ""
 
index d196c27ce1068d06a914135316f0defcd1ff520a..a17c32d077da3c8d152853a050c785e74bfb2080 100644 (file)
@@ -529,7 +529,14 @@ class BuildEnviron(object):
                                env["ICECC_PREFERRED_HOST"] = \
                                        self.settings.get("icecream_preferred_host")
 
-               # XXX what do we need else?
+               # Fake UTS_MACHINE, when we cannot use the personality syscall and
+               # if the host architecture is not equal to the target architecture.
+               if not self.pakfire.distro.personality and \
+                               not self.pakfire.config.host_arch == self.pakfire.distro.arch:
+                       env.update({
+                               "LD_PRELOAD"  : "/usr/lib/libpakfire_preload.so",
+                               "UTS_MACHINE" : self.pakfire.distro.arch,
+                       })
 
                return env
 
diff --git a/tools/fake-environ/Makefile b/tools/fake-environ/Makefile
new file mode 100644 (file)
index 0000000..67578ea
--- /dev/null
@@ -0,0 +1,25 @@
+
+include ../../Makeconfig
+
+LIB = libpakfire_preload.so
+
+SOURCES = $(wildcard *.c)
+OBJECTS = $(patsubst %.c,%.o,$(SOURCES))
+
+.PHONY: all
+all: $(LIB)
+
+%.o: %.c Makefile
+       $(CC) $(CFLAGS) -o $@ -c $<
+
+$(LIB): $(OBJECTS)
+       $(CC) $(CFLAGS) -shared -o $@ $? -ldl
+
+.PHONY: install
+install: all
+       -mkdir -pv $(DESTDIR)$(SCRIPT_DIR)
+       install -p -m 755 $(LIB) $(DESTDIR)$(LIBDIR)
+
+.PHONY: clean
+clean:
+       $(LIB)
diff --git a/tools/fake-environ/uname.c b/tools/fake-environ/uname.c
new file mode 100644 (file)
index 0000000..2485a81
--- /dev/null
@@ -0,0 +1,50 @@
+
+
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <stdlib.h>            /* for EXIT_FAILURE */
+#include <unistd.h>            /* for _exit() */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/syslog.h>
+#include <sys/utsname.h>
+
+#ifndef RTLD_NEXT
+#define RTLD_NEXT      ((void *) -1l)
+#endif
+
+typedef int (*uname_t)(struct utsname * buf);
+
+static void *get_libc_func(const char *funcname) {
+       char *error;
+
+       void *func = dlsym(RTLD_NEXT, funcname);
+       if ((error = dlerror()) != NULL) {
+               fprintf(stderr, "I can't locate libc function `%s' error: %s", funcname, error);
+               _exit(EXIT_FAILURE);
+       }
+
+       return func;
+}
+
+int uname(struct utsname *buf) {
+       char *env = NULL;
+
+       /* Call real uname to get the information we need. */
+       uname_t real_uname = (uname_t)get_libc_func("uname");
+       int ret = real_uname((struct utsname *) buf);
+
+       /* Replace release if requested. */
+       if ((env = getenv("UTS_RELEASE")) != NULL) {
+               strncpy(buf->release, env, _UTSNAME_RELEASE_LENGTH);
+       }
+
+       /* Replace machine type if requested. */
+       if ((env = getenv("UTS_MACHINE")) != NULL) {
+               strncpy(buf->machine, env, _UTSNAME_MACHINE_LENGTH);
+       }
+
+       return ret;
+}