From 82093d1889ee6343b29f99a03f6d0e384d6b818c Mon Sep 17 00:00:00 2001 From: Denis Benato Date: Wed, 22 Jan 2025 22:40:56 +0100 Subject: [PATCH] Add libpcap --- build.sh | 109 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 69 insertions(+), 40 deletions(-) diff --git a/build.sh b/build.sh index 02c10f2..9092627 100755 --- a/build.sh +++ b/build.sh @@ -101,19 +101,19 @@ setup_toolchain() { export SYSROOT="$LFS" #unset LD_LIBRARY_PATH - echo "[binaries]" > meson_cross.txt - echo "c = '$CC'" >> meson_cross.txt - echo "cpp = '$CPP'" >> meson_cross.txt - echo "ar = '$AR'" >> meson_cross.txt - #echo "windres = 'x86_64-w64-mingw32-windres'" >> meson_cross.txt - echo "strip = '$STRIP'" >> meson_cross.txt - echo "exe_wrapper = 'wine64'" >> meson_cross.txt - echo "" >> meson_cross.txt - echo "[host_machine]" >> meson_cross.txt - echo "system = 'linux'" >> meson_cross.txt - echo "cpu_family = '$CPU_FAMILY'" >> meson_cross.txt - echo "cpu = '$CPU'" >> meson_cross.txt - echo "endian = '$TARGET_ENDIANNESS'" >> meson_cross.txt + echo "[binaries]" > "$CROSS_TOOLS_DIR/meson_cross.txt" + echo "c = '$CC'" >> "$CROSS_TOOLS_DIR/meson_cross.txt" + echo "cpp = '$CPP'" >> "$CROSS_TOOLS_DIR/meson_cross.txt" + echo "ar = '$AR'" >> "$CROSS_TOOLS_DIR/meson_cross.txt" + #echo "windres = 'x86_64-w64-mingw32-windres'" >> "$CROSS_TOOLS_DIR/meson_cross.txt" + echo "strip = '$STRIP'" >> "$CROSS_TOOLS_DIR/meson_cross.txt" + echo "exe_wrapper = 'wine64'" >> "$CROSS_TOOLS_DIR/meson_cross.txt" + echo "" >> "$CROSS_TOOLS_DIR/meson_cross.txt" + echo "[host_machine]" >> "$CROSS_TOOLS_DIR/meson_cross.txt" + echo "system = 'linux'" >> "$CROSS_TOOLS_DIR/meson_cross.txt" + echo "cpu_family = '$CPU_FAMILY'" >> "$CROSS_TOOLS_DIR/meson_cross.txt" + echo "cpu = '$CPU'" >> "$CROSS_TOOLS_DIR/meson_cross.txt" + echo "endian = '$TARGET_ENDIANNESS'" >> "$CROSS_TOOLS_DIR/meson_cross.txt" } host_toolchain() { @@ -1530,6 +1530,61 @@ if [ ! -f "$STEPS_DIR/audit-userspace" ]; then touch "$STEPS_DIR/audit-userspace" 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 if "$READELF" -h $f | grep -Fq "Executable"; then echo "Stripping $f..." @@ -1580,33 +1635,7 @@ fi #"$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 rm -rf "$LFS"/usr/share/man