370 lines
11 KiB
Bash
370 lines
11 KiB
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
component_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
. "$component_dir/common.sh"
|
|
|
|
extract() {
|
|
tar -xf "$source_dir/$1" -C "$source_build_dir"
|
|
}
|
|
|
|
extract less-704.tar.gz
|
|
extract mandoc-1.14.6.tar.gz
|
|
extract file-5.48.tar.gz
|
|
extract gzip-1.14.tar.xz
|
|
extract bzip2-1.0.8.tar.gz
|
|
extract xz-5.8.3.tar.bz2
|
|
extract iproute2-7.1.0.tar.xz
|
|
extract libmnl-1.0.5.tar.bz2
|
|
extract libnftnl-1.3.1.tar.xz
|
|
extract nftables-1.1.6.tar.xz
|
|
|
|
pkgconfig_path="$sysroot/usr/lib/pkgconfig:$sysroot/usr/share/pkgconfig"
|
|
|
|
install_man_page() {
|
|
page=$1
|
|
name=${2:-${page##*/}}
|
|
section=${name##*.}
|
|
install -d -m 0755 "$base_root/usr/share/man/man$section"
|
|
install -m 0644 "$page" "$base_root/usr/share/man/man$section/$name"
|
|
}
|
|
|
|
install_command_man_page() {
|
|
tree=$1
|
|
command=$2
|
|
page=$(find "$tree" -type f -name "$command.[1-9]" -print | head -1)
|
|
if [ -n "$page" ]; then
|
|
install_man_page "$page"
|
|
fi
|
|
}
|
|
|
|
(
|
|
cd "$source_build_dir/less-704"
|
|
CC="$cc" \
|
|
AR="$ar" \
|
|
RANLIB="$ranlib" \
|
|
LIBS="-lcurses -lterminfo" \
|
|
./configure \
|
|
--build="$build_triplet" \
|
|
--host="$MOUSE_GNU_TARGET" \
|
|
--prefix=/usr \
|
|
--sysconfdir=/etc \
|
|
--with-regex=posix
|
|
make -s -j"$jobs" less lesskey lessecho
|
|
install -m 0755 less lesskey lessecho "$base_root/usr/bin/"
|
|
)
|
|
install_man_page "$source_build_dir/less-704/less.nro" less.1
|
|
install_man_page "$source_build_dir/less-704/lesskey.nro" lesskey.1
|
|
install_man_page "$source_build_dir/less-704/lessecho.nro" lessecho.1
|
|
|
|
(
|
|
cd "$source_build_dir/bzip2-1.0.8"
|
|
make -s -j"$jobs" \
|
|
CC="$cc" \
|
|
AR="$ar" \
|
|
RANLIB="$ranlib" \
|
|
CFLAGS="-O2" \
|
|
LDFLAGS="-static" \
|
|
bzip2 bzip2recover libbz2.a
|
|
install -m 0644 bzlib.h "$sysroot/usr/include/bzlib.h"
|
|
install -m 0644 libbz2.a "$sysroot/usr/lib/libbz2.a"
|
|
install -m 0755 bzip2 bzip2recover "$base_root/usr/bin/"
|
|
)
|
|
ln -s bzip2 "$base_root/usr/bin/bunzip2"
|
|
ln -s bzip2 "$base_root/usr/bin/bzcat"
|
|
for page in bzip2.1 bzgrep.1 bzmore.1 bzdiff.1; do
|
|
install_man_page "$source_build_dir/bzip2-1.0.8/$page"
|
|
done
|
|
|
|
(
|
|
cd "$source_build_dir/xz-5.8.3"
|
|
CC="$cc" \
|
|
AR="$ar" \
|
|
RANLIB="$ranlib" \
|
|
./configure \
|
|
--build="$build_triplet" \
|
|
--host="$MOUSE_GNU_TARGET" \
|
|
--prefix=/usr \
|
|
--disable-shared \
|
|
--enable-static \
|
|
--disable-nls \
|
|
--disable-doc \
|
|
--disable-xzdec \
|
|
--disable-lzmadec \
|
|
--disable-lzmainfo
|
|
make -s -j"$jobs" -C src/liblzma
|
|
make -s -C src/liblzma DESTDIR="$sysroot" install
|
|
make -s -j"$jobs" -C src/xz xz
|
|
install -m 0755 src/xz/xz "$base_root/usr/bin/xz"
|
|
)
|
|
for command in unxz xzcat lzma unlzma lzcat; do
|
|
ln -s xz "$base_root/usr/bin/$command"
|
|
done
|
|
for page in xz.1; do
|
|
install_man_page "$source_build_dir/xz-5.8.3/src/xz/$page"
|
|
done
|
|
|
|
(
|
|
cd "$source_build_dir/gzip-1.14"
|
|
CC="$cc" \
|
|
AR="$ar" \
|
|
RANLIB="$ranlib" \
|
|
gl_cv_func_getcwd_path_max=yes \
|
|
./configure \
|
|
--build="$build_triplet" \
|
|
--host="$MOUSE_GNU_TARGET" \
|
|
--prefix=/usr \
|
|
--disable-nls
|
|
make -s -j"$jobs"
|
|
install -m 0755 gzip "$base_root/usr/bin/gzip"
|
|
for script in gunzip zcat zcmp zdiff zgrep zless zmore; do
|
|
install -m 0755 "$script" "$base_root/usr/bin/$script"
|
|
done
|
|
)
|
|
for page in gzip.1 gunzip.1 zcat.1 zcmp.1 zdiff.1 zgrep.1 zless.1 zmore.1; do
|
|
install_man_page "$source_build_dir/gzip-1.14/$page"
|
|
done
|
|
|
|
file_native_build="$source_build_dir/file-5.48-native"
|
|
install -d -m 0755 "$file_native_build"
|
|
(
|
|
cd "$file_native_build"
|
|
CC="$native_cc" \
|
|
"$source_build_dir/file-5.48/configure" \
|
|
--disable-shared \
|
|
--enable-static \
|
|
--disable-zstdlib \
|
|
--disable-lzlib \
|
|
--disable-libseccomp
|
|
make -s -C src magic.h
|
|
make -s -j"$jobs" -C src file
|
|
)
|
|
|
|
(
|
|
cd "$source_build_dir/file-5.48"
|
|
CC="$cc" \
|
|
AR="$ar" \
|
|
RANLIB="$ranlib" \
|
|
PKG_CONFIG="$tools_dir/bin/pkgconf" \
|
|
PKG_CONFIG_LIBDIR="$pkgconfig_path" \
|
|
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
|
|
./configure \
|
|
--build="$build_triplet" \
|
|
--host="$MOUSE_GNU_TARGET" \
|
|
--prefix=/usr \
|
|
--disable-shared \
|
|
--enable-static \
|
|
--disable-zstdlib \
|
|
--disable-lzlib \
|
|
--disable-libseccomp
|
|
make -s -C src magic.h
|
|
make -s -j"$jobs" -C src file
|
|
make -s -C magic \
|
|
FILE_COMPILE="$file_native_build/src/file" \
|
|
magic.mgc
|
|
install -m 0755 src/file "$base_root/usr/bin/file"
|
|
install -d -m 0755 "$base_root/usr/share/misc"
|
|
install -m 0644 magic/magic.mgc "$base_root/usr/share/misc/magic.mgc"
|
|
)
|
|
install_man_page "$source_build_dir/file-5.48/doc/file.man" file.1
|
|
install_man_page "$source_build_dir/file-5.48/doc/magic.man" magic.5
|
|
|
|
unzip_source="$source_build_dir/libarchive-unzip-3.8.7"
|
|
install -d -m 0755 "$unzip_source"
|
|
tar -xf "$source_dir/libarchive-3.8.9.tar.xz" \
|
|
-C "$unzip_source" \
|
|
--strip-components=1
|
|
(
|
|
cd "$unzip_source"
|
|
CC="$cc" \
|
|
AR="$ar" \
|
|
RANLIB="$ranlib" \
|
|
PKG_CONFIG="$tools_dir/bin/pkgconf" \
|
|
PKG_CONFIG_LIBDIR="$pkgconfig_path" \
|
|
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
|
|
./configure \
|
|
--build="$build_triplet" \
|
|
--host="$MOUSE_GNU_TARGET" \
|
|
--prefix=/usr \
|
|
--disable-shared \
|
|
--enable-static \
|
|
--disable-bsdtar \
|
|
--disable-bsdcat \
|
|
--disable-bsdcpio \
|
|
--enable-bsdunzip=static \
|
|
--disable-acl \
|
|
--disable-xattr \
|
|
--without-libb2 \
|
|
--without-iconv \
|
|
--without-lz4 \
|
|
--without-zstd \
|
|
--without-xml2 \
|
|
--without-expat \
|
|
--without-openssl \
|
|
--without-cng
|
|
make -s -j"$jobs" bsdunzip
|
|
install -m 0755 bsdunzip "$base_root/usr/bin/unzip"
|
|
)
|
|
install_man_page "$unzip_source/unzip/bsdunzip.1" unzip.1
|
|
|
|
mandoc_source="$source_build_dir/mandoc-1.14.6"
|
|
cat >"$mandoc_source/configure.local" <<EOF
|
|
CC="$cc"
|
|
AR="$ar"
|
|
CFLAGS="-O2"
|
|
LDFLAGS="-static"
|
|
STATIC="-static"
|
|
PREFIX="/usr"
|
|
BINDIR="/usr/bin"
|
|
SBINDIR="/usr/sbin"
|
|
MANDIR="/usr/share/man"
|
|
MANPATH_BASE="/usr/share/man:/usr/local/man"
|
|
MANPATH_DEFAULT="/usr/share/man:/usr/local/man"
|
|
OSENUM=MANDOC_OS_OTHER
|
|
OSNAME="MOUSE"
|
|
BINM_PAGER="less"
|
|
LN="ln -sf"
|
|
EOF
|
|
(
|
|
cd "$mandoc_source"
|
|
./configure
|
|
make -s -j"$jobs"
|
|
make -s DESTDIR="$base_root" base-install
|
|
)
|
|
|
|
iproute_source="$source_build_dir/iproute2-7.1.0"
|
|
(
|
|
cd "$iproute_source"
|
|
CC="$cc" \
|
|
AR="$ar" \
|
|
YACC="bison -y" \
|
|
PKG_CONFIG="$tools_dir/bin/pkgconf" \
|
|
PKG_CONFIG_LIBDIR="$pkgconfig_path" \
|
|
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
|
|
sh ./configure
|
|
# Enter component directories through the top-level makefile. It defines
|
|
# and exports iproute2's path constants, feature macros, and UAPI includes;
|
|
# invoking the sub-makes directly silently drops them.
|
|
make -s -j"$jobs" \
|
|
CC="$cc" \
|
|
AR="$ar" \
|
|
YACC="bison -y" \
|
|
SHARED_LIBS=n \
|
|
LDFLAGS="-static" \
|
|
SUBDIRS=lib
|
|
make -s -j"$jobs" \
|
|
CC="$cc" \
|
|
AR="$ar" \
|
|
YACC="bison -y" \
|
|
SHARED_LIBS=n \
|
|
LDFLAGS="-static" \
|
|
SUBDIRS="ip tc bridge misc"
|
|
for target in ip/ip tc/tc bridge/bridge misc/ss; do
|
|
install -m 0755 "$target" "$base_root/sbin/${target##*/}"
|
|
done
|
|
)
|
|
for command in ip tc bridge ss; do
|
|
install_command_man_page "$iproute_source/man" "$command"
|
|
done
|
|
|
|
(
|
|
cd "$source_build_dir/libmnl-1.0.5"
|
|
CC="$cc" AR="$ar" RANLIB="$ranlib" ./configure \
|
|
--build="$build_triplet" \
|
|
--host="$MOUSE_GNU_TARGET" \
|
|
--prefix=/usr \
|
|
--disable-shared \
|
|
--enable-static
|
|
make -s -j"$jobs"
|
|
make -s DESTDIR="$sysroot" install
|
|
)
|
|
(
|
|
cd "$source_build_dir/libnftnl-1.3.1"
|
|
CC="$cc" \
|
|
AR="$ar" \
|
|
RANLIB="$ranlib" \
|
|
PKG_CONFIG="$tools_dir/bin/pkgconf" \
|
|
PKG_CONFIG_LIBDIR="$pkgconfig_path" \
|
|
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
|
|
./configure \
|
|
--build="$build_triplet" \
|
|
--host="$MOUSE_GNU_TARGET" \
|
|
--prefix=/usr \
|
|
--disable-shared \
|
|
--enable-static
|
|
make -s -j"$jobs"
|
|
make -s DESTDIR="$sysroot" install
|
|
)
|
|
# These are static-only cross-build dependencies. Libtool archives retain the
|
|
# target's /usr/lib prefix and make nftables' host libtool look outside the
|
|
# sysroot; the real .a archives and pkg-config metadata are sufficient.
|
|
rm -f "$sysroot/usr/lib/libmnl.la" "$sysroot/usr/lib/libnftnl.la"
|
|
(
|
|
cd "$source_build_dir/nftables-1.1.6"
|
|
patch -p1 <"$repo_dir/base/patches/nftables-posix-configure.patch"
|
|
CC="$cc" \
|
|
AR="$ar" \
|
|
RANLIB="$ranlib" \
|
|
YACC="bison -y" \
|
|
PKG_CONFIG="$tools_dir/bin/pkgconf" \
|
|
PKG_CONFIG_LIBDIR="$pkgconfig_path" \
|
|
PKG_CONFIG_SYSROOT_DIR="$sysroot" \
|
|
./configure \
|
|
--build="$build_triplet" \
|
|
--host="$MOUSE_GNU_TARGET" \
|
|
--prefix=/usr \
|
|
--sbindir=/sbin \
|
|
--disable-shared \
|
|
--enable-static \
|
|
--disable-man-doc \
|
|
--with-mini-gmp \
|
|
--without-cli \
|
|
--without-xtables \
|
|
--without-json \
|
|
--without-unitdir
|
|
make -s -j"$jobs" src/nft
|
|
install -m 0755 src/nft "$base_root/sbin/nft"
|
|
)
|
|
install_man_page "$source_build_dir/nftables-1.1.6/doc/nft.8"
|
|
|
|
for command in \
|
|
blkid dmesg fdisk findmnt flock losetup lsblk mount sfdisk swapoff swapon umount wipefs
|
|
do
|
|
install_command_man_page "$source_build_dir/util-linux-2.42.2" "$command"
|
|
done
|
|
for command in free pgrep pkill ps sysctl top uptime vmstat watch; do
|
|
install_command_man_page "$source_build_dir/procps-ng-4.0.6" "$command"
|
|
done
|
|
install_command_man_page "$source_build_dir/iputils-20250605" ping
|
|
|
|
while IFS= read -r page; do
|
|
filename=${page##*/}
|
|
command=${filename%.*}
|
|
if [ -x "$base_root/bin/$command" ] ||
|
|
[ -x "$base_root/sbin/$command" ] ||
|
|
[ -x "$base_root/usr/bin/$command" ] ||
|
|
[ -x "$base_root/usr/sbin/$command" ]
|
|
then
|
|
install_man_page "$page"
|
|
fi
|
|
done <<EOF
|
|
$(find "$source_build_dir/chimerautils-15.0.3" -type f -name '*.[1-9]' -print | LC_ALL=C sort)
|
|
EOF
|
|
|
|
host_mandoc_source="$static_dir/host-mandoc-1.14.6"
|
|
install -d -m 0755 "$host_mandoc_source"
|
|
tar -xf "$source_dir/mandoc-1.14.6.tar.gz" \
|
|
-C "$host_mandoc_source" \
|
|
--strip-components=1
|
|
cat >"$host_mandoc_source/configure.local" <<EOF
|
|
CC="$native_cc"
|
|
PREFIX="$tools_dir/mandoc-host"
|
|
EOF
|
|
(
|
|
cd "$host_mandoc_source"
|
|
./configure
|
|
make -s -j"$jobs" mandoc
|
|
install -d -m 0755 "$tools_dir/mandoc-host"
|
|
install -m 0755 mandoc "$tools_dir/mandoc-host/makewhatis"
|
|
)
|