Skip to content

Instantly share code, notes, and snippets.

@albttx
Last active December 6, 2016 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save albttx/8dab199c6fddab9b0916645f0826239e to your computer and use it in GitHub Desktop.
Save albttx/8dab199c6fddab9b0916645f0826239e to your computer and use it in GitHub Desktop.
#!/bin/bash
LFS=/mnt/ft_linux
LFS_TGT=$(uname -m)-lfs-linux-gnu
SRCS=$LFS/sources
ARCHIVES=$SRCS/archives
TAR="tar -xvf"
LOGFILE=$LFS/install_log.txt
###################################
# Launch this script as user: lfs #
###################################
if [ $(whoami) != lfs ];
then
echo "Please move to user lfs"
exit
fi
############
# BINUTILS #
############
cd $SRCS
$TAR $ARCHIVES/binutils-2.26.tar.bz2
cd binutils-2.26
mkdir -pv build && cd build
../configure --prefix=/tools --with-sysroot=$LFS --with-lib-path=/tools/lib --target=$LFS_TGT --disable-nls --disable-werror
make
case $(uname -m) in
x86_64) mkdir -v /tools/lib && ln -sv lib /tools/lib64 ;;
esac
make install
###########
# GCC - 1 #
###########
cd $SRCS
$TAR $ARCHIVES/gcc-5.3.0.tar.bz2
cd gcc-5.3.0
tar -xf $ARCHIVES/mpfr-3.1.3.tar.xz
mv -v mpfr-3.1.3 mpfr
tar -xf $ARCHIVES/gmp-6.1.0.tar.xz
mv -v gmp-6.1.0 gmp
tar -xf $ARCHIVES/mpc-1.0.3.tar.gz
mv -v mpc-1.0.3 mpc
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@g' $file.orig > $file
echo '
#undef STANDARD_STARTFILE_PREFIX_1
#undef STANDARD_STARTFILE_PREFIX_2
#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
touch $file.orig
done
mkdir -pv build && cd build
../configure \
--target=$LFS_TGT \
--prefix=/tools \
--with-glibc-version=2.11 \
--with-sysroot=$LFS \
--with-newlib \
--without-headers \
--with-local-prefix=/tools \
--with-native-system-header-dir=/tools/include \
--disable-nls \
--disable-shared \
--disable-multilib \
--disable-decimal-float \
--disable-threads \
--disable-libatomic \
--disable-libgomp \
--disable-libquadmath \
--disable-libssp \
--disable-libvtv \
--disable-libstdcxx \
--enable-languages=c,c++
make && make install
#####################
# LINUX HTTP HEADER #
#####################
cd $SRCS
$TAR $ARCHIVES/linux-4.4.2.tar.xz
cd linux-4.4.2
make mrproper
make INSTALL_HDR_PATH=dest headers_install
cp -rv dest/include/* /tools/include
#########
# GlibC #
#########
cd $SRCS
$TAR $ARCHIVES/glibc-2.23.tar.xz
cd glibc-2.23
mkdir -pv build && cd build
../configure \
--prefix=/tools \
--host=$LFS_TGT \
--build=$(../scripts/config.guess) \
--disable-profile \
--enable-kernel=2.6.32 \
--enable-obsolete-rpc \
--with-headers=/tools/include \
libc_cv_forced_unwind=yes \
libc_cv_ctors_header=yes \
libc_cv_c_cleanup=yes
make && make install
echo 'int main(){}' > dummy.c
$LFS_TGT-gcc dummy.c
readelf -l a.out | grep ': /tools'
rm -v dummy.c a.out
#############
# LIBSTCD++ #
#############
cd $SRCS/gcc-5.3.0/libstdc++-v3
mkdir -pv build && cd build
../configure \
--host=$LFS_TGT \
--prefix=/tools \
--disable-multilib \
--disable-nls \
--disable-libstdcxx-threads \
--disable-libstdcxx-pch \
--with-gxx-include-dir=/tools/$LFS_TGT/include/c++/5.3.0
make && make install
################
# BINUTILS - 2 #
################
cd $SRCS
rm -rf binutils-2.26
$TAR $ARCHIVES/binutils-2.26.tar.bz2
cd binutils-2.26
mkdir -pv build && cd build
CC=$LFS_TGT-gcc \
AR=$LFS_TGT-ar \
RANLIB=$LFS_TGT-ranlib \
../configure \
--prefix=/tools \
--disable-nls \
--disable-werror \
--with-lib-path=/tools/lib \
--with-sysroot
make && make install
make -C ld clean
make -C ld LIB_PATH=/usr/lib:/lib
cp -v ld/ld-new /tools/bin
############
# GCC - 2 #
############
cd $SRCS
rm -rf gcc-5.3.0
$TAR $ARCHIVES/gcc-5.3.0.tar.bz2
cd gcc-5.3.0
tar -xf $ARCHIVES/mpfr-3.1.3.tar.xz
mv -v mpfr-3.1.3 mpfr
tar -xf $ARCHIVES/gmp-6.1.0.tar.xz
mv -v gmp-6.1.0 gmp
tar -xf $ARCHIVES/mpc-1.0.3.tar.gz
mv -v mpc-1.0.3 mpc
mkdir -pv build && cd build
CC=$LFS_TGT-gcc \
CXX=$LFS_TGT-g++ \
AR=$LFS_TGT-ar \
RANLIB=$LFS_TGT-ranlib \
../configure \
--prefix=/tools \
--with-local-prefix=/tools \
--with-native-system-header-dir=/tools/include \
--enable-languages=c,c++ \
--disable-libstdcxx-pch \
--disable-multilib \
--disable-bootstrap \
--disable-libgomp
make && make install
ln -sv gcc /tools/bin/cc
echo 'int main(){}' > dummy.c
cc dummy.c
readelf -l a.out | grep ': /tools'
rm -v dummy.c a.out
############
# TCL-CORE #
############
cd $SRCS
$TAR $ARCHIVES/tcl-core8.6.4-src.tar.gz
cd tcl8.6.4
cd unix
./configure --prefix=/tools
make
TZ=UTC make test
make install
chmod -v u+w /tools/lib/libtcl8.6.so
make install-private-headers
ln -sv tclsh8.6 /tools/bin/tclsh
##########
# EXPECT #
##########
cd $SRCS
$TAR $ARCHIVES/expect5.45.tar.gz
cd expect5.45
cp -v configure{,.orig}
sed 's:/usr/local/bin:/bin:' configure.orig > configure
./configure --prefix=/tools \
--with-tcl=/tools/lib \
--with-tclinclude=/tools/include
make && make test
make SCRIPTS="" install
############
# DEJA GNU #
############
cd $SRCS
$TAR $ARCHIVES/dejagnu-1.5.3.tar.gz
cd dejagnu-1.5.3
./configure --prefix=/tools
make install && make check
#########
# check #
#########
cd $SRCS
$TAR $ARCHIVES/check-0.10.0.tar.gz
cd check-0.10.0
PKG_CONFIG= ./configure --prefix=/tools
make && make check && make install
###########
# NCURSES #
###########
cd $SRCS
$TAR $ARCHIVES/ncurses-6.0.tar.gz
cd ncurses-6.0
sed -i s/mawk// configure
./configure --prefix=/tools \
--with-shared \
--without-debug \
--without-ada \
--enable-widec \
--enable-overwrite
make && make install
########
# Bash #
########
cd $SRCS
$TAR $ARCHIVES/bash-4.3.30.tar.gz
cd bash-4.3.30
./configure --prefix=/tools --without-bash-malloc
make && make test && make install
ln -sv bash /tools/bin/sh
##########
# BZIP 2 #
##########
cd $SRCS
$TAR $ARCHIVES/bzip2-1.0.6.tar.gz
cd bzip2-1.0.6
make
make PREFIX=/tools install
##############
# Core Utils #
##############
cd $SRCS
$TAR $ARCHIVES/coreutils-8.25.tar.xz
cd coreutils-8.25
./configure --prefix=/tools --enable-install-program=hostname
make
make RUN_EXPENSIVE_TESTS=yes check
make install
##############
# Diff utils #
##############
cd $SRCS
$TAR $ARCHIVES/diffutils-3.3.tar.xz
cd diffutils-3.3
./configure --prefix=/tools
make && make check && make install
########
# FILE #
########
cd $SRCS
$TAR $ARCHIVES/file-5.25.tar.gz
cd file-5.25
./configure --prefix=/tools
make && make check && make install
##############
# Find utils #
##############
cd $SRCS
$TAR $ARCHIVES/findutils-4.6.0.tar.gz
cd findutils-4.6.0
./configure --prefix=/tools
make && make check && make install
########
# GAWK #
########
cd $SRCS
$TAR $ARCHIVES/gawk-4.1.3.tar.xz
cd gawk-4.1.3
./configure --prefix=/tools
make && make check && make install
############
# GET Text #
############
cd $SRCS
$TAR $ARCHIVES/gettext-0.19.7.tar.xz
cd gettext-0.19.7
cd gettext-tools
EMACS="no" ./configure --prefix=/tools --disable-shared
make -C gnulib-lib
make -C intl pluralx.c
make -C src msgfmt
make -C src msgmerge
make -C src xgettext
cp -v src/{msgfmt,msgmerge,xgettext} /tools/bin
########
# GREP #
########
cd $SRCS
$TAR $ARCHIVES/grep-2.23.tar.xz
cd grep-2.23
./configure --prefix=/tools
make && make check && make install
########
# GZIP #
########
cd $SRCS
$TAR $ARCHIVES/gzip-1.6.tar.xz
cd gzip-1.6
./configure --prefix=/tools
make && make check && make install
######
# M4 #
#######
cd $SRCS
$TAR $ARCHIVES/m4-1.4.17.tar.xz
cd m4-1.4.17
./configure --prefix=/tools
make && make check && make install
########
# MAKE #
########
cd $SRCS
$TAR $ARCHIVES/make-4.1.tar.bz2
cd make-4.1
./configure --prefix=/tools --without-guile
make && make check && make install
#########
# PATCH #
#########
cd $SRCS
$TAR $ARCHIVES/patch-2.7.5.tar.xz
cd patch-2.7.5.tar.xz
./configure --prefix=/tools
make && make check && make install
########
# PERL #
########
cd $SRCS
$TAR $ARCHIVES/perl-5.22.1.tar.bz2
cd perl-5.22.1
sh Configure -des -Dprefix=/tools -Dlibs=-lm
make
cp -v perl cpan/podlators/pod2man /tools/bin
mkdir -pv /tools/lib/perl5/5.22.1
cp -Rv lib/* /tools/lib/perl5/5.22.1
#######
# SED #
#######
cd $SRCS
$TAR $ARCHIVES/sed-4.2.2.tar.bz2
cd sed-4.2.2
./configure --prefix=/tools
make && make check && make install
#######
# TAR #
#######
cd $SRCS
$TAR $ARCHIVES/tar-1.28.tar.xz
cd tar-1.28
./configure --prefix=/tools
make && make check && make install
############
# TEXTINFO #
############
cd $SRCS
$TAR $ARCHIVES/texinfo-6.0.tar.xz
cd texinfo-6.0
./configure --prefix=/tools
make && make check && make install
##############
# UTIL LINUX #
##############
cd $SRCS
$TAR $ARCHIVES/util-linux-2.27.1.tar.xz
cd util-linux-2.27.1
./configure --prefix=/tools \
--without-python \
--disable-makeinstall-chown \
--without-systemdsystemunitdir \
PKG_CONFIG=""
make && make install
######
# XZ #
######
cd $SRCS
$TAR $ARCHIVES/xz-5.2.2.tar.xz
cd xz-5.2.2
./configure --prefix=/tools
make && make check && make install
##################
# DELETE SYMBOLS #
##################
strip --strip-debug /tools/lib/* /usr/bin/strip --strip-unneeded /tools/{,s}bin/*
rm -rf /tools/{,share}/{info,man,doc}
echo "------ END ------"
echo "please now visit :"
echo "http://www.fr.linuxfromscratch.org/view/lfs-7.9-fr/chapter05/changingowner.html"
#!/bin/bash
LFS=/mnt/ft_linux
SRCS=$LFS/sources
ARCHIVES=$SRCS/archives
TAR="tar -xvf"
cd $LFS
mkdir -pv $LFS/{dev,proc,sys,run}
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 -o gid=5,mode=620
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
mount -vt tmpfs tmpfs $LFS/run
if [ -h $LFS/dev/shm ]; then
mkdir -pv $LFS/$(readlink $LFS/dev/shm)
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment