Skip to content

Commit 9ad449d

Browse files
committed
test(ci): verify downloaded libs exist and are GNU archives
Add scripts/ci/check_deployed_libs.sh and run it after download_libs on linux, RPi, and msys2. Fail if tess2/kiss/zlib (or msys2 videoInput) are missing or not GNU ar. RPi still allows the zlib-only smoke-test archive. The Linux lib-paths workflow also downloads linux_64 and checks real files.
1 parent 105ceca commit 9ad449d

3 files changed

Lines changed: 263 additions & 28 deletions

File tree

‎.github/workflows/linux-lib-paths.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,14 @@ jobs:
2121
- uses: actions/checkout@v6
2222
- name: New lib/linux/<arch> and legacy lib/linux64 both resolve
2323
run: bash scripts/ci/linux/test_lib_paths.sh
24+
25+
download-and-check-linux-64:
26+
runs-on: ubuntu-24.04
27+
env:
28+
RELEASE: latest
29+
steps:
30+
- uses: actions/checkout@v6
31+
- name: Download linux 64 gcc10 libs
32+
run: ./scripts/linux/download_libs.sh -t $RELEASE -a 64 -g 10
33+
- name: Check deployed files and archive format
34+
run: bash scripts/ci/check_deployed_libs.sh --platform linux --arch 64

‎.github/workflows/of.yml‎

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ jobs:
106106
- name: Install dependencies
107107
run: ./scripts/ci/msys2/install.sh --msystem=${{ matrix.msystem }}
108108

109-
- name: List Directories
110-
shell: bash
111-
run: find . -type d
109+
- name: Check deployed libraries
110+
run: bash scripts/ci/check_deployed_libs.sh --platform msys2 --arch x86_64
112111

113112
- name: Build
114113
run: ./scripts/ci/msys2/build.sh
@@ -227,17 +226,8 @@ jobs:
227226
# fi
228227
- name: Download libs
229228
run: ./scripts/linux/download_libs.sh -t $RELEASE -a ${{matrix.cfg.libs}} -g 10
230-
- name: Library path check
231-
run: |
232-
echo "=== lib/linux/${{ matrix.cfg.libs }} ==="
233-
find libs -type d -path "*/lib/linux/${{ matrix.cfg.libs }}" | sort
234-
echo "=== zlib ==="; ls -lh libs/zlib/lib/linux/${{ matrix.cfg.libs }}
235-
if [ -f libs/glm/include/glm/vec2.hpp ]; then
236-
echo "=== glm present ==="
237-
else
238-
echo "=== glm missing — RPi apothecary latest is still the zlib smoke-test archive ==="
239-
fi
240-
echo "=== system curl ==="; curl --version 2>&1 | head -n1
229+
- name: Check deployed libraries
230+
run: bash scripts/ci/check_deployed_libs.sh --platform linux --arch ${{ matrix.cfg.libs }} --allow-incomplete
241231
- name: Install dependencies
242232
run: ./scripts/ci/linux/rpi/install.sh;
243233
- name: LS
@@ -344,14 +334,8 @@ jobs:
344334

345335
- name: Download libs
346336
run: ./scripts/linux/download_libs.sh -t $RELEASE -a ${{matrix.cfg.arch}} -g ${{matrix.cfg.GCC}}
347-
- name: Library path check
348-
run: |
349-
echo "=== lib/linux/${{ matrix.cfg.arch }} ==="
350-
find libs -type d -path "*/lib/linux/${{ matrix.cfg.arch }}" | sort
351-
echo "=== glm ==="; test -f libs/glm/include/glm/vec2.hpp
352-
echo "=== tess2 ==="; ls -lh libs/tess2/lib/linux/${{ matrix.cfg.arch }}
353-
echo "=== zlib ==="; ls -lh libs/zlib/lib/linux/${{ matrix.cfg.arch }}
354-
echo "=== system curl ==="; curl --version 2>&1 | head -n1
337+
- name: Check deployed libraries
338+
run: bash scripts/ci/check_deployed_libs.sh --platform linux --arch ${{ matrix.cfg.arch }}
355339
- name: Build
356340
run: |
357341
if [ "$TARGET" = "linux" ]; then
@@ -393,12 +377,8 @@ jobs:
393377
- name: Download libs
394378
run: ./scripts/linux/download_libs.sh -t $RELEASE -a ${{matrix.cfg.arch}} -g ${{matrix.cfg.GCC}}
395379

396-
- name: Library path check
397-
run: |
398-
echo "=== lib/linux/${{ matrix.cfg.arch }} ==="
399-
find libs -type d -path "*/lib/linux/${{ matrix.cfg.arch }}" | sort
400-
echo "=== glm ==="; test -f libs/glm/include/glm/vec2.hpp
401-
echo "=== tess2 ==="; ls -lh libs/tess2/lib/linux/${{ matrix.cfg.arch }}
380+
- name: Check deployed libraries
381+
run: bash scripts/ci/check_deployed_libs.sh --platform linux --arch ${{ matrix.cfg.arch }}
402382

403383
- name: Build
404384
run: |

‎scripts/ci/check_deployed_libs.sh‎

Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
1+
#!/usr/bin/env bash
2+
# Verify download_libs actually deployed binaries/headers, and that static
3+
# archives are GNU ar (the msys2 "unknown file type" / "treating as linker
4+
# script" failure mode).
5+
set -euo pipefail
6+
7+
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
8+
cd "$ROOT"
9+
10+
PLATFORM=""
11+
ARCH=""
12+
ALLOW_INCOMPLETE=0
13+
14+
usage() {
15+
cat <<EOF
16+
Usage: $0 --platform linux|msys2 --arch <arch> [--allow-incomplete]
17+
18+
linux arch: 64, arm64, aarch64, armv6l, armv7l
19+
msys2 arch: x86_64 (used as lib/msys2/x86_64 nested fallback)
20+
EOF
21+
}
22+
23+
while [[ $# -gt 0 ]]; do
24+
case "$1" in
25+
--platform)
26+
PLATFORM="$2"
27+
shift 2
28+
;;
29+
--arch)
30+
ARCH="$2"
31+
shift 2
32+
;;
33+
--allow-incomplete)
34+
ALLOW_INCOMPLETE=1
35+
shift
36+
;;
37+
-h | --help)
38+
usage
39+
exit 0
40+
;;
41+
*)
42+
echo "Unknown argument: $1"
43+
usage
44+
exit 1
45+
;;
46+
esac
47+
done
48+
49+
if [[ -z "$PLATFORM" || -z "$ARCH" ]]; then
50+
usage
51+
exit 1
52+
fi
53+
54+
pass=0
55+
fail=0
56+
warn=0
57+
58+
ok() {
59+
pass=$((pass + 1))
60+
echo " OK $*"
61+
}
62+
63+
bad() {
64+
fail=$((fail + 1))
65+
echo " FAIL $*"
66+
}
67+
68+
note() {
69+
warn=$((warn + 1))
70+
echo " WARN $*"
71+
}
72+
73+
is_gnu_ar() {
74+
local f="$1"
75+
if command -v python3 >/dev/null 2>&1; then
76+
python3 -c "import sys; sys.exit(0 if open(sys.argv[1],'rb').read(8)==b'!<arch>\n' else 1)" "$f"
77+
elif command -v python >/dev/null 2>&1; then
78+
python -c "import sys; sys.exit(0 if open(sys.argv[1],'rb').read(8)==b'!<arch>\n' else 1)" "$f"
79+
else
80+
# bash / dd fallback: first 7 bytes must be !<arch>
81+
local magic
82+
magic=$(dd if="$f" bs=7 count=1 2>/dev/null || true)
83+
[[ "$magic" == '!<arch>' ]]
84+
fi
85+
}
86+
87+
archive_lists_objects() {
88+
local f="$1"
89+
local listing
90+
if ! command -v ar >/dev/null 2>&1; then
91+
return 0
92+
fi
93+
listing=$(ar t "$f" 2>/dev/null || true)
94+
if [[ -z "$listing" ]]; then
95+
return 1
96+
fi
97+
# GNU ar prints foo.o / foo.obj. BSD ar on GNU archives may print /0.
98+
# Ignore symbol-table members named / or //.
99+
echo "$listing" | grep -v -E '^/{1,2}$' | grep -q .
100+
}
101+
102+
list_lib_trees() {
103+
local pattern="$1"
104+
local roots=()
105+
[[ -d libs ]] && roots+=(libs)
106+
[[ -d addons ]] && roots+=(addons)
107+
if [[ ${#roots[@]} -eq 0 ]]; then
108+
return 1
109+
fi
110+
find "${roots[@]}" -type d -path "$pattern" 2>/dev/null | sort
111+
}
112+
113+
echo "== deployed libraries platform=${PLATFORM} arch=${ARCH} =="
114+
115+
if [[ "$PLATFORM" == "linux" ]]; then
116+
SUBPATH="linux/${ARCH}"
117+
echo "--- trees under lib/${SUBPATH} ---"
118+
if list_lib_trees "*/lib/${SUBPATH}" | grep -q .; then
119+
list_lib_trees "*/lib/${SUBPATH}"
120+
ok "found lib/${SUBPATH} folders"
121+
else
122+
bad "no lib/${SUBPATH} folders under libs/ or addons/"
123+
fi
124+
125+
require_header() {
126+
local p="$1"
127+
if [[ -f "$p" ]]; then
128+
ok "header $p"
129+
else
130+
if [[ "$ALLOW_INCOMPLETE" -eq 1 ]]; then
131+
note "header missing $p (incomplete archive allowed)"
132+
else
133+
bad "header missing $p"
134+
fi
135+
fi
136+
}
137+
138+
require_archive() {
139+
local p="$1"
140+
if [[ ! -f "$p" ]]; then
141+
if [[ "$ALLOW_INCOMPLETE" -eq 1 ]]; then
142+
note "archive missing $p (incomplete archive allowed)"
143+
else
144+
bad "archive missing $p"
145+
fi
146+
return
147+
fi
148+
if [[ ! -s "$p" ]]; then
149+
bad "archive empty $p"
150+
return
151+
fi
152+
if is_gnu_ar "$p"; then
153+
ok "gnu ar magic $p ($(wc -c <"$p") bytes)"
154+
else
155+
bad "not a GNU ar archive $p"
156+
return
157+
fi
158+
if archive_lists_objects "$p"; then
159+
ok "ar members $p"
160+
else
161+
if command -v ar >/dev/null 2>&1; then
162+
bad "ar could not list object members in $p"
163+
ar t "$p" 2>&1 | head -20 || true
164+
else
165+
note "no ar on PATH; skipped member listing for $p"
166+
fi
167+
fi
168+
}
169+
170+
require_header "libs/glm/include/glm/vec2.hpp"
171+
require_header "libs/json/include/nlohmann/json.hpp"
172+
require_header "libs/utf8/include/utf8.h"
173+
require_archive "libs/tess2/lib/${SUBPATH}/libtess2.a"
174+
require_archive "libs/zlib/lib/${SUBPATH}/zlib.a"
175+
# kiss is named libkiss.a on linux; optional if formula set omitted it
176+
if [[ -f "libs/kiss/lib/${SUBPATH}/libkiss.a" ]]; then
177+
require_archive "libs/kiss/lib/${SUBPATH}/libkiss.a"
178+
else
179+
note "kiss not deployed at libs/kiss/lib/${SUBPATH}/libkiss.a"
180+
fi
181+
182+
elif [[ "$PLATFORM" == "msys2" ]]; then
183+
echo "--- trees under lib/msys2 ---"
184+
if list_lib_trees '*/lib/msys2' | grep -q .; then
185+
list_lib_trees '*/lib/msys2*'
186+
ok "found lib/msys2 folders"
187+
else
188+
bad "no lib/msys2 folders under libs/ or addons/"
189+
fi
190+
191+
# Prefer nested arch folder, then flat lib/msys2 (same as the makefile).
192+
resolve_msys2_a() {
193+
local libname="$1"
194+
local aname="$2"
195+
if [[ -f "libs/${libname}/lib/msys2/${ARCH}/${aname}" ]]; then
196+
echo "libs/${libname}/lib/msys2/${ARCH}/${aname}"
197+
elif [[ -f "libs/${libname}/lib/msys2/${aname}" ]]; then
198+
echo "libs/${libname}/lib/msys2/${aname}"
199+
fi
200+
}
201+
202+
check_msys2_a() {
203+
local libname="$1"
204+
local aname="$2"
205+
local p
206+
p=$(resolve_msys2_a "$libname" "$aname")
207+
if [[ -z "$p" ]]; then
208+
bad "missing ${aname} for ${libname} (tried lib/msys2/${ARCH}/ and lib/msys2/)"
209+
return
210+
fi
211+
ok "deployed $p"
212+
if [[ ! -s "$p" ]]; then
213+
bad "archive empty $p"
214+
return
215+
fi
216+
if is_gnu_ar "$p"; then
217+
ok "gnu ar magic $p ($(wc -c <"$p") bytes)"
218+
else
219+
bad "not a GNU ar archive $p"
220+
return
221+
fi
222+
if archive_lists_objects "$p"; then
223+
ok "ar members $p"
224+
ar t "$p" 2>/dev/null | head -8 || true
225+
else
226+
bad "ar could not list object members in $p (ld/lld will reject this)"
227+
ar t "$p" 2>&1 | head -20 || true
228+
fi
229+
}
230+
231+
check_msys2_a tess2 libtess2.a
232+
check_msys2_a kiss libkiss.a
233+
check_msys2_a videoInput videoInput.a
234+
else
235+
echo "Unsupported platform: $PLATFORM"
236+
exit 1
237+
fi
238+
239+
echo
240+
echo "Passed: ${pass} Failed: ${fail} Warnings: ${warn}"
241+
if [[ "$fail" -ne 0 ]]; then
242+
exit 1
243+
fi
244+
echo "Deployed library check OK"

0 commit comments

Comments
 (0)