diff --git a/.gitignore b/.gitignore index 0221127..cddbaac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.iso -sources -packages +*.tar.xz +*.img + diff --git a/01-toolchain b/01-toolchain index 810b33f..0834019 100755 --- a/01-toolchain +++ b/01-toolchain @@ -108,6 +108,10 @@ source $CWD/config PATH=/tools/bin:/bin:/usr/bin +TCDIR=$CWD/toolchain +PATCHDIR=$CWD/patches +FILEDIR=$CWD/files + export LC_ALL=C PATH MAKEFLAGS LFS LFS_TGT mkdir -p $TCDIR $SRCDIR $WORKDIR diff --git a/02-base b/02-base index 58abfdd..d97e47b 100755 --- a/02-base +++ b/02-base @@ -75,19 +75,6 @@ umount_pseudo() { unmount $LFS/sys } -mountbind_cache() { - # mount bind cachedir - mkdir -p $LFS/var/lib/pkg/{pkg,src} $CWD/{sources,packages} - mount --bind $CWD/sources $LFS/var/lib/pkg/src - mount --bind $CWD/packages $LFS/var/lib/pkg/pkg -} - -umountbind_cache() { - # umount binded cachedir - unmount $LFS/var/lib/pkg/src - unmount $LFS/var/lib/pkg/pkg -} - unmount() { while true; do mountpoint -q $1 || break @@ -95,7 +82,6 @@ unmount() { done } - runinchroot() { pushd $LFS &>/dev/null mount_pseudo @@ -117,7 +103,6 @@ interrupted() { die() { [ "$@" ] && printerror $@ - umountbind_cache umount_pseudo exit 1 } @@ -154,14 +139,12 @@ PKGS="filesystem linux-api-headers man-pages glibc tzdata zlib bzip2 file readli if [ ! -f $LFS/var/lib/pkg/db ]; then lfs_dirs fi - + +rm -fr $LFS/usr/ports mkdir -p $LFS/usr/ports/ -#runinchroot ports -u || die echo "==> Copying ports" cp -Ra ports/* $LFS/usr/ports/ -mountbind_cache - for pkg in $PKGS; do case $pkg in filesystem|gcc|bash|perl|coreutils) runinchroot pkgin -i -ic $pkg || die;; @@ -169,6 +152,4 @@ for pkg in $PKGS; do esac done -umountbind_cache - exit 0 diff --git a/03-mkiso b/03-mkiso index 77f261c..0d92faa 100755 --- a/03-mkiso +++ b/03-mkiso @@ -18,11 +18,18 @@ mount_pseudofs() { } umount_pseudofs() { - umount $LFS/dev/pts &>/dev/null - umount $LFS/dev &>/dev/null - umount $LFS/run &>/dev/null - umount $LFS/proc &>/dev/null - umount $LFS/sys &>/dev/null + unmount $LFS/dev/pts + unmount $LFS/dev + unmount $LFS/run + unmount $LFS/proc + unmount $LFS/sys +} + +unmount() { + while true; do + mountpoint -q $1 || break + umount $1 2>/dev/null + done } interrupted() { @@ -30,7 +37,6 @@ interrupted() { } cleanup() { - #rm -fr $LFS rm -fr $WDIR } @@ -50,13 +56,17 @@ printerror() { } CWD=$PWD +LFS="/mnt/lfs" +WORKDIR="$LFS/tmp" +WDIR="$WORKDIR/iso" +LABEL="LFSLIVECD" +OUTPUT="lfs-livecd-$(date +"%Y%m%d").iso" +FILEDIR="$CWD/files" -source $CWD/config +. $CWD/config isolinux_files="chain.c32 isolinux.bin ldlinux.c32 libutil.c32 reboot.c32 menu.c32 libcom32.c32 poweroff.c32" -OUTPUT=$OUTPUT.iso - rm -fr $WDIR mkdir -p $WDIR @@ -78,7 +88,7 @@ mksquashfs $LFS $WDIR/lfs/root.sfs \ -e $LFS/tools/ \ -e $LFS/tmp/* 2>/dev/null || die "failed create squashed filesystem" -printstep "Preparing kernel and initramfs..." +printstep "Preparing kernel and initramfs..." cp $LFS/boot/vmlinuz-lfs $WDIR/boot/vmlinuz || die "failed copying kernel" cp files/livecd.hook $LFS/etc/mkinitramfs.d kernver=$(file $LFS/boot/vmlinuz-lfs | cut -d ' ' -f9) @@ -114,14 +124,14 @@ xorriso -as mkisofs \ -isohybrid-mbr /usr/share/syslinux/isohdpfx.bin \ -c isolinux/boot.cat \ -b isolinux/isolinux.bin \ - -no-emul-boot \ - -boot-load-size 4 \ - -boot-info-table \ - -eltorito-alt-boot \ - -e boot/efiboot.img \ - -no-emul-boot \ - -isohybrid-gpt-basdat \ - -volid $LABEL \ + -no-emul-boot \ + -boot-load-size 4 \ + -boot-info-table \ + -eltorito-alt-boot \ + -e boot/efiboot.img \ + -no-emul-boot \ + -isohybrid-gpt-basdat \ + -volid $LABEL \ -o $OUTPUT $WDIR || die "failed create iso" printstep "Cleaning up..." diff --git a/backuptoolchain.sh b/backuptoolchain.sh new file mode 100755 index 0000000..3bb5cbb --- /dev/null +++ b/backuptoolchain.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +. ./config + +CWD=$PWD + +cd $LFS +tar cvJpf $CWD/toolchain.tar.xz tools + +exit 0 diff --git a/config b/config index 3293e3a..cca7c7d 100755 --- a/config +++ b/config @@ -1,16 +1,9 @@ +# config file for toolchain scripts +# modify according your needs MAKEFLAGS="-j$(nproc)" LFS="/mnt/lfs" LFS_TGT=$(uname -m)-lfs-linux-gnu - -TCDIR=$CWD/toolchain -SRCDIR=$CWD/sources -PATCHDIR=$CWD/patches -FILEDIR=$CWD/files -WORKDIR=/tmp - -LABEL=LFSLIVECD -OUTPUT=lfs-livecd-$(date +"%Y%m%d") -WDIR=/tmp/lfsiso - -#MULTILIB=yes +LFS_TGT32=i686-lfs-linux-gnu +SRCDIR=$LFS/var/lib/pkg/src +WORKDIR=$LFS/tmp diff --git a/ports/core/binutils/Pkgfile b/ports/core/binutils/Pkgfile index d20adb3..35ddeec 100755 --- a/ports/core/binutils/Pkgfile +++ b/ports/core/binutils/Pkgfile @@ -9,16 +9,12 @@ release=1 source=(https://ftp.gnu.org/gnu/binutils/$name-$version.tar.xz) build() { - if [ "$MULTILIB" = "yes" ]; then - multilibopt="--enable-multilib --with-lib-path=/usr/lib:/lib:/usr/lib32" - fi - cd $name-$version mkdir -v build cd build - ../configure $multilibopt \ + ../configure \ --prefix=/usr \ --enable-gold \ --enable-ld=default \ @@ -26,7 +22,9 @@ build() { --enable-shared \ --disable-werror \ --enable-64-bit-bfd \ - --with-system-zlib + --with-system-zlib \ + --enable-multilib \ + --with-lib-path=/usr/lib:/lib:/usr/lib32 make tooldir=/usr make tooldir=/usr DESTDIR=$PKG install } diff --git a/ports/core/gcc/Pkgfile b/ports/core/gcc/Pkgfile index 338b249..c7e28e8 100755 --- a/ports/core/gcc/Pkgfile +++ b/ports/core/gcc/Pkgfile @@ -9,12 +9,6 @@ release=1 source=(https://ftp.gnu.org/gnu/$name/$name-$version/$name-$version.tar.xz) build() { - if [ "$MULTILIB" = "yes" ]; then - multilibopt="--enable-multilib" - else - multilibopt="--disable-multilib" - fi - cd $name-$version sed -e '/m64=/s/lib64/lib/' \ @@ -28,11 +22,12 @@ build() { cd build SED=sed \ - ../configure $multilibopt \ + ../configure \ --prefix=/usr \ --enable-languages=c,c++ \ --disable-bootstrap \ - --with-system-zlib + --with-system-zlib \ + --enable-multilib make make -j1 DESTDIR=$PKG install diff --git a/ports/core/glibc/Pkgfile b/ports/core/glibc/Pkgfile index 1d07125..1999a37 100755 --- a/ports/core/glibc/Pkgfile +++ b/ports/core/glibc/Pkgfile @@ -10,10 +10,6 @@ source=(https://ftp.gnu.org/gnu/$name/$name-$version.tar.xz http://www.linuxfromscratch.org/patches/lfs/9.1/$name-$version-fhs-1.patch) build() { - if [ "$MULTILIB" = "yes" ]; then - multilibopt="--enable-multi-arch" - fi - cd $name-$version patch -Np1 -i ../$name-$version-fhs-1.patch @@ -26,12 +22,13 @@ build() { cd build CC="gcc -ffile-prefix-map=/tools=/usr" \ - ../configure $multilibopt \ + ../configure \ --prefix=/usr \ --disable-werror \ --enable-kernel=3.2 \ --enable-stack-protector=strong \ --with-headers=/usr/include \ + --enable-multi-arch \ libc_cv_slibdir=/lib make mkdir -p $PKG/etc @@ -45,7 +42,6 @@ build() { make install_root=$PKG localedata/install-locales # 32bit - if [ "$MULTILIB" = "yes" ]; then mkdir -v ../build32 cd ../build32 CC="gcc -m32" \ @@ -72,7 +68,6 @@ build() { ln -sv ../lib/locale $PKG/usr/lib32/locale echo "/usr/lib32" > $PKG/etc/ld.so.conf.d/lib32.conf cd - - fi cat > $PKG/etc/nsswitch.conf << "EOF" # Begin /etc/nsswitch.conf diff --git a/ports/core/libevent/Pkgfile b/ports/core/libevent/Pkgfile index f3cb095..4186d2a 100755 --- a/ports/core/libevent/Pkgfile +++ b/ports/core/libevent/Pkgfile @@ -4,7 +4,7 @@ name=libevent version=2.1.11 -release=2 +release=1 source=(https://github.com/libevent/libevent/releases/download/release-$version-stable/libevent-$version-stable.tar.gz) build() { diff --git a/ports/core/pkgutils/Pkgfile b/ports/core/pkgutils/Pkgfile index a0620ac..d5a8d04 100755 --- a/ports/core/pkgutils/Pkgfile +++ b/ports/core/pkgutils/Pkgfile @@ -24,9 +24,4 @@ build () { -e 's/ -static//' Makefile make DESTDIR=$PKG install install -m644 $SRC/pkgmk.conf $PKG/etc/pkgmk.conf - - if [ "$MULTILIB" = "yes" ]; then - sed -i 's/#export MULTILIB=/export MULTILIB=/' \ - $PKG/etc/pkgmk.conf - fi } diff --git a/ports/core/pkgutils/pkgmk.conf b/ports/core/pkgutils/pkgmk.conf index 402f220..2becd01 100755 --- a/ports/core/pkgutils/pkgmk.conf +++ b/ports/core/pkgutils/pkgmk.conf @@ -7,7 +7,6 @@ export CXXFLAGS="${CFLAGS}" export JOBS=$(nproc) export MAKEFLAGS="-j $JOBS" -#export MULTILIB="yes" case ${PKGMK_ARCH} in "64"|"") diff --git a/ports/core/wpa_supplicant/Pkgfile b/ports/core/wpa_supplicant/Pkgfile index f08b437..20c7fdb 100755 --- a/ports/core/wpa_supplicant/Pkgfile +++ b/ports/core/wpa_supplicant/Pkgfile @@ -6,7 +6,7 @@ name=wpa_supplicant version=2.9 bootscriptsversion=20191204 -release=2 +release=1 source=(https://w1.fi/releases/wpa_supplicant-$version.tar.gz http://anduin.linuxfromscratch.org/BLFS/blfs-bootscripts/blfs-bootscripts-$bootscriptsversion.tar.xz wpa_supplicant.conf) diff --git a/rootfs/etc/fstab b/rootfs/etc/fstab index fc6dc1d..a6e757f 100755 --- a/rootfs/etc/fstab +++ b/rootfs/etc/fstab @@ -1,5 +1,12 @@ # Begin /etc/fstab -# black fstab for liveiso +# file system mount-point type options dump fsck order +#/dev/ / defaults 1 1 +#/dev/ swap swap pri=1 0 0 +#proc /proc proc nosuid,noexec,nodev 0 0 +#sysfs /sys sysfs nosuid,noexec,nodev 0 0 +devpts /dev/pts devpts gid=5,mode=620 0 0 +#tmpfs /run tmpfs defaults 0 0 +#devtmpfs /dev devtmpfs mode=0755,nosuid 0 0 # End /etc/fstab diff --git a/run_qemu b/run_qemu new file mode 100755 index 0000000..eef0022 --- /dev/null +++ b/run_qemu @@ -0,0 +1,18 @@ +#!/bin/sh + +[ -f venom-vm.img ] || { + qemu-img create -f qcow2 venom-vm.img 50G +} + +exec qemu-system-x86_64 -enable-kvm \ + -cpu host \ + -drive file=venom-vm.img,if=virtio \ + -netdev user,id=vmnic,hostname=Venom \ + -device virtio-net,netdev=vmnic \ + -device virtio-rng-pci \ + -m 2G \ + -smp 4 \ + -monitor stdio \ + -name "VenomLinux VM" \ + -boot d \ + -cdrom $@ diff --git a/toolchain/01-binutils-pass1 b/toolchain/01-binutils-pass1 index f77ce85..33c793e 100755 --- a/toolchain/01-binutils-pass1 +++ b/toolchain/01-binutils-pass1 @@ -3,25 +3,20 @@ version=2.34 source=(http://ftp.gnu.org/gnu/binutils/binutils-$version.tar.xz) build() { - if [ "$MULTILIB" = "yes" ]; then - multilibopt="--with-lib-path=/tools/lib:/tools/lib32" - else - multilibopt="--with-lib-path=/tools/lib" - fi - cd $name-$version mkdir -v build cd build - ../configure $multilibopt \ + ../configure \ --prefix=/tools \ --with-sysroot=$LFS \ --target=$LFS_TGT \ --disable-nls \ - --disable-werror + --disable-werror \ + --with-lib-path=/tools/lib:/tools/lib32 make mkdir -v /tools/lib && ln -sv lib /tools/lib64 - [ "$MULTILIB" = "yes" ] && mkdir -p /tools/lib32 + mkdir -p /tools/lib32 make install } diff --git a/toolchain/02-gcc-pass1 b/toolchain/02-gcc-pass1 index 8eb014d..ac1ae4d 100755 --- a/toolchain/02-gcc-pass1 +++ b/toolchain/02-gcc-pass1 @@ -9,12 +9,6 @@ source=(http://ftp.gnu.org/gnu/gcc/gcc-$version/gcc-$version.tar.xz http://www.mpfr.org/mpfr-$mpfr_version/mpfr-$mpfr_version.tar.xz) build() { - if [ "$MULTILIB" = "yes" ]; then - multilibopt="--with-multilib-list=m32,m64" - else - multilibopt="--disable-multilib" - fi - cd $name-$version mv -v ../mpfr-$mpfr_version mpfr @@ -34,19 +28,14 @@ build() { touch $file.orig done - if [ "$MULTILIB" = "yes" ]; then - sed -i -e 's@/lib/ld-linux.so.2@/lib32/ld-linux.so.2@g' gcc/config/i386/linux64.h - sed -i -e '/MULTILIB_OSDIRNAMES/d' gcc/config/i386/t-linux64 - echo "MULTILIB_OSDIRNAMES = m64=../lib m32=../lib32 mx32=../libx32" >> gcc/config/i386/t-linux64 - else - sed -e '/m64=/s/lib64/lib/' \ - -i.orig gcc/config/i386/t-linux64 - fi + sed -i -e 's@/lib/ld-linux.so.2@/lib32/ld-linux.so.2@g' gcc/config/i386/linux64.h + sed -i -e '/MULTILIB_OSDIRNAMES/d' gcc/config/i386/t-linux64 + echo "MULTILIB_OSDIRNAMES = m64=../lib m32=../lib32 mx32=../libx32" >> gcc/config/i386/t-linux64 mkdir -v build cd build - ../configure $multilibopt \ + ../configure \ --target=$LFS_TGT \ --prefix=/tools \ --with-glibc-version=2.11 \ @@ -66,7 +55,8 @@ build() { --disable-libssp \ --disable-libvtv \ --disable-libstdcxx \ - --enable-languages=c,c++ + --enable-languages=c,c++ \ + --with-multilib-list=m32,m64 make make install } diff --git a/toolchain/04-glibc b/toolchain/04-glibc index 4eff3ba..4ef173a 100755 --- a/toolchain/04-glibc +++ b/toolchain/04-glibc @@ -5,14 +5,13 @@ source=(http://ftp.gnu.org/gnu/glibc/glibc-$version.tar.xz) build() { cd $name-$version - if [ "$MULTILIB" = "yes" ]; then mkdir -v build32 cd build32 echo slibdir=/tools/lib32 > configparms ../configure \ --prefix=/tools \ - --host=i686-lfs-linux-gnu \ + --host=$LFS_TGT32 \ --build=$(../scripts/config.guess) \ --libdir=/tools/lib32 \ --enable-kernel=3.2 \ @@ -22,7 +21,6 @@ build() { make make install cd - - fi mkdir -v build cd build diff --git a/toolchain/05-libstdc++ b/toolchain/05-libstdc++ index 3765a02..1377444 100755 --- a/toolchain/05-libstdc++ +++ b/toolchain/05-libstdc++ @@ -5,7 +5,6 @@ source=(http://ftp.gnu.org/gnu/gcc/gcc-$version/gcc-$version.tar.xz) build() { cd $name-$version - if [ "$MULTILIB" = "yes" ]; then mkdir -v build32 cd build32 @@ -23,7 +22,6 @@ build() { make make install cd - - fi mkdir -v build cd build diff --git a/toolchain/06-binutils-pass2 b/toolchain/06-binutils-pass2 index 74962e7..60c7276 100755 --- a/toolchain/06-binutils-pass2 +++ b/toolchain/06-binutils-pass2 @@ -20,10 +20,6 @@ build() { make make install make -C ld clean - if [ "$MULTILIB" = "yes" ]; then - make -C ld LIB_PATH=/usr/lib:/lib:/usr/lib32:/lib32 - else - make -C ld LIB_PATH=/usr/lib:/lib - fi + make -C ld LIB_PATH=/usr/lib:/lib:/usr/lib32 cp -v ld/ld-new /tools/bin } diff --git a/toolchain/07-gcc-pass2 b/toolchain/07-gcc-pass2 index 0f0e2e0..69f8d34 100755 --- a/toolchain/07-gcc-pass2 +++ b/toolchain/07-gcc-pass2 @@ -9,12 +9,6 @@ source=(http://ftp.gnu.org/gnu/gcc/gcc-$version/gcc-$version.tar.xz http://www.mpfr.org/mpfr-$mpfr_version/mpfr-$mpfr_version.tar.xz) build() { - if [ "$MULTILIB" = "yes" ]; then - multilibopt="--with-multilib-list=m32,m64" - else - multilibopt="--disable-multilib" - fi - cd $name-$version mv -v ../mpfr-$mpfr_version mpfr @@ -37,15 +31,10 @@ build() { touch $file.orig done - if [ "$MULTILIB" = "yes" ]; then - sed -i -e 's@/lib/ld-linux.so.2@/lib32/ld-linux.so.2@g' gcc/config/i386/linux64.h - sed -i -e '/MULTILIB_OSDIRNAMES/d' gcc/config/i386/t-linux64 - echo "MULTILIB_OSDIRNAMES = m64=../lib m32=../lib32 mx32=../libx32" >> gcc/config/i386/t-linux64 - else - sed -e '/m64=/s/lib64/lib/' \ - -i.orig gcc/config/i386/t-linux64 - fi - + sed -i -e 's@/lib/ld-linux.so.2@/lib32/ld-linux.so.2@g' gcc/config/i386/linux64.h + sed -i -e '/MULTILIB_OSDIRNAMES/d' gcc/config/i386/t-linux64 + echo "MULTILIB_OSDIRNAMES = m64=../lib m32=../lib32 mx32=../libx32" >> gcc/config/i386/t-linux64 + # fix a problem introduced by Glibc-2.31 sed -e '1161 s|^|//|' \ -i libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc @@ -57,14 +46,15 @@ build() { CXX=$LFS_TGT-g++ \ AR=$LFS_TGT-ar \ RANLIB=$LFS_TGT-ranlib \ - ../configure $multilibopt \ + ../configure \ --prefix=/tools \ --with-local-prefix=/tools \ --with-native-system-header-dir=/tools/include \ --enable-languages=c,c++ \ --disable-libstdcxx-pch \ --disable-bootstrap \ - --disable-libgomp + --disable-libgomp \ + --with-multilib-list=m32,m64 make make install ln -sv gcc /tools/bin/cc diff --git a/toolchain/41-pkgutils b/toolchain/41-pkgutils index e0a24c4..520d0d5 100755 --- a/toolchain/41-pkgutils +++ b/toolchain/41-pkgutils @@ -27,7 +27,6 @@ export CXXFLAGS="${CFLAGS}" export JOBS=$(nproc) export MAKEFLAGS="-j $JOBS" -#export MULTILIB="yes" PKGMK_SOURCE_DIR="/var/lib/pkg/src" PKGMK_PACKAGE_DIR="/var/lib/pkg/pkg" @@ -38,9 +37,4 @@ PKGMK_COMPRESSION_MODE="xz" # End of file EOF - -if [ "$MULTILIB" = "yes" ]; then - sed -i 's/#export MULTILIB=/export MULTILIB=/' \ - /tools/etc/pkgmk.conf -fi } diff --git a/toolchain/42-httpup b/toolchain/42-httpup deleted file mode 100755 index 0e8fa17..0000000 --- a/toolchain/42-httpup +++ /dev/null @@ -1,9 +0,0 @@ -name=httpup -version=0.5.0 -source=(https://crux.nu/files/$name-$version.tar.xz) - -build() { - cd $name-$version - make - make DESTDIR=$PKG prefix=/tools mandir=/tools/share/man install -} diff --git a/toolchain/45-wget b/toolchain/42-wget similarity index 100% rename from toolchain/45-wget rename to toolchain/42-wget diff --git a/toolchain/43-ports b/toolchain/43-ports deleted file mode 100755 index fb3321e..0000000 --- a/toolchain/43-ports +++ /dev/null @@ -1,12 +0,0 @@ -name=ports -version=1.6 -source=(https://crux.nu/files/tools/ports/$name-$version.tar.gz) - -build() { - cd $name-$version - make - make DESTDIR=$PKG BINDIR=/tools/bin ETCDIR=/tools/etc/ports PORTSDIR=/tools/etc/ports MANDIR=/tools/share/man install - install -D -m 755 $FILEDIR/httpup /tools/etc/ports/drivers/httpup - install -m 644 $FILEDIR/core.httpup /tools/etc/ports/core.httpup - sed 's,etc/ports,tools/etc/ports,g' -i /tools/bin/ports -} diff --git a/toolchain/44-nano b/toolchain/44-nano deleted file mode 100755 index 22a3e04..0000000 --- a/toolchain/44-nano +++ /dev/null @@ -1,10 +0,0 @@ -name=nano -version=4.8 -source=(https://www.nano-editor.org/dist/v${version::1}/nano-$version.tar.xz) - -build() { - cd $name-$version - ./configure --prefix=/tools - make - make install -} diff --git a/toolchain/99-cleaning b/toolchain/99-cleaning index 78fde9c..fddb801 100755 --- a/toolchain/99-cleaning +++ b/toolchain/99-cleaning @@ -6,8 +6,6 @@ build() { rm -rf /tools{,/share}/{info,man,doc} find /tools/{lib,libexec} -name \*.la -delete - if [ "$MULTILIB" = "yes" ]; then - strip --strip-debug /tools/lib32/* || true - find /tools/lib32 -name \*.la -delete - fi + strip --strip-debug /tools/lib32/* || true + find /tools/lib32 -name \*.la -delete }