hammer-editor/snap/snapcraft.yaml
2026-09-04 20:08:54 -07:00

91 lines
3.3 KiB
YAML

name: hammer-editor
# core24 (glibc 2.39), not core22 (glibc 2.35). A strict snap runs against the
# base's libc, not the host's, so the host having a newer glibc doesn't help:
# libnucleus_tao.so carries a non-weak GLIBC_2.39 version reference (Rust std's
# pidfd_spawnp / pidfd_getpid) and ld.so hard-fails the load on core22 with
# "version `GLIBC_2.39' not found". Nothing else we bundle needs past 2.36.
# core26 would give more headroom, but the gnome extension has no 2604 content
# snap yet.
base: core24
version: '3.9.7'
summary: A simple tool for building stories
description: |
Hammer is a multi-platform story editor application. It's designed for
novelists and storytellers who want an offline-first writing experience
with optional self-hosted synchronization.
icon: snap/gui/hammer-editor-store.png
grade: stable
confinement: strict
platforms:
amd64:
apps:
hammer-editor:
command: bin/hammer
extensions: [ gnome ]
plugs:
- home
- network
- network-bind
- desktop
- desktop-legacy
- wayland
- x11
- opengl
- removable-media
parts:
hammer:
plugin: nil
source: .
build-packages:
- wget
override-build: |
set -euo pipefail
# A full JDK, not a JRE: the build resolves its toolchain to this
# JVM and jpackage bundles it into lib/runtime/, so jlink and
# jpackage have to be present.
echo "Downloading Temurin JDK..."
wget https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.12%2B8/OpenJDK21U-jdk_x64_linux_hotspot_21.0.12_8.tar.gz -O jdk.tar.gz
echo "e4446ff06a276155697597cc0f1b15da004ff083f4964a35271ecee567177370 jdk.tar.gz" | sha256sum -c -
tar -xzf jdk.tar.gz
export JAVA_HOME=$PWD/jdk-21.0.12+8
export PATH=$JAVA_HOME/bin:$PATH
# Fail fast if the extract didn't produce a usable toolchain.
test -x "$JAVA_HOME/bin/java"
test -x "$JAVA_HOME/bin/jlink"
test -x "$JAVA_HOME/bin/jpackage"
echo "Building with JDK (JAVA_HOME=$JAVA_HOME)"
java -version
chmod +x ./gradlew
./gradlew :desktop:jvmJar --no-daemon
./gradlew :desktop:createDistributable -x desktopTest --no-daemon
# The installers/ path comes from outputBaseDir in
# desktop/build.gradle.kts; the app tree carries its own JVM at
# lib/runtime/, which the launcher below points JAVA_HOME at.
mkdir -p $CRAFT_PART_INSTALL/lib
cp -r desktop/build/installers/main/app/hammer $CRAFT_PART_INSTALL/lib/hammer
mkdir -p $CRAFT_PART_INSTALL/bin
cat > $CRAFT_PART_INSTALL/bin/hammer << 'EOF'
#!/bin/bash
export JAVA_HOME=$SNAP/lib/hammer/lib/runtime
export PATH=$JAVA_HOME/bin:$PATH
exec $SNAP/lib/hammer/bin/hammer "$@"
EOF
chmod +x $CRAFT_PART_INSTALL/bin/hammer
desktop-entry:
plugin: dump
source: snap/gui
organize:
hammer-editor.desktop: usr/share/applications/hammer-editor.desktop
hammer-editor.png: usr/share/icons/hicolor/256x256/apps/hammer-editor.png