Crafter.Review/packaging/flatpak/prune-base.sh
Jorijn van der Graaf b02de3ceff
build(flatpak): net.catcrafts.CrafterReview on the Crafter.Build base
The manifest builds on the Crafter.Build Flatpak (base:
net.catcrafts.CrafterBuild): its crafter-build, LLVM 23 and libc++
compile this project inside flatpak-builder, and crafter-build test runs
there too. Node 24.22.0 (for the Playwright MCP server) and a static
ripgrep 15.2.0 are bundled, pinned by sha256; claude is not, being
proprietary. finish-args: the network, the host's files and /tmp, and
gnupg's keyboxd socket only, never the agent.

The base's files belong to no module of this manifest, so `cleanup` does
not reach them: prune-base.sh keeps a named list (the binary, Node, rg,
the libc++ the binary links, share/crafter-review, this app's metainfo
and licences) and removes the rest, whatever a newer base adds.

`crafter-build run flatpak [--base=<branch>] [--jobs=N]` builds it and
smoke-tests --version and ldd through `flatpak build`; `run install`
installs it as the `local` branch. Until a Crafter.Build release with
scripts is on stable, `--base=local` builds against Crafter.Build's own
local install, from a gitignored manifest copy whose cache is its own.
Built that way: 4 tests green in the sandbox, the charter sha256s the
native build prints, no library missing, RUNPATH /app/lib only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 06:01:19 +01:00

41 lines
1.7 KiB
Shell

#!/bin/sh
# SPDX-License-Identifier: AGPL-3.0-only
# SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
#
# The base app, net.catcrafts.CrafterBuild, brings Crafter.Build's whole
# toolchain into /app so this project can be built inside flatpak-builder.
# The shipped app keeps what crafter-review runs on and nothing else: a list
# of what stays rather than of what goes, so whatever a newer base adds goes
# without anyone having to know about it.
set -eu
cd /app
keep() {
case "$1" in
bin | bin/crafter-review | bin/node | bin/npm | bin/npx | bin/rg) return 0 ;;
lib | lib/node | lib/node/*) return 0 ;;
# What a binary built by the base's crafter-build links through its
# /app/lib rpath.
lib/libc++.so.1* | lib/libc++abi.so.1* | lib/libunwind.so.1*) return 0 ;;
# Split into the .Debug extension at export.
lib/debug | lib/debug/*) return 0 ;;
share | share/crafter-review | share/crafter-review/*) return 0 ;;
# Named, not whole: the base's CrafterBuild metainfo and licences go.
share/metainfo | share/metainfo/net.catcrafts.CrafterReview.metainfo.xml) return 0 ;;
share/licenses | share/licenses/net.catcrafts.CrafterReview | share/licenses/net.catcrafts.CrafterReview/*) return 0 ;;
manifest*.json) return 0 ;;
esac
return 1
}
# Depth first: a directory comes after its contents, and goes only once it
# is empty.
find . -mindepth 1 -depth | sed 's|^\./||' | while IFS= read -r path; do
keep "$path" && continue
if [ -d "$path" ] && [ ! -L "$path" ]; then
rmdir "$path" 2>/dev/null || true
else
rm -f "$path"
fi
done
rm -f share/crafter-review/prune-base.sh