Files
Vernier/scripts/check-static-occt.sh

43 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
set -eu
if [ "$#" -eq 0 ]; then
echo "usage: $0 BINARY..." >&2
exit 2
fi
status=0
for binary in "$@"; do
if [ ! -f "$binary" ]; then
echo "static OCCT check: missing binary: $binary" >&2
status=1
continue
fi
needed=$(readelf -d "$binary") || {
echo "static OCCT check: readelf failed: $binary" >&2
status=1
continue
}
occt_needed=$(printf '%s\n' "$needed" | sed -n 's/.*Shared library: \[\(libTK[^]]*\)\].*/\1/p')
if [ -n "$occt_needed" ]; then
printf 'static OCCT check: %s has OCCT DT_NEEDED entries:\n%s\n' \
"$binary" "$occt_needed" >&2
status=1
fi
resolved=$(ldd "$binary" 2>&1) || {
echo "static OCCT check: ldd failed: $binary" >&2
status=1
continue
}
system_occt=$(printf '%s\n' "$resolved" | sed -n '/libTK[^ ]*[[:space:]]*=>[[:space:]]*\//p')
if [ -n "$system_occt" ]; then
printf 'static OCCT check: %s resolves OCCT from the host:\n%s\n' \
"$binary" "$system_occt" >&2
status=1
fi
done
exit "$status"