]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - tools/make-functions
Build preload lib to fake output of uname.
[ipfire-2.x.git] / tools / make-functions
index b4de26a170c79a5dc7274e98551d00703b23af96..144411cd31a4471ffbf9c6de6b035393024b5886 100644 (file)
@@ -2,7 +2,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2010  IPFire Team  <info@ipfire.org>                          #
+# Copyright (C) 2007-2011  IPFire Team  <info@ipfire.org>                     #
 #                                                                             #
 # 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        #
@@ -195,12 +195,14 @@ beautify()
 
 get_pkg_ver()
 {
-       PKG_VER=`grep ^VER $1 | awk '{print $3}'`
+       PKG_VER=`grep -E "^VER |^VER=|^VER      " $1 | awk '{print $3}'`
 
        if [ -z $PKG_VER ]; then
                PKG_VER=`grep "Exp " $1 | awk '{print $4}'`
        fi
-
+       if [ -z $PKG_VER ]; then
+               PKG_VER="?"
+       fi
        if [ ${#PKG_VER} -gt $VER_WIDTH ]; then
                # If a package version number is greater than $VER_WIDTH, we keep the first 4 characters
                # and replace enough characters to fit the resulting string on the screen.  We'll replace
@@ -268,10 +270,26 @@ exiterror() {
        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 \
@@ -286,6 +304,7 @@ entershell() {
                MACHINE="$MACHINE" \
                MACHINE_TYPE="$MACHINE_TYPE" \
                KGCC="ccache /usr/bin/gcc" \
+               $(fake_environ) \
                /tools/bin/bash
        if [ $? -ne 0 ]; then
                        beautify message FAIL
@@ -369,6 +388,7 @@ lfsmake1() {
                                                ROOT=$LFS \
                                                KVER=$KVER \
                                                MAKETUNING=$MAKETUNING \
+                                               $(fake_environ) \
                                                install >> $LOGFILE 2>&1
        local COMPILE_SUCCESS=$?
        local PKG_TIME_END=`date +%s`
@@ -399,6 +419,7 @@ lfsmake2() {
                                                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=$?
@@ -431,6 +452,7 @@ ipfiremake() {
                                                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
 
@@ -462,6 +484,7 @@ ipfiredist() {
                                        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