mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Stage a separate Nightly launch wrapper for Arch packages
This commit is contained in:
1 parent
73079f861b
commit
fa6843e311
4 files changed
+105
-1
No files matched your search
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
real_bin="$(dirname "$0")/.photocraft-nightly/photocraft"
|
||||
if [ "${1:-}" = "--version" ] || [ "${1:-}" = "-V" ] || [ "${1:-}" = "--launch-profile" ]; then
|
||||
exec "$real_bin" "$@"
|
||||
fi
|
||||
profile_base="${XDG_DATA_HOME:-${HOME:?HOME is required}/.local/share}"
|
||||
exec "$real_bin" --launch-profile nightly-v1 --profile-root "$profile_base/photocraft-nightly" -- "$@"
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
# Validate the staged Arch launcher without building or opening PhotoCraft.
|
||||
set -euo pipefail
|
||||
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
work="$(mktemp -d)"
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
stage="$work/source"
|
||||
dst="$work/dist"
|
||||
base=photocraft-0.0.1-nightly.1-linux-x86_64
|
||||
mkdir -p "$stage/bin" "$dst" "$work/extract"
|
||||
|
||||
# A local argv recorder stands in for the compiled binaries. It never opens a UI.
|
||||
cat >"$stage/bin/photocraft" <<'RECORDER'
|
||||
#!/bin/sh
|
||||
printf '<%s>\n' "$@"
|
||||
RECORDER
|
||||
chmod 755 "$stage/bin/photocraft"
|
||||
cp "$stage/bin/photocraft" "$stage/bin/photocraft-cli"
|
||||
|
||||
bash "$HERE/nightly-arch-tar.sh" "$stage" "$work/stage" "$dst" "$base"
|
||||
tar -xzf "$dst/$base.tar.gz" -C "$work/extract"
|
||||
bin="$work/extract/$base/bin"
|
||||
# Simulate the existing Arch bin-tree copy and public launcher rename.
|
||||
mkdir -p "$work/installed"
|
||||
cp -R "$bin" "$work/installed/bin"
|
||||
bin="$work/installed/bin"
|
||||
mv "$bin/photocraft" "$bin/photocraft-nightly"
|
||||
mv "$bin/photocraft-cli" "$bin/photocraft-nightly-cli"
|
||||
|
||||
test ! -e "$stage/bin/.photocraft-nightly"
|
||||
cmp "$stage/bin/photocraft" "$bin/.photocraft-nightly/photocraft"
|
||||
cmp "$stage/bin/photocraft-cli" "$bin/photocraft-nightly-cli"
|
||||
export HOME="$work/home with space"
|
||||
unset XDG_DATA_HOME
|
||||
expect() {
|
||||
expected="$1"
|
||||
shift
|
||||
actual=$(PATH="$bin:$PATH" photocraft-nightly "$@")
|
||||
if [[ "$actual" != "$expected" ]]; then
|
||||
printf 'expected:\n%s\nactual:\n%s\n' "$expected" "$actual" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
expect "$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$HOME/.local/share/photocraft-nightly" --)"
|
||||
export XDG_DATA_HOME="$work/xdg with space"
|
||||
expect "$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$XDG_DATA_HOME/photocraft-nightly" -- 'image with spaces.psd' '--other-name.psd')" \
|
||||
'image with spaces.psd' '--other-name.psd'
|
||||
expect '<--version>' --version
|
||||
expect '<-V>' -V
|
||||
expect "$(printf '<%s>\n' --launch-profile nightly-v1 --profile-root "$work/explicit with space" -- sample.psd)" \
|
||||
--launch-profile nightly-v1 --profile-root "$work/explicit with space" -- sample.psd
|
||||
|
||||
echo "PASS: Arch Nightly handoff isolates the profile and preserves launch arguments"
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
# Stage the PhotoCraft Nightly-only handoff for the Arch packager.
|
||||
set -euo pipefail
|
||||
|
||||
here="$(cd "$(dirname "$0")" && pwd)"
|
||||
source_tree="$1"
|
||||
work="$2"
|
||||
destination="$3"
|
||||
basename="$4"
|
||||
stage="$work/$basename"
|
||||
|
||||
mkdir -p "$work"
|
||||
cp -R "$source_tree" "$stage"
|
||||
mkdir "$stage/bin/.photocraft-nightly"
|
||||
mv "$stage/bin/photocraft" "$stage/bin/.photocraft-nightly/photocraft"
|
||||
cp "$here/nightly-arch-launch.sh" "$stage/bin/photocraft"
|
||||
chmod 755 "$stage/bin/photocraft"
|
||||
tar -C "$work" -czf "$destination/$basename.tar.gz" "$basename"
|
||||
echo "wrote $destination/$basename.tar.gz"
|
||||
@@ -7,7 +7,7 @@
|
||||
# $DIST/photocraft-<version>-linux-<arch>.rpm Fedora, openSUSE, RHEL, ...
|
||||
# $DIST/photocraft-<version>-linux-<arch>.tar.gz plain FHS-style tree (bin/, share/)
|
||||
#
|
||||
# Usage: packaging/linux/package.sh [--skip-build] [--formats "appimage deb rpm tar"]
|
||||
# Usage: packaging/linux/package.sh [--skip-build] [--formats "appimage deb rpm tar"] [--arch-tar-dir DIRECTORY]
|
||||
#
|
||||
# Needs: cargo; nfpm for deb/rpm (https://nfpm.goreleaser.com). By default AppImage tooling
|
||||
# is downloaded at verified pins into $CARGO_TARGET_DIR. Build on an old distro (CI: Ubuntu 22.04,
|
||||
@@ -27,10 +27,16 @@ APP_ID=ai.storyteller.photocraft
|
||||
|
||||
SKIP_BUILD=0
|
||||
FORMATS="appimage deb rpm tar"
|
||||
ARCH_TAR_DIR=
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--skip-build) SKIP_BUILD=1; shift ;;
|
||||
--formats) FORMATS="$2"; shift 2 ;;
|
||||
--arch-tar-dir)
|
||||
[[ -n "${2:-}" ]] || { echo "error: --arch-tar-dir needs a directory" >&2; exit 2; }
|
||||
ARCH_TAR_DIR="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h | --help) sed -n '2,19p' "$0"; exit 0 ;;
|
||||
*) echo "unknown argument: $1" >&2; exit 2 ;;
|
||||
esac
|
||||
@@ -52,6 +58,11 @@ if [[ "${PHOTOCRAFT_BUILD_CHANNEL:-}" == nightly-v1 || "$VERSION" == *-nightly*
|
||||
fi
|
||||
BASENAME="photocraft-$VERSION-linux-$ARCH"
|
||||
|
||||
if [[ -n "$ARCH_TAR_DIR" && "$IS_NIGHTLY" != 1 ]]; then
|
||||
echo "error: --arch-tar-dir is only for Nightly builds" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
echo "==> PhotoCraft $VERSION for Linux $ARCH ($FORMATS, channel=${PHOTOCRAFT_BUILD_CHANNEL:-stable})"
|
||||
|
||||
# The man-and-completions example writes photocraft-cli's man pages and shell completions below. It
|
||||
@@ -130,6 +141,17 @@ if has tar; then
|
||||
echo "wrote $DIST/$BASENAME.tar.gz"
|
||||
fi
|
||||
|
||||
# The Arch handoff keeps the same basename as the plain tarball in a separate directory.
|
||||
# Flatpak, OCI and direct tar consumers still get the original binary, not this launcher.
|
||||
if [[ -n "$ARCH_TAR_DIR" ]]; then
|
||||
mkdir -p "$ARCH_TAR_DIR"
|
||||
if [[ "$(cd "$ARCH_TAR_DIR" && pwd -P)" == "$(cd "$DIST" && pwd -P)" ]]; then
|
||||
echo "error: the Arch tar directory must differ from the release directory" >&2
|
||||
exit 2
|
||||
fi
|
||||
bash "$HERE/nightly-arch-tar.sh" "$STAGE/usr" "$WORK/arch-tar" "$ARCH_TAR_DIR" "$BASENAME"
|
||||
fi
|
||||
|
||||
# ---- .deb / .rpm --------------------------------------------------------------------------------
|
||||
if has deb || has rpm; then
|
||||
command -v nfpm >/dev/null || { echo "error: nfpm not found (https://nfpm.goreleaser.com/install/)" >&2; exit 1; }
|
||||
|
||||
Reference in new issue
Block a user