Skip to content

Commit

Permalink
build.sh: Check output with file
Browse files Browse the repository at this point in the history
Check with file resulted binaries.
It requires to add findutils (for find) in Rocky Linux 8).

Signed-off-by: Petr Vorel <pvorel@suse.cz>
  • Loading branch information
pevik committed Apr 16, 2024
1 parent 22debcf commit 4a11fc6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ jobs:
if: always()
run: ./build.sh build-log

- name: Check binaries
run: ./build.sh check-binaries

- name: Dist
run: if [ ! "$SKIP_DISC" ]; then ./build.sh dist; else echo "meson dist skipped"; fi

Expand Down
40 changes: 39 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ PREFIX="${PREFIX:-$HOME/iputils-install}"
BUILD_OPTS="-Dprefix=$PREFIX $EXTRA_BUILD_OPTS"
[ -f "meson.cross" ] && BUILD_OPTS="--cross-file $PWD/meson.cross $BUILD_OPTS"

BINARIES='arping clockdiff ping/ping tracepath'

# NOTE: meson iself checkes for minimal version
# see meson_version in meson.build, it fails if not required
# Meson version is 0.37.1 but project requires >=0.40.
Expand Down Expand Up @@ -91,6 +93,38 @@ build()
make -j$(getconf _NPROCESSORS_ONLN)
}

check_binaries()
{

echo "=== check_binaries ==="

local arch i
local bits="64"

case "${ARCH:-}" in
'') arch='x86-64';;
arm64) arch='aarch64';;
ppc64el) arch='PowerPC';;
s390x) arch='S/390';;
esac

if [ "${BUILD_32:-}" ]; then
bits=32
arch='80386'
fi

for i in $BINARIES; do
if echo "$EXTRA_BUILD_OPTS" | grep -i -q -- "-DBUILD_${i}=false"; then
echo "$i should not be build"
[ ! -x "$BUILD_DIR/$i" ]
continue
fi
-DBUILD_CLOCKDIFF=false
[ -x "$BUILD_DIR/$i" ]
file "$BUILD_DIR/$i" | grep -E "$i.*${bits}-bit .*(executable|shared object).*$arch.*dynamically linked"
done
}

install()
{
echo "=== install ==="
Expand Down Expand Up @@ -147,7 +181,7 @@ cd `dirname $0`

cmd=
case "${1:-}" in
build|build-log|configure|dependencies|dist|info|install|install-log|test|test-log|"") cmd="${1:-}";;
build|build-log|check-binaries|configure|dependencies|dist|info|install|install-log|test|test-log|"") cmd="${1:-}";;
*) echo "ERROR: wrong command '$1'" >&2; exit 1;;
esac

Expand All @@ -167,6 +201,10 @@ if [ -z "$cmd" -o "$cmd" = "build" ]; then
build
fi

if [ -z "$cmd" -o "$cmd" = "check-binaries" ]; then
check_binaries
fi

if [ "$cmd" = "build-log" ]; then
print_log meson-log.txt
fi
Expand Down
1 change: 1 addition & 0 deletions ci/fedora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set -ex
yum -y install \
clang \
file \
findutils \
gcc \
gettext \
git \
Expand Down

0 comments on commit 4a11fc6

Please sign in to comment.