Add dev deploy scripts and a user-local install path
deploy-dev.sh (build host) stages an install tree, streams it as tar.zst or builds the regent-git package. regent-deploy.sh (workstation) pulls a build over an existing ssh connection, unpacks it into ~/.local and recompiles the schema, warning first if the two machines' GTK/libadwaita versions differ. The GResource lookup now also searches XDG_DATA_HOME so a user-local install works, and --version prints the build without needing a display.
This commit is contained in:
7 files changed
+289
-10
No files matched your search
+4
-1
@@ -1,4 +1,7 @@
|
||||
/_build/
|
||||
/_build*/
|
||||
/dist/
|
||||
/target/
|
||||
*.gresource
|
||||
*.pkg.tar.*
|
||||
/build-aux/regent-git/pkg/
|
||||
/build-aux/regent-git/src/
|
||||
@@ -74,6 +74,23 @@ UI lives in `data/resources/ui/*.blp` (Blueprint) and is compiled to `.ui` by
|
||||
runs set `GSETTINGS_SCHEMA_DIR=_build/data` (see the run recipes in
|
||||
`README.md`).
|
||||
|
||||
## Dev deploy
|
||||
|
||||
The build host (`nuc`) compiles; the workstation (`nanoo`, the laptop) is where
|
||||
the UI is tested. `build-aux/deploy-dev.sh` runs on the build host,
|
||||
`build-aux/regent-deploy.sh` on the workstation — installed there as
|
||||
`~/.local/bin/regent-deploy` (see `README.md` for the one-time setup).
|
||||
|
||||
- Move builds by **pulling** from the workstation (`ssh build-host … | tar -x`).
|
||||
Nothing listens for inbound connections on either machine; do not add an sshd
|
||||
to the workstation just for this.
|
||||
- Test installs go to `~/.local` (XDG user layout) and need no root. Never
|
||||
install system-wide on the workstation just to try something.
|
||||
- The two machines must agree on GTK/libadwaita versions; the wrapper compares
|
||||
them and warns. If they drift, update both before debugging anything else.
|
||||
- `--pkg` builds `build-aux/regent-git/PKGBUILD`, which packages the working
|
||||
tree and is a preview of the real release packaging.
|
||||
|
||||
## Testing
|
||||
|
||||
- Loopback with no public relays and no display:
|
||||
|
||||
@@ -39,6 +39,43 @@ dbus-run-session -- sh -c \
|
||||
./_build/regent'
|
||||
```
|
||||
|
||||
## Testing on another machine
|
||||
|
||||
The build host compiles; you test on the workstation it should actually run on.
|
||||
`build-aux/deploy-dev.sh` runs on the build host and `build-aux/regent-deploy.sh`
|
||||
on the workstation; a build is moved with the workstation *pulling*, so nothing
|
||||
new listens for connections anywhere.
|
||||
|
||||
Install the wrapper once, on the workstation:
|
||||
|
||||
```sh
|
||||
mkdir -p ~/.local/bin
|
||||
ssh nuc-zt 'cat ~/src/regent/build-aux/regent-deploy.sh' > ~/.local/bin/regent-deploy
|
||||
chmod +x ~/.local/bin/regent-deploy
|
||||
```
|
||||
|
||||
Then, after every change:
|
||||
|
||||
```sh
|
||||
regent-deploy
|
||||
```
|
||||
|
||||
That asks the build host which GTK/libadwaita it builds against, warns if the two
|
||||
machines have drifted (a mismatch surfaces as a symbol lookup error), pulls the
|
||||
install tree, unpacks it into `~/.local` (no root needed), recompiles the
|
||||
GSettings schema, and prints the version it installed. `REGENT_DEPLOY_PKG=1
|
||||
regent-deploy` builds and installs a real `regent-git` package instead (asks for
|
||||
`sudo`).
|
||||
|
||||
Directly on the build host, without a workstation:
|
||||
|
||||
```sh
|
||||
build-aux/deploy-dev.sh # write a tarball to /tmp/regent-dev/
|
||||
build-aux/deploy-dev.sh --pkg # build the regent-git pacman package
|
||||
build-aux/deploy-dev.sh --versions # GTK/libadwaita this host builds against
|
||||
build-aux/deploy-dev.sh --help
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[Unlicense](LICENSE) — public domain.
|
||||
Executable
+92
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build Regent and produce something installable elsewhere.
|
||||
#
|
||||
# Runs on the build host. Modes:
|
||||
# --emit stream a tar.zst of the install tree on stdout (logs go to
|
||||
# stderr) so the other machine can pipe it straight into tar:
|
||||
# ssh HOST '<repo>/build-aux/deploy-dev.sh --emit' \
|
||||
# | tar -x --zstd -C ~/.local
|
||||
# (default) write that same tarball to a file and print its path
|
||||
# --pkg build the `regent-git` pacman package and print its path
|
||||
# --versions print the GTK/libadwaita versions this host builds against
|
||||
#
|
||||
# The install tree is rooted at /usr, so extracting it into $HOME/.local yields
|
||||
# the XDG layout: ~/.local/bin/regent, ~/.local/share/<app-id>/, ...
|
||||
set -euo pipefail
|
||||
|
||||
log() { printf 'deploy: %s\n' "$*" >&2; }
|
||||
die() { printf 'deploy: %s\n' "$*" >&2; exit 1; }
|
||||
|
||||
ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
||||
cd "$ROOT"
|
||||
|
||||
MODE=stage
|
||||
case "${1:-}" in
|
||||
--emit) MODE=emit ;;
|
||||
--pkg) MODE=pkg ;;
|
||||
--versions) MODE=versions ;;
|
||||
''|--stage) ;;
|
||||
-h|--help) sed -n '2,20p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;;
|
||||
*) die "unknown option: $1 (try --help)" ;;
|
||||
esac
|
||||
|
||||
if [ "$MODE" = versions ]; then
|
||||
printf 'gtk4=%s libadwaita=%s\n' \
|
||||
"$(pkg-config --modversion gtk4)" "$(pkg-config --modversion libadwaita-1)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for tool in cargo meson pkg-config tar zstd; do
|
||||
command -v "$tool" >/dev/null || die "$tool not found"
|
||||
done
|
||||
|
||||
# Version stamp: crate version plus commit count and short SHA, so each build
|
||||
# from a new commit sorts higher than the previous one.
|
||||
CARGO_VER=$(sed -n 's/^version *= *"\(.*\)"/\1/p' Cargo.toml | head -1)
|
||||
SHA=$(git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
||||
COUNT=$(git rev-list --count HEAD 2>/dev/null || echo 0)
|
||||
DIRTY=""
|
||||
git diff --quiet --ignore-submodules HEAD 2>/dev/null || DIRTY=".dirty"
|
||||
PKGVER="${CARGO_VER:-0.0.0}.r${COUNT}.g${SHA}${DIRTY}"
|
||||
log "version ${PKGVER}"
|
||||
|
||||
OUT_DIR=${REGENT_OUT_DIR:-/tmp/regent-dev}
|
||||
mkdir -p "$OUT_DIR"
|
||||
|
||||
if [ "$MODE" = pkg ]; then
|
||||
command -v makepkg >/dev/null || die "makepkg not found"
|
||||
log "building regent-git with makepkg"
|
||||
( cd build-aux/regent-git \
|
||||
&& REGENT_DEV_PKGVER="$PKGVER" REGENT_REPO="$ROOT" makepkg -f --noconfirm ) >&2
|
||||
PKG=$(ls -t build-aux/regent-git/regent-git-*.pkg.tar.* | head -1)
|
||||
install -m644 "$PKG" "$OUT_DIR/"
|
||||
printf '%s\n' "$OUT_DIR/$(basename "$PKG")"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
BUILD_DIR=${REGENT_BUILD_DIR:-_build}
|
||||
# `meson install` cannot change the prefix, so the build directory is always
|
||||
# configured with /usr — the staged tree is then $STAGE/usr, which unpacks into
|
||||
# $HOME/.local as the standard XDG layout.
|
||||
if [ -d "$BUILD_DIR" ]; then
|
||||
meson setup --reconfigure --prefix=/usr "$BUILD_DIR" >&2
|
||||
else
|
||||
log "configuring $BUILD_DIR"
|
||||
meson setup --prefix=/usr "$BUILD_DIR" >&2
|
||||
fi
|
||||
log "compiling"
|
||||
meson compile -C "$BUILD_DIR" >&2
|
||||
|
||||
STAGE=$(mktemp -d "${TMPDIR:-/tmp}/regent-stage.XXXXXX")
|
||||
trap 'rm -rf "$STAGE"' EXIT
|
||||
log "staging the install tree"
|
||||
meson install -C "$BUILD_DIR" --destdir "$STAGE" --quiet >&2
|
||||
|
||||
if [ "$MODE" = emit ]; then
|
||||
log "streaming the install tree to stdout"
|
||||
tar -C "$STAGE/usr" -cf - . | zstd -q -c
|
||||
else
|
||||
OUT="$OUT_DIR/regent-$PKGVER.tar.zst"
|
||||
tar -C "$STAGE/usr" -cf - . | zstd -q -c > "$OUT"
|
||||
printf '%s\n' "$OUT"
|
||||
fi
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regent dev deploy — run this on the workstation.
|
||||
#
|
||||
# Pulls a freshly built Regent from the build host and installs it into
|
||||
# ~/.local (no root required), then recompiles the GSettings schema so the app
|
||||
# picks up the new one.
|
||||
#
|
||||
# regent-deploy # install tree into ~/.local (fast)
|
||||
# REGENT_DEPLOY_PKG=1 regent-deploy # pacman package instead (sudo)
|
||||
#
|
||||
# Environment:
|
||||
# REGENT_BUILD_HOST ssh target of the build host (default: nuc-zt)
|
||||
# REGENT_REPO_PATH repo path on the build host (default: ~/src/regent)
|
||||
set -euo pipefail
|
||||
|
||||
HOST=${REGENT_BUILD_HOST:-nuc-zt}
|
||||
REPO=${REGENT_REPO_PATH:-'~/src/regent'}
|
||||
REMOTE="$REPO/build-aux/deploy-dev.sh"
|
||||
|
||||
say() { printf 'regent-deploy: %s\n' "$*"; }
|
||||
die() { printf 'regent-deploy: %s\n' "$*" >&2; exit 1; }
|
||||
|
||||
command -v ssh >/dev/null || die "ssh not found"
|
||||
command -v pkg-config >/dev/null || die "pkg-config not found"
|
||||
command -v tar >/dev/null || die "tar not found"
|
||||
|
||||
# A binary built against a newer libadwaita/GTK than this machine has will die
|
||||
# with a symbol lookup error, so compare first instead of letting you debug it.
|
||||
local_versions=$(printf 'gtk4=%s libadwaita=%s' \
|
||||
"$(pkg-config --modversion gtk4)" "$(pkg-config --modversion libadwaita-1)")
|
||||
remote_versions=$(ssh "$HOST" "$REMOTE --versions")
|
||||
|
||||
if [ "$remote_versions" != "$local_versions" ]; then
|
||||
printf 'regent-deploy: WARNING: build host and this machine disagree:\n' >&2
|
||||
printf ' %-7s %s\n' "$HOST" "$remote_versions" >&2
|
||||
printf ' %-7s %s\n' "local" "$local_versions" >&2
|
||||
printf 'regent-deploy: the app may fail to start. Update both machines and retry.\n' >&2
|
||||
fi
|
||||
|
||||
if [ -n "${REGENT_DEPLOY_PKG:-}" ]; then
|
||||
tmp=$(mktemp -d "${TMPDIR:-/tmp}/regent-pkg.XXXXXX")
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
say "building a package on $HOST (this compiles there)"
|
||||
pkg=$(ssh "$HOST" "$REMOTE --pkg")
|
||||
say "fetching $(basename "$pkg")"
|
||||
scp -q "$HOST:$pkg" "$tmp/"
|
||||
say "installing with pacman (needs sudo)"
|
||||
sudo pacman -U --noconfirm "$tmp/$(basename "$pkg")"
|
||||
else
|
||||
say "pulling the install tree into ~/.local"
|
||||
ssh "$HOST" "$REMOTE --emit" | tar -x --zstd -C "$HOME/.local"
|
||||
glib-compile-schemas "$HOME/.local/share/glib-2.0/schemas"
|
||||
update-desktop-database "$HOME/.local/share/applications" >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
if command -v regent >/dev/null; then
|
||||
say "installed: $(regent --version)"
|
||||
else
|
||||
say "installed $HOME/.local/bin/regent"
|
||||
fi
|
||||
@@ -0,0 +1,38 @@
|
||||
# Maintainer: Râu Cao <raucao@kosmos.org>
|
||||
# Development package: builds the local working tree rather than a release
|
||||
# tarball. The released package is `regent` (see the plan), built from a
|
||||
# tarball attached to a Gitea release.
|
||||
pkgname=regent-git
|
||||
pkgver=${REGENT_DEV_PKGVER:-0.0.0}
|
||||
pkgrel=1
|
||||
pkgdesc="Remote signer for Nostr (NIP-46) — development build"
|
||||
arch=('x86_64')
|
||||
url="https://gitea.kosmos.org/raucao/regent"
|
||||
license=('Unlicense')
|
||||
depends=('gtk4' 'libadwaita' 'glib2' 'glibc' 'gcc-libs')
|
||||
makedepends=('cargo' 'meson' 'blueprint-compiler')
|
||||
provides=('regent')
|
||||
conflicts=('regent')
|
||||
source=()
|
||||
sha256sums=()
|
||||
|
||||
# The working tree to build. Set by deploy-dev.sh; the default works when this
|
||||
# package is built in place.
|
||||
_repo="${REGENT_REPO:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)}"
|
||||
_builddir="_build-pkg"
|
||||
|
||||
build() {
|
||||
cd "$_repo"
|
||||
if [ -d "$_builddir" ]; then
|
||||
# Reconfigure instead of wiping so cargo's incremental state survives.
|
||||
meson setup --reconfigure "$_builddir" --prefix=/usr --buildtype=release
|
||||
else
|
||||
meson setup "$_builddir" --prefix=/usr --buildtype=release
|
||||
fi
|
||||
meson compile -C "$_builddir"
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "$_repo"
|
||||
DESTDIR="$pkgdir" meson install -C "$_builddir" --no-rebuild
|
||||
}
|
||||
+41
-9
@@ -7,28 +7,60 @@ mod application;
|
||||
mod config;
|
||||
mod window;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub const APP_ID: &str = "org.kosmos.raucao.Regent";
|
||||
pub const RESOURCE_PATH: &str = "/org/kosmos/raucao/Regent";
|
||||
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
fn main() -> glib::ExitCode {
|
||||
// Answered before the application is built so it works without a display.
|
||||
if std::env::args().skip(1).any(|arg| arg == "--version" || arg == "-V") {
|
||||
println!("{APP_ID} {VERSION}");
|
||||
return glib::ExitCode::SUCCESS;
|
||||
}
|
||||
|
||||
register_resources();
|
||||
application::run()
|
||||
}
|
||||
|
||||
/// Register the UI GResource. Meson installs it as
|
||||
/// `<datadir>/<app-id>/<app-id>.gresource`; `REGENT_GRESOURCE` overrides the
|
||||
/// lookup, which is what development and tests use.
|
||||
/// Directories that may hold an installed copy of the GResource, in the order
|
||||
/// the XDG base directory specification gives them: the user's data home first
|
||||
/// (`~/.local/share`, where a `meson install --prefix=$HOME/.local` lands),
|
||||
/// then the system data directories.
|
||||
fn search_dirs() -> Vec<PathBuf> {
|
||||
let mut dirs = Vec::new();
|
||||
|
||||
let data_home = std::env::var_os("XDG_DATA_HOME")
|
||||
.map(PathBuf::from)
|
||||
.or_else(|| std::env::var_os("HOME").map(|home| PathBuf::from(home).join(".local/share")));
|
||||
if let Some(dir) = data_home {
|
||||
dirs.push(dir);
|
||||
}
|
||||
|
||||
let data_dirs =
|
||||
std::env::var("XDG_DATA_DIRS").unwrap_or_else(|_| "/usr/local/share:/usr/share".to_string());
|
||||
dirs.extend(
|
||||
data_dirs
|
||||
.split(':')
|
||||
.filter(|dir| !dir.is_empty())
|
||||
.map(PathBuf::from),
|
||||
);
|
||||
|
||||
dirs
|
||||
}
|
||||
|
||||
/// Register the UI GResource. `REGENT_GRESOURCE` overrides the lookup, which is
|
||||
/// what development and tests use.
|
||||
fn register_resources() {
|
||||
let file_name = format!("{APP_ID}.gresource");
|
||||
|
||||
let path = std::env::var_os("REGENT_GRESOURCE")
|
||||
.map(std::path::PathBuf::from)
|
||||
.map(PathBuf::from)
|
||||
.or_else(|| {
|
||||
let data_dirs =
|
||||
std::env::var("XDG_DATA_DIRS").unwrap_or_else(|_| "/usr/local/share:/usr/share".to_string());
|
||||
data_dirs
|
||||
.split(':')
|
||||
.map(|dir| std::path::Path::new(dir).join(APP_ID).join(&file_name))
|
||||
search_dirs()
|
||||
.into_iter()
|
||||
.map(|dir| dir.join(APP_ID).join(&file_name))
|
||||
.find(|path| path.exists())
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user