static-toolbox/build/targets/build_tcpdump.sh

48 lines
1.4 KiB
Bash
Raw Permalink Normal View History

2020-07-24 08:24:19 +00:00
#!/bin/bash
2021-04-19 12:20:54 +00:00
if [ -z "$GITHUB_WORKSPACE" ];then
echo "GITHUB_WORKSPACE environemnt variable not set!"
exit 1
fi
2020-07-24 08:24:19 +00:00
if [ "$#" -ne 1 ];then
echo "Usage: ${0} [x86|x86_64|armhf|aarch64]"
echo "Example: ${0} x86_64"
exit 1
fi
2021-04-19 12:20:54 +00:00
set -e
set -o pipefail
set -x
2020-07-24 08:24:19 +00:00
source $GITHUB_WORKSPACE/build/lib.sh
init_lib "$1"
build_tcpdump() {
fetch "https://github.com/the-tcpdump-group/tcpdump.git" "${BUILD_DIRECTORY}/tcpdump" git
cd "${BUILD_DIRECTORY}/tcpdump"
git clean -fdx
git checkout tcpdump-4.9.3
export LIBPCAP_PATH="${BUILD_DIRECTORY}/libpcap"
CFLAGS="${GCC_OPTS} -I${LIBPCAP_PATH} -L${LIBPCAP_PATH}" \
CXXFLAGS="${GXX_OPTS}" \
CPPFLAGS="-static" \
LDFLAGS="-static" \
./configure \
--host="$(get_host_triple)"
make -j4
strip tcpdump
}
main() {
lib_build_libpcap
build_tcpdump
local version
version=$(get_version "${BUILD_DIRECTORY}/tcpdump/tcpdump --version 2>&1 | head -n1 | awk '{print \$3}'")
2021-04-19 12:20:54 +00:00
version_number=$(echo "$version" | cut -d"-" -f2)
2021-04-19 12:51:33 +00:00
cp "${BUILD_DIRECTORY}/tcpdump/tcpdump" "${OUTPUT_DIRECTORY}/tcpdump${version}"
2020-07-24 08:24:19 +00:00
echo "[+] Finished building tcpdump ${CURRENT_ARCH}"
2023-05-22 06:44:33 +00:00
echo "PACKAGED_NAME=tcpdump${version}" >> $GITHUB_OUTPUT
echo "PACKAGED_NAME_PATH=${OUTPUT_DIRECTORY}/*" >> $GITHUB_OUTPUT
echo "PACKAGED_VERSION=${version_number}" >> $GITHUB_OUTPUT
2020-07-24 08:24:19 +00:00
}
main