Add libpcap

This commit is contained in:
Denis Benato 2025-01-22 22:40:56 +01:00
parent 8a3e9a03e8
commit 82093d1889

109
build.sh
View file

@ -101,19 +101,19 @@ setup_toolchain() {
export SYSROOT="$LFS" export SYSROOT="$LFS"
#unset LD_LIBRARY_PATH #unset LD_LIBRARY_PATH
echo "[binaries]" > meson_cross.txt echo "[binaries]" > "$CROSS_TOOLS_DIR/meson_cross.txt"
echo "c = '$CC'" >> meson_cross.txt echo "c = '$CC'" >> "$CROSS_TOOLS_DIR/meson_cross.txt"
echo "cpp = '$CPP'" >> meson_cross.txt echo "cpp = '$CPP'" >> "$CROSS_TOOLS_DIR/meson_cross.txt"
echo "ar = '$AR'" >> meson_cross.txt echo "ar = '$AR'" >> "$CROSS_TOOLS_DIR/meson_cross.txt"
#echo "windres = 'x86_64-w64-mingw32-windres'" >> meson_cross.txt #echo "windres = 'x86_64-w64-mingw32-windres'" >> "$CROSS_TOOLS_DIR/meson_cross.txt"
echo "strip = '$STRIP'" >> meson_cross.txt echo "strip = '$STRIP'" >> "$CROSS_TOOLS_DIR/meson_cross.txt"
echo "exe_wrapper = 'wine64'" >> meson_cross.txt echo "exe_wrapper = 'wine64'" >> "$CROSS_TOOLS_DIR/meson_cross.txt"
echo "" >> meson_cross.txt echo "" >> "$CROSS_TOOLS_DIR/meson_cross.txt"
echo "[host_machine]" >> meson_cross.txt echo "[host_machine]" >> "$CROSS_TOOLS_DIR/meson_cross.txt"
echo "system = 'linux'" >> meson_cross.txt echo "system = 'linux'" >> "$CROSS_TOOLS_DIR/meson_cross.txt"
echo "cpu_family = '$CPU_FAMILY'" >> meson_cross.txt echo "cpu_family = '$CPU_FAMILY'" >> "$CROSS_TOOLS_DIR/meson_cross.txt"
echo "cpu = '$CPU'" >> meson_cross.txt echo "cpu = '$CPU'" >> "$CROSS_TOOLS_DIR/meson_cross.txt"
echo "endian = '$TARGET_ENDIANNESS'" >> meson_cross.txt echo "endian = '$TARGET_ENDIANNESS'" >> "$CROSS_TOOLS_DIR/meson_cross.txt"
} }
host_toolchain() { host_toolchain() {
@ -1530,6 +1530,61 @@ if [ ! -f "$STEPS_DIR/audit-userspace" ]; then
touch "$STEPS_DIR/audit-userspace" touch "$STEPS_DIR/audit-userspace"
fi fi
# build libcap2
if [ ! -f "$STEPS_DIR/libcap2" ]; then
if [ ! -d "$TMP_BUILD_DIR/libcap2" ]; then
tar -xzf "$BASE_DIR/sources/libcap-2.73.tar.gz"
mv "libcap-2.73" "$TMP_BUILD_DIR/libcap2"
fi
cd "$TMP_BUILD_DIR/libcap2"
mkdir -vp build
cd build
# NOTE: with CGO_ENABLED we need all relevant make options in build(), check() and package() otherwise the package is not reproducible
_common_make_options=(
CGO_CPPFLAGS="$CPPFLAGS"
CGO_CFLAGS="$CFLAGS"
CGO_CXXFLAGS="$CXXFLAGS"
CGO_LDFLAGS="$LDFLAGS"
CGO_REQUIRED="1"
GOFLAGS="-buildmode=pie -mod=readonly -modcacherw"
GO_BUILD_FLAGS="-ldflags '-compressdwarf=false -linkmode=external'"
)
make_options=(
"${_common_make_options[@]}"
DYNAMIC=yes
KERNEL_HEADERS=/usr/include
lib=lib
prefix=/usr
sbindir=bin
-C ..
)
make "${make_options[@]}"
export GOPATH="$srcdir"
make_options=(
"${_common_make_options[@]}"
DESTDIR="$LFS"
RAISE_SETFCAP=no
lib=lib
prefix=/usr
sbindir=bin
install
-C ..
)
make "${make_options[@]}"
cd "$BASE_DIR"
touch "$STEPS_DIR/libcap2"
fi
for f in "$LFS"/usr/bin/*; do for f in "$LFS"/usr/bin/*; do
if "$READELF" -h $f | grep -Fq "Executable"; then if "$READELF" -h $f | grep -Fq "Executable"; then
echo "Stripping $f..." echo "Stripping $f..."
@ -1580,33 +1635,7 @@ fi
#"$TARGET_MACHINE_TRIPLET-strip" --strip-unneeded $LFS/bin/* #"$TARGET_MACHINE_TRIPLET-strip" --strip-unneeded $LFS/bin/*
# build libcap2
#if [ ! -f "$STEPS_DIR/libcap2" ]; then
# if [ ! -d "$TMP_BUILD_DIR/libcap2" ]; then
# tar -xzf "$BASE_DIR/sources/libcap-2.73.tar.gz"
# mv "libcap2" "$TMP_BUILD_DIR/libcap2"
# fi
# cd "$TMP_BUILD_DIR/libcap2"
#
# mkdir -vp build
# cd build
#
# echo "rootsbindir=/usr/sbin" > configparms
#
# "../configure" \
# --prefix=/usr \
# --disable-static \
# --target=$TARGET_MACHINE_TRIPLET \
# --host=$(build-aux/config.guess) \
# --build=$(build-aux/config.guess) \
#
# make -j 32
# make DESTDIR=$LFS install
#
# cd "$BASE_DIR"
#
# touch "$STEPS_DIR/libcap2"
#fi
# Remove man pages: totally useless # Remove man pages: totally useless
rm -rf "$LFS"/usr/share/man rm -rf "$LFS"/usr/share/man