Bundle Stockfish 19 with every package and set it up on first start
Some checks are pending
CI / check (push) Waiting to run
CI / windows-build (push) Waiting to run

- packaging/stockfish.sh fetches the pinned official universal build (SHA-256
  checked) for Linux and Windows and the source archive for the release.
- deb/rpm/Arch, AppImage, Flatpak, tarball and Windows zip ship it unmodified
  (AppImage: added after linuxdeploy, packed with appimagetool).
- The app resolves the built-in engine at run time (EngineConfig::builtin),
  adds it on first start (or a system stockfish), and offers engines found on
  the computer in Settings > Engines.
- install.sh installs Stockfish into ~/.local/lib/chesspenguin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vrubel 2026-10-18 11:53:30 +03:00
parent 6db8d67821
commit 56cfb4d09f
22 changed files with 383 additions and 35 deletions

View file

@ -1,5 +1,6 @@
#!/usr/bin/env bash
# Builds ChessPenguin-<version>-x86_64.AppImage from target/release/chesspenguin.
# Builds ChessPenguin-<version>-x86_64.AppImage from target/release/chesspenguin and the
# Stockfish fetched by `packaging/stockfish.sh linux build/stockfish`.
# Usage (repository root): VERSION=0.1.0 packaging/build-appimage.sh dist/
set -euo pipefail
@ -11,7 +12,9 @@ trap 'rm -rf "${work}"' EXIT
curl -fsSL -o "${work}/linuxdeploy" \
https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
chmod +x "${work}/linuxdeploy"
curl -fsSL -o "${work}/appimagetool" \
https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
chmod +x "${work}/linuxdeploy" "${work}/appimagetool"
appdir="${work}/AppDir"
install -Dm755 target/release/chesspenguin "${appdir}/usr/bin/chesspenguin"
@ -21,12 +24,20 @@ for size in 16 24 32 48 64 128 256 512; do
"${appdir}/usr/share/icons/hicolor/${size}x${size}/apps/${app_id}.png"
done
mkdir -p "${out_dir}"
export LINUXDEPLOY_OUTPUT_VERSION="${version}"
export OUTPUT="${out_dir}/ChessPenguin-${version}-x86_64.AppImage"
# 1. linuxdeploy fills the AppDir (dependencies, AppRun, desktop entry, icon).
APPIMAGE_EXTRACT_AND_RUN=1 "${work}/linuxdeploy" \
--appdir "${appdir}" \
--desktop-file "packaging/${app_id}.desktop" \
--icon-file "packaging/icons/hicolor/256x256/apps/${app_id}.png" \
--output appimage
echo "Built ${OUTPUT}"
--icon-file "packaging/icons/hicolor/256x256/apps/${app_id}.png"
# 2. Stockfish is added afterwards: linuxdeploy would rewrite its RUNPATH, and the bundled
# engine must stay the unmodified official binary.
install -Dm755 build/stockfish/stockfish "${appdir}/usr/lib/chesspenguin/stockfish"
install -Dm644 build/stockfish/Copying.txt "${appdir}/usr/share/licenses/chesspenguin/stockfish-Copying.txt"
# 3. appimagetool packs the AppDir as is.
mkdir -p "${out_dir}"
output="${out_dir}/ChessPenguin-${version}-x86_64.AppImage"
ARCH=x86_64 VERSION="${version}" APPIMAGE_EXTRACT_AND_RUN=1 \
"${work}/appimagetool" --no-appstream "${appdir}" "${output}"
echo "Built ${output}"

View file

@ -22,6 +22,16 @@ build-options:
env:
CARGO_HOME: /run/build/chesspenguin/cargo
modules:
# Bundled Stockfish (GPL-3.0). Keep in sync with packaging/stockfish.sh.
- name: stockfish
buildsystem: simple
build-commands:
- install -Dm755 stockfish-linux-x86-64-universal /app/lib/chesspenguin/stockfish
- install -Dm644 Copying.txt /app/share/licenses/chesspenguin/stockfish-Copying.txt
sources:
- type: archive
url: https://github.com/official-stockfish/Stockfish/releases/download/sf_19/stockfish-linux-x86-64-universal.tar.gz
sha256: 9defc0d4e55d49c65a6d042f3e571a39fcea499ade6dbe741b53b8c65e03611f
- name: chesspenguin
buildsystem: simple
build-commands:
@ -38,3 +48,4 @@ modules:
- .flatpak-builder
- pgnFilesforExample
- engines
- build

View file

@ -1,4 +1,5 @@
# deb and rpm packages (https://nfpm.goreleaser.com). Run from the repository root:
# deb, rpm and Arch packages (https://nfpm.goreleaser.com). Run from the repository root:
# packaging/stockfish.sh linux build/stockfish
# VERSION=0.1.0 nfpm package -f packaging/nfpm.yaml -p deb -t dist/ (deb, rpm, archlinux)
name: chesspenguin
arch: amd64
@ -12,8 +13,9 @@ homepage: https://github.com/vrubelroman/chessPenguin
license: GPL-3.0-or-later
description: |
Chess database for Linux.
View, enter and analyse chess games in PGN with any UCI engine
(Stockfish and others): variations, comments, multi-line analysis.
View, enter and analyse chess games in PGN: variations, comments,
multi-line engine analysis and whole-game review. Stockfish is included;
any other UCI engine can be added.
contents:
- src: target/release/chesspenguin
@ -47,6 +49,15 @@ contents:
dst: /usr/share/doc/chesspenguin/THIRD_PARTY_NOTICES.md
- src: examples/classics.pgn
dst: /usr/share/doc/chesspenguin/examples/classics.pgn
# Bundled Stockfish (GPL-3.0); the application looks for it in ../lib/chesspenguin.
- src: build/stockfish/stockfish
dst: /usr/lib/chesspenguin/stockfish
file_info:
mode: 0755
- src: build/stockfish/Copying.txt
dst: /usr/share/licenses/chesspenguin/stockfish-Copying.txt
- src: build/stockfish/AUTHORS
dst: /usr/share/doc/chesspenguin/stockfish-AUTHORS
overrides:
deb:

65
packaging/stockfish.sh Executable file
View file

@ -0,0 +1,65 @@
#!/usr/bin/env bash
# Fetches the official Stockfish release bundled with ChessPenguin and checks its SHA-256.
#
# packaging/stockfish.sh linux dist/stockfish -> stockfish, Copying.txt, AUTHORS
# packaging/stockfish.sh windows dist/stockfish -> stockfish.exe, Copying.txt, AUTHORS
# packaging/stockfish.sh source dist -> stockfish-<tag>-source.tar.gz (GPL source offer)
#
# The "universal" builds pick the code path for the CPU at run time (x86-64 up to AVX-512),
# so one binary serves every machine. When updating, also update the archive URL and
# sha256 in packaging/flatpak/io.github.vrubelroman.chessPenguin.yml.
set -euo pipefail
tag="sf_19"
base="https://github.com/official-stockfish/Stockfish/releases/download/${tag}"
linux_asset="stockfish-linux-x86-64-universal.tar.gz"
linux_sha256="9defc0d4e55d49c65a6d042f3e571a39fcea499ade6dbe741b53b8c65e03611f"
windows_asset="stockfish-windows-x86-64-universal.zip"
windows_sha256="3c8bf1f9ea66a09350a40df4f632288285ac206d99f33ab5842c408fc30b48a7"
target="${1:?usage: $0 linux|windows|source OUT_DIR}"
out="${2:?usage: $0 linux|windows|source OUT_DIR}"
mkdir -p "${out}"
work="$(mktemp -d)"
trap 'rm -rf "${work}"' EXIT
fetch() { # asset sha256
curl -fsSL --retry 3 -o "${work}/$1" "${base}/$1"
echo "$2 ${work}/$1" | sha256sum -c --quiet -
}
# Copies the engine executable matching a glob plus the license files from an unpacked release.
install_from() { # dir glob dest_name
local exe
exe="$(find "$1" -type f -name "$2" | head -n1)"
[[ -n "${exe}" ]] || { echo "stockfish.sh: no $2 in the archive" >&2; exit 1; }
install -m755 "${exe}" "${out}/$3"
for f in Copying.txt AUTHORS; do
local src
src="$(find "$1" -type f -name "${f}" | head -n1)"
[[ -n "${src}" ]] && install -m644 "${src}" "${out}/${f}"
done
}
case "${target}" in
linux)
fetch "${linux_asset}" "${linux_sha256}"
tar -xzf "${work}/${linux_asset}" -C "${work}"
install_from "${work}" "stockfish-linux-x86-64*" stockfish
;;
windows)
fetch "${windows_asset}" "${windows_sha256}"
python3 -m zipfile -e "${work}/${windows_asset}" "${work}/x" 2>/dev/null \
|| python -m zipfile -e "${work}/${windows_asset}" "${work}/x"
install_from "${work}/x" "stockfish-windows-x86-64*.exe" stockfish.exe
;;
source)
curl -fsSL --retry 3 -o "${out}/stockfish-${tag}-source.tar.gz" \
"https://github.com/official-stockfish/Stockfish/archive/refs/tags/${tag}.tar.gz"
;;
*)
echo "usage: $0 linux|windows|source OUT_DIR" >&2
exit 2
;;
esac
echo "Stockfish ${tag} (${target}) -> ${out}"