diff --git a/build/install_deps_alpine.sh b/build/install_deps_alpine.sh index 15b52b7..70e273b 100755 --- a/build/install_deps_alpine.sh +++ b/build/install_deps_alpine.sh @@ -28,4 +28,4 @@ apk add \ curl \ rsync \ util-linux \ - patch \ No newline at end of file + patch diff --git a/build/lib.sh b/build/lib.sh index 3d09984..aeb5f01 100755 --- a/build/lib.sh +++ b/build/lib.sh @@ -7,7 +7,7 @@ GIT_LIBPCAP="https://github.com/the-tcpdump-group/libpcap.git" BUILD_DIRECTORY="/build" OUTPUT_DIRECTORY="/output" -GCC_OPTS="-static -fPIC" +GCC_OPTS="-static -static-libgcc -fPIC" GXX_OPTS="-static -static-libstdc++ -fPIC" TMP_DIR=$(mktemp -dt building_lib.XXXXXX) trap "rm -rf ${TMP_DIR}" EXIT TERM @@ -103,17 +103,17 @@ extract(){ fi if [ -f "$source" ] ; then case $source in - *.tar.bz2) tar xjf "$source" -C "$destination" --strip-components 1 ;; - *.tar.gz) tar xzf "$source" -C "$destination" --strip-components 1 ;; - *.tar.xz) tar xvfJ "$source" -C "$destination" --strip-components 1 ;; - *.tar) tar xf "$source" -C "$destination" --strip-components 1 ;; - *.tbz2) tar xjf "$source" -C "$destination" --strip-components 1 ;; - *.tgz) tar xzf "$source" -C "$destination" --strip-components 1 ;; + *.tar.bz2) tar xjf "$source" -C "$destination" --strip-components 1 ;; + *.tar.gz) tar xzf "$source" -C "$destination" --strip-components 1 ;; + *.tar.xz) tar xvfJ "$source" -C "$destination" --strip-components 1 ;; + *.tar) tar xf "$source" -C "$destination" --strip-components 1 ;; + *.tbz2) tar xjf "$source" -C "$destination" --strip-components 1 ;; + *.tgz) tar xzf "$source" -C "$destination" --strip-components 1 ;; *) echo "'${source}' cannot be extracted via extract()" ;; esac else echo "'${source}' is not a valid file" - fi + fi } # Remove leading and @@ -121,7 +121,7 @@ extract(){ trim(){ local var="$*" var="${var#"${var%%[![:space:]]*}"}" - var="${var%"${var##*[![:space:]]}"}" + var="${var%"${var##*[![:space:]]}"}" echo -n "$var" } @@ -174,6 +174,26 @@ get_version(){ echo "$version" } +# even after cleanup, the above *still fails* on armhf/arm64 with version+=Invalid +get_version_simple(){ + local cmd="$1" + if [ -z "$cmd" ];then + echo "Please provide a command to determine the version" >&2 + echo "Example: /build/test --version | awk '{print \$2}'" >&2 + exit 1 + fi + + local version="-" + version+=$(eval "$cmd") + + if [ "$version" == "-" ];then + version+="${CURRENT_ARCH}" + else + version+="-${CURRENT_ARCH}" + fi + echo "$version" +} + lib_create_tmp_dir(){ local tmp_dir=$(mktemp -dt -p ${TMP_DIR} tmpdir.XXXXXX) echo "$tmp_dir" @@ -293,14 +313,16 @@ lib_build_libpcap(){ fetch "$GIT_LIBPCAP" "${BUILD_DIRECTORY}/libpcap" git cd "${BUILD_DIRECTORY}/libpcap" || { echo "Cannot cd to ${BUILD_DIRECTORY}/libpcap"; exit 1; } git clean -fdx - git checkout libpcap-1.9.1 + git checkout libpcap-1.10.5 + ./autogen.sh CFLAGS="${GCC_OPTS}" \ CXXFLAGS="${GXX_OPTS}" \ ./configure \ --host="$(get_host_triple)" \ --with-pcap=linux \ - --disable-shared \ - --enable-static + --enable-ipv6=no \ + --enable-remote=no \ + --disable-shared make -j4 echo "[+] Finished building libpcap ${CURRENT_ARCH}" -} \ No newline at end of file +} diff --git a/build/targets/build_gdb.sh b/build/targets/build_gdb.sh index 366a147..b6652ff 100755 --- a/build/targets/build_gdb.sh +++ b/build/targets/build_gdb.sh @@ -18,7 +18,7 @@ build_gdb() { fetch "$GIT_BINUTILS_GDB" "${BUILD_DIRECTORY}/binutils-gdb" git cd "${BUILD_DIRECTORY}/binutils-gdb/" || { echo "Cannot cd to ${BUILD_DIRECTORY}/binutils-gdb/"; exit 1; } git clean -fdx - git checkout gdb-13.2-release + git checkout gdb-12.1-release CMD="CFLAGS=\"${GCC_OPTS}\" " CMD+="CXXFLAGS=\"${GXX_OPTS}\" " CMD+="LDFLAGS=\"-static\" " diff --git a/build/targets/build_tcpdump.sh b/build/targets/build_tcpdump.sh index 5e5c4dd..45e4342 100755 --- a/build/targets/build_tcpdump.sh +++ b/build/targets/build_tcpdump.sh @@ -20,9 +20,9 @@ build_tcpdump() { git clean -fdx git checkout tcpdump-4.99.5 # need to create configure when using newer tags - autoconf -fv + ./autogen.sh export LIBPCAP_PATH="${BUILD_DIRECTORY}/libpcap" - CFLAGS="${GCC_OPTS} -I${LIBPCAP_PATH} -L${LIBPCAP_PATH}" \ + CFLAGS="${GCC_OPTS} -I. -I${LIBPCAP_PATH} -L${LIBPCAP_PATH}" \ CXXFLAGS="${GXX_OPTS}" \ CPPFLAGS="-static" \ LDFLAGS="-static" \ @@ -36,7 +36,9 @@ main() { lib_build_libpcap build_tcpdump local version - version=$(get_version "${BUILD_DIRECTORY}/tcpdump/tcpdump --version 2>&1 | head -n1 | awk '{print \$3}'") + ##version=$(get_version "${BUILD_DIRECTORY}/tcpdump/tcpdump --version 2>&1 | head -n1 | awk '{print \$3}'") + version=$(get_version_simple "cat ${BUILD_DIRECTORY}/tcpdump/VERSION") + echo "Got version: ${version}" version_number=$(echo "$version" | cut -d"-" -f2) cp "${BUILD_DIRECTORY}/tcpdump/tcpdump" "${OUTPUT_DIRECTORY}/tcpdump${version}" echo "[+] Finished building tcpdump ${CURRENT_ARCH}"