Problem with chrooting to new enviroment

Aleksander Kurczyk aleksander810 at gmail.com
Wed Nov 4 16:21:56 PST 2009


Hi
I have problem with chroting to new enviroment (chapter 6.4). When I execute
a commands from chapter 6.4 of LFS handbook, chroot return an error
indicating the absence of a file or directory. This file, of course exist.
To install LFS I use scripts shown below and LFS LiveCD.

Commands which I execute after I boot my PC from LFS LiveCD:
wget 78.88.20.95/instalator && chmod +x instalator && ./instalator
wget 78.88.20.95/instalator2 && chmod +x instalator2 && ./instalator2
wget 78.88.20.95/instalator3 && chmod +x instalator3 && ./instalator3
exit #Exit from bash
exit #Exit from su
wget 78.88.20.95/instalator4 && chmod +x instalator4 && ./instalator4
#Now I see an error.

Content of the first script:
#!/bin/bash
cfdisk /dev/hda
mke2fs -jv /dev/hda2
mkswap /dev/hda1
export LFS=/mnt/lfs
mkdir -pv $LFS
mount -v -t ext3 /dev/hda2 $LFS
/sbin/swapon -v /dev/hda1
mkdir -v $LFS/sources
chmod -v a+wt $LFS/sources
cd $LFS/sources
wget http://www.linuxfromscratch.org/lfs/view/stable/wget-list
wget -i wget-list
mkdir -v $LFS/tools
ln -sv $LFS/tools /
groupadd lfs
useradd -s /bin/bash -g lfs -m -k /dev/null lfs
passwd lfs
chown -v lfs $LFS/tools
chown -v lfs $LFS/sources
su - lfs

Two script:
#!/bin/bash
#bash_profile
cat > ~/.bash_profile << "EOF"
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
EOF
#bashrc
cat > ~/.bashrc << "EOF"
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
LFS_TGT=$(uname -m)-lfs-linux-gnu
PATH=/tools/bin:/bin:/usr/bin
export LFS LC_ALL LFS_TGT PATH
EOF
#source
source ~/.bash_profile

3nd script:
#!/bin/bash
#Binutils
cd $LFS/sources
tar -jxf binutils-2.19.1.tar.bz2
cd binutils-2.19.1
mkdir -v ../binutils-build
cd ../binutils-build
../binutils-2.19.1/configure \
    --target=$LFS_TGT --prefix=/tools \
    --disable-nls --disable-werror
make
case $(uname -m) in
  x86_64) mkdir -v /tools/lib && ln -sv lib /tools/lib64 ;;
esac
make install
#GCC
cd $LFS/sources
tar -jxf gcc-4.4.1.tar.bz2
cd gcc-4.4.1
tar -jxf ../mpfr-2.4.1.tar.bz2
mv -v mpfr-2.4.1 mpfr
tar -jxf ../gmp-4.3.1.tar.bz2
mv -v gmp-4.3.1 gmp
mkdir -v ../gcc-build
cd ../gcc-build
../gcc-4.4.1/configure \
    --target=$LFS_TGT --prefix=/tools \
    --disable-nls --disable-shared --disable-multilib \
    --disable-decimal-float --disable-threads \
    --disable-libmudflap --disable-libssp \
    --disable-libgomp --enable-languages=c
make
make install
ln -vs libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | \
    sed 's/libgcc/&_eh/'`
#Linux
cd $LFS/sources
tar -jxf linux-2.6.30.2.tar.bz2
cd linux-2.6.30.2
make mrproper
make headers_check
make INSTALL_HDR_PATH=dest headers_install
cp -rv dest/include/* /tools/include
#Glibc
cd $LFS/sources
tar -jxf glibc-2.10.1.tar.bz2
cd glibc-2.10.1
cp -v nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S{,.orig}
sed -e 's/FUTEX_WAIT\( | FUTEX_CLOCK_REALTIME, reg\)/FUTEX_WAIT_BITSET\1/' \
        <nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S.orig \
        >nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
mkdir -v ../glibc-build
cd ../glibc-build
case `uname -m` in
  i?86) echo "CFLAGS += -march=i486 -mtune=native" > configparms ;;
esac
../glibc-2.10.1/configure --prefix=/tools \
    --host=$LFS_TGT --build=$(../glibc-2.10.1/scripts/config.guess) \
    --disable-profile --enable-add-ons \
    --enable-kernel=2.6.18 --with-headers=/tools/include \
    libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes
make
make install
#Binutils2
cd $LFS/sources
tar -jxf binutils-2.19.1.tar.bz2
cd binutils-2.19.1
mkdir -v ../binutils-build
cd ../binutils-build
CC="$LFS_TGT-gcc -B/tools/lib/" \
   AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \
   ../binutils-2.19.1/configure --prefix=/tools \
   --disable-nls --with-lib-path=/tools/lib
make
make install
make -C ld clean
make -C ld LIB_PATH=/usr/lib:/lib
cp -v ld/ld-new /tools/bin
#GCC2
cd $LFS/sources
tar -jxf gcc-4.4.1.tar.bz2
cd gcc-4.4.1
patch -Np1 -i ../gcc-4.4.1-startfiles_fix-1.patch
cp -v gcc/Makefile.in{,.orig}
sed 's@\./fixinc\.sh at -c true@' gcc/Makefile.in.orig > gcc/Makefile.in
cp -v gcc/Makefile.in{,.tmp}
sed 's/^T_CFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in.tmp \
  > gcc/Makefile.in
for file in \
 $(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
do
  cp -uv $file{,.orig}
  sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
  -e 's@/usr@/tools at g' $file.orig > $file
  echo '
#undef STANDARD_INCLUDE_DIR
#define STANDARD_INCLUDE_DIR 0
#define STANDARD_STARTFILE_PREFIX_1 ""
#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
  touch $file.orig
done
case $(uname -m) in
  x86_64)
    for file in $(find gcc/config -name t-linux64) ; do \
      cp -v $file{,.orig}
      sed '/MULTILIB_OSDIRNAMES/d' $file.orig > $file
    done
  ;;
esac
tar -jxf ../mpfr-2.4.1.tar.bz2
mv -v mpfr-2.4.1 mpfr
tar -jxf ../gmp-4.3.1.tar.bz2
mv -v gmp-4.3.1 gmp
mkdir -v ../gcc-build
cd ../gcc-build
CC="$LFS_TGT-gcc -B/tools/lib/" \
    AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \
    ../gcc-4.4.1/configure --prefix=/tools \
    --with-local-prefix=/tools --enable-clocale=gnu \
    --enable-shared --enable-threads=posix \
    --enable-__cxa_atexit --enable-languages=c,c++ \
    --disable-libstdcxx-pch --disable-multilib \
    --disable-bootstrap
make
make install
ln -vs gcc /tools/bin/cc
#Tcl
cd $LFS/sources
tar -zxf tcl8.5.7-src.tar.gz
cd tcl8.5.7
cd unix
./configure --prefix=/tools
make
TZ=UTC make test
make install
chmod -v u+w /tools/lib/libtcl8.5.so
make install-private-headers
ln -sv tclsh8.5 /tools/bin/tclsh
#Expect
cd $LFS/sources
tar -zxf expect-5.43.0.tar.gz
cd expect-5.43.0
patch -Np1 -i ../expect-5.43.0-spawn-1.patch
patch -Np1 -i ../expect-5.43.0-tcl_8.5.5_fix-1.patch
cp -v configure{,.orig}
sed 's:/usr/local/bin:/bin:' configure.orig > configure
./configure --prefix=/tools --with-tcl=/tools/lib \
  --with-tclinclude=/tools/include --with-x=no
make
make test
make SCRIPTS="" install
#DejaGNU
cd $LFS/sources
tar -zxf dejagnu-1.4.4.tar.gz
cd dejagnu-1.4.4
./configure --prefix=/tools
make install
make check
#Ncurses
cd $LFS/sources
tar -zxf ncurses-5.7.tar.gz
cd ncurses-5.7
./configure --prefix=/tools --with-shared \
    --without-debug --without-ada --enable-overwrite
make
make install
#Bash
cd $LFS/sources
tar -zxf bash-4.0.tar.gz
cd bash-4.0
patch -Np1 -i ../bash-4.0-fixes-3.patch
./configure --prefix=/tools --without-bash-malloc
make
make tests
make install
ln -vs bash /tools/bin/sh
#Bzip2
cd $LFS/sources
tar -zxf bzip2-1.0.5.tar.gz
cd bzip2-1.0.5
make
make PREFIX=/tools install
#Coreutils
cd $LFS/sources
tar -zxf coreutils-7.4.tar.gz
cd coreutils-7.4
./configure --prefix=/tools --enable-install-program=hostname
make
make RUN_EXPENSIVE_TESTS=yes check
make install
cp -v src/su /tools/bin/su-tools
#Diffutils
cd $LFS/sources
tar -zxf diffutils-2.8.1.tar.gz
cd diffutils-2.8.1
./configure --prefix=/tools
make
make install
#Findutils
cd $LFS/sources
tar -zxf findutils-4.4.2.tar.gz
cd findutils-4.4.2
./configure --prefix=/tools
make
make check
make install
#Gawk
cd $LFS/sources
tar -jxf gawk-3.1.7.tar.bz2
cd gawk-3.1.7
./configure --prefix=/tools
make
make check
make install
#Gettext
cd $LFS/sources
tar -zxf gettext-0.17.tar.gz
cd gettext-0.17
cd gettext-tools
./configure --prefix=/tools --disable-shared
make -C gnulib-lib
make -C src msgfmt
cp -v src/msgfmt /tools/bin
#Grep
cd $LFS/sources
tar -jxf grep-2.5.4.tar.bz2
cd grep-2.5.4
./configure --prefix=/tools \
    --disable-perl-regexp \
    --without-included-regex
make
make check
make install
#Gzip
cd $LFS/sources
tar -zxf gzip-1.3.12.tar.gz
cd gzip-1.3.12
for file in gzip.c lib/utimens.{c,h} ; do \
   cp -v $file{,.orig}
   sed 's/futimens/gl_&/' $file.orig > $file
done
./configure --prefix=/tools
make
make check
make install
#M4
cd $LFS/sources
tar -jxf m4-1.4.13.tar.bz2
cd m4-1.4.13
./configure --prefix=/tools
make
make check
make install
#Make
cd $LFS/sources
tar -jxf make-3.81.tar.bz2
cd make-3.81
./configure --prefix=/tools
make
make check
make install
#Patch
cd $LFS/sources
tar -zxf patch-2.5.9.tar.gz
cd patch-2.5.9
patch -Np1 -i ../patch-2.5.9-fixes-1.patch
./configure --prefix=/tools
make
make install
#Perl
cd $LFS/sources
tar -zxf perl-5.10.0.tar.gz
cd perl-5.10.0
patch -Np1 -i ../perl-5.10.0-consolidated-1.patch
sh Configure -des -Dprefix=/tools \
                  -Dstatic_ext='Data/Dumper Fcntl IO POSIX'
make perl utilities ext/Errno/pm_to_blib
cp -v perl pod/pod2man /tools/bin
mkdir -pv /tools/lib/perl5/5.10.0
cp -Rv lib/* /tools/lib/perl5/5.10.0
#Sed
cd $LFS/sources
tar -jxf sed-4.2.1.tar.bz2
cd sed-4.2.1
make
make check
make install
#Tar
cd $LFS/sources
tar -jxf tar-1.22.tar.bz2
cd tar-1.22
./configure --prefix=/tools
make
make check
make install
#Texinfo
cd $LFS/sources
tar -zxf texinfo-4.13a.tar.gz
cd texinfo-4.13a
./configure --prefix=/tools
make
make check
make install
#Stripping
strip --strip-debug /tools/lib/*
strip --strip-unneeded /tools/{,s}bin/*
rm -rf /tools/{info,man}

Content of instalator4 script:
#!/bin/bash
export LFS=/mnt/lfs
chown -R root:root $LFS/tools
mkdir -pv $LFS/{dev,proc,sys}
mknod -m 600 $LFS/dev/console c 5 1
mknod -m 666 $LFS/dev/null c 1 3
mount -v --bind /dev $LFS/dev
mount -vt devpts devpts $LFS/dev/pts
mount -vt tmpfs shm $LFS/dev/shm
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
chroot "$LFS" /tools/bin/env -i \
    HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
    PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
    /tools/bin/bash --login +h

This scripts is avalible to download too from my PC:
http://78.88.20.95/instalator
http://78.88.20.95/instalator2
http://78.88.20.95/instalator3
http://78.88.20.95/instalator4

Please, help me!!!

P.S. Sorry, but my English is not very good, I'm from Poland.

-- 
Pozdrawiam
Aleksander Kurczyk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfromscratch.org/pipermail/lfs-support/attachments/20091105/c3377287/attachment.html>


More information about the lfs-support mailing list