mirror of
https://github.com/jmcorgan/fips.git
synced 2026-07-22 07:48:26 +00:00
Drop the `tui`, `ble`, and `gateway` cargo features and replace them with platform cfg gates. Plain `cargo build` now produces every subsystem appropriate for the target platform with no feature flags required. Motivation: - `default = ["tui", "ble"]` broke `cargo build` on macOS and Windows because `ble` pulled in `bluer` (BlueZ, Linux-only). Every non-Linux packager needed `--no-default-features`. - The feature flags on `ble` and `gateway` were redundant with their platform-gated deps (`bluer`, `rustables`). The parallel gating was inconsistent and error-prone. - `tui` feature protected against a ratatui binary-size concern that no longer applies in 2026. Cargo.toml: - Remove `tui`, `ble`, `gateway` features; `default = []`. - Promote `ratatui` to a non-optional top-level dependency. - Move `rustables` from top-level optional into the Linux target block, non-optional. - Split `bluer` into its own target block with `cfg(all(target_os = "linux", not(target_env = "musl")))` — BlueZ isn't available on musl router targets and `libdbus-sys` doesn't cross-compile to musl without pkg-config sysroot setup. - Drop `required-features` from the `fipstop` and `fips-gateway` `[[bin]]` entries. build.rs: - Emit a `bluer_available` custom cfg when `target_os == "linux"` and `target_env != "musl"`, for use in place of the verbose full predicate in source cfg gates. Source: - Replace every `#[cfg(feature = "gateway")]` with `#[cfg(target_os = "linux")]`. Gateway code works on both glibc and musl Linux (rustables is fine on musl). - Replace every `#[cfg(feature = "ble")]` with `#[cfg(bluer_available)]`. BLE-specific code (BluerIo module, bluer type conversions, BLE transport instance creation, resolve_ble_addr) is excluded on musl and non-Linux. Generic `BleAddr`, `BleIo` trait, `MockBleIo`, and `BleTransport<I>` still compile on all targets. - `src/bin/fips-gateway.rs`: always compiled, but `main()` is gated to Linux. Non-Linux stub exits 1 with a diagnostic. Existing non-Linux packaging scripts don't ship it, so the stub binary sits unused. Packaging and CI: - Drop `--features` and `--no-default-features` flags from every packaging script and workflow. Defaults now match each platform's capabilities. - AUR `fips-git` automatically aligns with stable `PKGBUILD` (both build with defaults). Verified: `cargo build --release` with no flags produces all four binaries on glibc Linux; all unit and integration tests pass across Linux/macOS/Windows/OpenWrt (musl) in CI.
102 lines
2.5 KiB
Bash
Executable File
102 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Build a .deb package for FIPS using cargo-deb.
|
|
#
|
|
# Usage: ./build-deb.sh [--target <triple>] [--version <version>] [--no-build]
|
|
#
|
|
# Prerequisites: cargo-deb (install with: cargo install cargo-deb)
|
|
# Output: deploy/fips_<version>_<arch>.deb
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
PROJECT_ROOT="${SCRIPT_DIR}/../.."
|
|
|
|
usage() {
|
|
cat <<'EOF'
|
|
Usage: packaging/debian/build-deb.sh [options]
|
|
|
|
Options:
|
|
--target <triple> Rust target triple to build/package
|
|
--version <version> Override Debian package version
|
|
--no-build Package existing binaries without running cargo build
|
|
-h, --help Show this help
|
|
EOF
|
|
}
|
|
|
|
TARGET_TRIPLE=""
|
|
VERSION_OVERRIDE=""
|
|
NO_BUILD=0
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--target)
|
|
TARGET_TRIPLE="${2:?missing value for --target}"
|
|
shift 2
|
|
;;
|
|
--version)
|
|
VERSION_OVERRIDE="${2:?missing value for --version}"
|
|
shift 2
|
|
;;
|
|
--no-build)
|
|
NO_BUILD=1
|
|
shift
|
|
;;
|
|
-h|--help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "Unknown option: $1" >&2
|
|
usage >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
cd "${PROJECT_ROOT}"
|
|
|
|
# Ensure cargo-deb is available
|
|
if ! command -v cargo-deb &>/dev/null; then
|
|
echo "cargo-deb not found. Install with: cargo install cargo-deb" >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Derive SOURCE_DATE_EPOCH from git if not already set (reproducible builds)
|
|
if [ -z "${SOURCE_DATE_EPOCH:-}" ]; then
|
|
export SOURCE_DATE_EPOCH=$(git log -1 --format=%ct)
|
|
fi
|
|
|
|
# Build the .deb package
|
|
echo "Building .deb package..."
|
|
OUTPUT_DIR="$(mktemp -d)"
|
|
trap 'rm -rf "${OUTPUT_DIR}"' EXIT
|
|
|
|
cargo_args=(deb --output "${OUTPUT_DIR}")
|
|
if [[ -n "${TARGET_TRIPLE}" ]]; then
|
|
cargo_args+=(--target "${TARGET_TRIPLE}")
|
|
fi
|
|
if [[ -n "${VERSION_OVERRIDE}" ]]; then
|
|
cargo_args+=(--deb-version "${VERSION_OVERRIDE}")
|
|
fi
|
|
if [[ "${NO_BUILD}" -eq 1 ]]; then
|
|
cargo_args+=(--no-build)
|
|
fi
|
|
cargo "${cargo_args[@]}"
|
|
|
|
# Move output to deploy/
|
|
mkdir -p deploy
|
|
DEB_FILE=$(find "${OUTPUT_DIR}" -maxdepth 1 -name '*.deb' -printf '%T@ %p\n' | sort -rn | head -1 | cut -d' ' -f2)
|
|
|
|
if [ -z "${DEB_FILE}" ]; then
|
|
echo "Error: No .deb file found in ${OUTPUT_DIR}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
cp "${DEB_FILE}" deploy/
|
|
BASENAME=$(basename "${DEB_FILE}")
|
|
echo "Package built: deploy/${BASENAME}"
|
|
echo ""
|
|
echo "Install with: sudo dpkg -i deploy/${BASENAME}"
|
|
echo "Remove with: sudo dpkg -r fips"
|
|
echo "Purge with: sudo dpkg -P fips (removes config and identity keys)"
|