Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/install_deps_alpine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ apk add \
curl \
rsync \
util-linux \
patch
patch
48 changes: 35 additions & 13 deletions build/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -103,25 +103,25 @@ 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
# trailing whitespaces.
trim(){
local var="$*"
var="${var#"${var%%[![:space:]]*}"}"
var="${var%"${var##*[![:space:]]}"}"
var="${var%"${var##*[![:space:]]}"}"
echo -n "$var"
}

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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}"
}
}
2 changes: 1 addition & 1 deletion build/targets/build_gdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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\" "
Expand Down
8 changes: 5 additions & 3 deletions build/targets/build_tcpdump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand All @@ -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}"
Expand Down
Loading