#!/usr/bin/env bash set -Eeuo pipefail ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) # The bundled Linux rules must match the expected user-provided settings. diff -u "$ROOT/packaging/rustproxy.logrotate" - <<'CONFIG' /var/log/rustproxy/*.jsonl /var/log/rustproxy/*.log /var/log/rustproxy/vhosts/*.jsonl { daily maxsize 512M rotate 14 missingok notifempty compress delaycompress copytruncate su rustproxy rustproxy } CONFIG # All three log groups must also be tracked by native FreeBSD newsyslog. OPNSENSE_CONF="$ROOT/opnsense/plugin/src/etc/newsyslog.conf.d/rustproxy.conf" for pattern in '/var/log/rustproxy/*.jsonl' '/var/log/rustproxy/*.log' '/var/log/rustproxy/vhosts/*.jsonl'; do grep -Fq "$pattern " "$OPNSENSE_CONF" done [[ $(grep -c '^/var/log/rustproxy/' "$OPNSENSE_CONF") == 3 ]] grep -Fq '14 100M $D0 GBEZPN' "$OPNSENSE_CONF" grep -Fq '14 100M $D0 GBEZP /var/run/rustproxy/daemon.pid SIGHUP' "$OPNSENSE_CONF" grep -Fq ' -H -P ${pidfile}' "$ROOT/opnsense/plugin/src/etc/rc.d/rustproxy" grep -Fq 'COPY packaging/ /opt/rust-package-builder/packaging/' "$ROOT/Dockerfile" grep -Fq 'packaging_revision=$PACKAGING_REVISION' "$ROOT/scripts/build-linux-release.sh" grep -Fq 'packaging_revision=$PACKAGING_REVISION' "$ROOT/scripts/build-opnsense-release.sh" # Test staging and native PKG manifest without compiling Rust or signing RPM/DEB. for tool in file zstd tar sha256sum python3; do command -v "$tool" >/dev/null 2>&1 || { echo "SKIP packaging integration: missing $tool"; exit 0; } done WORK=$(mktemp -d) trap 'rm -rf "$WORK"' EXIT mkdir -p "$WORK/source" "$WORK/linux" if command -v logrotate >/dev/null 2>&1; then # Test parser compatibility even if the local test machine has no rustproxy user. sed 's/su rustproxy rustproxy/su root root/' "$ROOT/packaging/rustproxy.logrotate" > "$WORK/logrotate-test.conf" logrotate -d -s "$WORK/logrotate.state" "$WORK/logrotate-test.conf" > "$WORK/logrotate-output" 2>&1 grep -Fq 'reading config file' "$WORK/logrotate-output" fi printf '[package]\nname = "rust-proxy"\nversion = "1.0.0"\n' > "$WORK/source/Cargo.toml" python3 - "$WORK/bin" <<'PY' from pathlib import Path import struct, sys p = Path(sys.argv[1]) # ELF header with FreeBSD OSABI is enough to check the OPNsense packaging path. e_ident = b'\x7fELF\x02\x01\x01\x09' + bytes(8) header = struct.pack(' "$WORK/manifest.json" python3 - "$WORK/manifest.json" <<'PY' import json, sys with open(sys.argv[1]) as f: manifest=json.load(f) path='/usr/local/etc/newsyslog.conf.d/rustproxy.conf' assert path in manifest['files'], f'{path} missing from PKG manifest' assert path in manifest['files'] and len(manifest['files'][path]) == 64 assert '/usr/local/etc/rc.d/rustproxy' in manifest['files'] PY zstd -dc "$WORK/os-rustproxy.pkg" | tar -xOf - /usr/local/etc/newsyslog.conf.d/rustproxy.conf > "$WORK/packaged-newsyslog.conf" cmp "$OPNSENSE_CONF" "$WORK/packaged-newsyslog.conf" echo 'log rotation package integration: OK'