Skip to content

Commit c933bb4

Browse files
committed
fix(packaging): declare runtime deps and handle openSUSE trust-store path
The Fedora and openSUSE install round-trips failed because: 1. ca-certificates is not in those minimal base images, so postinstall's update-ca-trust / update-ca-certificates command was absent and the trust-store install silently no-op'd. 2. openSUSE ships update-ca-certificates but reads anchors from /etc/pki/trust/anchors (Debian uses /usr/local/share/ca-certificates). The original postinstall blindly used the Debian path, so the CA never reached the trust store. Fixes: - Declare ca-certificates and systemd as package deps so dnf/apt/zypper pull them automatically. - Detect the right anchor directory in postinstall (Debian / openSUSE / RHEL) before copying the CA. - preremove now removes from all three possible anchor paths. - test-install.sh accepts the openSUSE path as a valid trust-store location during verification.
1 parent 602ac26 commit c933bb4

4 files changed

Lines changed: 28 additions & 5 deletions

File tree

.github/scripts/test-install.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ test -f /etc/ai-proxy/ca-key.pem
4343
# Env file: Debian uses /etc/default, RHEL uses /etc/sysconfig
4444
test -s /etc/default/ai-proxy || test -s /etc/sysconfig/ai-proxy
4545

46-
# CA should be in the OS trust store
46+
# CA should be in the OS trust store. The anchor directory varies by distro
47+
# family (Debian, openSUSE, RHEL); accept any of them.
4748
trust_found=0
4849
[ -f /usr/local/share/ca-certificates/ai-proxy.crt ] && trust_found=1
50+
[ -f /etc/pki/trust/anchors/ai-proxy.crt ] && trust_found=1
4951
[ -f /etc/pki/ca-trust/source/anchors/ai-proxy.crt ] && trust_found=1
5052
if [ "$trust_found" != "1" ]; then
5153
echo "CA not installed into trust store" >&2
@@ -78,6 +80,7 @@ fi
7880

7981
# Trust-store entry and binary must be gone after remove
8082
test ! -f /usr/local/share/ca-certificates/ai-proxy.crt
83+
test ! -f /etc/pki/trust/anchors/ai-proxy.crt
8184
test ! -f /etc/pki/ca-trust/source/anchors/ai-proxy.crt
8285
test ! -x /usr/bin/ai-proxy
8386

packaging/linux/nfpm.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ vendor: laplaque
1313
homepage: https://github.com/laplaque/ai-anonymizing-proxy
1414
license: MIT
1515

16+
# Runtime dependencies. ca-certificates supplies the trust-store update tool
17+
# (update-ca-certificates on Debian/openSUSE, update-ca-trust on RHEL/Fedora);
18+
# systemd is required for the service unit. Both are typically present on
19+
# every supported distro but minimal container/cloud images omit them.
20+
depends:
21+
- ca-certificates
22+
- systemd
23+
1624
contents:
1725
- src: ./bin/ai-proxy
1826
dst: /usr/bin/ai-proxy

packaging/linux/postinstall.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
#!/bin/sh
22
set -eu
33

4-
# Detect distro family for trust-store integration
4+
# Detect distro family for trust-store integration. Debian and openSUSE both
5+
# ship `update-ca-certificates` but use different anchor directories; RHEL
6+
# uses `update-ca-trust` with a third path. Pick by the presence of the
7+
# distro-specific anchor directory rather than by tool name alone.
58
TRUST_DIR=""
69
TRUST_NAME=ai-proxy.crt
710
TRUST_UPDATE=""
8-
if command -v update-ca-certificates >/dev/null 2>&1; then
11+
if [ -d /usr/local/share/ca-certificates ] && command -v update-ca-certificates >/dev/null 2>&1; then
12+
# Debian / Ubuntu
913
TRUST_DIR=/usr/local/share/ca-certificates
1014
TRUST_UPDATE=update-ca-certificates
11-
elif command -v update-ca-trust >/dev/null 2>&1; then
15+
elif [ -d /etc/pki/trust/anchors ] && command -v update-ca-certificates >/dev/null 2>&1; then
16+
# openSUSE / SLES
17+
TRUST_DIR=/etc/pki/trust/anchors
18+
TRUST_UPDATE=update-ca-certificates
19+
elif [ -d /etc/pki/ca-trust/source/anchors ] && command -v update-ca-trust >/dev/null 2>&1; then
20+
# RHEL / Fedora / Alma / Rocky
1221
TRUST_DIR=/etc/pki/ca-trust/source/anchors
1322
TRUST_UPDATE=update-ca-trust
1423
else

packaging/linux/preremove.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ fi
1414

1515
# Remove CA from trust store. The cert+key under /etc/ai-proxy/ stay — they
1616
# are user data and conffile semantics handle their removal on purge.
17+
# Cover all three anchor directories since the file may have been placed in
18+
# any one of them depending on the distro family detected at install time.
1719
if command -v update-ca-certificates >/dev/null 2>&1; then
1820
rm -f /usr/local/share/ca-certificates/ai-proxy.crt
19-
update-ca-certificates --fresh >/dev/null 2>&1 || true
21+
rm -f /etc/pki/trust/anchors/ai-proxy.crt
22+
update-ca-certificates --fresh >/dev/null 2>&1 || update-ca-certificates >/dev/null 2>&1 || true
2023
elif command -v update-ca-trust >/dev/null 2>&1; then
2124
rm -f /etc/pki/ca-trust/source/anchors/ai-proxy.crt
2225
update-ca-trust >/dev/null 2>&1 || true

0 commit comments

Comments
 (0)