This commit is contained in:
emmett1 2020-06-28 23:38:04 +08:00
parent bc26b67553
commit d4888352ff
27 changed files with 110 additions and 176 deletions

5
.gitignore vendored
View file

@ -1,3 +1,4 @@
*.iso
sources
packages
*.tar.xz
*.img

View file

@ -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

23
02-base
View file

@ -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

View file

@ -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..."

10
backuptoolchain.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/sh
. ./config
CWD=$PWD
cd $LFS
tar cvJpf $CWD/toolchain.tar.xz tools
exit 0

17
config
View file

@ -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

View file

@ -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
}

View file

@ -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

View file

@ -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

View file

@ -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() {

View file

@ -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
}

View file

@ -7,7 +7,6 @@ export CXXFLAGS="${CFLAGS}"
export JOBS=$(nproc)
export MAKEFLAGS="-j $JOBS"
#export MULTILIB="yes"
case ${PKGMK_ARCH} in
"64"|"")

View file

@ -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)

View file

@ -1,5 +1,12 @@
# Begin /etc/fstab
# black fstab for liveiso
# file system mount-point type options dump fsck order
#/dev/<xxx> / <fff> defaults 1 1
#/dev/<yyy> 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

18
run_qemu Executable file
View file

@ -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 $@

View file

@ -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
}

View file

@ -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
}

View file

@ -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

View file

@ -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

View file

@ -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
}

View file

@ -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

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}