Files
HomerandClaude Opus 5.5 b52263d0bb Security (S11, S14, S16): the shell's own autocomplete is gone; least privilege in CI; set-up refuses root and another version's release
S11. autocomplete = 'shell' had the shell integration send what was typed
to the engine itself: it could not see a private pane or the AI switch,
and had its own timeout and no chosen model. autocomplete.bash and
autocomplete.zsh are removed, with what exported their switch; the shell
integration keeps its zones and the status record. 'shell' turns nothing
on and is said in the log.

S14. The build job may only read the repository; a job of its own,
for a tag only and after the build passed, downloads the build's artefact
and publishes the release with write access. Every action is pinned by
its commit, with the tag it was taken from beside it.

S16. The set-up program refuses to run as root (everything goes into the
person's own home). A signed SHA256SUMS whose first line names a product
and version must name the release asked for: an older signed release served
under the newest tag is refused. Sums that name nothing yet are still taken,
and that is said. Tests for both, and for the root refusal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 08:07:20 +00:00

115 lines
5.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Package LLeMbas TERM for Linux from a finished build: a .deb and a tarball with the same tree.
#
# llembas/packaging/package.sh [target-dir] [out-dir] (default: target, llembas/packaging/dist)
#
# Expects: the three release binaries in <target-dir>/release. Builds nothing itself.
#
# The tree (the tarball has it under llembas-term-<version>/, the .deb under /):
# usr/lib/llembas-term/ llembas-term, llembas-term-gui, llembas-term-mux-server, and
# llembas-term-setup (installs the LLeMbas CLI and LLeMbas IDE
# when they are missing; the package carries neither)
# usr/bin/ links to those four
# usr/share/llembas-term/shell/ shell integration: llembas-term.sh, wezterm.sh
# usr/share/llembas-term/lua/ the LLeMbas layer's source, to read (the binary has it built in)
# usr/share/applications, metainfo, icons/hicolor
# usr/share/doc/llembas-term/ licences: ours and WezTerm's (LICENSE.md, licenses/), README,
# CHANGELOG
# etc/profile.d/llembas-term.sh (.deb only)
set -euo pipefail
cd "$(dirname "$0")/../.."
TARGET="${1:-target}"
OUT="${2:-llembas/packaging/dist}"
VERSION="$(tr -d '[:space:]' < VERSION)"
ARCH="$(dpkg --print-architecture)"
REL="$TARGET/release"
for b in llembas-term llembas-term-gui llembas-term-mux-server; do
[ -x "$REL/$b" ] || { echo "package: $REL/$b is not built" >&2; exit 1; }
done
work="$(mktemp -d)"
trap 'rm -rf "${work:?}"' EXIT
root="$work/root"
lib="$root/usr/lib/llembas-term"
share="$root/usr/share/llembas-term"
doc="$root/usr/share/doc/llembas-term"
install -d "$lib" "$root/usr/bin" "$share/shell" "$share/lua/llembas" "$doc"
for b in llembas-term llembas-term-gui llembas-term-mux-server; do
install -m755 -s "$REL/$b" "$lib/$b"
ln -s "../lib/llembas-term/$b" "$root/usr/bin/$b"
done
# No copy of the LLeMbas CLI or of LLeMbas IDE: each is its own installation, the same one used
# outside this terminal. The set-up program installs what is missing, by their own installers.
install -m755 llembas/setup/llembas-term-setup "$lib/llembas-term-setup"
ln -s ../lib/llembas-term/llembas-term-setup "$root/usr/bin/llembas-term-setup"
install -m644 llembas/shell/llembas-term.sh "$share/shell/"
install -m644 assets/shell-integration/wezterm.sh "$share/shell/wezterm.sh"
install -m644 llembas/lua/default-config.lua "$share/lua/default-config.lua"
install -m644 llembas/lua/llembas/init.lua llembas/lua/llembas/core.lua "$share/lua/llembas/"
install -Dm644 llembas/packaging/eu.llembas.term.desktop "$root/usr/share/applications/eu.llembas.term.desktop"
install -Dm644 llembas/packaging/eu.llembas.term.appdata.xml "$root/usr/share/metainfo/eu.llembas.term.appdata.xml"
for size in 128 256 512; do
install -Dm644 "llembas/packaging/icons/eu.llembas.term-$size.png" \
"$root/usr/share/icons/hicolor/${size}x${size}/apps/eu.llembas.term.png"
done
install -Dm644 llembas/packaging/icons/eu.llembas.term.svg "$root/usr/share/icons/hicolor/scalable/apps/eu.llembas.term.svg"
install -m644 LICENSE.md README.md CHANGELOG.md "$doc/"
install -d "$doc/licenses"
install -m644 licenses/* "$doc/licenses/"
mkdir -p "$OUT"
# The tarball: the tree as it is, to unpack anywhere (the binaries find each other by their own location; source usr/share/llembas-term/shell/llembas-term.sh from the shell's rc).
name="llembas-term-$VERSION-linux-$ARCH"
cp -a "$root" "$work/$name"
tar -C "$work" --owner=0 --group=0 --numeric-owner -cJf "$OUT/$name.tar.xz" "$name"
# The .deb. Debian sorts 1.0.0-beta.1 above 1.0.0 (what follows the dash is a revision), so a
# beta's package says ~beta, which sorts below its release.
debver="${VERSION/-/\~}"
install -Dm644 llembas/packaging/profile.sh "$root/etc/profile.d/llembas-term.sh"
install -d "$root/DEBIAN"
mkdir -p "$work/shlibs/debian"
: > "$work/shlibs/debian/control"
depends="$(cd "$work/shlibs" && dpkg-shlibdeps -O -e "$lib/llembas-term" -e "$lib/llembas-term-gui" -e "$lib/llembas-term-mux-server" 2>/dev/null | sed -n 's/^shlibs:Depends=//p')"
[ -n "$depends" ] || { echo "package: could not work out the library dependencies" >&2; exit 1; }
# Up to 1.0.0-beta.5 the package was llembas-tty. Conflicts with Replaces is how a package takes
# another's place whole (Debian Policy 7.6.2): installing this one removes that one first, and
# Provides keeps the old name answered. Its files are all under names of its own, so nothing of
# it is left but its /etc/profile.d file (a conffile, kept until purged), which does nothing.
cat > "$root/DEBIAN/control" <<CONTROL
Package: llembas-term
Version: $debver
Architecture: $ARCH
Maintainer: LLeMbas <houmeres@houmeres.sk>
Section: utils
Priority: optional
Homepage: https://llembas.eu
Depends: $depends
Recommends: curl, openssh-client, git
Replaces: llembas-tty
Conflicts: llembas-tty
Provides: llembas-tty
Description: A terminal with LLeMbas built in
LLeMbas TERM is a terminal emulator and multiplexer, a fork of WezTerm,
with the LLeMbas agent built in. By default it is an ordinary terminal.
It installs beside WezTerm and shares nothing with it.
CONTROL
echo "/etc/profile.d/llembas-term.sh" > "$root/DEBIAN/conffiles"
# The file is named by the version as written (a dash): a forge's upload turns ~ into a dot, and
# SHA256SUMS would then name a file that is not there. The package's own Version keeps the ~.
dpkg-deb --root-owner-group -b "$root" "$OUT/llembas-term_${VERSION}_${ARCH}.deb" >/dev/null
base="${VERSION%%-*}"
if [ "$VERSION" != "$base" ]; then
dpkg --compare-versions "$debver" lt "$base" || { echo "package: $debver does not sort below $base" >&2; exit 1; }
fi
ls -l "$OUT"