Skip to content

Commit a9d184a

Browse files
test
Signed-off-by: Roman Nikitenko <rnikiten@redhat.com>
1 parent 5e6582d commit a9d184a

1 file changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
RUNTIME_DIR="${1:-/checode/checode-linux-libc/ubi8}"
5+
LIBS_DIR="${RUNTIME_DIR}/ld_libs"
6+
NODE_BIN="${RUNTIME_DIR}/node"
7+
8+
echo "Runtime: ${RUNTIME_DIR}"
9+
echo "Libs: ${LIBS_DIR}"
10+
echo "Node: ${NODE_BIN}"
11+
echo
12+
13+
if [ ! -x "${NODE_BIN}" ]; then
14+
echo "ERROR: node binary not found: ${NODE_BIN}" >&2
15+
exit 1
16+
fi
17+
18+
if [ ! -d "${LIBS_DIR}" ]; then
19+
echo "ERROR: libs dir not found: ${LIBS_DIR}" >&2
20+
exit 1
21+
fi
22+
23+
TMP_NEEDS="$(mktemp)"
24+
TMP_HAVE="$(mktemp)"
25+
TMP_MISS="$(mktemp)"
26+
trap 'rm -f "$TMP_NEEDS" "$TMP_HAVE" "$TMP_MISS"' EXIT
27+
28+
# Collect what we have in ld_libs (basename only).
29+
find "${LIBS_DIR}" -maxdepth 1 -type f -name '*.so*' -exec basename {} \; | sort -u > "${TMP_HAVE}"
30+
31+
scan_needed() {
32+
f="$1"
33+
# objdump is available in UBI images while readelf may be absent.
34+
objdump -p "$f" 2>/dev/null | awk '/NEEDED/ {print $2}' || true
35+
}
36+
37+
# Scan node and all native addons.
38+
scan_needed "${NODE_BIN}" >> "${TMP_NEEDS}"
39+
find "${RUNTIME_DIR}" -type f -name '*.node' 2>/dev/null | while read -r so; do
40+
scan_needed "$so" >> "${TMP_NEEDS}"
41+
done
42+
43+
sort -u "${TMP_NEEDS}" -o "${TMP_NEEDS}"
44+
45+
echo "=== NEEDED (unique) ==="
46+
cat "${TMP_NEEDS}"
47+
echo
48+
49+
echo "=== HAVE in ld_libs ==="
50+
cat "${TMP_HAVE}"
51+
echo
52+
53+
# Ignore glibc core, usually expected from the host/container base.
54+
grep -Ev '^(linux-vdso\.so\.1|libc\.so\.6|libm\.so\.6|libpthread\.so\.0|libdl\.so\.2|librt\.so\.1|ld-linux-.*\.so.*)$' "${TMP_NEEDS}" > "${TMP_MISS}" || true
55+
56+
echo "=== MISSING in ld_libs (excluding glibc core) ==="
57+
MISSING_COUNT=0
58+
while read -r need; do
59+
[ -z "$need" ] && continue
60+
if ! grep -qx "$need" "${TMP_HAVE}"; then
61+
echo "$need"
62+
MISSING_COUNT=$((MISSING_COUNT + 1))
63+
fi
64+
done < "${TMP_MISS}"
65+
66+
echo
67+
if [ "${MISSING_COUNT}" -eq 0 ]; then
68+
echo "OK: no missing non-glibc SONAMEs in ld_libs"
69+
else
70+
echo "FAIL: missing ${MISSING_COUNT} SONAME(s)"
71+
exit 2
72+
fi

0 commit comments

Comments
 (0)