From 88a1a06ad1eef41069e4284c40882d5407cba5f0 Mon Sep 17 00:00:00 2001 From: eggfriedrice Date: Tue, 27 Oct 2026 21:41:08 +0100 Subject: [PATCH 1/3] run the tests of the aur source package with nextest, one process per test --- CHANGELOG.md | 6 ++++++ packaging/efr-code/PKGBUILD | 9 +++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed07b6c09..6d354910e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ into the GitHub release notes, and it stops when the section is missing. ## [Unreleased] +### Fixed + +- A build of the `efr-code` AUR package on a computer with many cores no longer fails + in its tests. The package now runs them with `cargo-nextest`, as CI does, so each + test runs in a process of its own. + ### Changed - efrd reads the output of your shell with the terminal core of Ghostty 1.4 (a commit diff --git a/packaging/efr-code/PKGBUILD b/packaging/efr-code/PKGBUILD index 7c4a8cfe4..4a55f07ff 100644 --- a/packaging/efr-code/PKGBUILD +++ b/packaging/efr-code/PKGBUILD @@ -18,8 +18,8 @@ url='https://github.com/eggfriedrice24/eggfriedrice.code' license=('MIT') depends=('glibc' 'libgcc' 'zsh') makedepends=('cargo') -# The scope tests of check() run git. -checkdepends=('git') +# check() runs the tests with nextest, as CI does; the scope tests run git. +checkdepends=('cargo-nextest' 'git') optdepends=('bubblewrap: the kernel sandbox of the auto mode (also needs Linux 7.1 or newer)' 'fzf: the live search picker of ,resume (0.46 or newer)' 'git: project roots and the git facts of a turn' @@ -109,7 +109,8 @@ check() { export CARGO_TARGET_DIR=target # The leaf crates of the justfile, as `just test-leaf` runs them. The other tests # need a real zsh session, bubblewrap and a kernel sandbox, which a build chroot - # does not have. + # does not have. nextest runs each test in a process of its own, as the tests + # expect: some of them install a log subscriber for their thread only. local crate crates args=() read -ra crates <<<"$(sed -nE 's/^leaf_crates := "(.*)"$/\1/p' justfile)" if (( ${#crates[@]} == 0 )); then @@ -120,7 +121,7 @@ check() { args+=(-p "$crate") done _drop_cflags_optimization - INSTA_UPDATE=no cargo test --frozen "${args[@]}" --lib --tests + INSTA_UPDATE=no cargo nextest run --frozen "${args[@]}" --lib --tests } package() { From e2474d95d9c4541e93965aefd5247a79d778c21c Mon Sep 17 00:00:00 2001 From: eggfriedrice Date: Tue, 27 Oct 2026 21:41:11 +0100 Subject: [PATCH 2/3] add the efr-code-git aur package that builds the newest commit of main --- .github/workflows/aur-git.yml | 198 ++++++++++++++++++++++++ .github/workflows/aur.yml | 3 +- CHANGELOG.md | 6 + README.md | 6 +- docs/releasing.md | 11 +- docs/start/install.md | 8 +- packaging/efr-code-git/LICENSE | 12 ++ packaging/efr-code-git/PKGBUILD | 175 +++++++++++++++++++++ packaging/efr-code-git/efr-code.install | 1 + 9 files changed, 411 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/aur-git.yml create mode 100644 packaging/efr-code-git/LICENSE create mode 100644 packaging/efr-code-git/PKGBUILD create mode 120000 packaging/efr-code-git/efr-code.install diff --git a/.github/workflows/aur-git.yml b/.github/workflows/aur-git.yml new file mode 100644 index 000000000..476c84fd1 --- /dev/null +++ b/.github/workflows/aur-git.yml @@ -0,0 +1,198 @@ +# Builds packaging/efr-code-git, the AUR package "efr-code-git" that builds the newest +# commit of main, and publishes it to the AUR when its files change. +# +# Required repository secret (only to publish): +# AUR_SSH_PRIVATE_KEY the key of aur.yml; docs/releasing.md has the setup. +# +# Triggers: +# - pull_request that changes the package or this workflow: a test build of the +# commit of the pull request. Nothing is pushed. +# - push to main that changes the package or this workflow: a test build of the +# commit, then a push to ssh://aur@aur.archlinux.org/efr-code-git.git when the +# PKGBUILD, the install file or the LICENSE differ from the AUR. A new commit of +# main alone is no reason to push: an AUR -git package keeps its pkgver until its +# PKGBUILD changes, and makepkg finds the newest commit itself. +# - schedule, every Monday: a test build of main. It finds a change on main that +# breaks the package, such as a new pin in docs/ghostty-pin.md, before a user does. +# - workflow_dispatch: as a push to main. +# +# The test build always builds the checked-out commit: the source line of the PKGBUILD +# is pointed at the checkout. In an archlinux:base-devel container, makepkg runs +# prepare(), build(), check() and package(), and namcap checks the result. The PKGBUILD +# that goes to the AUR keeps its source line, with the pkgver of the test build. + +name: aur-git + +on: + pull_request: + paths: + - packaging/efr-code-git/** + - packaging/efr-code/efr-code.install + - .github/workflows/aur-git.yml + push: + branches: + - main + paths: + - packaging/efr-code-git/** + - packaging/efr-code/efr-code.install + - .github/workflows/aur-git.yml + schedule: + - cron: "17 5 * * 1" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: aur-git-${{ github.ref }} + cancel-in-progress: false + +jobs: + build: + name: Build efr-code-git + runs-on: ubuntu-latest + container: + image: archlinux:base-devel + defaults: + run: + shell: bash + env: + PKG: efr-code-git + AUR_SSH: ssh://aur@aur.archlinux.org + # Only a push to main or a manual run publishes. + PUBLISH: ${{ (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' }} + steps: + - name: Install tooling + # git before checkout so the action produces a real git checkout. rust is + # installed here, so that makepkg -s finds cargo and does not pick rustup for + # it. The image's keyring may predate a packager key, so it is refreshed first. + run: | + pacman -Sy --noconfirm --needed archlinux-keyring + pacman -Su --noconfirm --needed git namcap openssh rust sudo + + # The whole history, so that pkgver() counts the commits of main. + - name: Checkout + uses: actions/checkout@v7 + with: + fetch-depth: 0 + + - name: Create non-root build user + # makepkg refuses to run as root. makepkg -s installs the dependencies of the + # PKGBUILD through pacman, so the user may run it. The checkout belongs to + # root, so git must trust it for the builder. + run: | + useradd -m builder + echo 'builder ALL=(ALL) NOPASSWD: /usr/bin/pacman' > /etc/sudoers.d/builder + su - builder -c "git config --global --add safe.directory '*'" + + - name: Test build and namcap + id: build + run: | + set -euo pipefail + build="/home/builder/$PKG" + install -d -o builder -g builder "$build" + # install copies the target of a link: efr-code-git links efr-code.install + # from packaging/efr-code. + for file in "packaging/$PKG"/*; do + install -o builder -g builder -m 644 "$file" "$build/" + done + commit=$(git rev-parse HEAD) + sed -i "s|^source=.*|source=(\"\$pkgname::git+file://$GITHUB_WORKSPACE#commit=$commit\")|" "$build/PKGBUILD" + grep '^source=' "$build/PKGBUILD" + + su - builder -c "cd '$build' && makepkg -sf --noconfirm" + pkgver=$(sed -n 's/^pkgver=//p' "$build/PKGBUILD") + echo "pkgver=$pkgver" >> "$GITHUB_OUTPUT" + echo "built $PKG $pkgver from $commit" + + log=$(mktemp) + for target in "$build/PKGBUILD" "$build/$PKG"-[0-9]*.pkg.tar.zst; do + if [[ ! -f "$target" ]]; then + echo "::error::$target does not exist" + exit 1 + fi + echo "::group::namcap $target" + namcap "$target" | tee -a "$log" + echo "::endgroup::" + done + echo "::group::files" + pacman -Qlp "$build/$PKG"-[0-9]*.pkg.tar.zst + echo "::endgroup::" + # namcap prints findings as " E: ..." and its own failures to read a + # target as "Error: ...", always exiting 0; both must fail. + if grep -E '^([^ ]+( \([^)]*\))? E: |Error: )' "$log"; then + echo "::error::namcap reported errors or could not analyse a target (warnings above are informational)" + exit 1 + fi + + - name: Set up SSH for aur.archlinux.org + if: env.PUBLISH == 'true' + env: + AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }} + run: | + set -euo pipefail + if [[ -z "$AUR_SSH_PRIVATE_KEY" ]]; then + echo "::error::secret AUR_SSH_PRIVATE_KEY is not set" + exit 1 + fi + ssh_dir="$HOME/.ssh" + install -d -m 700 "$ssh_dir" + printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > "$ssh_dir/aur" + chmod 600 "$ssh_dir/aur" + ssh-keygen -y -f "$ssh_dir/aur" > /dev/null + + # The pinned host keys of aur.archlinux.org, the same as in aur.yml; change + # both files together. Their fingerprints match the "SSH Fingerprints" box on + # https://aur.archlinux.org/. + cat > "$ssh_dir/aur_known_hosts" <<'KNOWN_HOSTS' + aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN + aur.archlinux.org ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLMiLrP8pVi5BFX2i3vepSUnpedeiewE5XptnUnau+ZoeUOPkpoCgZZuYfpaIQfhhJJI5qgnjJmr4hyJbe/zxow= + aur.archlinux.org ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDKF9vAFWdgm9Bi8uc+tYRBmXASBb5cB5iZsB7LOWWFeBrLp3r14w0/9S2vozjgqY5sJLDPONWoTTaVTbhe3vwO8CBKZTEt1AcWxuXNlRnk9FliR1/eNB9uz/7y1R0+c1Md+P98AJJSJWKN12nqIDIhjl2S1vOUvm7FNY43fU2knIhEbHybhwWeg+0wxpKwcAd/JeL5i92Uv03MYftOToUijd1pqyVFdJvQFhqD4v3M157jxS5FTOBrccAEjT+zYmFyD8WvKUa9vUclRddNllmBJdy4NyLB8SvVZULUPrP3QOlmzemeKracTlVOUG1wsDbxknF1BwSCU7CmU6UFP90kpWIyz66bP0bl67QAvlIc52Yix7pKJPbw85+zykvnfl2mdROsaT8p8R9nwCdFsBc9IiD0NhPEHcyHRwB8fokXTajk2QnGhL+zP5KnkmXnyQYOCUYo3EKMXIlVOVbPDgRYYT/XqvBuzq5S9rrU70KoI/S5lDnFfx/+lPLdtcnnEPk= + KNOWN_HOSTS + chmod 600 "$ssh_dir/aur_known_hosts" + echo "GIT_SSH_COMMAND=ssh -i ${ssh_dir}/aur -o IdentitiesOnly=yes -o UserKnownHostsFile=${ssh_dir}/aur_known_hosts -o StrictHostKeyChecking=yes" >> "$GITHUB_ENV" + + - name: Push to AUR + if: env.PUBLISH == 'true' + env: + PKGVER: ${{ steps.build.outputs.pkgver }} + run: | + set -euo pipefail + aur_dir="$HOME/aur-$PKG" + # A package that does not exist yet clones as an empty repository. + git clone "$AUR_SSH/$PKG.git" "$aur_dir" + + # The files of packaging/ with the pkgver of the test build. The PKGBUILD keeps + # its source line. + stage="/home/builder/stage-$PKG" + install -d -o builder -g builder "$stage" + files=(.SRCINFO) + for file in "packaging/$PKG"/*; do + install -o builder -g builder -m 644 "$file" "$stage/" + files+=("${file##*/}") + done + sed -i "s/^pkgver=.*/pkgver=$PKGVER/" "$stage/PKGBUILD" + su - builder -c "cd '$stage' && makepkg --printsrcinfo > .SRCINFO" + + # Only a change of the files counts; a different pkgver alone does not. + changed=false + for file in "${files[@]}"; do + [[ "$file" == .SRCINFO ]] && continue + if [[ ! -f "$aur_dir/$file" ]] || + ! diff -q <(sed '/^pkgver=/d' "$stage/$file") <(sed '/^pkgver=/d' "$aur_dir/$file") > /dev/null; then + changed=true + fi + done + if [[ "$changed" != true ]]; then + echo "$PKG: the AUR has these files already; nothing to push" + exit 0 + fi + + for file in "${files[@]}"; do + cp "$stage/$file" "$aur_dir/" + done + git -C "$aur_dir" config user.name "eggfriedrice" + git -C "$aur_dir" config user.email "eggfriedricew.g.o@gmail.com" + git -C "$aur_dir" add -- "${files[@]}" + git -C "$aur_dir" commit -m "upgpkg: $PKGVER-1" + git -C "$aur_dir" push origin HEAD:master diff --git a/.github/workflows/aur.yml b/.github/workflows/aur.yml index deb090a6b..26e332040 100644 --- a/.github/workflows/aur.yml +++ b/.github/workflows/aur.yml @@ -133,7 +133,8 @@ jobs: # Ed25519 SHA256:RFzBCUItH9LZS0cKB5UE6ceAYhBD5C8GeOBip8Z11+4 # ECDSA SHA256:uTa/0PndEgPZTf76e1DFqXKJEXKsn7m9ivhLQtzGOCI # RSA SHA256:5s5cIyReIfNNVGRFdDbe3hdYiI5OelHGpw2rOUud3Q8 - # If the AUR rotates its keys, update these lines from that page. + # If the AUR rotates its keys, update these lines from that page, and the same + # lines in aur-git.yml. cat > "$ssh_dir/aur_known_hosts" <<'KNOWN_HOSTS' aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN aur.archlinux.org ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLMiLrP8pVi5BFX2i3vepSUnpedeiewE5XptnUnau+ZoeUOPkpoCgZZuYfpaIQfhhJJI5qgnjJmr4hyJbe/zxow= diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d354910e..93173f00b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ into the GitHub release notes, and it stops when the section is missing. ## [Unreleased] +### Added + +- A third AUR package, `efr-code-git`. It builds the newest commit of `main`, so you + get changes before a release. It can break between releases. The install page tells + how to install and update it. + ### Fixed - A build of the `efr-code` AUR package on a computer with many cores no longer fails diff --git a/README.md b/README.md index a62b66e65..9881a98de 100644 --- a/README.md +++ b/README.md @@ -36,10 +36,10 @@ The guide to install and use efr is in [`docs/`](docs/). mdBook builds the same ## Install -On Arch Linux, install a package from the AUR. `efr-code` builds from source, and `efr-code-bin` installs the release build. Then do the three steps as your own user: +On Arch Linux, install a package from the AUR. `efr-code` builds from source, `efr-code-bin` installs the release build, and `efr-code-git` builds the newest commit of `main`. Then do the three steps as your own user: ```sh -yay -S efr-code # or: yay -S efr-code-bin +yay -S efr-code # or: yay -S efr-code-bin, yay -S efr-code-git echo "source /usr/share/zsh/plugins/efr/efr.plugin.zsh" >> ~/.zshrc systemctl --user enable --now efrd # start the daemon now and at every login efr login openai # log in to your ChatGPT plan in a browser @@ -113,7 +113,7 @@ All settings are in one optional file, `config.toml` in the config root (`~/.con | `crates/` | The Rust workspace, one crate for each bounded context | | `shell/zsh/` | The zsh plugin | | `systemd/` | The user unit for the daemon | -| `packaging/` | The AUR packages `efr-code` and `efr-code-bin`; `docs/releasing.md` tells how a release reaches them | +| `packaging/` | The AUR packages `efr-code`, `efr-code-bin` and `efr-code-git`; `docs/releasing.md` tells how they reach the AUR | ## Building diff --git a/docs/releasing.md b/docs/releasing.md index a60dc9c59..9246ce1ea 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -24,7 +24,7 @@ Do these steps once, before the first release. `"resultcount":0`, or show packages of the account `eggfriedrice`: ```sh - curl -s 'https://aur.archlinux.org/rpc/v5/info?arg[]=efr-code&arg[]=efr-code-bin' + curl -s 'https://aur.archlinux.org/rpc/v5/info?arg[]=efr-code&arg[]=efr-code-bin&arg[]=efr-code-git' ``` 2. Give the AUR account `eggfriedrice` an SSH key for the workflow. You can use a key @@ -37,8 +37,13 @@ Do these steps once, before the first release. gh secret set AUR_SSH_PRIVATE_KEY < aur ``` -The AUR makes the package repositories `efr-code` and `efr-code-bin` on the first -push. +The AUR makes the package repositories `efr-code`, `efr-code-bin` and `efr-code-git` +on the first push. + +`efr-code-git` has no release step. `aur-git.yml` builds it on each pull request that +changes `packaging/efr-code-git/`, and each Monday from `main`. After a merge that +changes its files, it pushes them to the AUR. A new commit of `main` alone changes +nothing on the AUR: `makepkg` finds the newest commit itself. For the docs site, do these steps once in the settings of the repository on GitHub: diff --git a/docs/start/install.md b/docs/start/install.md index 201faa83a..17d72da8a 100644 --- a/docs/start/install.md +++ b/docs/start/install.md @@ -30,15 +30,19 @@ These programs are optional. efr works without them, but some parts do not: ## Install from the AUR -There are two packages. Install one of them: +There are three packages. Install one of them: - `efr-code` builds efr from the source of the release tag. For the build, it downloads Zig 0.17.0 from ziglang.org. It does not use the Zig of the Arch repositories. - `efr-code-bin` installs the release build from GitHub. +- `efr-code-git` builds the newest commit of `main`. It gets the changes before a + release, and it can break between releases. For the build, it downloads the + Zig and the ghostty commit that `docs/ghostty-pin.md` of that commit names. To + update it, build it again, for example with `yay -S efr-code-git`. ```sh -yay -S efr-code # or: yay -S efr-code-bin +yay -S efr-code # or: yay -S efr-code-bin, yay -S efr-code-git ``` The packages install these files: diff --git a/packaging/efr-code-git/LICENSE b/packaging/efr-code-git/LICENSE new file mode 100644 index 000000000..e679ae497 --- /dev/null +++ b/packaging/efr-code-git/LICENSE @@ -0,0 +1,12 @@ +Copyright (C) 2026 eggfriedrice + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/packaging/efr-code-git/PKGBUILD b/packaging/efr-code-git/PKGBUILD new file mode 100644 index 000000000..2be40b7a1 --- /dev/null +++ b/packaging/efr-code-git/PKGBUILD @@ -0,0 +1,175 @@ +# Maintainer: eggfriedrice + +# Builds efr from the newest commit of main, with the ghostty screen backend. The +# efr-code package builds the release tag, and efr-code-bin installs its build. +# +# The ghostty screen needs a build of libghostty-vt by the exact Zig that +# docs/ghostty-pin.md pins, from the ghostty commit that it names. Both move on main, +# so this package reads them from that file of the checkout in prepare(). It fetches +# ghostty by its commit, and it checks the official Zig build from ziglang.org with +# the minisign key of the Zig project. It does not use the Zig of the Arch +# repositories. All downloads happen in the sources and in prepare(); build() needs +# no network. +pkgname=efr-code-git +pkgver=0.0.6.r0.g00000000 +pkgrel=1 +pkgdesc='Terminal-first AI agent harness that lives in zsh, with a daemon that owns the state (main branch)' +arch=('x86_64') +url='https://github.com/eggfriedrice24/eggfriedrice.code' +license=('MIT') +depends=('glibc' 'libgcc' 'zsh') +makedepends=('cargo' 'git' 'minisign') +# check() runs the tests with nextest, as CI does; the scope tests run git. +checkdepends=('cargo-nextest' 'git') +optdepends=('bubblewrap: the kernel sandbox of the auto mode (also needs Linux 7.1 or newer)' + 'fzf: the live search picker of ,resume (0.46 or newer)' + 'git: project roots and the git facts of a turn' + 'xdg-dbus-proxy: read-only system queries in the auto mode (0.1.9 or newer)' + 'xdg-utils: let efr login openai open the browser with EFR_OPEN_BROWSER=1') +provides=("efr-code=${pkgver%%.r*}") +conflicts=('efr-code' 'efr-code-bin') +# The same file as packaging/efr-code/efr-code.install. +install=efr-code.install +# The -flto of makepkg.conf makes GCC write LTO bytecode into the C objects of +# aws-lc-sys, which the lld of rustc cannot link. The Cargo profile has its own LTO. +options=('!lto') +source=("$pkgname::git+$url.git#branch=main") +b2sums=('SKIP') +# The minisign key of the Zig project, as https://ziglang.org/download/ shows it. +_zig_key='RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U' + +# Keep debug info in the binaries so makepkg can split it into the -debug package. +export CARGO_PROFILE_RELEASE_DEBUG=2 CARGO_PROFILE_RELEASE_STRIP=false + +# The release version of the workspace, the number of commits and the short commit. +# The count only grows on main, so a newer commit always has a higher pkgver. +pkgver() { + cd "$pkgname" + local version + version="$(sed -nE '/^\[workspace\.package\]/,/^\[/s/^version = "([^"]+)"/\1/p' Cargo.toml)" + printf '%s.r%s.g%s' "$version" "$(git rev-list --count HEAD)" "$(git rev-parse --short=8 HEAD)" +} + +# The ghostty commit and the Zig version of docs/ghostty-pin.md in the checkout. +_pin_ghostty() { + sed -nE 's/^\| ghostty \| `([0-9a-f]{40})`.*/\1/p' "$srcdir/$pkgname/docs/ghostty-pin.md" +} +_pin_zig() { + sed -nE 's/^\| Zig \| ([0-9]+\.[0-9]+\.[0-9]+) exactly.*/\1/p' "$srcdir/$pkgname/docs/ghostty-pin.md" +} + +# aws-lc-sys (under rustls) must build its jitter entropy source with -O0 and fails +# with any other level. cc appends CFLAGS last, so the -O2 of makepkg.conf would win. +# Without a -O in CFLAGS, cc takes the level of the Cargo profile, so the rest of the +# C code stays optimized. +_drop_cflags_optimization() { + local flag kept=() + for flag in $CFLAGS; do + [[ $flag == -O* ]] || kept+=("$flag") + done + export CFLAGS="${kept[*]}" +} + +prepare() { + local ghostty zig zigdir + ghostty="$(_pin_ghostty)" + zig="$(_pin_zig)" + if [[ -z "$ghostty" || -z "$zig" ]]; then + echo "no ghostty commit or Zig version in docs/ghostty-pin.md" >&2 + return 1 + fi + zigdir="zig-$CARCH-linux-$zig" + + cd "$srcdir/$pkgname" + export RUSTUP_TOOLCHAIN=stable + cargo fetch --locked --target host-tuple + + # Zig of the pin, checked against the key of the Zig project before it runs. + cd "$srcdir" + rm -rf zig "$zigdir" "$zigdir.tar.xz" "$zigdir.tar.xz.minisig" + curl -fsSL --retry 3 -o "$zigdir.tar.xz" "https://ziglang.org/download/$zig/$zigdir.tar.xz" + curl -fsSL --retry 3 -o "$zigdir.tar.xz.minisig" "https://ziglang.org/download/$zig/$zigdir.tar.xz.minisig" + minisign -V -q -P "$_zig_key" -m "$zigdir.tar.xz" + mkdir zig + tar -xJf "$zigdir.tar.xz" -C zig --strip-components=1 + + # ghostty at the commit of the pin. git checks the commit by its hash. + rm -rf ghostty + git init -q ghostty + git -C ghostty fetch -q --depth 1 https://github.com/ghostty-org/ghostty.git "$ghostty" + git -C ghostty -c advice.detachedHead=false checkout -q FETCH_HEAD + + # The Zig packages of the ghostty build. Zig fetches them into zig-pkg/ of the + # ghostty source, where build() finds them. A lazy package is fetched only when + # the build asks for it, and --help asks for the ones of these options, so they + # must stay the options that libghostty-vt-sys's build.rs passes; zig build + # --fetch=all would fetch about 550 MB instead of 30 MB. + cd "$srcdir/ghostty" + ZIG_GLOBAL_CACHE_DIR="$srcdir/zig-global-cache" "$srcdir/zig/zig" build \ + -Demit-lib-vt=true -Doptimize=ReleaseFast -Dcpu=baseline \ + -Demit-xcframework=false -Dapp-runtime=none --help > /dev/null +} + +build() { + cd "$pkgname" + export RUSTUP_TOOLCHAIN=stable + export CARGO_TARGET_DIR=target + # libghostty-vt-sys runs zig from PATH and builds this ghostty source with the + # packages from prepare(); docs/ghostty-pin.md lists its variables. + export PATH="$srcdir/zig:$PATH" + export GHOSTTY_SOURCE_DIR="$srcdir/ghostty" + export ZIG_GLOBAL_CACHE_DIR="$srcdir/zig-global-cache" + export LIBGHOSTTY_VT_SYS_CPU=baseline + _drop_cflags_optimization + # The packages and the feature of `just build-release`. + cargo build --frozen --release -p efr-daemon -p efr-cli -p efr-sbx \ + --features efr-daemon/screen-ghostty + + # A build with the sandbox's test seams lets a test replace the launcher and the + # probe; it must never ship. + if [[ "$(target/release/efrd --test-seams)" != off ]]; then + echo "target/release/efrd has the test-sandbox-fake feature" >&2 + return 1 + fi +} + +check() { + cd "$pkgname" + export RUSTUP_TOOLCHAIN=stable + export CARGO_TARGET_DIR=target + # The leaf crates of the justfile, as `just test-leaf` runs them. The other tests + # need a real zsh session, bubblewrap and a kernel sandbox, which a build chroot + # does not have. nextest runs each test in a process of its own, as the tests + # expect: some of them install a log subscriber for their thread only. + local crate crates args=() + read -ra crates <<<"$(sed -nE 's/^leaf_crates := "(.*)"$/\1/p' justfile)" + if (( ${#crates[@]} == 0 )); then + echo "no leaf_crates in the justfile" >&2 + return 1 + fi + for crate in "${crates[@]}"; do + args+=(-p "$crate") + done + _drop_cflags_optimization + INSTA_UPDATE=no cargo nextest run --frozen "${args[@]}" --lib --tests +} + +package() { + cd "$pkgname" + install -Dm0755 -t "$pkgdir/usr/bin/" target/release/efr target/release/efrd + # efrd finds its sandbox launcher in ../lib/efr/ next to its own directory. It is + # never on PATH. + install -Dm0755 -t "$pkgdir/usr/lib/efr/" target/release/efr-sbx + install -Dm0644 -t "$pkgdir/usr/share/zsh/plugins/efr/" shell/zsh/efr.plugin.zsh + # The unit of `just install` with the daemon in /usr/bin. + install -dm0755 "$pkgdir/usr/lib/systemd/user" + sed 's|^ExecStart=%h/\.local/bin/efrd$|ExecStart=/usr/bin/efrd|' systemd/efrd.service \ + > "$pkgdir/usr/lib/systemd/user/efrd.service" + grep -qx 'ExecStart=/usr/bin/efrd' "$pkgdir/usr/lib/systemd/user/efrd.service" + # Each background job runs in a cgroup of its own below efrd's (ADR 0021). + grep -qx 'Delegate=yes' "$pkgdir/usr/lib/systemd/user/efrd.service" + install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE + install -Dm0644 -t "$pkgdir/usr/share/doc/efr-code/" README.md \ + docs/config.md docs/permissions.md docs/sandbox.md + install -Dm0644 -t "$pkgdir/usr/share/doc/efr-code/examples/" crates/efr-config/examples/config.toml +} diff --git a/packaging/efr-code-git/efr-code.install b/packaging/efr-code-git/efr-code.install new file mode 120000 index 000000000..4281200b1 --- /dev/null +++ b/packaging/efr-code-git/efr-code.install @@ -0,0 +1 @@ +../efr-code/efr-code.install \ No newline at end of file From 5243a9d1e65f99970f366e0e2f7b21ba228bd119 Mon Sep 17 00:00:00 2001 From: eggfriedrice Date: Tue, 27 Oct 2026 22:20:33 +0100 Subject: [PATCH 3/3] let root trust the checkout in the aur-git build --- .github/workflows/aur-git.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/aur-git.yml b/.github/workflows/aur-git.yml index 476c84fd1..87a696a58 100644 --- a/.github/workflows/aur-git.yml +++ b/.github/workflows/aur-git.yml @@ -78,11 +78,12 @@ jobs: - name: Create non-root build user # makepkg refuses to run as root. makepkg -s installs the dependencies of the - # PKGBUILD through pacman, so the user may run it. The checkout belongs to - # root, so git must trust it for the builder. + # PKGBUILD through pacman, so the user may run it. The checkout belongs to the + # user of the runner, so git must trust it for root and for the builder. run: | useradd -m builder echo 'builder ALL=(ALL) NOPASSWD: /usr/bin/pacman' > /etc/sudoers.d/builder + git config --global --add safe.directory "$GITHUB_WORKSPACE" su - builder -c "git config --global --add safe.directory '*'" - name: Test build and namcap