refactor
- extract patch to version file - added silent to bootstrap configure functions & glibc patch section - renamed build.sh to build.bash - moved flags, utilities and version to their own files - extract glibc patch url to version file
This commit is contained in:
@@ -4,176 +4,9 @@ set -euo pipefail
|
||||
|
||||
umask 022
|
||||
|
||||
export LC_ALL="POSIX"
|
||||
|
||||
export TARGET="x86_64-axe-linux-gnu"
|
||||
|
||||
export MAKEFLAGS="-j$(nproc)"
|
||||
|
||||
export SYSROOT="$PWD/sysroot"
|
||||
|
||||
export PROJDIR="$PWD"
|
||||
|
||||
export SOURCES="$SYSROOT/sources"
|
||||
|
||||
export CROSS="$SYSROOT/cross"
|
||||
|
||||
export PATH="$CROSS/bin:/usr/bin:/usr/sbin"
|
||||
|
||||
export CONFIG_SITE="$SYSROOT/usr/share/config.site"
|
||||
|
||||
BINUTILS_VERSION=2.45.1
|
||||
BINUTILS_URL=https://mirror.ufs.ac.za/gnu/binutils/binutils-$BINUTILS_VERSION.tar.xz
|
||||
|
||||
GCC_VERSION=15.2.0
|
||||
GCC_URL=https://mirror.ufs.ac.za/gnu/gcc/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.xz
|
||||
|
||||
GMP_VERSION=6.3.0
|
||||
GMP_URL=https://mirror.ufs.ac.za/gnu/gmp/gmp-$GMP_VERSION.tar.xz
|
||||
|
||||
MPC_VERSION=1.3.1
|
||||
MPC_URL=https://mirror.ufs.ac.za/gnu/mpc/mpc-$MPC_VERSION.tar.gz
|
||||
|
||||
MPFR_VERSION=4.2.2
|
||||
MPFR_URL=https://mirror.ufs.ac.za/gnu/mpfr/mpfr-$MPFR_VERSION.tar.xz
|
||||
|
||||
ISL_VERSION=0.27
|
||||
ISL_URL=https://libisl.sourceforge.io/isl-$ISL_VERSION.tar.xz
|
||||
|
||||
GLIBC_VERSION=2.43
|
||||
GLIBC_URL=https://mirror.ufs.ac.za/gnu/glibc/glibc-$GLIBC_VERSION.tar.xz
|
||||
|
||||
LINUX_VERSION=6.18.7
|
||||
IFS='.' read -r LINUX_VERSION_MAJOR LINUX_VERSION_MINOR LINUX_VERSION_PATCH <<< $LINUX_VERSION
|
||||
LINUX_URL=https://cdn.kernel.org/pub/linux/kernel/v$LINUX_VERSION_MAJOR.x/linux-$LINUX_VERSION.tar.xz
|
||||
|
||||
M4_VERSION=1.4.20
|
||||
M4_URL=https://mirror.ufs.ac.za/gnu/m4/m4-$M4_VERSION.tar.xz
|
||||
|
||||
NCURSES_VERSION=6.6
|
||||
NCURSES_URL=https://mirror.ufs.ac.za/gnu/ncurses/ncurses-$NCURSES_VERSION.tar.gz
|
||||
|
||||
BASH_VERSION=5.3
|
||||
BASH_URL=https://mirror.ufs.ac.za/gnu/bash/bash-$BASH_VERSION.tar.gz
|
||||
|
||||
COREUTILS_VERSION=9.9
|
||||
COREUTILS_URL=https://mirror.ufs.ac.za/gnu/coreutils/coreutils-$COREUTILS_VERSION.tar.xz
|
||||
|
||||
DIFFUTILS_VERSION=3.12
|
||||
DIFFUTILS_URL=https://mirror.ufs.ac.za/gnu/diffutils/diffutils-$DIFFUTILS_VERSION.tar.xz
|
||||
|
||||
FILE_VERSION=5.46
|
||||
FILE_URL=https://astron.com/pub/file/file-$FILE_VERSION.tar.gz
|
||||
|
||||
FINDUTILS_VERSION=4.10.0
|
||||
FINDUTILS_URL=https://mirror.ufs.ac.za/gnu/findutils/findutils-$FINDUTILS_VERSION.tar.xz
|
||||
|
||||
GAWK_VERSION=5.3.2
|
||||
GAWK_URL=https://mirror.ufs.ac.za/gnu/gawk/gawk-$GAWK_VERSION.tar.xz
|
||||
|
||||
GREP_VERSION=3.12
|
||||
GREP_URL=https://mirror.ufs.ac.za/gnu/grep/grep-$GREP_VERSION.tar.xz
|
||||
|
||||
GZIP_VERSION=1.14
|
||||
GZIP_URL=https://mirror.ufs.ac.za/gnu/gzip/gzip-$GZIP_VERSION.tar.xz
|
||||
|
||||
MAKE_VERSION=4.4.1
|
||||
MAKE_URL=https://mirror.ufs.ac.za/gnu/make/make-$MAKE_VERSION.tar.gz
|
||||
|
||||
PATCH_VERSION=2.8
|
||||
PATCH_URL=https://mirror.ufs.ac.za/gnu/patch/patch-$PATCH_VERSION.tar.xz
|
||||
|
||||
SED_VERSION=4.9
|
||||
SED_URL=https://mirror.ufs.ac.za/gnu/sed/sed-$SED_VERSION.tar.xz
|
||||
|
||||
TAR_VERSION=1.35
|
||||
TAR_URL=https://mirror.ufs.ac.za/gnu/tar/tar-$TAR_VERSION.tar.xz
|
||||
|
||||
XZ_VERSION=5.8.2
|
||||
XZ_URL=https://github.com//tukaani-project/xz/releases/download/v$XZ_VERSION/xz-$XZ_VERSION.tar.xz
|
||||
|
||||
create_directories() {
|
||||
if [ ! -d "$SYSROOT" ]; then
|
||||
mkdir -p "$SYSROOT"/{etc,cross,sources,usr,dev,proc,sys,run}
|
||||
mkdir -p "$SYSROOT"/usr/{bin,sbin,lib,include}
|
||||
mkdir -p "$SYSROOT"/var/{cache,lib,run}
|
||||
|
||||
for directory in bin sbin lib; do
|
||||
ln -fs usr/$directory "$SYSROOT"/$directory
|
||||
done
|
||||
|
||||
ln -s usr/lib "$SYSROOT"/lib64
|
||||
|
||||
ln -s run "$SYSROOT"/var/run
|
||||
ln -sfv run/lock "$SYSROOT"/var/lock
|
||||
|
||||
install -dv -m 0750 "$SYSROOT"/root
|
||||
install -dv -m 1777 "$SYSROOT"/tmp "$SYSROOT"/var/tmp
|
||||
fi
|
||||
}
|
||||
|
||||
create_files() {
|
||||
if [[ ! -L "$SYSROOT"/etc/mtab ]]; then
|
||||
sudo ln -s proc/self/mounts "$SYSROOT"/etc/mtab
|
||||
|
||||
cat > "$SYSROOT"/etc/hosts <<- "EOF"
|
||||
127.0.0.1 localhost axe
|
||||
::1 localhost
|
||||
EOF
|
||||
|
||||
cat > "$SYSROOT"/etc/passwd <<- "EOF"
|
||||
root:x:0:0:root:/root:/usr/bin/bash
|
||||
uuidd:x:6:6::/dev/null:/usr/bin/nologin
|
||||
messagebus:x:7:7::/run/dbus:/usr/bin/nologin
|
||||
nobody:x:65534:65534::/dev/null:/usr/bin/nologin
|
||||
EOF
|
||||
|
||||
cat > "$SYSROOT"/etc/group <<- "EOF"
|
||||
root:x:0:
|
||||
tty:x:1:
|
||||
audio:x:2:
|
||||
video:x:3:
|
||||
input:x:4:
|
||||
wheel:x:5:
|
||||
uuidd:x:6:
|
||||
messagebus:x:7:
|
||||
users:x:999:
|
||||
nogroup:x:65534:
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
create_sysroot() {
|
||||
create_directories
|
||||
create_files
|
||||
}
|
||||
|
||||
change_owner() {
|
||||
sudo chown -R root:root "$SYSROOT"/{etc,cross,usr,dev,proc,sys,run,var}
|
||||
}
|
||||
|
||||
do_mount() {
|
||||
if ! mountpoint -q "$SYSROOT/dev"; then
|
||||
sudo mount --bind /dev "$SYSROOT"/dev
|
||||
sudo mount -t devpts devpts -o gid=5,mode=0620 "$SYSROOT"/dev/pts
|
||||
sudo mount -t proc proc "$SYSROOT"/proc
|
||||
sudo mount -t sysfs sysfs "$SYSROOT"/sys
|
||||
sudo mount -t tmpfs tmpfs "$SYSROOT"/run
|
||||
if [ -h "$SYSROOT"/dev/shm ]; then
|
||||
sudo install -d -m 1777 "$SYSROOT"$(realpath /dev/shm)
|
||||
else
|
||||
sudo mount -t tmpfs -o nosuid,nodev tmpfs "$SYSROOT"/dev/shm
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
do_unmount() {
|
||||
sudo umount -R "$SYSROOT/"
|
||||
}
|
||||
|
||||
fetch() {
|
||||
wget -N -c --show-progress -q -P "$SOURCES" $1
|
||||
}
|
||||
. version.bash
|
||||
. flags.bash
|
||||
. utilities.bash
|
||||
|
||||
bootstrap_binutils() {
|
||||
fetch $BINUTILS_URL
|
||||
@@ -190,7 +23,9 @@ bootstrap_binutils() {
|
||||
--enable-gprofng=no \
|
||||
--disable-werror \
|
||||
--enable-new-dtags \
|
||||
--enable-default-hash-style=gnu
|
||||
--enable-default-hash-style=gnu \
|
||||
--silent \
|
||||
--quiet
|
||||
|
||||
make && make install
|
||||
|
||||
@@ -235,7 +70,9 @@ bootstap_gcc() {
|
||||
--disable-libssp \
|
||||
--disable-libvtv \
|
||||
--disable-libstdcxx \
|
||||
--enable-languages=c,c++
|
||||
--enable-languages=c,c++ \
|
||||
--silent \
|
||||
--quiet
|
||||
|
||||
make && make install
|
||||
|
||||
@@ -260,13 +97,13 @@ bootstap_linux() {
|
||||
|
||||
bootstap_glibc() {
|
||||
fetch $GLIBC_URL
|
||||
fetch https://www.linuxfromscratch.org/patches/lfs/development/glibc-fhs-1.patch
|
||||
fetch $GLIBC_PATCH_URL
|
||||
|
||||
cd "$SOURCES" && tar xf glibc-$GLIBC_VERSION.tar.xz && cd glibc-$GLIBC_VERSION
|
||||
|
||||
ln -sf ld-linux-x86-64.so.2 "$SYSROOT"/lib/ld-lsb-x86-64.so.3
|
||||
|
||||
patch -Np1 -i "$SOURCES"/glibc-fhs-1.patch
|
||||
patch -sNp1 -i "$SOURCES"/glibc-fhs-1.patch
|
||||
|
||||
mkdir -p build && cd build
|
||||
|
||||
@@ -279,13 +116,16 @@ bootstap_glibc() {
|
||||
--disable-nscd \
|
||||
--disable-nls \
|
||||
libc_cv_slibdir=/usr/lib \
|
||||
--enable-kernel=$LINUX_VERSION
|
||||
--enable-kernel=$LINUX_VERSION \
|
||||
--silent \
|
||||
--quiet
|
||||
|
||||
|
||||
make && make DESTDIR="$SYSROOT" install
|
||||
|
||||
sed '/RTLDLIST=/s@/usr@@g' -i "$SYSROOT"/usr/bin/ldd
|
||||
|
||||
cd "$SOURCES" && rm -rf gcc-$GLIBC_VERSION
|
||||
cd "$SOURCES" && rm -rf glibc-$GLIBC_VERSION
|
||||
}
|
||||
|
||||
bootstap_libstdcpp() {
|
||||
@@ -300,7 +140,10 @@ bootstap_libstdcpp() {
|
||||
--disable-multilib \
|
||||
--disable-nls \
|
||||
--disable-libstdcxx-pch \
|
||||
--with-gxx-include-dir=/cross/$TARGET/include/c++/$GCC_VERSION
|
||||
--with-gxx-include-dir=/cross/$TARGET/include/c++/$GCC_VERSION \
|
||||
--silent \
|
||||
--quiet
|
||||
|
||||
|
||||
make && make DESTDIR="$SYSROOT" install
|
||||
|
||||
@@ -660,7 +503,7 @@ toolchain_gcc() {
|
||||
#bootstap_linux
|
||||
#bootstap_glibc
|
||||
#bootstap_libstdcpp
|
||||
#toolchain_m4
|
||||
toolchain_m4
|
||||
#toolchain_ncurses
|
||||
#toolchain_bash
|
||||
#toolchain_coreutils
|
||||
19
flags.bash
Normal file
19
flags.bash
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export LC_ALL="POSIX"
|
||||
|
||||
export TARGET="x86_64-axe-linux-gnu"
|
||||
|
||||
export MAKEFLAGS="-j$(nproc) --no-print-directory --silent"
|
||||
|
||||
export SYSROOT="$PWD/sysroot"
|
||||
|
||||
export PROJDIR="$PWD"
|
||||
|
||||
export SOURCES="$SYSROOT/sources"
|
||||
|
||||
export CROSS="$SYSROOT/cross"
|
||||
|
||||
export PATH="$CROSS/bin:/usr/bin:/usr/sbin"
|
||||
|
||||
export CONFIG_SITE="$SYSROOT/usr/share/config.site"
|
||||
84
utilities.bash
Normal file
84
utilities.bash
Normal file
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
create_directories() {
|
||||
if [ ! -d "$SYSROOT" ]; then
|
||||
mkdir -p "$SYSROOT"/{etc,cross,sources,usr,dev,proc,sys,run}
|
||||
mkdir -p "$SYSROOT"/usr/{bin,sbin,lib,include}
|
||||
mkdir -p "$SYSROOT"/var/{cache,lib,run}
|
||||
|
||||
for directory in bin sbin lib; do
|
||||
ln -fs usr/$directory "$SYSROOT"/$directory
|
||||
done
|
||||
|
||||
ln -s usr/lib "$SYSROOT"/lib64
|
||||
|
||||
ln -s run "$SYSROOT"/var/run
|
||||
ln -sfv run/lock "$SYSROOT"/var/lock
|
||||
|
||||
install -dv -m 0750 "$SYSROOT"/root
|
||||
install -dv -m 1777 "$SYSROOT"/tmp "$SYSROOT"/var/tmp
|
||||
fi
|
||||
}
|
||||
|
||||
create_files() {
|
||||
if [[ ! -L "$SYSROOT"/etc/mtab ]]; then
|
||||
sudo ln -s proc/self/mounts "$SYSROOT"/etc/mtab
|
||||
|
||||
cat > "$SYSROOT"/etc/hosts <<- "EOF"
|
||||
127.0.0.1 localhost axe
|
||||
::1 localhost
|
||||
EOF
|
||||
|
||||
cat > "$SYSROOT"/etc/passwd <<- "EOF"
|
||||
root:x:0:0:root:/root:/usr/bin/bash
|
||||
uuidd:x:6:6::/dev/null:/usr/bin/nologin
|
||||
messagebus:x:7:7::/run/dbus:/usr/bin/nologin
|
||||
nobody:x:65534:65534::/dev/null:/usr/bin/nologin
|
||||
EOF
|
||||
|
||||
cat > "$SYSROOT"/etc/group <<- "EOF"
|
||||
root:x:0:
|
||||
tty:x:1:
|
||||
audio:x:2:
|
||||
video:x:3:
|
||||
input:x:4:
|
||||
wheel:x:5:
|
||||
uuidd:x:6:
|
||||
messagebus:x:7:
|
||||
users:x:999:
|
||||
nogroup:x:65534:
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
create_sysroot() {
|
||||
create_directories
|
||||
create_files
|
||||
}
|
||||
|
||||
change_owner() {
|
||||
sudo chown -R root:root "$SYSROOT"/{etc,cross,usr,dev,proc,sys,run,var}
|
||||
}
|
||||
|
||||
do_mount() {
|
||||
if ! mountpoint -q "$SYSROOT/dev"; then
|
||||
sudo mount --bind /dev "$SYSROOT"/dev
|
||||
sudo mount -t devpts devpts -o gid=5,mode=0620 "$SYSROOT"/dev/pts
|
||||
sudo mount -t proc proc "$SYSROOT"/proc
|
||||
sudo mount -t sysfs sysfs "$SYSROOT"/sys
|
||||
sudo mount -t tmpfs tmpfs "$SYSROOT"/run
|
||||
if [ -h "$SYSROOT"/dev/shm ]; then
|
||||
sudo install -d -m 1777 "$SYSROOT"$(realpath /dev/shm)
|
||||
else
|
||||
sudo mount -t tmpfs -o nosuid,nodev tmpfs "$SYSROOT"/dev/shm
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
do_unmount() {
|
||||
sudo umount -R "$SYSROOT/"
|
||||
}
|
||||
|
||||
fetch() {
|
||||
wget -N -c --show-progress -q -P "$SOURCES" $1
|
||||
}
|
||||
76
version.bash
Normal file
76
version.bash
Normal file
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
export BINUTILS_VERSION=2.45.1
|
||||
export BINUTILS_URL=https://mirror.ufs.ac.za/gnu/binutils/binutils-$BINUTILS_VERSION.tar.xz
|
||||
|
||||
export GCC_VERSION=15.2.0
|
||||
export GCC_URL=https://mirror.ufs.ac.za/gnu/gcc/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.xz
|
||||
|
||||
export GMP_VERSION=6.3.0
|
||||
export GMP_URL=https://mirror.ufs.ac.za/gnu/gmp/gmp-$GMP_VERSION.tar.xz
|
||||
|
||||
export MPC_VERSION=1.3.1
|
||||
export MPC_URL=https://mirror.ufs.ac.za/gnu/mpc/mpc-$MPC_VERSION.tar.gz
|
||||
|
||||
export MPFR_VERSION=4.2.2
|
||||
export MPFR_URL=https://mirror.ufs.ac.za/gnu/mpfr/mpfr-$MPFR_VERSION.tar.xz
|
||||
|
||||
export ISL_VERSION=0.27
|
||||
export ISL_URL=https://libisl.sourceforge.io/isl-$ISL_VERSION.tar.xz
|
||||
|
||||
export GLIBC_VERSION=2.43
|
||||
export GLIBC_URL=https://mirror.ufs.ac.za/gnu/glibc/glibc-$GLIBC_VERSION.tar.xz
|
||||
|
||||
export GLIBC_PATCH_URL=https://www.linuxfromscratch.org/patches/lfs/development/glibc-fhs-1.patch
|
||||
|
||||
export LINUX_VERSION=6.18.7
|
||||
IFS='.' read -r LINUX_VERSION_MAJOR LINUX_VERSION_MINOR LINUX_VERSION_PATCH <<< $LINUX_VERSION
|
||||
export LINUX_URL=https://cdn.kernel.org/pub/linux/kernel/v$LINUX_VERSION_MAJOR.x/linux-$LINUX_VERSION.tar.xz
|
||||
|
||||
export M4_VERSION=1.4.20
|
||||
export M4_URL=https://mirror.ufs.ac.za/gnu/m4/m4-$M4_VERSION.tar.xz
|
||||
|
||||
export NCURSES_VERSION=6.6
|
||||
export NCURSES_URL=https://mirror.ufs.ac.za/gnu/ncurses/ncurses-$NCURSES_VERSION.tar.gz
|
||||
|
||||
export BASH_VERSION=5.3
|
||||
export BASH_URL=https://mirror.ufs.ac.za/gnu/bash/bash-$BASH_VERSION.tar.gz
|
||||
|
||||
export COREUTILS_VERSION=9.9
|
||||
export COREUTILS_URL=https://mirror.ufs.ac.za/gnu/coreutils/coreutils-$COREUTILS_VERSION.tar.xz
|
||||
|
||||
export DIFFUTILS_VERSION=3.12
|
||||
export DIFFUTILS_URL=https://mirror.ufs.ac.za/gnu/diffutils/diffutils-$DIFFUTILS_VERSION.tar.xz
|
||||
|
||||
export FILE_VERSION=5.46
|
||||
export FILE_URL=https://astron.com/pub/file/file-$FILE_VERSION.tar.gz
|
||||
|
||||
export FINDUTILS_VERSION=4.10.0
|
||||
export FINDUTILS_URL=https://mirror.ufs.ac.za/gnu/findutils/findutils-$FINDUTILS_VERSION.tar.xz
|
||||
|
||||
export GAWK_VERSION=5.3.2
|
||||
export GAWK_URL=https://mirror.ufs.ac.za/gnu/gawk/gawk-$GAWK_VERSION.tar.xz
|
||||
|
||||
export GREP_VERSION=3.12
|
||||
export GREP_URL=https://mirror.ufs.ac.za/gnu/grep/grep-$GREP_VERSION.tar.xz
|
||||
|
||||
export GZIP_VERSION=1.14
|
||||
export GZIP_URL=https://mirror.ufs.ac.za/gnu/gzip/gzip-$GZIP_VERSION.tar.xz
|
||||
|
||||
export MAKE_VERSION=4.4.1
|
||||
export MAKE_URL=https://mirror.ufs.ac.za/gnu/make/make-$MAKE_VERSION.tar.gz
|
||||
|
||||
export PATCH_VERSION=2.8
|
||||
export PATCH_URL=https://mirror.ufs.ac.za/gnu/patch/patch-$PATCH_VERSION.tar.xz
|
||||
|
||||
export SED_VERSION=4.9
|
||||
export SED_URL=https://mirror.ufs.ac.za/gnu/sed/sed-$SED_VERSION.tar.xz
|
||||
|
||||
export TAR_VERSION=1.35
|
||||
export TAR_URL=https://mirror.ufs.ac.za/gnu/tar/tar-$TAR_VERSION.tar.xz
|
||||
|
||||
export XZ_VERSION=5.8.2
|
||||
export XZ_URL=https://github.com//tukaani-project/xz/releases/download/v$XZ_VERSION/xz-$XZ_VERSION.tar.xz
|
||||
|
||||
export GETTEXT_VERSION=1.0
|
||||
export GETTEXT_URL=https://mirror.ufs.ac.za/gnu/gettext/gettext-$GETTEXT_VERSION.tar.xz
|
||||
Reference in New Issue
Block a user