--- /dev/null
+###############################################################################
+# #
+# IPFire.org - A linux based firewall #
+# Copyright (C) 2007 Michael Tremer & Christian Schmidt #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+###############################################################################
+
+###############################################################################
+# Definitions
+###############################################################################
+
+include Config
+
+VER = 1.0
+
+THISAPP = fake-environ
+DIR_APP = $(DIR_SRC)/$(THISAPP)
+TARGET = $(DIR_INFO)/$(THISAPP)-tools$(PASS)
+
+###############################################################################
+# Top-level Rules
+###############################################################################
+
+install : $(TARGET)
+
+check :
+
+download :
+
+md5 :
+
+###############################################################################
+# Installation Details
+###############################################################################
+
+$(TARGET) :
+ @$(PREBUILD)
+ @rm -rf $(DIR_APP)
+ cp -rvf $(DIR_SRC)/src/$(THISAPP) $(DIR_APP)
+
+ cd $(DIR_APP) && make install CFLAGS="$(CFLAGS)" \
+ TOOLS_DIR="/tools"
+
+ @rm -rf $(DIR_APP)
+ @$(POSTBUILD)
MACHINE=`uname -m`
GIT_TAG=$(git tag | tail -1) # Git Tag
GIT_LASTCOMMIT=$(git log | head -n1 | cut -d" " -f2 |head -c8) # Last commit
-TOOLCHAINVER=1
+TOOLCHAINVER=2
BUILDMACHINE=$MACHINE
if [ "$MACHINE" = "x86_64" ]; then
export NATIVEGCC GCCmajor=${NATIVEGCC:0:1} GCCminor=${NATIVEGCC:2:1} GCCrelease=${NATIVEGCC:4:1}
ORG_PATH=$PATH
export PATH=$BASEDIR/build/usr/local/bin:$BASEDIR/build/tools/bin:$PATH
+ lfsmake1 fake-environ PASS=1
lfsmake1 ccache PASS=1
lfsmake1 make PASS=1
lfsmake1 binutils PASS=1
fi
lfsmake1 glibc
lfsmake1 cleanup-toolchain PASS=1
+ lfsmake1 fake-environ PASS=2
lfsmake1 tcl
lfsmake1 expect
lfsmake1 dejagnu
--- /dev/null
+
+ifeq "$(CFLAGS)" ""
+ $(error CLFAGS not defined.)
+endif
+
+ifeq "$(TOOLS_DIR)" ""
+ $(error TOOLS_DIR not defined.)
+endif
+
+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 $(TOOLS_DIR)/lib/
+ install -p -m 755 $(LIB) $(TOOLS_DIR)/lib
+
+.PHONY: clean
+clean:
+ $(LIB)
--- /dev/null
+
+
+#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;
+}
exit 1
}
+fake_environ() {
+ [ -e "${BASEDIR}/build/tools/lib/libpakfire_preload.so" ] || return
+
+ local env="LD_PRELOAD=/tools/lib/libpakfire_preload.so"
+
+ # Fake kernel version, because some of the packages do not compile
+ # with kernel 3.0 and later.
+ env="${env} UTS_RELEASE=${KVER}"
+
+ # Fake machine version.
+ env="${env} UTS_MACHINE=${MACHINE}"
+
+ echo "${env}"
+}
+
entershell() {
if [ ! -e $BASEDIR/build/usr/src/lfs/ ]; then
exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/"
fi
+
echo "Entering to a shell inside LFS chroot, go out with exit"
$linux32 chroot $LFS /tools/bin/env -i HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
PATH=/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
MACHINE="$MACHINE" \
MACHINE_TYPE="$MACHINE_TYPE" \
KGCC="ccache /usr/bin/gcc" \
+ $(fake_environ) \
/tools/bin/bash
if [ $? -ne 0 ]; then
beautify message FAIL
ROOT=$LFS \
KVER=$KVER \
MAKETUNING=$MAKETUNING \
+ $(fake_environ) \
install >> $LOGFILE 2>&1
local COMPILE_SUCCESS=$?
local PKG_TIME_END=`date +%s`
KVER=$KVER MAKETUNING=$MAKETUNING \
BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
MACHINE_TYPE="$MACHINE_TYPE" \
+ $(fake_environ) \
/tools/bin/bash -x -c "cd /usr/src/lfs && \
make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
local COMPILE_SUCCESS=$?
KVER=$KVER MAKETUNING=$MAKETUNING \
BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
MACHINE_TYPE="$MACHINE_TYPE" \
+ $(fake_environ) \
/bin/bash -x -c "cd /usr/src/lfs && \
make -f $* LFS_BASEDIR=/usr/src install" >>$LOGFILE 2>&1
KVER=$KVER \
BUILDTARGET="$BUILDTARGET" MACHINE="$MACHINE" \
MACHINE_TYPE="$MACHINE_TYPE" \
+ $(fake_environ) \
/bin/bash -x -c "cd /usr/src/lfs && \
make -f $1 LFS_BASEDIR=/usr/src dist" >>$LOGFILE 2>&1