feat(packaging): paquets .deb et .rpm de rustscreen-cli dans la release
CI / Formatting, tests and builds (push) Failing after 3s
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>
This commit is contained in:
1 parent
41e2bb5a92
commit
868a9dd4a4
7 files changed
+194
-10
No files matched your search
@@ -102,6 +102,11 @@ jobs:
|
||||
set -euo pipefail
|
||||
./scripts/build-appimage.sh
|
||||
|
||||
- name: .deb and .rpm
|
||||
run: |
|
||||
set -euo pipefail
|
||||
./scripts/build-linux-packages.sh
|
||||
|
||||
- name: GoReleaser
|
||||
run: |
|
||||
set -euo pipefail
|
||||
@@ -132,6 +137,7 @@ jobs:
|
||||
mkdir -p dist/release
|
||||
cp "dist-appimage/rustscreen-${VERSION}-x86_64.AppImage" dist/release/
|
||||
cp "$CARGO_TARGET_DIR/release/rustscreen-cli" dist/release/
|
||||
cp dist-packages/*.deb dist-packages/*.rpm dist/release/
|
||||
notes="docs/releases/${GITHUB_REF_NAME}.md"
|
||||
if [ -f "$notes" ]; then
|
||||
goreleaser release --clean --release-notes "$notes"
|
||||
|
||||
@@ -30,6 +30,7 @@ diag-*.zip
|
||||
|
||||
# Empaquetage local
|
||||
dist-appimage/
|
||||
dist-packages/
|
||||
.cache/
|
||||
SHA256SUMS
|
||||
|
||||
|
||||
+9
-3
@@ -29,9 +29,11 @@ gitea_urls:
|
||||
# send GoReleaser to GitHub.
|
||||
force_token: gitea
|
||||
|
||||
# What the release ships, built beforehand and gathered in `dist/release`
|
||||
# (GoReleaser only globs inside the repository). A missing file fails the
|
||||
# release rather than publishing an incomplete one.
|
||||
# What the release ships: the binary, the AppImage, the .deb and the .rpm,
|
||||
# built beforehand and gathered in `dist/release` (GoReleaser only globs
|
||||
# inside the repository). The packages come from nfpm directly: see
|
||||
# `scripts/build-linux-packages.sh` for why not GoReleaser's own. A missing
|
||||
# file fails the release rather than publishing an incomplete one.
|
||||
release:
|
||||
gitea:
|
||||
owner: heap
|
||||
@@ -42,6 +44,8 @@ release:
|
||||
extra_files:
|
||||
- glob: "dist/release/rustscreen-{{ .Version }}-x86_64.AppImage"
|
||||
- glob: "dist/release/rustscreen-cli"
|
||||
- glob: "dist/release/rustscreen-cli_{{ .Version }}_amd64.deb"
|
||||
- glob: "dist/release/rustscreen-cli-{{ .Version }}-1.x86_64.rpm"
|
||||
|
||||
checksum:
|
||||
name_template: SHA256SUMS
|
||||
@@ -49,6 +53,8 @@ checksum:
|
||||
extra_files:
|
||||
- glob: "dist/release/rustscreen-{{ .Version }}-x86_64.AppImage"
|
||||
- glob: "dist/release/rustscreen-cli"
|
||||
- glob: "dist/release/rustscreen-cli_{{ .Version }}_amd64.deb"
|
||||
- glob: "dist/release/rustscreen-cli-{{ .Version }}-1.x86_64.rpm"
|
||||
|
||||
# `--snapshot` (local check): the artifacts are named after this version.
|
||||
snapshot:
|
||||
|
||||
@@ -41,11 +41,22 @@ const SERVER_STOP_TIMEOUT: Duration = Duration::from_secs(3);
|
||||
/// the interface comes back.
|
||||
const INTERFACE_DOWN: &str = "interface_down";
|
||||
|
||||
/// The viewer installed next to the executable (`viewer/index.html`), as the
|
||||
/// Windows installer lays it out (#96). `None` when there is none.
|
||||
/// The viewer installed with the executable. `None` when there is none.
|
||||
pub fn installed_viewer() -> Option<PathBuf> {
|
||||
let dir = std::env::current_exe().ok()?.parent()?.join("viewer");
|
||||
dir.join("index.html").is_file().then_some(dir)
|
||||
viewer_beside(&std::env::current_exe().ok()?)
|
||||
}
|
||||
|
||||
/// Where an installer puts the viewer relative to `executable`: next to it as
|
||||
/// the Windows installer does (#96), or in `share` as the Linux packages do
|
||||
/// (`/usr/bin` and `/usr/share/rustscreen/viewer`, #51).
|
||||
fn viewer_beside(executable: &std::path::Path) -> Option<PathBuf> {
|
||||
let bin = executable.parent()?;
|
||||
[
|
||||
bin.join("viewer"),
|
||||
bin.parent()?.join("share/rustscreen/viewer"),
|
||||
]
|
||||
.into_iter()
|
||||
.find(|dir| dir.join("index.html").is_file())
|
||||
}
|
||||
|
||||
/// What the caller sets once and for all.
|
||||
@@ -1511,3 +1522,25 @@ fn now_ms() -> u64 {
|
||||
fn lock<T>(mutex: &Mutex<T>) -> std::sync::MutexGuard<'_, T> {
|
||||
mutex.lock().unwrap_or_else(|e| e.into_inner())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn the_viewer_is_found_next_to_the_executable_or_in_share() {
|
||||
let root = std::env::temp_dir().join(format!("rs-viewer-{}", std::process::id()));
|
||||
let executable = root.join("usr/bin/rustscreen-cli");
|
||||
assert_eq!(viewer_beside(&executable), None);
|
||||
let share = root.join("usr/share/rustscreen/viewer");
|
||||
std::fs::create_dir_all(&share).unwrap();
|
||||
std::fs::write(share.join("index.html"), "").unwrap();
|
||||
assert_eq!(viewer_beside(&executable), Some(share));
|
||||
// Next to the executable comes first, as on Windows.
|
||||
let beside = root.join("usr/bin/viewer");
|
||||
std::fs::create_dir_all(&beside).unwrap();
|
||||
std::fs::write(beside.join("index.html"), "").unwrap();
|
||||
assert_eq!(viewer_beside(&executable), Some(beside));
|
||||
std::fs::remove_dir_all(&root).unwrap();
|
||||
}
|
||||
}
|
||||
+24
-3
@@ -90,11 +90,32 @@ le configure de libvpx, pages HTML retirées par le filtre de sources.
|
||||
Les fichiers nouveaux doivent être connus de git (`git add`, ou `git add -N` avant un commit):
|
||||
un flake ne voit que les fichiers suivis.
|
||||
|
||||
## .deb et .rpm
|
||||
|
||||
```sh
|
||||
cargo build --release -p rs-session --features pipewire --bin rustscreen-cli # hors de Nix
|
||||
npm --prefix apps/viewer run build
|
||||
./scripts/build-linux-packages.sh
|
||||
```
|
||||
|
||||
Le script produit `dist-packages/rustscreen-cli_<version>_amd64.deb` et
|
||||
`rustscreen-cli-<version>-1.x86_64.rpm` avec **nfpm** (épinglé, condensat vérifié, ou celui du
|
||||
`PATH`). Le binaire va dans `/usr/bin`, le viewer dans `/usr/share/rustscreen/viewer`, où l'hôte le
|
||||
trouve seul. Dépendance: `libpipewire-0.3-0` (Debian, Ubuntu, dont le paquet `t64` de la 24.04
|
||||
fournit ce nom) ou `pipewire-libs` (Fedora).
|
||||
|
||||
Pourquoi nfpm et pas les paquets de GoReleaser: sans construction propre, GoReleaser ne sait faire
|
||||
que des paquets « toutes architectures », qui installeraient un binaire x86_64 sur une machine ARM.
|
||||
|
||||
Un binaire construit dans `nix develop` charge la glibc de `/nix/store` et ne démarrerait pas
|
||||
ailleurs: le script le refuse. `RUSTSCREEN_ALLOW_NIX_BINARY=1` le laisse passer pour vérifier
|
||||
l'empaquetage seul.
|
||||
|
||||
## Publier une release
|
||||
|
||||
Une étiquette `vX.Y.Z` poussée lance `.gitea/workflows/release.yml`, et rien d'autre ne publie.
|
||||
La chaîne refuse une étiquette qui ne correspond pas à la version du `Cargo.toml`, construit le
|
||||
binaire et l'AppImage avec les scripts ci-dessus, puis passe la main à **GoReleaser** (#97,
|
||||
binaire, l'AppImage, le .deb et le .rpm avec les scripts ci-dessus, puis passe la main à **GoReleaser** (#97,
|
||||
`.goreleaser.yaml`), qui crée ou remplace la release Gitea, ses pièces jointes et `SHA256SUMS`.
|
||||
|
||||
GoReleaser ne compile rien: la pile Rust demande libvpx, PipeWire et le viewer déjà construit, ce
|
||||
@@ -117,5 +138,5 @@ dans la release.
|
||||
|
||||
## Ce que le paquet ne fait pas encore
|
||||
|
||||
L'installateur Windows n'est pas publié par la chaîne (voir plus haut), et les paquets `.deb` et
|
||||
`.rpm` n'existent pas (#51).
|
||||
L'installateur Windows n'est pas publié par la chaîne (voir plus haut). Les paquets Linux ne
|
||||
contiennent que la ligne de commande: l'application de bureau n'est pas encore empaquetée (#51).
|
||||
@@ -0,0 +1,41 @@
|
||||
# .deb and .rpm of the command line host (#51), built by
|
||||
# `scripts/build-linux-packages.sh`, which sets ARCH and VERSION and runs nfpm
|
||||
# from a staging directory holding the files below (nfpm does not expand
|
||||
# variables in source paths).
|
||||
#
|
||||
# The binary goes in /usr/bin, the viewer in /usr/share/rustscreen/viewer,
|
||||
# where `rs_session::installed_viewer` finds it. libvpx is linked statically;
|
||||
# libpipewire is not bundled, the client must speak the version of the
|
||||
# machine's PipeWire daemon.
|
||||
name: rustscreen-cli
|
||||
arch: ${ARCH}
|
||||
platform: linux
|
||||
version: ${VERSION}
|
||||
section: video
|
||||
priority: optional
|
||||
maintainer: heap <gitea@localhost>
|
||||
description: |
|
||||
Screen sharing host served to a web browser on the local network.
|
||||
The viewer installs nothing: it opens a URL, or scans a QR code.
|
||||
homepage: https://gitea-nubo.hopledge.com/heap/rustscreen
|
||||
license: Apache-2.0
|
||||
|
||||
contents:
|
||||
- src: rustscreen-cli
|
||||
dst: /usr/bin/rustscreen-cli
|
||||
file_info:
|
||||
mode: 0755
|
||||
- src: viewer
|
||||
dst: /usr/share/rustscreen/viewer
|
||||
type: tree
|
||||
- src: LICENSE
|
||||
dst: /usr/share/doc/rustscreen-cli/LICENSE
|
||||
|
||||
overrides:
|
||||
deb:
|
||||
# Ubuntu 24.04 names it libpipewire-0.3-0t64, which provides this name.
|
||||
depends:
|
||||
- libpipewire-0.3-0
|
||||
rpm:
|
||||
depends:
|
||||
- pipewire-libs
|
||||
Executable
+76
@@ -0,0 +1,76 @@
|
||||
#!/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"
|
||||
Reference in new issue
Block a user