build: add portable desktop packages

This commit is contained in:
2026-07-13 22:29:58 +08:00
parent f4e911c14a
commit 20952e8477
20 changed files with 476 additions and 34 deletions
+31
View File
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
OFFICIAL_PLUGINS="${VERSTAK_OFFICIAL_PLUGINS_DIR:-$ROOT/../verstak-official-plugins}"
OUTPUT="${VERSTAK_LINUX_BUNDLE_DIR:-$ROOT/build/linux-amd64}"
if [[ ! -d "$OFFICIAL_PLUGINS" ]]; then
echo "official plugins repository not found: $OFFICIAL_PLUGINS" >&2
exit 1
fi
echo "=== verstak desktop Linux amd64 bundle ==="
(cd "$OFFICIAL_PLUGINS" && ./scripts/build.sh)
"$ROOT/scripts/install-dev-plugins.sh"
"$ROOT/scripts/build.sh"
BINARY="$ROOT/build/bin/verstak-desktop"
if [[ ! -x "$BINARY" ]]; then
echo "desktop binary was not produced: $BINARY" >&2
exit 1
fi
rm -rf "$OUTPUT"
mkdir -p "$OUTPUT"
install -m 755 "$BINARY" "$OUTPUT/verstak-desktop"
install -m 644 "$ROOT/README.md" "$ROOT/LICENSE" "$OUTPUT/"
cp -R "$ROOT/plugins" "$OUTPUT/plugins"
chmod -R a+rX "$OUTPUT/plugins"
echo "Linux bundle: $OUTPUT"
+6 -3
View File
@@ -53,9 +53,12 @@ if [[ ! -d "$WINDOWS_PLUGIN_DIST" ]]; then
exit 1
fi
# Wails generates Windows resources and invokes the supplied MinGW compiler.
# -clean resets build/bin, so copy the finished executable only afterwards.
"$WAILS" build -clean -platform windows/amd64 -compiler "$WINDOWS_CC" -o verstak-desktop.exe
# Wails' -compiler option selects a Go binary, not a C compiler. Cross-CGO
# therefore has to be supplied through the standard Go environment instead.
# The runtime is bundled by package-windows-portable.sh, so never compile an
# Evergreen downloader into the portable executable.
CC="$WINDOWS_CC" CGO_ENABLED=1 "$WAILS" build -clean -platform windows/amd64 \
-webview2 error -o verstak-desktop.exe
WINDOWS_BINARY="$ROOT/build/bin/verstak-desktop.exe"
if [[ ! -f "$WINDOWS_BINARY" ]]; then
+118
View File
@@ -0,0 +1,118 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
VERSION="${1:-}"
APPIMAGETOOL_URL="${APPIMAGETOOL_URL:-https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage}"
if [[ -z "$VERSION" || ! "$VERSION" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]]; then
echo "usage: $0 <version>" >&2
echo "example: $0 v0.1.0-alpha.1" >&2
exit 2
fi
if ! command -v ldd >/dev/null || ! command -v file >/dev/null; then
echo "ldd and file are required to bundle AppImage runtime libraries" >&2
exit 1
fi
"$ROOT/scripts/build-linux-bundle.sh"
APPIMAGETOOL="${APPIMAGETOOL_BIN:-$ROOT/build/tools/appimagetool-x86_64.AppImage}"
if [[ ! -x "$APPIMAGETOOL" ]]; then
if ! command -v curl >/dev/null; then
echo "appimagetool is missing; install curl or set APPIMAGETOOL_BIN" >&2
exit 1
fi
mkdir -p "$(dirname "$APPIMAGETOOL")"
curl --fail --location --show-error "$APPIMAGETOOL_URL" -o "$APPIMAGETOOL"
chmod +x "$APPIMAGETOOL"
fi
BUNDLE="${VERSTAK_LINUX_BUNDLE_DIR:-$ROOT/build/linux-amd64}"
APPDIR="$ROOT/build/appimage/AppDir"
RELEASE_ROOT="$ROOT/release"
ARCHIVE="$RELEASE_ROOT/verstak-linux-x86_64-$VERSION.AppImage"
WEBKIT_RUNTIME_DIR="${VERSTAK_WEBKIT_RUNTIME_DIR:-/usr/lib/x86_64-linux-gnu/webkit2gtk-4.1}"
if [[ ! -d "$WEBKIT_RUNTIME_DIR" ]] || [[ ! -x "$WEBKIT_RUNTIME_DIR/WebKitWebProcess" ]]; then
echo "WebKitWebProcess was not found at $WEBKIT_RUNTIME_DIR" >&2
echo "Set VERSTAK_WEBKIT_RUNTIME_DIR to the WebKitGTK 4.1 runtime directory." >&2
exit 1
fi
rm -rf "$APPDIR" "$ARCHIVE"
mkdir -p "$APPDIR/usr/bin" "$APPDIR/usr/lib" "$APPDIR/usr/share/applications" \
"$APPDIR/usr/share/icons/hicolor/scalable/apps"
install -m 755 "$ROOT/packaging/linux/AppRun" "$APPDIR/AppRun"
install -m 755 "$BUNDLE/verstak-desktop" "$APPDIR/usr/bin/verstak-desktop"
install -m 644 "$ROOT/packaging/linux/verstak.desktop" "$APPDIR/verstak.desktop"
install -m 644 "$ROOT/packaging/linux/verstak.desktop" "$APPDIR/usr/share/applications/verstak.desktop"
install -m 644 "$ROOT/packaging/linux/verstak.svg" "$APPDIR/verstak.svg"
install -m 644 "$ROOT/packaging/linux/verstak.svg" "$APPDIR/usr/share/icons/hicolor/scalable/apps/verstak.svg"
cp -R "$BUNDLE/plugins" "$APPDIR/usr/bin/plugins"
cp -a "$WEBKIT_RUNTIME_DIR" "$APPDIR/usr/lib/webkit2gtk-4.1"
copy_runtime_dir() {
local source="$1"
local target="$2"
if [[ -d "$source" ]]; then
mkdir -p "$target"
cp -a "$source/." "$target/"
fi
}
copy_runtime_dir /usr/lib/x86_64-linux-gnu/gio/modules "$APPDIR/usr/lib/gio/modules"
copy_runtime_dir /usr/lib/x86_64-linux-gnu/gstreamer-1.0 "$APPDIR/usr/lib/gstreamer-1.0"
copy_runtime_dir /usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0 "$APPDIR/usr/lib/gdk-pixbuf-2.0"
copy_runtime_dir /usr/share/glib-2.0/schemas "$APPDIR/usr/share/glib-2.0/schemas"
declare -A queued=()
queue_elf() {
local candidate="$1"
[[ -f "$candidate" ]] || return
if [[ "$(file --brief "$candidate")" != *ELF* ]]; then
return
fi
if [[ -z "${queued[$candidate]:-}" ]]; then
queued[$candidate]=1
printf '%s\n' "$candidate" >> "$APPDIR/.elf-queue"
fi
}
queue_elf "$APPDIR/usr/bin/verstak-desktop"
while IFS= read -r candidate; do
queue_elf "$candidate"
done < <(find "$APPDIR/usr/lib/webkit2gtk-4.1" "$APPDIR/usr/lib/gio/modules" \
"$APPDIR/usr/lib/gstreamer-1.0" "$APPDIR/usr/lib/gdk-pixbuf-2.0" -type f)
while IFS= read -r candidate; do
if ldd "$candidate" | grep -q 'not found'; then
echo "unresolved shared library in $candidate" >&2
exit 1
fi
while IFS= read -r library; do
case "$(basename "$library")" in
libc.so.6|libm.so.6|libpthread.so.0|librt.so.1|libdl.so.2|ld-linux-x86-64.so.2)
continue
;;
esac
bundled="$APPDIR/usr/lib/$(basename "$library")"
if [[ ! -e "$bundled" ]]; then
cp -aL "$library" "$bundled"
fi
queue_elf "$bundled"
done < <(ldd "$candidate" | awk '/=> \/[^ ]+/ { print $3 } /^\// { print $1 }')
done < "$APPDIR/.elf-queue"
rm -f "$APPDIR/.elf-queue"
if command -v glib-compile-schemas >/dev/null; then
glib-compile-schemas "$APPDIR/usr/share/glib-2.0/schemas"
fi
mkdir -p "$RELEASE_ROOT"
ARCH=x86_64 APPIMAGE_EXTRACT_AND_RUN=1 "$APPIMAGETOOL" "$APPDIR" "$ARCHIVE"
(cd "$RELEASE_ROOT" && find . -maxdepth 1 -type f \( -name '*.deb' -o -name '*.AppImage' -o -name '*.zip' \) \
-printf '%f\n' | LC_ALL=C sort | xargs -r sha256sum > SHA256SUMS)
echo "AppImage: $ARCHIVE"
echo "checksums: $RELEASE_ROOT/SHA256SUMS"
+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
VERSION="${1:-}"
if [[ -z "$VERSION" || ! "$VERSION" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]]; then
echo "usage: $0 <version>" >&2
echo "example: $0 v0.1.0-alpha.1" >&2
exit 2
fi
if ! command -v dpkg-deb >/dev/null; then
echo "dpkg-deb is required to create a Debian package" >&2
exit 1
fi
"$ROOT/scripts/build-linux-bundle.sh"
PACKAGE_VERSION="${VERSION#v}"
BUNDLE="${VERSTAK_LINUX_BUNDLE_DIR:-$ROOT/build/linux-amd64}"
STAGING="$ROOT/build/deb/verstak_$PACKAGE_VERSION"
RELEASE_ROOT="$ROOT/release"
ARCHIVE="$RELEASE_ROOT/verstak_${PACKAGE_VERSION}_amd64.deb"
rm -rf "$STAGING" "$ARCHIVE"
mkdir -p "$STAGING/DEBIAN" "$STAGING/opt/verstak" "$STAGING/usr/bin" \
"$STAGING/usr/share/applications" "$STAGING/usr/share/icons/hicolor/scalable/apps" \
"$STAGING/usr/share/doc/verstak"
sed "s/@VERSION@/$PACKAGE_VERSION/g" "$ROOT/packaging/deb/control" > "$STAGING/DEBIAN/control"
install -m 755 "$ROOT/packaging/deb/verstak" "$STAGING/usr/bin/verstak"
install -m 755 "$BUNDLE/verstak-desktop" "$STAGING/opt/verstak/verstak-desktop"
install -m 644 "$BUNDLE/README.md" "$BUNDLE/LICENSE" "$STAGING/usr/share/doc/verstak/"
install -m 644 "$ROOT/packaging/linux/verstak.desktop" "$STAGING/usr/share/applications/verstak.desktop"
install -m 644 "$ROOT/packaging/linux/verstak.svg" "$STAGING/usr/share/icons/hicolor/scalable/apps/verstak.svg"
cp -R "$BUNDLE/plugins" "$STAGING/opt/verstak/plugins"
mkdir -p "$RELEASE_ROOT"
dpkg-deb --root-owner-group --build "$STAGING" "$ARCHIVE"
(cd "$RELEASE_ROOT" && find . -maxdepth 1 -type f \( -name '*.deb' -o -name '*.AppImage' -o -name '*.zip' \) \
-printf '%f\n' | LC_ALL=C sort | xargs -r sha256sum > SHA256SUMS)
echo "Debian package: $ARCHIVE"
echo "checksums: $RELEASE_ROOT/SHA256SUMS"
+77
View File
@@ -0,0 +1,77 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
VERSION="${1:-}"
WEBVIEW2_CAB="${VERSTAK_WEBVIEW2_CAB:-}"
WEBVIEW2_URL="${VERSTAK_WEBVIEW2_URL:-}"
if [[ -z "$VERSION" || ! "$VERSION" =~ ^[A-Za-z0-9][A-Za-z0-9._-]*$ ]]; then
echo "usage: $0 <version>" >&2
echo "example: $0 v0.1.0-alpha.1" >&2
exit 2
fi
for command in cabextract curl python3 zip; do
if ! command -v "$command" >/dev/null; then
echo "$command is required to create the Windows portable archive" >&2
exit 1
fi
done
if [[ -z "$WEBVIEW2_CAB" ]]; then
if [[ -z "$WEBVIEW2_URL" ]]; then
WEBVIEW2_URL="$(python3 - <<'PY'
import re
import sys
import urllib.request
with urllib.request.urlopen('https://developer.microsoft.com/en-us/microsoft-edge/webview2/', timeout=30) as response:
page = response.read().decode('utf-8')
page = page.replace(r'\u002F', '/')
match = re.search(r'"x64","(https://[^\"]+Microsoft\.WebView2\.FixedVersionRuntime[^\"]+\.x64\.cab)"', page)
if not match:
sys.exit('could not locate the x64 FixedVersionRuntime CAB on the Microsoft WebView2 download page')
print(match.group(1))
PY
)"
fi
WEBVIEW2_CAB="$ROOT/build/downloads/$(basename "${WEBVIEW2_URL%%\?*}")"
mkdir -p "$(dirname "$WEBVIEW2_CAB")"
if [[ ! -f "$WEBVIEW2_CAB" ]]; then
curl --fail --location --show-error "$WEBVIEW2_URL" -o "$WEBVIEW2_CAB"
fi
fi
if [[ ! -f "$WEBVIEW2_CAB" ]]; then
echo "FixedVersionRuntime CAB was not found: $WEBVIEW2_CAB" >&2
exit 1
fi
"$ROOT/scripts/build-windows.sh"
RUNTIME_EXTRACT="$ROOT/build/webview2-runtime"
rm -rf "$RUNTIME_EXTRACT"
mkdir -p "$RUNTIME_EXTRACT"
cabextract -q -d "$RUNTIME_EXTRACT" "$WEBVIEW2_CAB"
WEBVIEW2_RUNTIME_DIR="$(dirname "$(find "$RUNTIME_EXTRACT" -type f -iname msedgewebview2.exe -print -quit)")"
if [[ -z "$WEBVIEW2_RUNTIME_DIR" || ! -f "$WEBVIEW2_RUNTIME_DIR/msedgewebview2.exe" ]]; then
echo "FixedVersionRuntime CAB does not contain msedgewebview2.exe" >&2
exit 1
fi
RELEASE_ROOT="$ROOT/release"
STAGING="$RELEASE_ROOT/verstak-windows-amd64-$VERSION"
ARCHIVE="$RELEASE_ROOT/verstak-windows-amd64-$VERSION.zip"
rm -rf "$STAGING" "$ARCHIVE"
mkdir -p "$STAGING"
cp -R "$ROOT/build/windows-amd64/." "$STAGING/"
install -m 644 "$ROOT/README.md" "$ROOT/LICENSE" "$STAGING/"
install -m 644 "$ROOT/packaging/windows/Verstak.cmd" "$STAGING/Verstak.cmd"
cp -R "$WEBVIEW2_RUNTIME_DIR" "$STAGING/webview2"
(cd "$RELEASE_ROOT" && zip -qr "$(basename "$ARCHIVE")" "$(basename "$STAGING")")
(cd "$RELEASE_ROOT" && find . -maxdepth 1 -type f \( -name '*.deb' -o -name '*.AppImage' -o -name '*.zip' \) \
-printf '%f\n' | LC_ALL=C sort | xargs -r sha256sum > SHA256SUMS)
echo "Windows portable archive: $ARCHIVE"
echo "checksums: $RELEASE_ROOT/SHA256SUMS"
+3 -1
View File
@@ -11,7 +11,9 @@ fi
bash -n "$BUILDER"
grep -Fq -- '-platform windows/amd64' "$BUILDER"
grep -Fq -- '-compiler "$WINDOWS_CC"' "$BUILDER"
grep -Fq 'CC="$WINDOWS_CC"' "$BUILDER"
grep -Fq 'CGO_ENABLED=1' "$BUILDER"
grep -Fq -- '-webview2 error' "$BUILDER"
grep -Fq 'dist-windows' "$BUILDER"
grep -Fq 'verstak-desktop.exe' "$BUILDER"
grep -Fq 'x86_64-w64-mingw32-gcc' "$BUILDER"
+28
View File
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
for script in build-linux-bundle.sh package-deb.sh package-appimage.sh package-windows-portable.sh; do
path="$ROOT/scripts/$script"
if [[ ! -x "$path" ]]; then
echo "packaging script is missing or not executable: $path" >&2
exit 1
fi
bash -n "$path"
done
grep -Fq 'dpkg-deb' "$ROOT/scripts/package-deb.sh"
grep -Fq -- '--build' "$ROOT/scripts/package-deb.sh"
grep -Fq 'packaging/deb/control' "$ROOT/scripts/package-deb.sh"
grep -Fq 'libwebkit2gtk-4.1-0' "$ROOT/packaging/deb/control"
grep -Fq 'appimagetool' "$ROOT/scripts/package-appimage.sh"
grep -Fq 'WebKitWebProcess' "$ROOT/scripts/package-appimage.sh"
grep -Fq 'FixedVersionRuntime' "$ROOT/scripts/package-windows-portable.sh"
grep -Fq 'msedgewebview2.exe' "$ROOT/scripts/package-windows-portable.sh"
grep -Fq 'zip -qr' "$ROOT/scripts/package-windows-portable.sh"
grep -Fq 'WebviewBrowserPath' "$ROOT/platform_options_windows.go"
grep -Fq 'webview2' "$ROOT/platform_options_windows.go"
grep -Fq 'chmod -R a+rX' "$ROOT/scripts/build-linux-bundle.sh"
echo "desktop package script contracts passed"