Release packaging: tar.gz, AppImage, Arch package (damson-bin), installer.sh

tools/package.sh builds dist/ offline; installer.sh installs the tar.gz or AppImage per user or
system-wide with a checksum and glibc check; README install section and 0.1.0 release notes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-26 13:58:10 -06:00
commit fb1bb9b292
6 changed files with 361 additions and 0 deletions

View file

@ -78,6 +78,22 @@ not recovered.
Vi mode, spell checking, snippets, and reopening a file with a chosen encoding. Long lines are not virtualised. It runs one window per launch. Linux only for now.
## Install a release
Downloads are on the [Releases page](https://archlinux.tail7c4f5e.ts.net/git/astar76/Damson/releases): Linux x86_64 only. The binaries are built on Arch Linux and need
**glibc 2.43 or newer**, so they run on Arch and other up-to-date rolling distributions; older distributions
(Debian, Ubuntu LTS, Fedora releases with an older glibc) cannot run them and should build from source.
- **Arch Linux:** `sudo pacman -U Damson-0.1.0-arch-x86_64.pkg.tar.zst` (package `damson-bin`; remove it with
`sudo pacman -R damson-bin`).
- **Installer (any distribution):** put `installer.sh` next to the downloaded tar.gz or AppImage and
`SHA256SUMS-0.1.0`, then run `sh installer.sh` (your home, `~/.local`, no root) or `sh installer.sh --system`
(`/usr/local`, sudo only for the copy). It checks the checksum and refuses, in plain words, when glibc is too old.
`sh installer.sh --uninstall` removes it; add `--purge` to delete settings and data too.
- **tar.gz:** unpack it, then `./install.sh` inside the folder (same options as `installer.sh`) and later
`./uninstall.sh` (`--purge` for settings and data).
- **AppImage:** `chmod +x Damson-0.1.0-x86_64.AppImage` and run it. System libraries are not bundled.
## Install from source
You need Rust and a C compiler to build. Nothing else is needed at runtime except the usual graphics

20
docs/releases/0.1.0.md Normal file
View file

@ -0,0 +1,20 @@
# Damson 0.1.0
First release. Linux x86_64, glibc 2.43 or newer (Arch and other up-to-date rolling distributions).
## Files
- `Damson-0.1.0-x86_64.AppImage`
- `Damson-0.1.0-Linux-x86_64.tar.gz` (install.sh and uninstall.sh for your home folder)
- `Damson-0.1.0-arch-x86_64.pkg.tar.zst` (Arch package `damson-bin`: `sudo pacman -U Damson-0.1.0-arch-x86_64.pkg.tar.zst`)
- `SHA256SUMS-0.1.0`
`installer.sh` from the repository installs the tar.gz or AppImage into `~/.local` or `/usr/local` and removes it again.
## What is in it
A Material You code editor with 462 languages built in: the scrolling preview rail, multi-cursor, folding, split view,
find and replace, search in files, outline, a git panel, hot exit, and language servers when they are installed.
## Known gaps
- Needs glibc 2.43 or newer; older distributions must build from source.
- Not done yet: vi mode, spell checking, snippets, reopening with a chosen encoding; one window per launch.
- Packages were smoke-tested on Arch (a hidden session, start and close); the Arch package was not installed with pacman in tests.

157
installer.sh Executable file
View file

@ -0,0 +1,157 @@
#!/bin/sh
# Damson installer. Installs from a release tar.gz or AppImage, or removes an install.
# installer.sh [--user|--system] [--prefix DIR] [--url URL] [FILE]
# installer.sh --uninstall [--purge] [--user|--system] [--prefix DIR]
# --user (default): ~/.local, no root. --system: /usr/local, sudo only for the copy.
# Without FILE it uses the unpacked release folder it sits in, or Damson-*-Linux-x86_64.tar.gz or
# Damson-*-x86_64.AppImage next to it. SHA256SUMS-<version> beside the file is checked when present.
# --purge also deletes settings and data (~/.config/damson: settings and recovery copies). DESTDIR=dir stages under dir (no sudo).
# Needs glibc 2.43 or newer.
set -eu
app=damson main=damson need=2.43
mode=install scope=user purge=0 prefix= url= file=
while [ $# -gt 0 ]; do
case $1 in
--user) scope=user ;;
--system) scope=system ;;
--prefix) [ $# -ge 2 ] || { echo "--prefix needs a folder." >&2; exit 2; }; prefix=$2; shift ;;
--url) [ $# -ge 2 ] || { echo "--url needs an address." >&2; exit 2; }; url=$2; shift ;;
--uninstall) mode=uninstall ;;
--purge) purge=1 ;;
-h|--help) sed -n '2,9p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
-*) echo "Unknown option: $1 (see --help)." >&2; exit 2 ;;
*) file=$1 ;;
esac
shift
done
[ "$purge" = 0 ] || [ "$mode" = uninstall ] || { echo "--purge only goes with --uninstall." >&2; exit 2; }
if [ -z "$prefix" ]; then
if [ "$scope" = system ]; then prefix=/usr/local; else prefix=$HOME/.local; fi
fi
case $prefix in /*) ;; *) echo "--prefix must be an absolute path." >&2; exit 2 ;; esac
prefix=${prefix%/}
destdir=${DESTDIR:-}
root=$destdir$prefix
list=$root/lib/$app/files
sudo=
if [ -z "$destdir" ] && [ "$(id -u)" != 0 ]; then
d=$root; while [ ! -e "$d" ]; do d=$(dirname "$d"); done
[ -w "$d" ] || sudo=sudo
fi
refresh() {
[ -z "$destdir" ] || return 0
command -v update-desktop-database >/dev/null 2>&1 && $sudo update-desktop-database -q "$root/share/applications" 2>/dev/null || true
[ -f "$root/share/icons/hicolor/index.theme" ] && command -v gtk-update-icon-cache >/dev/null 2>&1 \
&& $sudo gtk-update-icon-cache -q -t -f "$root/share/icons/hicolor" 2>/dev/null || true
}
# Removes the files the last install listed, then the folders that became empty.
remove_listed() {
[ -f "$list" ] || return 0
while IFS= read -r f; do
[ -n "$f" ] || continue
$sudo rm -f "$root/$f"
d=$(dirname "$f")
while [ "$d" != . ] && $sudo rmdir "$root/$d" 2>/dev/null; do d=$(dirname "$d"); done
done < "$list"
$sudo rm -f "$list"
$sudo rmdir "$root/lib/$app" "$root/lib" 2>/dev/null || true
}
if [ "$mode" = uninstall ]; then
if [ ! -f "$list" ]; then
echo "Damson is not installed in $prefix (no $list)." >&2
[ "$purge" = 1 ] || exit 1
else
remove_listed
refresh
echo "Damson removed from $prefix."
fi
if [ "$purge" = 1 ]; then
rm -rf "${XDG_CONFIG_HOME:-$HOME/.config}/damson"
echo "Settings and data removed (~/.config/damson: settings and recovery copies)."
else
echo "Settings and data are kept (--purge deletes them)."
fi
exit 0
fi
# glibc check (DAMSON_GLIBC overrides the detected version, for tests)
have=${DAMSON_GLIBC:-$(getconf GNU_LIBC_VERSION 2>/dev/null | sed 's/^glibc //')}
if [ -z "$have" ]; then
echo "Damson needs glibc $need or newer, and this system does not report a glibc (musl?). Nothing was installed." >&2; exit 1
fi
if [ "$(printf '%s\n%s\n' "$need" "$have" | sort -V | head -n 1)" != "$need" ]; then
echo "Damson needs glibc $need or newer, and this system has glibc $have. Nothing was installed." >&2; exit 1
fi
here=$(cd "$(dirname "$0")" && pwd)
tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT INT TERM
if [ -n "$url" ]; then
file=$tmp/$(basename "${url%%\?*}")
if command -v curl >/dev/null 2>&1; then curl -fL -o "$file" -- "$url"
elif command -v wget >/dev/null 2>&1; then wget -O "$file" -- "$url"
else echo "Neither curl nor wget is installed, so $url cannot be fetched." >&2; exit 1; fi
fi
src=
if [ -z "$file" ]; then
if [ -f "$here/bin/$main" ]; then src=$here
else
for f in "$here"/Damson-*-Linux-x86_64.tar.gz "$here"/Damson-*-x86_64.AppImage; do
[ -f "$f" ] && { file=$f; break; }
done
fi
fi
if [ -z "$src" ]; then
[ -n "$file" ] && [ -f "$file" ] || { echo "No Damson tar.gz or AppImage was given or found next to the installer." >&2; exit 1; }
dir=$(dirname "$file"); name=$(basename "$file")
for s in "$dir"/SHA256SUMS-*; do
[ -f "$s" ] || continue
line=$(grep -F " $name" "$s" | head -n 1 || true)
[ -n "$line" ] || continue
[ "${line%% *}" = "$(sha256sum "$file" | cut -d' ' -f1)" ] \
|| { echo "The checksum of $name does not match $(basename "$s"). Nothing was installed." >&2; exit 1; }
echo "Checksum ok."
done
mkdir "$tmp/x"
case $name in
*.tar.gz)
tar -xzf "$file" -C "$tmp/x"
src=$(find "$tmp/x" -maxdepth 1 -mindepth 1 -type d | head -n 1)
[ -n "$src" ] && [ -f "$src/bin/$main" ] || { echo "$name has no bin/$main, so it is not a Damson release." >&2; exit 1; } ;;
*.AppImage)
cp "$file" "$tmp/app"; chmod 755 "$tmp/app"
(cd "$tmp/x" && "$tmp/app" --appimage-extract >/dev/null 2>&1) || true
[ -d "$tmp/x/squashfs-root/usr/share" ] || { echo "Could not read the contents of $name. Nothing was installed." >&2; exit 1; }
src=$tmp/src; mkdir -p "$src/bin"
mv "$tmp/app" "$src/bin/$main"
mv "$tmp/x/squashfs-root/usr/share" "$src/share"
[ ! -d "$tmp/x/squashfs-root/usr/lib" ] || mv "$tmp/x/squashfs-root/usr/lib" "$src/lib" ;;
*) echo "Unknown file type: $name (need .tar.gz or .AppImage)." >&2; exit 1 ;;
esac
fi
# Stage with launchers pointing at this prefix, then copy and list every file for --uninstall.
st=$tmp/stage
mkdir -p "$st"
for d in bin lib share; do [ ! -d "$src/$d" ] || cp -R "$src/$d" "$st/$d"; done
for d in "$st"/share/applications/*.desktop; do
[ -f "$d" ] || continue
for b in "$st"/bin/*; do
b=$(basename "$b")
sed -i -e "s#^Exec=$b\( \|\$\)#Exec=$prefix/bin/$b\1#" -e "s#^TryExec=$b\$#TryExec=$prefix/bin/$b#" "$d"
done
done
chmod 755 "$st"/bin/*
(cd "$st" && find . \( -type f -o -type l \) | sed 's|^\./||' | sort) > "$tmp/files"
mkdir -p "$st/lib/$app"; echo "lib/$app/files" >> "$tmp/files"; cp "$tmp/files" "$st/lib/$app/files"
remove_listed
$sudo mkdir -p "$root"
$sudo cp -R "$st/." "$root/"
refresh
echo "Damson installed in $prefix/bin/$main"
case ":$PATH:" in *":$prefix/bin:"*) ;; *) echo "Note: $prefix/bin is not on your PATH." ;; esac

39
packaging/arch/.SRCINFO Normal file
View file

@ -0,0 +1,39 @@
pkgbase = damson-bin
pkgdesc = Material You code editor with 462 languages built in
pkgver = 0.1.0
pkgrel = 1
url = https://archlinux.tail7c4f5e.ts.net/git/astar76/Damson
arch = x86_64
license = MIT
depends = glibc>=2.43
depends = gcc-libs
depends = dbus
depends = fontconfig
depends = libglvnd
depends = wayland
depends = libxkbcommon
depends = libxkbcommon-x11
depends = libx11
depends = libxcb
depends = libxcursor
depends = libxi
depends = libxrender
depends = hicolor-icon-theme
optdepends = xdg-desktop-portal: open and save dialogs
optdepends = git: the git panel and changed lines
optdepends = clang: C and C++ language server (clangd)
optdepends = rust-analyzer: Rust language server
optdepends = python-lsp-server: Python language server
optdepends = gopls: Go language server
optdepends = typescript-language-server: TypeScript and JavaScript language server
optdepends = bash-language-server: shell language server
optdepends = lua-language-server: Lua language server
optdepends = sudo: saving files that need root
provides = damson
conflicts = damson
options = !strip
options = !debug
source = Damson-0.1.0-Linux-x86_64.tar.gz::https://archlinux.tail7c4f5e.ts.net/git/astar76/Damson/releases/download/v0.1.0/Damson-0.1.0-Linux-x86_64.tar.gz
sha256sums = b5c5b113b8c66f37de0b1ef02a83b918be8f15aef763ad128f072ad80b0156be
pkgname = damson-bin

39
packaging/arch/PKGBUILD Normal file
View file

@ -0,0 +1,39 @@
# Maintainer: astar76
# Built by tools/package.sh from the release tar.gz (TARBALL=file://… for an offline build); it keeps pkgver,
# sha256sums and the glibc floor current.
pkgname=damson-bin
pkgver=0.1.0
pkgrel=1
pkgdesc='Material You code editor with 462 languages built in'
arch=('x86_64')
url='https://archlinux.tail7c4f5e.ts.net/git/astar76/Damson'
license=('MIT')
# Linked: libc, libm, libgcc_s. dlopened (strings of the binary): libEGL/libGL (libglvnd), libwayland-client/-egl, libxkbcommon(-x11), libX11, libX11-xcb, libxcb, libXcursor, libXi, libXrender, libfontconfig, libdbus-1. Runs fc-match (fontconfig); git only for the git panel.
depends=('glibc>=2.43' 'gcc-libs' 'dbus' 'fontconfig' 'libglvnd' 'wayland' 'libxkbcommon' 'libxkbcommon-x11' 'libx11' 'libxcb' 'libxcursor' 'libxi' 'libxrender' 'hicolor-icon-theme')
optdepends=(
'xdg-desktop-portal: open and save dialogs'
'git: the git panel and changed lines'
'clang: C and C++ language server (clangd)'
'rust-analyzer: Rust language server'
'python-lsp-server: Python language server'
'gopls: Go language server'
'typescript-language-server: TypeScript and JavaScript language server'
'bash-language-server: shell language server'
'lua-language-server: Lua language server'
'sudo: saving files that need root'
)
provides=('damson')
conflicts=('damson')
options=('!strip' '!debug')
source=("Damson-$pkgver-Linux-x86_64.tar.gz::${TARBALL:-$url/releases/download/v$pkgver/Damson-$pkgver-Linux-x86_64.tar.gz}")
sha256sums=('b5c5b113b8c66f37de0b1ef02a83b918be8f15aef763ad128f072ad80b0156be')
package() {
cd "$srcdir/damson-$pkgver"
install -d "$pkgdir/usr"
for d in bin lib share; do [ ! -d "$d" ] || cp -R "$d" "$pkgdir/usr/"; done
if [ -d "$pkgdir/usr/share/licenses/damson" ] && [ "$pkgname" != damson ]; then
mv "$pkgdir/usr/share/licenses/damson" "$pkgdir/usr/share/licenses/$pkgname"
fi
install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
}

90
tools/package.sh Executable file
View file

@ -0,0 +1,90 @@
#!/bin/bash
# Damson release packages. Run: tools/package.sh (see the common part below for what it makes)
set -euo pipefail
root=$(cd "$(dirname "$0")/.." && pwd)
APP=damson NAME=Damson DESKTOP=damson.desktop
BINS=(damson)
ver=$(sed -n 's/^version = "\(.*\)"/\1/p' "$root/Cargo.toml" | head -n 1)
build() { nice cargo build --release --locked -q -j 2; }
# share/ as it lands under the prefix
stage() {
local s=$1 b=$rel/damson
install -Dm644 packaging/damson.desktop "$s/applications/damson.desktop"
install -Dm644 packaging/damson.metainfo.xml "$s/metainfo/damson.metainfo.xml"
install -Dm644 packaging/damson.svg "$s/icons/hicolor/scalable/apps/damson.svg"
for n in 16 24 32 48 64 128 256 512; do
mkdir -p "$s/icons/hicolor/${n}x$n/apps"; "$b" --export-icon "$n" "$s/icons/hicolor/${n}x$n/apps/damson.png"
done
install -Dm644 LICENSE "$s/licenses/damson/LICENSE"
install -Dm644 assets/syntax/LICENSES.md "$s/licenses/damson/syntax-definitions.md"
install -Dm644 assets/syntax/KSyntaxHighlighting-MIT.txt "$s/licenses/damson/KSyntaxHighlighting-MIT.txt"
}
# ---------------------------------------------------------------- common part (same in every project)
# Builds into dist/: $NAME-<v>-Linux-x86_64.tar.gz (install.sh, uninstall.sh), $NAME-<v>-x86_64.AppImage (GUI only),
# $NAME-<v>-arch-x86_64.pkg.tar.zst (makepkg from that tar.gz, offline) and SHA256SUMS-<v>.
# It also writes the tar.gz checksum and version into $PKGDIR/PKGBUILD and .SRCINFO, and the glibc floor read
# from the binary into installer.sh and the PKGBUILD. Nothing is downloaded: appimagetool comes from
# ~/Projects/Mulberry/dist and runs extracted (no FUSE, no runtime fetch). Never writes to releases/.
# SKIP_BUILD=1 packages the existing build. CARGO_TARGET_DIR is honoured.
cd "$root"; PKGDIR=${PKGDIR:-packaging/arch}
[ "${SKIP_BUILD:-}" = 1 ] || build
rel=${CARGO_TARGET_DIR:-$root/target}/release
out=$root/dist
work=$(mktemp -d); trap 'rm -rf "$work"' EXIT
export SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH:-$(git log -1 --format=%ct 2>/dev/null || date +%s)}
# glibc floor: the newest GLIBC_x.y symbol version any shipped binary (or EXTRA_ELF library) needs.
glibc=$(for b in "${BINS[@]}" ${EXTRA_ELF[@]+"${EXTRA_ELF[@]}"}; do objdump -T "$rel/$b"; done | grep -o 'GLIBC_[0-9.]*' | sed 's/GLIBC_//' | sort -uV | tail -n 1)
[ -n "$glibc" ] || { echo "could not read the glibc version from the binary" >&2; exit 1; }
sed -i "s/^app=$APP main=\([^ ]*\) need=.*/app=$APP main=\1 need=$glibc/; s/glibc [0-9.]* or newer\./glibc $glibc or newer./" installer.sh
sed -i "s/'glibc>=[0-9.]*'/'glibc>=$glibc'/" $PKGDIR/PKGBUILD
# tar.gz: bin/ and share/ laid out like a prefix, so installer.sh and the PKGBUILD just copy them.
rm -rf "$out"; mkdir -p "$out"
t=$work/$APP-$ver
mkdir -p "$t/bin" "$t/share" # stage may add $t/lib too
for b in "${BINS[@]}"; do install -m755 "$rel/$b" "$t/bin/$b"; done
stage "$t/share"
install -m755 installer.sh "$t/install.sh"
printf '#!/bin/sh\n# Removes %s installed by install.sh. --purge also deletes settings and data; --system or --prefix DIR as for install.sh.\nexec sh "$(dirname "$0")/install.sh" --uninstall "$@"\n' "$NAME" > "$t/uninstall.sh"
chmod 755 "$t/uninstall.sh"
cp README.md "$t/"
find "$t" -exec touch -h -d "@$SOURCE_DATE_EPOCH" {} +
tgz=$NAME-$ver-Linux-x86_64.tar.gz
tar -C "$work" --sort=name --owner=0 --group=0 --numeric-owner -cf - "$APP-$ver" | gzip -n -9 > "$out/$tgz"
# AppImage (GUI apps): the same tree under usr/, desktop file and icon at the top.
if [ -n "${DESKTOP:-}" ]; then
a=$work/AppDir
mkdir -p "$a/usr"
cp -R "$t/bin" "$t/share" "$a/usr/"; [ ! -d "$t/lib" ] || cp -R "$t/lib" "$a/usr/"
cp "$a/usr/share/applications/$DESKTOP" "$a/"
icon=$(sed -n 's/^Icon=//p' "$a/$DESKTOP" | head -n 1)
for ext in svg png; do
f=$(find "$a/usr/share/icons" -name "$icon.$ext" | sort -V | tail -n 1)
[ -n "$f" ] && { cp "$f" "$a/$icon.$ext"; break; }
done
cat > "$a/AppRun" <<RUN
#!/bin/sh
here=\$(dirname "\$(readlink -f "\$0")")
exec "\$here/usr/bin/${BINS[0]}" "\$@"
RUN
chmod +x "$a/AppRun"
cp ~/Projects/Mulberry/dist/appimagetool "$work/appimagetool"
(cd "$work" && ./appimagetool --appimage-extract >/dev/null)
ARCH=x86_64 "$work/squashfs-root/AppRun" --no-appstream "$a" "$out/$NAME-$ver-x86_64.AppImage" >"$work/ait.log" 2>&1 \
|| { tail -20 "$work/ait.log"; exit 1; }
fi
# Arch package from the local tar.gz; the repo's PKGBUILD gets this version and checksum.
sum=$(sha256sum "$out/$tgz" | cut -d' ' -f1)
sed -i "s/^pkgver=.*/pkgver=$ver/; s/^sha256sums=.*/sha256sums=('$sum')/" $PKGDIR/PKGBUILD
mkdir "$work/arch"; cp $PKGDIR/PKGBUILD "$work/arch/"
(cd "$work/arch" && makepkg --printsrcinfo > "$root/$PKGDIR/.SRCINFO")
(cd "$work/arch" && TARBALL="file://$out/$tgz" makepkg -f -C --nodeps --noconfirm >"$work/makepkg.log" 2>&1) \
|| { tail -20 "$work/makepkg.log"; exit 1; }
cp "$work"/arch/"$APP"-bin-"$ver"-*-x86_64.pkg.tar.zst "$out/$NAME-$ver-arch-x86_64.pkg.tar.zst"
(cd "$out" && sha256sum "$NAME-$ver"-* > "SHA256SUMS-$ver")
echo "glibc floor: $glibc"
ls -l "$out"