From: Michael Tremer Date: Thu, 20 Apr 2017 16:02:15 +0000 (+0200) Subject: make.sh: Create a function to execute a command in chroot X-Git-Tag: v2.19-core112~131 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9d928e829cfe6eaa748dc58873ac22eb29a66ff6;p=people%2Fstevee%2Fipfire-2.x.git make.sh: Create a function to execute a command in chroot Signed-off-by: Michael Tremer --- diff --git a/tools/make-functions b/tools/make-functions index 01222569fc..08ac7a1a66 100644 --- a/tools/make-functions +++ b/tools/make-functions @@ -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 }