]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - tools/make-functions
make.sh: Create a function to execute a command in chroot
[people/pmueller/ipfire-2.x.git] / tools / make-functions
index 01222569fc3ed4386c5330a4ef5d4530e9e73ede..08ac7a1a66aea32da0cf59aab059ba64727dcd0b 100644 (file)
@@ -490,36 +490,49 @@ file_is_static() {
        file ${file} 2>/dev/null | grep -q "statically linked"
 }
 
-entershell() {
-       if [ ! -e $BASEDIR/build/usr/src/lfs/ ]; then
-               exiterror "No such file or directory: $BASEDIR/build/usr/src/lfs/"
-       fi
-
+enterchroot() {
        # Install QEMU helper, if needed
        qemu_install_helper
 
-       echo "Entering to a shell inside LFS chroot, go out with exit"
-       chroot $LFS /tools/bin/env -i HOME=/root TERM=$TERM PS1='ipfire build chroot ($(uname -m)) \u:\w\$ ' \
-               PATH=/tools/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
-               VERSION=$VERSION CONFIG_ROOT=$CONFIG_ROOT \
-               NAME="$NAME" SNAME="$SNAME" SLOGAN="$SLOGAN" \
+       local PATH="/tools/ccache/bin:/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin"
+
+       PATH="${PATH}" chroot ${LFS} env -i \
+               HOME="/root" \
+               TERM="${TERM}" \
+               PS1="${PS1}" \
+               PATH="${PATH}" \
+               NAME="${NAME}" \
+               SNAME="${SNAME}" \
+               VERSION="${VERSION}" \
+               SLOGAN="${SLOGAN}" \
+               CONFIG_ROOT="${CONFIG_ROOT}" \
                CFLAGS="${CFLAGS} ${HARDENING_CFLAGS}" \
                CXXFLAGS="${CXXFLAGS} ${HARDENING_CFLAGS}" \
+               BUILDTARGET="${BUILDTARGET}" \
+               CROSSTARGET="${CROSSTARGET}" \
+               BUILD_ARCH="${BUILD_ARCH}" \
                CCACHE_DIR=/usr/src/ccache \
                CCACHE_COMPRESS="${CCACHE_COMPRESS}" \
                CCACHE_COMPILERCHECK="${CCACHE_COMPILERCHECK}" \
-               KVER=$KVER \
-               BUILDTARGET="$BUILDTARGET" \
-               CROSSTARGET="${CROSSTARGET}" \
-               BUILD_ARCH="${BUILD_ARCH}" \
+               KVER="${KVER}" \
                $(fake_environ) \
                $(qemu_environ) \
-               /tools/bin/bash -i
-       if [ $? -ne 0 ]; then
-                       beautify message FAIL
-                       exiterror "chroot error"
-       else
+               $@
+}
+
+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"
+       local PS1="ipfire build chroot ($(uname -m)) \u:\w\$ "
+
+       if enterchroot bash -i; then
                stdumount
+       else
+               beautify message FAIL
+               exiterror "chroot error"
        fi
 }