diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-01 21:35:30 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-01 21:38:36 +0100 |
| commit | 7830b3c5e89f0339949940b8986bf4849ad7f223 (patch) | |
| tree | d4ebb4f10583cef1da3b181e093dd5d65ac8a0bb /scripts/installers | |
| parent | v4.2.1: plain-language game copy and a balance fetch on login (diff) | |
| download | zagan-bet-7830b3c5e89f0339949940b8986bf4849ad7f223.tar.gz zagan-bet-7830b3c5e89f0339949940b8986bf4849ad7f223.zip | |
v4.3.0: package the desktop app with verifiable installers
publish.sh builds the GUI with the gui-release profile, names it zagan-bet-gui-<version>-<platform>-<arch>, and renders a bash and a PowerShell installer next to each app. Both embed the app's SHA-256, verify the file (or fetch it), install per-user and add a launcher: a desktop entry plus an SVG icon on Linux, a Start-menu shortcut on Windows.
The download page gains a Desktop app section with the apps and installers, keeps the terminal client and server, links the public git repository for the GPL source, and lists every file in the sha256sum block. deploy.sh verifies all four artifact kinds. Publishing refuses a dirty tree so the linked history matches the binaries.
Diffstat (limited to '')
| -rw-r--r-- | scripts/installers/linux.sh.in | 78 | ||||
| -rw-r--r-- | scripts/installers/windows.ps1.in | 75 |
2 files changed, 153 insertions, 0 deletions
diff --git a/scripts/installers/linux.sh.in b/scripts/installers/linux.sh.in new file mode 100644 index 0000000..5b53c02 --- /dev/null +++ b/scripts/installers/linux.sh.in | |||
| @@ -0,0 +1,78 @@ | |||
| 1 | #!/usr/bin/env bash | ||
| 2 | # Zagan-Bet desktop installer for Linux. | ||
| 3 | # | ||
| 4 | # Verifies the app against its published SHA-256, installs it for the current | ||
| 5 | # user and adds a launcher. Put the downloaded app next to this script, or run | ||
| 6 | # the script on its own and it will fetch the matching binary. | ||
| 7 | set -euo pipefail | ||
| 8 | |||
| 9 | VERSION="__VERSION__" | ||
| 10 | BINARY="__BINARY__" | ||
| 11 | SHA256="__SHA256__" | ||
| 12 | URL="__URL__" | ||
| 13 | |||
| 14 | say() { printf '%s\n' "$*"; } | ||
| 15 | die() { printf 'install: %s\n' "$*" >&2; exit 1; } | ||
| 16 | |||
| 17 | command -v sha256sum >/dev/null 2>&1 || die "sha256sum is required" | ||
| 18 | |||
| 19 | here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | ||
| 20 | source_file="" | ||
| 21 | for candidate in "$here/$BINARY" "./$BINARY" "$HOME/Downloads/$BINARY"; do | ||
| 22 | if [ -f "$candidate" ]; then | ||
| 23 | source_file=$candidate | ||
| 24 | break | ||
| 25 | fi | ||
| 26 | done | ||
| 27 | |||
| 28 | cleanup="" | ||
| 29 | if [ -z "$source_file" ]; then | ||
| 30 | command -v curl >/dev/null 2>&1 || die "put $BINARY next to this installer, or install curl" | ||
| 31 | cleanup=$(mktemp) || die "cannot create a temporary file" | ||
| 32 | say "Downloading $BINARY..." | ||
| 33 | curl -fsSL --max-time 300 "$URL" -o "$cleanup" || die "download failed" | ||
| 34 | source_file=$cleanup | ||
| 35 | fi | ||
| 36 | trap 'if [ -n "$cleanup" ]; then rm -f "$cleanup"; fi' EXIT | ||
| 37 | |||
| 38 | actual=$(sha256sum "$source_file" | awk '{print $1}') | ||
| 39 | [ "$actual" = "$SHA256" ] || die "checksum mismatch: expected $SHA256, got $actual" | ||
| 40 | |||
| 41 | bin_dir="${XDG_BIN_HOME:-$HOME/.local/bin}" | ||
| 42 | data_dir="${XDG_DATA_HOME:-$HOME/.local/share}" | ||
| 43 | app="$bin_dir/zagan-bet-gui" | ||
| 44 | desktop_dir="$data_dir/applications" | ||
| 45 | icon_dir="$data_dir/icons/hicolor/scalable/apps" | ||
| 46 | |||
| 47 | mkdir -p "$bin_dir" "$desktop_dir" "$icon_dir" | ||
| 48 | install -m 0755 "$source_file" "$app" | ||
| 49 | |||
| 50 | cat > "$icon_dir/zagan-bet.svg" <<'ICON' | ||
| 51 | __ICON__ | ||
| 52 | ICON | ||
| 53 | |||
| 54 | cat > "$desktop_dir/zagan-bet.desktop" <<DESKTOP | ||
| 55 | [Desktop Entry] | ||
| 56 | Type=Application | ||
| 57 | Name=Zagan-Bet | ||
| 58 | Comment=Slots, roulette, blackjack and crash | ||
| 59 | Exec=$app | ||
| 60 | Icon=zagan-bet | ||
| 61 | Terminal=false | ||
| 62 | Categories=Game; | ||
| 63 | DESKTOP | ||
| 64 | chmod 0644 "$desktop_dir/zagan-bet.desktop" "$icon_dir/zagan-bet.svg" | ||
| 65 | |||
| 66 | if command -v update-desktop-database >/dev/null 2>&1; then | ||
| 67 | update-desktop-database "$desktop_dir" >/dev/null 2>&1 || true | ||
| 68 | fi | ||
| 69 | if command -v gtk-update-icon-cache >/dev/null 2>&1; then | ||
| 70 | gtk-update-icon-cache -q "$data_dir/icons/hicolor" >/dev/null 2>&1 || true | ||
| 71 | fi | ||
| 72 | |||
| 73 | say "Installed Zagan-Bet $VERSION to $app" | ||
| 74 | say "A launcher was added to your applications menu." | ||
| 75 | case ":$PATH:" in | ||
| 76 | *":$bin_dir:"*) ;; | ||
| 77 | *) say "Add $bin_dir to PATH to start it as 'zagan-bet-gui'." ;; | ||
| 78 | esac | ||
diff --git a/scripts/installers/windows.ps1.in b/scripts/installers/windows.ps1.in new file mode 100644 index 0000000..fd2b8b3 --- /dev/null +++ b/scripts/installers/windows.ps1.in | |||
| @@ -0,0 +1,75 @@ | |||
| 1 | # Zagan-Bet desktop installer for Windows. | ||
| 2 | # | ||
| 3 | # Verifies the app against its published SHA-256, installs it for the current | ||
| 4 | # user and adds a Start-menu shortcut. Put the downloaded app next to this | ||
| 5 | # script, or run the script on its own and it will fetch the matching binary. | ||
| 6 | # | ||
| 7 | # Run it with: | ||
| 8 | # powershell -ExecutionPolicy Bypass -File .\zagan-bet-gui-*-install.ps1 | ||
| 9 | $ErrorActionPreference = "Stop" | ||
| 10 | |||
| 11 | $Version = "__VERSION__" | ||
| 12 | $Binary = "__BINARY__" | ||
| 13 | $Sha256 = "__SHA256__" | ||
| 14 | $Url = "__URL__" | ||
| 15 | |||
| 16 | function Stop-Install([string]$Message) { | ||
| 17 | Write-Host "install: $Message" -ForegroundColor Red | ||
| 18 | exit 1 | ||
| 19 | } | ||
| 20 | |||
| 21 | $here = Split-Path -Parent $MyInvocation.MyCommand.Path | ||
| 22 | $candidates = @( | ||
| 23 | (Join-Path $here $Binary), | ||
| 24 | (Join-Path (Get-Location) $Binary), | ||
| 25 | (Join-Path $env:USERPROFILE "Downloads\$Binary") | ||
| 26 | ) | ||
| 27 | $sourceFile = $null | ||
| 28 | foreach ($candidate in $candidates) { | ||
| 29 | if (Test-Path -LiteralPath $candidate) { | ||
| 30 | $sourceFile = $candidate | ||
| 31 | break | ||
| 32 | } | ||
| 33 | } | ||
| 34 | |||
| 35 | $temporary = $null | ||
| 36 | if (-not $sourceFile) { | ||
| 37 | $temporary = Join-Path ([System.IO.Path]::GetTempPath()) $Binary | ||
| 38 | Write-Host "Downloading $Binary..." | ||
| 39 | try { | ||
| 40 | Invoke-WebRequest -Uri $Url -OutFile $temporary -UseBasicParsing | ||
| 41 | } catch { | ||
| 42 | Stop-Install "download failed: $_" | ||
| 43 | } | ||
| 44 | $sourceFile = $temporary | ||
| 45 | } | ||
| 46 | |||
| 47 | try { | ||
| 48 | $actual = (Get-FileHash -LiteralPath $sourceFile -Algorithm SHA256).Hash.ToLowerInvariant() | ||
| 49 | if ($actual -ne $Sha256.ToLowerInvariant()) { | ||
| 50 | Stop-Install "checksum mismatch: expected $Sha256, got $actual" | ||
| 51 | } | ||
| 52 | |||
| 53 | $installDir = Join-Path $env:LOCALAPPDATA "Programs\Zagan-Bet" | ||
| 54 | New-Item -ItemType Directory -Force -Path $installDir | Out-Null | ||
| 55 | $target = Join-Path $installDir "zagan-bet-gui.exe" | ||
| 56 | Copy-Item -LiteralPath $sourceFile -Destination $target -Force | ||
| 57 | |||
| 58 | $startMenu = Join-Path $env:APPDATA "Microsoft\Windows\Start Menu\Programs" | ||
| 59 | New-Item -ItemType Directory -Force -Path $startMenu | Out-Null | ||
| 60 | $shortcutPath = Join-Path $startMenu "Zagan-Bet.lnk" | ||
| 61 | $shell = New-Object -ComObject WScript.Shell | ||
| 62 | $shortcut = $shell.CreateShortcut($shortcutPath) | ||
| 63 | $shortcut.TargetPath = $target | ||
| 64 | $shortcut.WorkingDirectory = $installDir | ||
| 65 | $shortcut.IconLocation = "$target,0" | ||
| 66 | $shortcut.Description = "Slots, roulette, blackjack and crash" | ||
| 67 | $shortcut.Save() | ||
| 68 | |||
| 69 | Write-Host "Installed Zagan-Bet $Version to $target" | ||
| 70 | Write-Host "A Start-menu shortcut was created." | ||
| 71 | } finally { | ||
| 72 | if ($temporary -and (Test-Path -LiteralPath $temporary)) { | ||
| 73 | Remove-Item -LiteralPath $temporary -Force | ||
| 74 | } | ||
| 75 | } | ||
