From 77a330d525e56b9c9b52d8f41474d2a17dab2c31 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 11 Dec 2011 03:34:29 +0100 Subject: [PATCH] Fake output of uname(3) on different host arches. --- po/pakfire.pot | 30 +++++++++++----------- python/pakfire/builder.py | 9 ++++++- tools/fake-environ/Makefile | 25 +++++++++++++++++++ tools/fake-environ/uname.c | 50 +++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 16 deletions(-) create mode 100644 tools/fake-environ/Makefile create mode 100644 tools/fake-environ/uname.c diff --git a/po/pakfire.pot b/po/pakfire.pot index ec67bf4c6..0e84beaf9 100644 --- a/po/pakfire.pot +++ b/po/pakfire.pot @@ -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 \n" "Language-Team: LANGUAGE \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 "" diff --git a/python/pakfire/builder.py b/python/pakfire/builder.py index d196c27ce..a17c32d07 100644 --- a/python/pakfire/builder.py +++ b/python/pakfire/builder.py @@ -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 index 000000000..67578ea61 --- /dev/null +++ b/tools/fake-environ/Makefile @@ -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 index 000000000..2485a810f --- /dev/null +++ b/tools/fake-environ/uname.c @@ -0,0 +1,50 @@ + + +#include +#include +#include +#include /* for EXIT_FAILURE */ +#include /* for _exit() */ +#include +#include +#include +#include +#include + +#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; +} -- 2.39.5