generated from GarandPLG/rust-flake-template
Add Linux packaging workflow and related scripts
Introduce a new CI workflow `.gitea/workflows/packages.yml` that builds deb, rpm, AppImage, Flatpak and AUR packages on push and PR events. Add packaging helpers (`build.sh`, `stage.sh`, spec file, PKGBUILD, desktop entry, SVG icon) and supporting assets under `packaging/`. Update `.gitignore` to ignore the generated `dist` directory. Expand documentation (CODE_MAP, AGENTS, PROGRESS, TESTING and new PACKAGING.md) to describe the packaging process and its limitations. Adjust `src/app/threads/audio.rs` and `tests/audio.rs` imports to support loading audio files from installed package layouts.
This commit is contained in:
1 parent
8ee037ccef
commit
c3dbfe435a
15 files changed
+399
-12
No files matched your search
@@ -0,0 +1,28 @@
|
||||
# Test recipe: CI supplies the source archive from the checked-out commit.
|
||||
pkgname=war-in-tunnels
|
||||
pkgver=0.1.0
|
||||
pkgrel=1
|
||||
pkgdesc='Underground strategy game in your terminal'
|
||||
arch=('x86_64')
|
||||
url='https://gitea.garandplg.com/GarandPLG/war-in-tunnels'
|
||||
license=('MIT')
|
||||
depends=('alsa-lib' 'gcc-libs' 'glibc')
|
||||
makedepends=('cargo' 'pkgconf')
|
||||
options=('!debug')
|
||||
source=("$pkgname-$pkgver.tar.gz")
|
||||
sha256sums=('SKIP')
|
||||
|
||||
build() {
|
||||
cd "$srcdir/$pkgname-$pkgver"
|
||||
cargo build --release --locked
|
||||
}
|
||||
|
||||
check() {
|
||||
cd "$srcdir/$pkgname-$pkgver"
|
||||
cargo test --release --locked
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "$srcdir/$pkgname-$pkgver"
|
||||
sh packaging/stage.sh "$pkgdir/usr"
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
format=${1:?expected deb, rpm, appimage or flatpak}
|
||||
version=$(python3 -c 'import tomllib; print(tomllib.load(open("Cargo.toml", "rb"))["package"]["version"])')
|
||||
mkdir -p dist
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
sh packaging/stage.sh "$work/root/usr"
|
||||
desktop-file-validate "$work/root/usr/share/applications/com.garandplg.WarInTunnels.desktop"
|
||||
"$work/root/usr/bin/war-in-tunnels" --version | grep -Fx "war_in_tunnels $version"
|
||||
test -s "$work/root/usr/lib/war-in-tunnels/soundtracks/default/calm.ogg"
|
||||
|
||||
case "$format" in
|
||||
deb)
|
||||
mkdir -p "$work/root/DEBIAN"
|
||||
cat > "$work/root/DEBIAN/control" <<EOF
|
||||
Package: war-in-tunnels
|
||||
Version: $version
|
||||
Architecture: amd64
|
||||
Maintainer: GarandPLG
|
||||
Depends: libasound2, libc6 (>= 2.36), libgcc-s1
|
||||
Section: games
|
||||
Priority: optional
|
||||
Description: Underground strategy game in your terminal
|
||||
EOF
|
||||
output="$PWD/dist/war-in-tunnels_${version}_amd64.deb"
|
||||
dpkg-deb --root-owner-group --build "$work/root" "$output"
|
||||
dpkg-deb --info "$output"
|
||||
dpkg-deb --extract "$output" "$work/extracted"
|
||||
"$work/extracted/usr/bin/war-in-tunnels" --version
|
||||
;;
|
||||
rpm)
|
||||
rpmbuild -bb packaging/war-in-tunnels.spec \
|
||||
--define "_topdir $work/rpmbuild" \
|
||||
--define "package_version $version" \
|
||||
--define "staging $work/root" \
|
||||
--define '_build_id_links none'
|
||||
cp "$work"/rpmbuild/RPMS/x86_64/*.rpm dist/
|
||||
rpm -qp --requires dist/*.rpm
|
||||
mkdir "$work/extracted"
|
||||
rpm2cpio dist/*.rpm | (cd "$work/extracted" && cpio -idm --quiet)
|
||||
"$work/extracted/usr/bin/war-in-tunnels" --version
|
||||
;;
|
||||
appimage)
|
||||
appdir="$work/WarInTunnels.AppDir"
|
||||
mv "$work/root" "$appdir"
|
||||
cp packaging/com.garandplg.WarInTunnels.desktop "$appdir/"
|
||||
cp packaging/com.garandplg.WarInTunnels.svg "$appdir/"
|
||||
mkdir -p "$appdir/usr/lib/bundled"
|
||||
# Bundle ALSA; glibc and the ELF loader come from the host.
|
||||
cp -L /usr/lib/x86_64-linux-gnu/libasound.so.2 "$appdir/usr/lib/bundled/"
|
||||
cat > "$appdir/AppRun" <<'EOF'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
appdir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||
export LD_LIBRARY_PATH="$appdir/usr/lib/bundled${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
||||
exec "$appdir/usr/bin/war-in-tunnels" "$@"
|
||||
EOF
|
||||
chmod +x "$appdir/AppRun"
|
||||
curl -fL --retry 3 https://github.com/AppImage/appimagetool/releases/download/1.9.1/appimagetool-x86_64.AppImage -o "$work/appimagetool"
|
||||
# Extract without executing the runtime: works without FUSE and with host binfmt handlers.
|
||||
7z x "$work/appimagetool" "-o$work/appimagetool-dir" > /dev/null
|
||||
output="$PWD/dist/war-in-tunnels-${version}-x86_64.AppImage"
|
||||
ARCH=x86_64 "$work/appimagetool-dir/AppRun" --no-appstream "$appdir" "$output"
|
||||
7z x "$output" "-o$work/appimage-check" > /dev/null
|
||||
"$work/appimage-check/AppRun" --version
|
||||
;;
|
||||
flatpak)
|
||||
appid=com.garandplg.WarInTunnels
|
||||
# Package the Debian-built binary against a newer glibc runtime; no nested sandbox is needed.
|
||||
flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
|
||||
flatpak --user install -y --noninteractive --no-related flathub org.freedesktop.Platform//25.08
|
||||
flatpak build-init "$work/flatpak" "$appid" org.freedesktop.Platform org.freedesktop.Platform 25.08
|
||||
cp -a "$work/root/usr/." "$work/flatpak/files/"
|
||||
install -Dm755 /usr/lib/x86_64-linux-gnu/libasound.so.2 "$work/flatpak/files/lib/libasound.so.2"
|
||||
flatpak build-finish --command=war-in-tunnels --socket=pulseaudio --device=all "$work/flatpak"
|
||||
# The icon is repository-owned; its validator cannot create a sandbox in standard Docker.
|
||||
flatpak build-export --disable-sandbox "$work/repo" "$work/flatpak" test
|
||||
output="$PWD/dist/war-in-tunnels-${version}-x86_64.flatpak"
|
||||
flatpak build-bundle --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo "$work/repo" "$output" "$appid" test
|
||||
flatpak --user install -y --noninteractive --no-related "$output"
|
||||
location=$(flatpak --user info --show-location "$appid")
|
||||
test -s "$location/files/lib/war-in-tunnels/soundtracks/default/calm.ogg"
|
||||
"$location/files/bin/war-in-tunnels" --version
|
||||
;;
|
||||
*)
|
||||
echo "Unknown package format: $format" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,8 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=War in Tunnels
|
||||
Comment=Underground strategy game in your terminal
|
||||
Exec=war-in-tunnels
|
||||
Icon=com.garandplg.WarInTunnels
|
||||
Terminal=true
|
||||
Categories=Game;StrategyGame;
|
||||
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
|
||||
<rect width="128" height="128" rx="16" fill="#20252b"/>
|
||||
<path d="M20 104V56a44 44 0 0 1 88 0v48H88V56a24 24 0 0 0-48 0v48Z" fill="#bd985e"/>
|
||||
<path d="M51 91V59l13 15 13-15v32" fill="none" stroke="#e9edf0" stroke-width="7"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 325 B |
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
prefix=${1:?installation prefix required}
|
||||
binary=${2:-target/release/war_in_tunnels}
|
||||
install -Dm755 "$binary" "$prefix/lib/war-in-tunnels/war-in-tunnels"
|
||||
mkdir -p "$prefix/bin"
|
||||
cat > "$prefix/bin/war-in-tunnels" <<'EOF'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
bindir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||
exec "$bindir/../lib/war-in-tunnels/war-in-tunnels" "$@"
|
||||
EOF
|
||||
chmod +x "$prefix/bin/war-in-tunnels"
|
||||
cp -r soundtracks "$prefix/lib/war-in-tunnels/"
|
||||
install -Dm644 LICENSE "$prefix/share/licenses/war-in-tunnels/LICENSE"
|
||||
install -Dm644 packaging/com.garandplg.WarInTunnels.desktop "$prefix/share/applications/com.garandplg.WarInTunnels.desktop"
|
||||
install -Dm644 packaging/com.garandplg.WarInTunnels.svg "$prefix/share/icons/hicolor/scalable/apps/com.garandplg.WarInTunnels.svg"
|
||||
@@ -0,0 +1,21 @@
|
||||
Name: war-in-tunnels
|
||||
Version: %{package_version}
|
||||
Release: 1
|
||||
Summary: Underground strategy game in your terminal
|
||||
License: MIT
|
||||
URL: https://gitea.garandplg.com/GarandPLG/war-in-tunnels
|
||||
Requires: alsa-lib
|
||||
|
||||
%description
|
||||
A terminal-based underground strategy game.
|
||||
|
||||
%install
|
||||
mkdir -p %{buildroot}
|
||||
cp -a %{staging}/. %{buildroot}/
|
||||
|
||||
%files
|
||||
/usr/bin/war-in-tunnels
|
||||
/usr/lib/war-in-tunnels
|
||||
/usr/share/applications/com.garandplg.WarInTunnels.desktop
|
||||
/usr/share/icons/hicolor/scalable/apps/com.garandplg.WarInTunnels.svg
|
||||
%license /usr/share/licenses/war-in-tunnels/LICENSE
|
||||
Reference in new issue
Block a user