fix(packaging): record required library ABIs on Arch and OpenBSD

This commit is contained in:
Kevin Yue committed 2026-11-03 00:02:24 +08:00
1 parent a02dfd10ab
commit 9001b768c1
6 files changed
+64 -1

No files matched your search

+2
View File
@@ -261,7 +261,9 @@ package-openbsd: clean-bsd-package
$(MAKE) install-bsd DESTDIR=$(CURDIR)/.build/openbsd/pkgroot PREFIX=$(PREFIX) GPGUI_BINARY="$(GPGUI_BINARY)"
cp packaging/bsd/openbsd/COMMENT .build/openbsd/+COMMENT
cp packaging/bsd/openbsd/DESC .build/openbsd/+DESC
sh scripts/openbsd-library-dependencies.sh .build/openbsd/pkgroot > .build/openbsd/WANTLIB
{ \
cat .build/openbsd/WANTLIB; \
echo '@unexec-delete /bin/rm -f /usr/local/libexec/gpclient/gpgui /var/db/gpclient/scripts/vpnc-script /var/db/gpclient/scripts/vpnc-script.metadata || echo "Warning: failed to remove gpclient runtime files" >&2'; \
echo '@unexec-delete /bin/rmdir /usr/local/libexec/gpclient 2>/dev/null || true'; \
echo '@unexec-delete /bin/rmdir /var/db/gpclient/scripts 2>/dev/null || true'; \
+1 -1
View File
@@ -224,7 +224,7 @@ fn main() {
pkg_config::probe_library("liblz4").unwrap();
pkg_config::probe_library("gnutls").unwrap();
// Below are required by gnutls
// OpenConnect also uses Hogweed/GMP directly for its GnuTLS backend.
pkg_config::probe_library("p11-kit-1").unwrap();
pkg_config::probe_library("hogweed").unwrap();
pkg_config::probe_library("nettle").unwrap();
@@ -43,6 +43,8 @@ build() {
}
package() {
# Record the Hogweed ABI used by OpenConnect.
depends+=('libhogweed.so')
cd "${_pkgname_prefix}"
DESTDIR="$pkgdir" make install
+2
View File
@@ -31,6 +31,8 @@ build() {
}
package() {
# Record the Hogweed ABI used by OpenConnect.
depends+=('libhogweed.so')
cd "$pkgname-$pkgver"
make install DESTDIR="$pkgdir"
+16
View File
@@ -0,0 +1,16 @@
#!/bin/sh
# Record the library ABIs required by the staged OpenBSD executables.
set -eu
root=$1
temp=$(mktemp -d)
trap 'rm -rf "$temp"' EXIT HUP INT TERM
find "$root" -type f > "$temp/files"
while IFS= read -r file; do
case $(file -b "$file") in
ELF*) objdump -p "$file" >> "$temp/headers" ;;
esac
done < "$temp/files"
test -s "$temp/headers"
sed -n 's/^[[:space:]]*NEEDED[[:space:]]*lib\([^[:space:]]*\)\.so\.\([0-9][0-9]*\.[0-9][0-9]*\)[[:space:]]*$/@wantlib \1.\2/p' \
"$temp/headers" | LC_ALL=C sort -u
@@ -0,0 +1,41 @@
#!/bin/sh
set -eu
root=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
temp=$(mktemp -d)
trap 'rm -rf "$temp"' EXIT HUP INT TERM
mkdir -p "$temp/bin" "$temp/stage/bin"
touch "$temp/stage/bin/gpclient" "$temp/stage/bin/gpauth" "$temp/stage/bin/script"
cat > "$temp/bin/file" <<'EOF'
#!/bin/sh
case $2 in
*/script) echo 'POSIX shell script, ASCII text executable' ;;
*) echo 'ELF 64-bit LSB shared object, x86-64' ;;
esac
EOF
cat > "$temp/bin/objdump" <<'EOF'
#!/bin/sh
case $2 in
*/gpclient)
printf 'Dynamic Section:\n NEEDED libhogweed.so.3.1\n NEEDED libc.so.103.0\n'
;;
*/gpauth)
printf ' NEEDED libc.so.103.0\n NEEDED libc++abi.so.9.0\n'
;;
*) exit 1 ;;
esac
EOF
chmod +x "$temp/bin/file" "$temp/bin/objdump"
PATH="$temp/bin:$PATH" sh "$root/scripts/openbsd-library-dependencies.sh" "$temp/stage" > "$temp/actual"
cat > "$temp/expected" <<'EOF'
@wantlib c++abi.9.0
@wantlib c.103.0
@wantlib hogweed.3.1
EOF
diff -u "$temp/expected" "$temp/actual"
# Failure to inspect an ELF file must stop packaging, not omit its requirements.
printf '#!/bin/sh\nexit 1\n' > "$temp/bin/objdump"
if PATH="$temp/bin:$PATH" sh "$root/scripts/openbsd-library-dependencies.sh" "$temp/stage" > /dev/null; then
echo 'Expected ELF inspection failure' >&2
exit 1
fi
echo 'OpenBSD library dependency checks passed.'