CI / Formatting, tests and builds (push) Failing after 3s
scripts/build-linux-packages.sh assemble les paquets avec nfpm, épinglé avec son condensat: binaire dans /usr/bin, viewer dans /usr/share/rustscreen/viewer, dépendance libpipewire-0.3-0 (Debian, Ubuntu) ou pipewire-libs (Fedora). GoReleaser les publie avec le reste. nfpm directement plutôt que les paquets de GoReleaser: sans construction propre, GoReleaser ne fait que des paquets « all », qui installeraient un binaire x86_64 sur une machine ARM. L'hôte trouve désormais le viewer dans ../share/rustscreen/viewer en plus d'à côté de l'exécutable. Le script refuse un binaire construit dans Nix, qui chargerait la glibc de /nix/store. Vérifié: paquets amd64 avec la bonne dépendance, binaire extrait du .deb qui sert le viewer installé, publication simulée avec les quatre fichiers dans SHA256SUMS. Refs #51, #97 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
77 lines
2.4 KiB
Bash
Executable File
77 lines
2.4 KiB
Bash
Executable File
#!/bin/sh
|
|
# Builds the .deb and .rpm of rustscreen-cli (#51) from the binary and the
|
|
# viewer already built, like the AppImage.
|
|
#
|
|
# ./scripts/build-linux-packages.sh [output-dir]
|
|
#
|
|
# nfpm, not GoReleaser's packaging: without a build of its own, GoReleaser
|
|
# can only make packages for every architecture ("all"), which would install
|
|
# an x86_64 binary on an ARM machine. GoReleaser publishes the result.
|
|
set -eu
|
|
|
|
ROOT=$(cd "$(dirname "$0")/.." && pwd)
|
|
OUT=${1:-"$ROOT/dist-packages"}
|
|
VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' "$ROOT/Cargo.toml" | head -1)
|
|
TARGET_DIR=${CARGO_TARGET_DIR:-"$ROOT/target"}
|
|
BIN=${RUSTSCREEN_BIN:-"$TARGET_DIR/release/rustscreen-cli"}
|
|
VIEWER="$ROOT/apps/viewer/dist"
|
|
|
|
# nfpm is pinned with its checksum, like appimagetool, unless one is already
|
|
# in the PATH (`nix shell nixpkgs#nfpm`).
|
|
NFPM_VERSION=2.47.0
|
|
NFPM_SHA256=0660ca602b2d2d2ae4781a06c692b3eeb9d437ffea05b831d76e41f4a3188783
|
|
CACHE=${RUSTSCREEN_CACHE:-"$ROOT/.cache/packages"}
|
|
|
|
for file in "$BIN" "$VIEWER/index.html"; do
|
|
if [ ! -f "$file" ]; then
|
|
echo "missing: $file (build the binary and the viewer first)" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
if command -v nfpm >/dev/null 2>&1; then
|
|
NFPM=nfpm
|
|
else
|
|
NFPM="$CACHE/nfpm-$NFPM_VERSION/nfpm"
|
|
if [ ! -x "$NFPM" ]; then
|
|
mkdir -p "$(dirname "$NFPM")"
|
|
archive="$(dirname "$NFPM")/nfpm.tar.gz"
|
|
curl -fsSL -o "$archive" \
|
|
"https://github.com/goreleaser/nfpm/releases/download/v$NFPM_VERSION/nfpm_${NFPM_VERSION}_Linux_x86_64.tar.gz"
|
|
echo "$NFPM_SHA256 $archive" | sha256sum -c -
|
|
tar -xzf "$archive" -C "$(dirname "$NFPM")" nfpm
|
|
rm "$archive"
|
|
fi
|
|
fi
|
|
|
|
# A binary built under `nix develop` loads glibc from /nix/store: it would
|
|
# not start on the machine that installs the package.
|
|
if grep -qa '/nix/store/[^/]*-glibc-[^/]*/lib/ld-linux' "$BIN"; then
|
|
if [ -z "${RUSTSCREEN_ALLOW_NIX_BINARY:-}" ]; then
|
|
echo "$BIN loads glibc from /nix/store: build it outside Nix (or set RUSTSCREEN_ALLOW_NIX_BINARY=1 to check the packaging only)" >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
case "$(uname -m)" in
|
|
x86_64) ARCH=amd64 ;;
|
|
aarch64) ARCH=arm64 ;;
|
|
*) ARCH=$(uname -m) ;;
|
|
esac
|
|
|
|
STAGE="$OUT/stage"
|
|
rm -rf "$STAGE"
|
|
mkdir -p "$STAGE"
|
|
cp "$BIN" "$STAGE/rustscreen-cli"
|
|
strip "$STAGE/rustscreen-cli" 2>/dev/null || true
|
|
cp -r "$VIEWER" "$STAGE/viewer"
|
|
cp "$ROOT/LICENSE" "$STAGE/"
|
|
|
|
export VERSION ARCH
|
|
for format in deb rpm; do
|
|
(cd "$STAGE" && "$NFPM" package --config "$ROOT/packaging/linux/nfpm.yaml" \
|
|
--packager "$format" --target "$OUT/")
|
|
done
|
|
rm -rf "$STAGE"
|
|
ls -l "$OUT"
|