#!/bin/bash # SPDX-License-Identifier: Apache-2.0 # Build one s3-genindex .deb for one architecture. # Usage: build-deb.sh # # The version is also baked into the binary at link time (see Makefile # LDFLAGS), so `s3-genindex -version` is the source of truth for "which # build". The .deb itself only carries the release version. set -euo pipefail PACKAGE="${1:?usage: build-deb.sh }" ARCH="${2:?usage: build-deb.sh }" VERSION="${3:?usage: build-deb.sh }" REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" PKG="${PACKAGE}_${VERSION}_${ARCH}" STAGING="$(mktemp -d)" trap 'rm -rf "$STAGING"' EXIT echo "Building ${PKG}.deb" install -d "$STAGING/DEBIAN" install -d "$STAGING/usr/bin" install -d "$STAGING/usr/share/man/man1" # s3-genindex is a CLI tool, so /usr/bin (on every login PATH) is the # right place; no /usr/sbin, no systemd unit, no /etc conffile. install -m 755 "$REPO_ROOT/build/${ARCH}/${PACKAGE}" "$STAGING/usr/bin/${PACKAGE}" gzip -9 -c "$REPO_ROOT/docs/${PACKAGE}.1" > "$STAGING/usr/share/man/man1/${PACKAGE}.1.gz" sed "s/@VERSION@/${VERSION}/;s/@ARCH@/${ARCH}/" \ "$REPO_ROOT/debian/${PACKAGE}.control.in" > "$STAGING/DEBIAN/control" mkdir -p "$REPO_ROOT/build" OUT="$REPO_ROOT/build/${PKG}.deb" dpkg-deb --build --root-owner-group "$STAGING" "$OUT" echo "Built: $OUT"