diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d0849c..6f4a172 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,3 +59,31 @@ jobs: - name: Run workspace checks run: pnpm check + + validate-aur-source: + name: Build source AUR package on Arch Linux + runs-on: ubuntu-latest + timeout-minutes: 90 + steps: + - name: Checkout + uses: actions/checkout@v7.0.0 + with: + fetch-depth: 0 + + - name: Build and inspect source package + run: | + set -euo pipefail + release_tag="$(git describe --tags --abbrev=0 --match 'v[0-9]*')" + export LOOPWIRE_AUR_VERSION="${release_tag#v}" + docker run --rm \ + --env LOOPWIRE_AUR_VERSION \ + --volume "$GITHUB_WORKSPACE:/workspace:ro" \ + archlinux@sha256:84cd9ef000b3cff245ec028e87965b84724f4bf1cc63fc2741ba927b88515ed6 \ + bash -ceu ' + pacman -Syu --noconfirm --needed \ + curl git namcap nodejs pipewire pnpm rust webkit2gtk-4.1 wireplumber + useradd --create-home aur-builder + runuser -u aur-builder -- env HOME=/home/aur-builder \ + bash /workspace/scripts/verify-aur-source-package.sh \ + --version "$LOOPWIRE_AUR_VERSION" + ' diff --git a/.github/workflows/publish-aur.yml b/.github/workflows/publish-aur.yml new file mode 100644 index 0000000..d5a7a41 --- /dev/null +++ b/.github/workflows/publish-aur.yml @@ -0,0 +1,112 @@ +name: Publish AUR +run-name: Publish AUR ${{ inputs.package }} from ${{ inputs.tag }} + +on: + workflow_dispatch: + inputs: + tag: + description: Published v-prefixed release tag + required: true + type: string + package: + description: AUR package base to publish + required: true + default: all + type: choice + options: + - all + - loopwire + - loopwire-bin + +permissions: + contents: read + +concurrency: + group: aur-${{ inputs.tag }}-${{ inputs.package }} + cancel-in-progress: false + +jobs: + publish: + name: Build and publish AUR metadata + if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) + runs-on: ubuntu-latest + timeout-minutes: 90 + environment: aur + steps: + - name: Checkout + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + fetch-depth: 0 + ref: ${{ github.event.repository.default_branch }} + + - name: Verify published release tag + env: + GH_TOKEN: ${{ github.token }} + LOOPWIRE_AUR_TAG: ${{ inputs.tag }} + run: | + set -euo pipefail + tag_pattern='^v[0-9]+[.][0-9]+[.][0-9]+$' + if [[ ! "$LOOPWIRE_AUR_TAG" =~ $tag_pattern ]]; then + echo "AUR publication requires a stable v-prefixed semver tag." >&2 + exit 1 + fi + git rev-parse --verify "refs/tags/${LOOPWIRE_AUR_TAG}^{commit}" + release_state="$( + gh release view "$LOOPWIRE_AUR_TAG" --repo "$GITHUB_REPOSITORY" \ + --json isDraft,isPrerelease \ + --jq '"\(.isDraft) \(.isPrerelease)"' + )" + if [ "$release_state" != "false false" ]; then + echo "AUR publication requires a non-draft, non-prerelease GitHub release." >&2 + exit 1 + fi + + - name: Prepare ephemeral AUR key + env: + AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }} + run: | + set -euo pipefail + if [ -z "${AUR_SSH_PRIVATE_KEY:-}" ]; then + echo "The aur environment is missing AUR_SSH_PRIVATE_KEY." >&2 + exit 1 + fi + key_dir="$RUNNER_TEMP/aur-key" + mkdir -p "$key_dir" + printf '%s\n' "$AUR_SSH_PRIVATE_KEY" >"$key_dir/aur" + chmod 0600 "$key_dir/aur" + ssh-keygen -y -f "$key_dir/aur" >"$key_dir/aur.pub" + chmod 0644 "$key_dir/aur.pub" + + - name: Build and publish selected recipes from Arch Linux + env: + LOOPWIRE_AUR_PACKAGE: ${{ inputs.package }} + LOOPWIRE_AUR_TAG: ${{ inputs.tag }} + run: | + set -euo pipefail + checkout_root="$RUNNER_TEMP/aur-checkouts" + mkdir -p "$checkout_root" + docker run --rm \ + --env LOOPWIRE_AUR_PACKAGE \ + --env LOOPWIRE_AUR_TAG \ + --volume "$GITHUB_WORKSPACE:/workspace:ro" \ + --volume "$RUNNER_TEMP/aur-key:/run/secrets/aur-key:ro" \ + --volume "$checkout_root:/aur" \ + archlinux@sha256:84cd9ef000b3cff245ec028e87965b84724f4bf1cc63fc2741ba927b88515ed6 \ + bash -ceu ' + pacman -Syu --noconfirm --needed \ + curl git namcap nodejs openssh pipewire pnpm rust webkit2gtk-4.1 wireplumber + useradd --create-home aur-builder + chown -R aur-builder:aur-builder /aur + install -d -m 0700 -o aur-builder -g aur-builder /home/aur-builder/.ssh + cp /run/secrets/aur-key/aur /home/aur-builder/.ssh/aur + cp /run/secrets/aur-key/aur.pub /home/aur-builder/.ssh/aur.pub + chown aur-builder:aur-builder /home/aur-builder/.ssh/aur* + chmod 0600 /home/aur-builder/.ssh/aur + chmod 0644 /home/aur-builder/.ssh/aur.pub + runuser -u aur-builder -- env HOME=/home/aur-builder \ + bash /workspace/scripts/deploy-aur-package.sh \ + --package "$LOOPWIRE_AUR_PACKAGE" \ + --tag "$LOOPWIRE_AUR_TAG" \ + --checkout-root /aur \ + --key /home/aur-builder/.ssh/aur + ' diff --git a/apps/docs/docs/developer/github-actions-setup.md b/apps/docs/docs/developer/github-actions-setup.md index 12a8e9e..eeea6c2 100644 --- a/apps/docs/docs/developer/github-actions-setup.md +++ b/apps/docs/docs/developer/github-actions-setup.md @@ -56,6 +56,21 @@ repository, variable, and secret preflight. Review the displayed names and type Public configuration uses the GitHub `vars` context. Credentials and signing material use the `secrets` context. During migration, workflows still fall back to older repository secrets when the matching Actions variable is absent. +## AUR publication environment + +The manually dispatched `Publish AUR` workflow uses a separate GitHub environment named `aur`. Configure required +reviewers on that environment, then add one environment secret named `AUR_SSH_PRIVATE_KEY`. Use a dedicated +passphrase-free automation key whose public half is registered on the maintainer's AUR account; do not reuse the +interactive, passphrase-protected local key and never commit either private key. + +```bash +gh api --method PUT repos/OWNER/REPO/environments/aur +gh secret set AUR_SSH_PRIVATE_KEY --repo OWNER/REPO --env aur < ~/.ssh/loopwire-aur-actions +``` + +The environment gate is the authority boundary: pull requests and ordinary pushes only build the recipes, while an +approved manual dispatch can publish `loopwire`, `loopwire-bin`, or both from an already-public stable release tag. + ## Input integrity and secrecy - The command never accepts sensitive values as CLI flags or environment variables. diff --git a/apps/docs/docs/developer/release.md b/apps/docs/docs/developer/release.md index 871f613..f1b73a0 100644 --- a/apps/docs/docs/developer/release.md +++ b/apps/docs/docs/developer/release.md @@ -779,11 +779,23 @@ configured and readiness passes. ```bash pnpm verify:aur +pnpm verify:aur:source -- --version 0.1.0 ``` -The AUR smoke renders `packaging/aur/PKGBUILD.in` against generated local artifacts, runs `makepkg --nodeps` in a temp -directory when `makepkg` is available, and checks the resulting package archive contains `usr/bin/loopwire`. It does not -install the package or submit anything to AUR. +The lightweight AUR smoke renders both `packaging/aur/loopwire-bin/PKGBUILD.in` and +`packaging/aur/loopwire/PKGBUILD.in`, builds the binary recipe, and validates the source recipe metadata. +`verify:aur:source` performs the full tagged-source compilation and package-content inspection on Arch. Neither command +installs or submits anything. + +After the GitHub release is public, publish one or both package bases from a clean Arch checkout: + +```bash +pnpm deploy:aur -- --package loopwire --tag v0.1.0 --key ~/.ssh/aur +pnpm deploy:aur -- --package loopwire-bin --tag v0.1.0 --key ~/.ssh/aur +``` + +The manual `Publish AUR` workflow uses the same helper inside an Arch container. It is isolated behind the `aur` +GitHub environment and never runs on a pull request or ordinary branch push. ## Documentation Ceremony diff --git a/apps/docs/docs/guide/install.md b/apps/docs/docs/guide/install.md index f502f20..9d53906 100644 --- a/apps/docs/docs/guide/install.md +++ b/apps/docs/docs/guide/install.md @@ -1,6 +1,21 @@ # Install -Loopwire is not released yet. The current install path is for contributors and early testers working from source. +Loopwire 0.1.0 is published for early testers. Arch users can choose the stable source-built `loopwire` package or +the prebuilt `loopwire-bin` package; contributors can still work directly from a source checkout. + +## Arch User Repository + +Build the stable tagged source package: + +```bash +git clone https://aur.archlinux.org/loopwire.git +cd loopwire +makepkg -si +``` + +For the faster prebuilt release-artifact package, use the separate `loopwire-bin` package base instead. The variants +conflict because they install the same commands; do not install both at once. A future live-VCS package, if added, +will use the `loopwire-git` name. ## Source Install @@ -75,7 +90,8 @@ paths declare or wrap that dependency for you. Package metadata templates now exist under `packaging/`: -- `packaging/aur/PKGBUILD.in` for future AUR `loopwire-bin`. +- `packaging/aur/loopwire/PKGBUILD.in` for stable tagged source builds. +- `packaging/aur/loopwire-bin/PKGBUILD.in` for signed prebuilt release artifacts. - `flake.nix` exposes `packages..loopwire-bin` from `packaging/nix/loopwire-bin.nix`, currently with fake hashes until the first public release provides real artifact hashes. - Repository-owned deb recipes for Ubuntu 24.04 and Debian 13, plus RPM recipes for Fedora 44 and openSUSE @@ -133,5 +149,5 @@ pnpm verify:nix-release -- \ Non-Nix CI and local machines may use `--skip-build-if-missing-nix` only to check wiring. Release evidence and final release proof must not use that skip as Nix package proof. -These channels are not published yet. Do not submit AUR metadata or expose a release-ready Nix package until versioned -artifacts and real checksums exist. +The AUR recipes are published as separate package bases. The Nix package remains a template; do not expose it as +release-ready until real hashes and non-skipped Nix build proof exist. diff --git a/apps/docs/docs/guide/support-matrix.md b/apps/docs/docs/guide/support-matrix.md index 6f7f60f..bddca66 100644 --- a/apps/docs/docs/guide/support-matrix.md +++ b/apps/docs/docs/guide/support-matrix.md @@ -72,7 +72,8 @@ the Tauri shell command bridge. | AppImage | Local Tauri bundle smoke | Blocked on release publishing. | | Ubuntu 24.04 / Debian 13 deb | Verified in matching KVM guests at commit `70eee4e`; review snapshot in `vm/native-package-proof/` | Blocked on release publishing. | | Fedora 44 / openSUSE Tumbleweed RPM | Verified in matching KVM guests at commit `70eee4e`; review snapshot in `vm/native-package-proof/` | Blocked on release publishing. | -| AUR `loopwire-bin` | `pnpm verify:aur` on Arch with `makepkg` | Blocked on tagged artifacts. | +| AUR `loopwire` | Tagged source build through `pnpm verify:aur:source` | Published for 0.1.0. | +| AUR `loopwire-bin` | Signed release-artifact build through `pnpm verify:aur` | Published for 0.1.0. | | Nix flake package template | `pnpm verify:packaging` | Blocked on real release hashes and Nix build proof. | The flake package output is `packages..loopwire-bin`; it uses fake hashes until published artifacts exist. diff --git a/apps/docs/docs/release-notes/unreleased.md b/apps/docs/docs/release-notes/unreleased.md index 0f236f9..3dbbef8 100644 --- a/apps/docs/docs/release-notes/unreleased.md +++ b/apps/docs/docs/release-notes/unreleased.md @@ -2,6 +2,12 @@ These notes describe source-tree progress. They are not a public release announcement. +## Packaging + +- The AUR now keeps two honest stable recipes: `loopwire` compiles the immutable tagged source archive, while + `loopwire-bin` continues to consume signed prebuilt release artifacts. Both are built and inspected before a manual, + environment-protected AUR publication workflow may push their separate package repositories. + ## Desktop UI Rebuild - GitHub Actions setup now has a cross-platform guided command that separates public variables from secrets, explains diff --git a/package.json b/package.json index d6a56ab..31f46e8 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "dsp:plan": "pnpm --filter @loopwire/core build && pnpm --filter @loopwire/audio-host build && node scripts/describe-dsp-provider.mjs", "dsp:verify": "pnpm dsp:plan -- --execute", "deploy:docs:bunny": "bash scripts/deploy-docs-bunny.sh", + "deploy:aur": "bash scripts/deploy-aur-package.sh", "e2e:ui": "node scripts/e2e-desktop-ui.mjs", "e2e:shell": "node scripts/e2e-desktop-shell.mjs", "detect:audio": "pnpm --filter @loopwire/audio-host build && node scripts/detect-audio-backends.mjs --pretty", @@ -55,6 +56,7 @@ "nix:render-release": "bash scripts/render-nix-release-package.sh", "verify:nix-release": "bash scripts/verify-nix-release-package.sh", "verify:aur": "bash scripts/verify-aur-package.sh", + "verify:aur:source": "bash scripts/verify-aur-source-package.sh", "verify:docs": "bash scripts/verify-docs.sh", "verify:site": "node scripts/verify-static-site.mjs", "verify:desktop-binary-launch": "bash scripts/verify-desktop-binary-launch.sh", diff --git a/packaging/README.md b/packaging/README.md index c91bfc5..1ce7f1b 100644 --- a/packaging/README.md +++ b/packaging/README.md @@ -1,7 +1,8 @@ # Packaging -Loopwire package metadata is release-artifact-first. AUR, Nix, curl installer, and native distro packages consume -the same release artifacts: +Loopwire binary package metadata is release-artifact-first. `loopwire-bin`, Nix, the curl installer, and native +distro packages consume the same release artifacts, while the unsuffixed AUR `loopwire` recipe compiles the immutable +tagged source archive: - `loopwire-linux-x86_64.tar.gz` - `loopwire-linux-aarch64.tar.gz` @@ -31,22 +32,44 @@ verify the key pair without placing the private key under the repository. ## AUR -`packaging/aur/PKGBUILD.in` is a template for `loopwire-bin`. Replace: +The two stable AUR recipes are deliberately separate: -- `@VERSION@`, -- `@SHA256_X86_64@`, -- `@SHA256_AARCH64@`. +- `packaging/aur/loopwire/PKGBUILD.in` builds the immutable tagged source archive and owns the exact `loopwire` + package base. +- `packaging/aur/loopwire-bin/PKGBUILD.in` consumes the signed architecture-specific release tarballs and owns + `loopwire-bin`. -The generated `PKGBUILD` must be tested with `makepkg` against published artifacts before any AUR submission. +The source template replaces `@VERSION@`, `@PKGREL@`, and `@SHA256_SOURCE@`. The binary template replaces +`@VERSION@`, `@PKGREL@`, `@SHA256_X86_64@`, and `@SHA256_AARCH64@`. The recipes declare conflicts/provides so only +one variant can own the installed `loopwire` files; a future live-VCS recipe must use the separate `loopwire-git` +package base. + +Every generated `PKGBUILD` must be tested with `makepkg` against its published tag or release artifacts before AUR +submission. For local release-shaped smoke, render the template against generated artifacts and build without installing: ```bash pnpm verify:aur +pnpm verify:aur:source -- --version 0.1.0 +``` + +`verify:aur` builds the binary recipe and checks the source recipe metadata. `verify:aur:source` performs the heavier +tagged source compilation and package-content inspection. Neither command installs or submits a package. + +Publish from a clean Arch checkout with the AUR key loaded or available for an interactive passphrase prompt: + +```bash +pnpm deploy:aur -- --package loopwire --tag v0.1.0 --key ~/.ssh/aur +pnpm deploy:aur -- --package loopwire-bin --tag v0.1.0 --key ~/.ssh/aur ``` -That command uses `makepkg --nodeps` in a temp directory when `makepkg` is available. It does not install the package or -submit anything to AUR. +The helper downloads checksum-bound inputs, builds and inspects the package, generates `.SRCINFO`, increments `pkgrel` +when same-version metadata changes, commits `PKGBUILD`, `.SRCINFO`, and `LICENSE-MIT`, pushes the package-aligned AUR +Git repo, and verifies the remote commit. `.github/workflows/publish-aur.yml` exposes the same path as an +environment-protected +manual dispatch after its dedicated `AUR_SSH_PRIVATE_KEY` secret is configured. The workflow pins the AUR Ed25519 host +key in `packaging/aur/known_hosts`; verify any future key rotation against the official AUR homepage before updating it. ## Nix @@ -197,9 +220,9 @@ verifies multi-architecture checksum entries, signs the manifest, installs the g through `scripts/install.sh`, and proves `loopwire --background --help` works from the extracted and installed launcher. -`verify:aur` renders the AUR template from generated local artifacts, runs `makepkg --nodeps` in a temp directory, and -checks the package archive contains `usr/bin/loopwire`, `usr/bin/loopwire-dsp-provider`, and -`usr/bin/loopwire-jack-ports`. It skips cleanly on hosts without `makepkg`. +`verify:aur` renders both AUR templates, runs a `makepkg --nodeps` binary-package build, checks the package archive, +and validates source-package `.SRCINFO`. It skips cleanly on hosts without `makepkg`. `verify:aur:source` separately +builds the tagged source recipe and checks the complete runtime, desktop entry, and icon. `verify:packaging` statically checks that package metadata points at the same release artifact names as the installer and that the flake exposes the binary package template without replacing fake hashes with unverified values. It also diff --git a/packaging/aur/LICENSE-MIT b/packaging/aur/LICENSE-MIT new file mode 100644 index 0000000..8693de9 --- /dev/null +++ b/packaging/aur/LICENSE-MIT @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Loopwire contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packaging/aur/known_hosts b/packaging/aur/known_hosts new file mode 100644 index 0000000..66a3f9a --- /dev/null +++ b/packaging/aur/known_hosts @@ -0,0 +1 @@ +aur.archlinux.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEuBKrPzbawxA/k2g6NcyV5jmqwJ2s+zpgZGZ7tpLIcN diff --git a/packaging/aur/PKGBUILD.in b/packaging/aur/loopwire-bin/PKGBUILD.in similarity index 82% rename from packaging/aur/PKGBUILD.in rename to packaging/aur/loopwire-bin/PKGBUILD.in index 7d45d99..f3d2b8b 100644 --- a/packaging/aur/PKGBUILD.in +++ b/packaging/aur/loopwire-bin/PKGBUILD.in @@ -1,23 +1,28 @@ # Maintainer: Loopwire contributors pkgname=loopwire-bin pkgver=@VERSION@ -pkgrel=1 -pkgdesc="Linux virtual audio routing workspace" +pkgrel=@PKGREL@ +pkgdesc="Linux virtual audio routing application" arch=("x86_64" "aarch64") url="https://github.com/sandwichfarm/loopwire" license=("MIT" "Apache-2.0") +provides=("loopwire=${pkgver}") +conflicts=("loopwire") depends=("webkit2gtk-4.1" "nodejs" "pipewire" "wireplumber") optdepends=( "pipewire-pulse: PulseAudio compatibility" "jack2: JACK bridge diagnostics" "alsa-utils: ALSA diagnostics" ) +source=("LICENSE-MIT") source_x86_64=("loopwire-linux-x86_64.tar.gz::${url}/releases/download/v${pkgver}/loopwire-linux-x86_64.tar.gz") source_aarch64=("loopwire-linux-aarch64.tar.gz::${url}/releases/download/v${pkgver}/loopwire-linux-aarch64.tar.gz") +sha256sums=("@SHA256_LICENSE@") sha256sums_x86_64=("@SHA256_X86_64@") sha256sums_aarch64=("@SHA256_AARCH64@") package() { + install -Dm644 "${srcdir}/LICENSE-MIT" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE-MIT" install -Dm755 loopwire "${pkgdir}/usr/bin/loopwire" install -Dm755 loopwire-dsp-provider "${pkgdir}/usr/bin/loopwire-dsp-provider" install -Dm755 loopwire-jack-ports "${pkgdir}/usr/bin/loopwire-jack-ports" diff --git a/packaging/aur/loopwire/PKGBUILD.in b/packaging/aur/loopwire/PKGBUILD.in new file mode 100644 index 0000000..35f91cc --- /dev/null +++ b/packaging/aur/loopwire/PKGBUILD.in @@ -0,0 +1,69 @@ +# Maintainer: Loopwire contributors +pkgname=loopwire +pkgver=@VERSION@ +pkgrel=@PKGREL@ +pkgdesc="Linux virtual audio routing application" +arch=("x86_64" "aarch64") +url="https://github.com/sandwichfarm/loopwire" +license=("MIT" "Apache-2.0") +conflicts=("loopwire-bin" "loopwire-git") +depends=("webkit2gtk-4.1" "nodejs>=22.12.0" "pipewire" "wireplumber") +makedepends=("pnpm" "rust") +optdepends=( + "pipewire-pulse: PulseAudio compatibility" + "jack2: JACK bridge diagnostics" + "alsa-utils: ALSA diagnostics" +) +source=( + "${pkgname}-${pkgver}.tar.gz::${url}/archive/refs/tags/v${pkgver}.tar.gz" + "LICENSE-MIT" +) +sha256sums=( + "@SHA256_SOURCE@" + "@SHA256_LICENSE@" +) + +prepare() { + cd "${pkgname}-${pkgver}" + pnpm install --frozen-lockfile +} + +build() { + cd "${pkgname}-${pkgver}" + pnpm --filter @loopwire/core build + pnpm --filter @loopwire/audio-host build + + local release_config + release_config="$(printf '{"version":"%s"}' "${pkgver}")" + pnpm --filter @loopwire/desktop exec tauri build --no-bundle --config "${release_config}" + + SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-0}" bash scripts/package-release.sh \ + --binary apps/desktop/src-tauri/target/release/loopwire \ + --version "${pkgver}" \ + --arch "${CARCH}" \ + --output-dir "${srcdir}/release" +} + +package() { + local release_root="${srcdir}/release-root" + mkdir -p "${release_root}" + tar -xzf "${srcdir}/release/loopwire-linux-${CARCH}.tar.gz" -C "${release_root}" + + install -Dm755 "${release_root}/loopwire" "${pkgdir}/usr/bin/loopwire" + install -Dm755 "${release_root}/loopwire-dsp-provider" "${pkgdir}/usr/bin/loopwire-dsp-provider" + install -Dm755 "${release_root}/loopwire-jack-ports" "${pkgdir}/usr/bin/loopwire-jack-ports" + install -Dm755 "${release_root}/loopwire-detect-audio" "${pkgdir}/usr/bin/loopwire-detect-audio" + install -dm755 "${pkgdir}/usr/lib/loopwire" + cp -R "${release_root}/libexec/loopwire/." "${pkgdir}/usr/lib/loopwire/" + find "${pkgdir}/usr/lib/loopwire" -type d -exec chmod 0755 {} + + find "${pkgdir}/usr/lib/loopwire" -type f -exec chmod 0644 {} + + chmod 0755 "${pkgdir}/usr/lib/loopwire/loopwire-gui" + + cd "${srcdir}/${pkgname}-${pkgver}" + install -Dm644 packaging/common/loopwire.desktop \ + "${pkgdir}/usr/share/applications/loopwire.desktop" + install -Dm644 apps/desktop/src-tauri/icons/icon.svg \ + "${pkgdir}/usr/share/icons/hicolor/scalable/apps/loopwire.svg" + install -Dm644 "${srcdir}/LICENSE-MIT" \ + "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE-MIT" +} diff --git a/scripts/deploy-aur-package.sh b/scripts/deploy-aur-package.sh new file mode 100755 index 0000000..c6149b2 --- /dev/null +++ b/scripts/deploy-aur-package.sh @@ -0,0 +1,313 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +workspace_root="$(cd "$repo_root/.." && pwd)" +package_selection="loopwire" +checkout_root="$workspace_root/aur" +key_path="${AUR_SSH_KEY:-$HOME/.ssh/aur}" +tag="" + +die() { + printf 'error: %s\n' "$*" >&2 + exit 1 +} + +usage() { + cat <<'USAGE' +Build, validate, and publish Loopwire AUR recipes. + +Usage: + deploy-aur-package.sh [--package loopwire|loopwire-bin|all] [--tag vX.Y.Z] + [--checkout-root DIR] [--key PATH] + +Defaults: + --package loopwire + --tag newest v-prefixed tag reachable from HEAD + --checkout-root ../aur relative to the repository root + --key ~/.ssh/aur + +The stable `loopwire` recipe builds the tagged source archive. `loopwire-bin` +consumes the signed architecture-specific release artifacts. Each recipe is +fully built with makepkg and inspected with namcap before its AUR Git push. +USAGE +} + +while [ "$#" -gt 0 ]; do + case "$1" in + --) shift ;; + --package) package_selection="${2:?missing value for --package}"; shift 2 ;; + --tag) tag="${2:?missing value for --tag}"; shift 2 ;; + --checkout-root) checkout_root="${2:?missing value for --checkout-root}"; shift 2 ;; + --key) key_path="${2:?missing value for --key}"; shift 2 ;; + -h | --help) usage; exit 0 ;; + *) die "unknown argument: $1" ;; + esac +done + +case "$package_selection" in + loopwire) packages=(loopwire) ;; + loopwire-bin) packages=(loopwire-bin) ;; + all) packages=(loopwire loopwire-bin) ;; + *) die "--package must be loopwire, loopwire-bin, or all" ;; +esac + +for command_name in awk curl git makepkg namcap openssl sed sha256sum ssh ssh-add ssh-agent ssh-keygen tar; do + command -v "$command_name" >/dev/null 2>&1 || die "required command is missing: $command_name" +done +[[ -d "$repo_root/.git" ]] || die "Loopwire checkout not found: $repo_root" +[[ -f "$repo_root/packaging/release-signing-public.pem" ]] || die "release public key not found" +[[ -f "$repo_root/scripts/verify-release-signature.sh" ]] || die "release signature verifier not found" +known_hosts_path="$repo_root/packaging/aur/known_hosts" +[[ -f "$known_hosts_path" ]] || die "pinned AUR known_hosts file not found" +expected_host_fingerprint="SHA256:RFzBCUItH9LZS0cKB5UE6ceAYhBD5C8GeOBip8Z11+4" +actual_host_fingerprint="$(ssh-keygen -lf "$known_hosts_path" | awk '{ print $2 }')" +[[ "$actual_host_fingerprint" = "$expected_host_fingerprint" ]] || \ + die "pinned AUR host key does not match the official Ed25519 fingerprint" +[[ -f "$key_path" ]] || die "expected SSH private key at $key_path" +[[ "$(stat -c '%a' "$key_path")" == "600" ]] || die "$key_path must have mode 600" + +git -C "$repo_root" diff --quiet || die "Loopwire has tracked unstaged changes" +git -C "$repo_root" diff --cached --quiet || die "Loopwire has staged changes" +if [ -z "$tag" ]; then + tag="$(git -C "$repo_root" describe --tags --abbrev=0 --match 'v[0-9]*' 2>/dev/null)" || \ + die "no v-prefixed release tag is reachable from HEAD" +fi +[[ "$tag" =~ ^v([0-9]+([.][0-9]+)*)$ ]] || die "release tag must look like v1.2.3; got $tag" +version="${tag#v}" + +tmp_dir="$(mktemp -d -t loopwire-aur-deploy.XXXXXXXX)" +started_agent=0 +cleanup() { + rm -rf -- "$tmp_dir" + if [ "$started_agent" = "1" ]; then + ssh-agent -k >/dev/null 2>&1 || true + fi +} +trap cleanup EXIT + +if [[ ! -S "${SSH_AUTH_SOCK:-}" ]]; then + eval "$(ssh-agent -s)" >/dev/null + started_agent=1 +fi +public_key_path="$key_path.pub" +if [ ! -f "$public_key_path" ]; then + public_key_path="$tmp_dir/aur.pub" + ssh-keygen -y -f "$key_path" >"$public_key_path" +fi +key_fingerprint="$(ssh-keygen -lf "$public_key_path" | awk '{ print $2 }')" +if ! ssh-add -l 2>/dev/null | grep -Fq "$key_fingerprint"; then + printf 'Unlocking AUR key %s...\n' "$key_fingerprint" + ssh-add "$key_path" +fi +auth_output="$( + ssh -i "$key_path" \ + -o IdentitiesOnly=yes \ + -o BatchMode=yes \ + -o StrictHostKeyChecking=yes \ + -o "UserKnownHostsFile=$known_hosts_path" \ + -T aur@aur.archlinux.org 2>&1 || true +)" +printf '%s\n' "$auth_output" +[[ "$auth_output" == *"Welcome to AUR"* ]] || die "AUR did not accept $key_path" +printf -v git_ssh_command \ + 'ssh -i %q -o IdentitiesOnly=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile=%q' \ + "$key_path" "$known_hosts_path" + +release_dir="$tmp_dir/release" +mkdir -p "$release_dir" +if [[ " ${packages[*]} " == *" loopwire "* ]]; then + source_archive="$release_dir/loopwire-${version}.tar.gz" + curl --fail --location --retry 3 --silent --show-error \ + "https://github.com/sandwichfarm/loopwire/archive/refs/tags/${tag}.tar.gz" \ + --output "$source_archive" +fi +if [[ " ${packages[*]} " == *" loopwire-bin "* ]]; then + release_base="https://github.com/sandwichfarm/loopwire/releases/download/$tag" + for asset in SHA256SUMS SHA256SUMS.sig loopwire-linux-x86_64.tar.gz loopwire-linux-aarch64.tar.gz; do + curl --fail --location --retry 3 --silent --show-error \ + "$release_base/$asset" --output "$release_dir/$asset" + done + bash "$repo_root/scripts/verify-release-signature.sh" \ + --release-dir "$release_dir" \ + --public-key "$repo_root/packaging/release-signing-public.pem" + ( + cd "$release_dir" + sha256sum --check --ignore-missing SHA256SUMS + ) +fi + +render_pkgbuild() { + local package_name="$1" + local package_rel="$2" + local output="$3" + local source_mode="$4" + local args=( + --package "$package_name" + --version "$version" + --pkgrel "$package_rel" + --output "$output" + ) + if [ "$package_name" = "loopwire" ]; then + args+=(--source-archive "$source_archive") + else + args+=(--release-dir "$release_dir") + fi + if [ "$source_mode" = "published" ]; then + args+=(--published) + fi + bash "$repo_root/scripts/render-aur-pkgbuild.sh" "${args[@]}" >/dev/null +} + +generate_srcinfo() { + local pkgbuild="$1" + local output="$2" + local metadata_dir + metadata_dir="$(mktemp -d "$tmp_dir/srcinfo.XXXXXXXX")" + cp "$pkgbuild" "$metadata_dir/PKGBUILD" + ( + cd "$metadata_dir" + makepkg --printsrcinfo + ) >"$output" +} + +prepare_checkout() { + local package_name="$1" + local checkout="$checkout_root/$package_name" + local remote="aur@aur.archlinux.org:${package_name}.git" + mkdir -p "$checkout_root" + if [ -e "$checkout" ] && [ ! -d "$checkout/.git" ]; then + die "AUR checkout path exists but is not a Git repository: $checkout" + fi + if [ ! -d "$checkout/.git" ]; then + if GIT_SSH_COMMAND="$git_ssh_command" \ + git ls-remote --exit-code "$remote" refs/heads/master >/dev/null 2>&1; then + GIT_SSH_COMMAND="$git_ssh_command" git clone "$remote" "$checkout" >/dev/null + else + mkdir -p "$checkout" + git -C "$checkout" init --initial-branch=master >/dev/null + git -C "$checkout" remote add origin "$remote" + fi + fi + [[ -z "$(git -C "$checkout" status --porcelain)" ]] || die "AUR checkout has uncommitted changes: $checkout" + existing_remote="$(git -C "$checkout" remote get-url origin 2>/dev/null || true)" + [ "$existing_remote" = "$remote" ] || die "AUR checkout origin is $existing_remote, expected $remote" + git -C "$checkout" config core.sshCommand "$git_ssh_command" + if git -C "$checkout" ls-remote --exit-code origin refs/heads/master >/dev/null 2>&1; then + git -C "$checkout" fetch origin master + if git -C "$checkout" rev-parse --verify HEAD >/dev/null 2>&1; then + git -C "$checkout" merge --ff-only FETCH_HEAD >/dev/null + else + git -C "$checkout" checkout -B master FETCH_HEAD >/dev/null + fi + fi + printf '%s\n' "$checkout" +} + +publish_package() { + local package_name="$1" + local checkout package_dir candidate_pkgbuild candidate_srcinfo current_version current_rel package_rel + checkout="$(prepare_checkout "$package_name")" + package_dir="$tmp_dir/$package_name" + mkdir -p "$package_dir" + candidate_pkgbuild="$package_dir/PKGBUILD.published" + candidate_srcinfo="$package_dir/.SRCINFO.published" + current_version="" + current_rel="0" + if [ -f "$checkout/.SRCINFO" ]; then + current_version="$(awk '$1 == "pkgver" && $2 == "=" { print $3; exit }' "$checkout/.SRCINFO")" + current_rel="$(awk '$1 == "pkgrel" && $2 == "=" { print $3; exit }' "$checkout/.SRCINFO")" + fi + package_rel="1" + if [ "$current_version" = "$version" ] && [[ "$current_rel" =~ ^[0-9]+$ ]]; then + package_rel="$current_rel" + fi + render_pkgbuild "$package_name" "$package_rel" "$candidate_pkgbuild" published + generate_srcinfo "$candidate_pkgbuild" "$candidate_srcinfo" + if [ -f "$checkout/PKGBUILD" ] && [ -f "$checkout/.SRCINFO" ] && \ + [ -f "$checkout/LICENSE-MIT" ] && \ + cmp -s "$candidate_pkgbuild" "$checkout/PKGBUILD" && \ + cmp -s "$candidate_srcinfo" "$checkout/.SRCINFO" && \ + cmp -s "$repo_root/packaging/aur/LICENSE-MIT" "$checkout/LICENSE-MIT"; then + printf '%s is already current at %s-%s.\n' "$package_name" "$version" "$package_rel" + return + fi + if [ "$current_version" = "$version" ] && [[ "$current_rel" =~ ^[0-9]+$ ]]; then + package_rel="$((current_rel + 1))" + render_pkgbuild "$package_name" "$package_rel" "$candidate_pkgbuild" published + generate_srcinfo "$candidate_pkgbuild" "$candidate_srcinfo" + fi + + build_dir="$package_dir/build" + mkdir -p "$build_dir" + render_pkgbuild "$package_name" "$package_rel" "$build_dir/PKGBUILD" local + cp "$repo_root/packaging/aur/LICENSE-MIT" "$build_dir/LICENSE-MIT" + if [ "$package_name" = "loopwire" ]; then + cp "$source_archive" "$build_dir/loopwire-${version}.tar.gz" + else + cp "$release_dir/loopwire-linux-x86_64.tar.gz" "$build_dir/" + cp "$release_dir/loopwire-linux-aarch64.tar.gz" "$build_dir/" + fi + printf 'Building %s %s-%s...\n' "$package_name" "$version" "$package_rel" + ( + cd "$build_dir" + makepkg --force --nodeps --noconfirm --cleanbuild --clean + ) + package_file="$(find "$build_dir" -maxdepth 1 -type f -name "${package_name}-*.pkg.tar.*" ! -name "${package_name}-debug-*" -print -quit)" + [ -n "$package_file" ] || die "makepkg did not produce the $package_name package" + namcap_log="$package_dir/namcap.log" + namcap "$candidate_pkgbuild" "$package_file" | tee "$namcap_log" + grep -Fq " E: " "$namcap_log" && die "namcap reported an error for $package_name" + + install -m 0644 "$candidate_pkgbuild" "$checkout/PKGBUILD" + install -m 0644 "$candidate_srcinfo" "$checkout/.SRCINFO" + install -m 0644 "$repo_root/packaging/aur/LICENSE-MIT" "$checkout/LICENSE-MIT" + git -C "$checkout" add PKGBUILD .SRCINFO LICENSE-MIT + git -C "$checkout" diff --cached --quiet && return + + author_name="$(git -C "$repo_root" config user.name || true)" + author_email="$(git -C "$repo_root" config user.email || true)" + git -C "$checkout" config user.name "${author_name:-Loopwire release bot}" + git -C "$checkout" config user.email "${author_email:-aur@loopwire.app}" + recipe_kind="source-built" + [ "$package_name" = "loopwire-bin" ] && recipe_kind="release-binary" + commit_message="$package_dir/commit-message" + cat >"$commit_message" <&2 - usage >&2 - exit 2 - ;; + --) shift ;; + --package) package_name="${2:?missing value for --package}"; shift 2 ;; + --version) version="${2:?missing value for --version}"; shift 2 ;; + --pkgrel) pkgrel="${2:?missing value for --pkgrel}"; shift 2 ;; + --release-dir) release_dir="${2:?missing value for --release-dir}"; shift 2 ;; + --source-archive) source_archive="${2:?missing value for --source-archive}"; shift 2 ;; + --output) output_path="${2:?missing value for --output}"; shift 2 ;; + --published) published="true"; shift ;; + -h | --help) usage; exit 0 ;; + *) echo "Unknown argument: $1" >&2; usage >&2; exit 2 ;; esac done -if [ -z "$version" ] || [ -z "$release_dir" ] || [ -z "$output_path" ]; then +if [ -z "$package_name" ] || [ -z "$version" ] || [ -z "$output_path" ]; then usage >&2 exit 2 fi - -if [ ! -f "$template_path" ]; then - echo "Missing template: $template_path" >&2 - exit 1 +if [[ ! "$version" =~ ^[0-9]+([.][0-9]+)*$ ]]; then + echo "Version must contain dot-separated integers: $version" >&2 + exit 2 fi - -release_dir="${release_dir%/}" -x86_asset="$release_dir/loopwire-linux-x86_64.tar.gz" -aarch64_asset="$release_dir/loopwire-linux-aarch64.tar.gz" - -if [ ! -f "$x86_asset" ] || [ ! -f "$aarch64_asset" ]; then - echo "Release directory must contain x86_64 and aarch64 tarballs: $release_dir" >&2 - exit 1 +if [[ ! "$pkgrel" =~ ^[1-9][0-9]*$ ]]; then + echo "pkgrel must be a positive integer: $pkgrel" >&2 + exit 2 fi -x86_hash="$(sha256sum "$x86_asset" | awk '{ print $1 }')" -aarch64_hash="$(sha256sum "$aarch64_asset" | awk '{ print $1 }')" -release_dir_abs="$(cd "$release_dir" && pwd -P)" +root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +license_file="$root/packaging/aur/LICENSE-MIT" +[ -f "$license_file" ] || { + echo "Missing AUR license file: $license_file" >&2 + exit 1 +} +license_hash="$(sha256sum "$license_file" | awk '{ print $1 }')" tmp_output="$(mktemp)" -rendered_output="$(mktemp)" cleanup() { - rm -f "$tmp_output" "$rendered_output" + rm -f "$tmp_output" "${tmp_output}.local" } trap cleanup EXIT -sed \ - -e "s/@VERSION@/${version}/g" \ - -e "s/@SHA256_X86_64@/${x86_hash}/g" \ - -e "s/@SHA256_AARCH64@/${aarch64_hash}/g" \ - "$template_path" >"$tmp_output" +case "$package_name" in + loopwire-bin) + template_path="$root/packaging/aur/loopwire-bin/PKGBUILD.in" + release_dir="${release_dir%/}" + x86_asset="$release_dir/loopwire-linux-x86_64.tar.gz" + aarch64_asset="$release_dir/loopwire-linux-aarch64.tar.gz" + if [ ! -f "$x86_asset" ] || [ ! -f "$aarch64_asset" ]; then + echo "loopwire-bin requires both release tarballs in: $release_dir" >&2 + exit 1 + fi + x86_hash="$(sha256sum "$x86_asset" | awk '{ print $1 }')" + aarch64_hash="$(sha256sum "$aarch64_asset" | awk '{ print $1 }')" + sed \ + -e "s/@VERSION@/${version}/g" \ + -e "s/@PKGREL@/${pkgrel}/g" \ + -e "s/@SHA256_LICENSE@/${license_hash}/g" \ + -e "s/@SHA256_X86_64@/${x86_hash}/g" \ + -e "s/@SHA256_AARCH64@/${aarch64_hash}/g" \ + "$template_path" >"$tmp_output" + if [ "$published" = "false" ]; then + release_dir_abs="$(cd "$release_dir" && pwd -P)" + awk -v release_dir="$release_dir_abs" ' + /^source_x86_64=/ { + print "source_x86_64=(\"loopwire-linux-x86_64.tar.gz::file://" release_dir "/loopwire-linux-x86_64.tar.gz\")" + next + } + /^source_aarch64=/ { + print "source_aarch64=(\"loopwire-linux-aarch64.tar.gz::file://" release_dir "/loopwire-linux-aarch64.tar.gz\")" + next + } + { print } + ' "$tmp_output" >"${tmp_output}.local" + mv "${tmp_output}.local" "$tmp_output" + fi + ;; + loopwire) + template_path="$root/packaging/aur/loopwire/PKGBUILD.in" + if [ ! -f "$source_archive" ]; then + echo "loopwire requires --source-archive FILE" >&2 + exit 1 + fi + source_hash="$(sha256sum "$source_archive" | awk '{ print $1 }')" + sed \ + -e "s/@VERSION@/${version}/g" \ + -e "s/@PKGREL@/${pkgrel}/g" \ + -e "s/@SHA256_SOURCE@/${source_hash}/g" \ + -e "s/@SHA256_LICENSE@/${license_hash}/g" \ + "$template_path" >"$tmp_output" + ;; + *) echo "Unsupported AUR package: $package_name" >&2; exit 2 ;; +esac -awk -v release_dir="$release_dir_abs" ' - /^source_x86_64=/ { - print "source_x86_64=(\"loopwire-linux-x86_64.tar.gz::file://" release_dir "/loopwire-linux-x86_64.tar.gz\")" - next - } - /^source_aarch64=/ { - print "source_aarch64=(\"loopwire-linux-aarch64.tar.gz::file://" release_dir "/loopwire-linux-aarch64.tar.gz\")" - next - } - { print } -' "$tmp_output" >"$rendered_output" +if grep -Eq '@[A-Z0-9_]+@' "$tmp_output"; then + echo "Rendered PKGBUILD contains an unresolved placeholder." >&2 + exit 1 +fi mkdir -p "$(dirname "$output_path")" -cp "$rendered_output" "$output_path" +cp "$tmp_output" "$output_path" echo "Rendered $output_path" diff --git a/scripts/verify-aur-package.sh b/scripts/verify-aur-package.sh index a084bec..7cc03c4 100644 --- a/scripts/verify-aur-package.sh +++ b/scripts/verify-aur-package.sh @@ -13,7 +13,8 @@ cleanup() { trap cleanup EXIT release_dir="$tmp_dir/release" -work_dir="$tmp_dir/aur" +work_dir="$tmp_dir/aur-bin" +source_work_dir="$tmp_dir/aur-source" binary="$tmp_dir/loopwire" pnpm --filter @loopwire/core build >/dev/null @@ -27,19 +28,23 @@ chmod 0755 "$binary" bash scripts/package-release.sh \ --binary "$binary" \ - --version "0.0.0-smoke" \ + --version "0.0.0" \ --arch x86_64 \ --output-dir "$release_dir" >/dev/null bash scripts/package-release.sh \ --binary "$binary" \ - --version "0.0.0-smoke" \ + --version "0.0.0" \ --arch aarch64 \ --output-dir "$release_dir" >/dev/null -mkdir -p "$work_dir" +mkdir -p "$work_dir" "$source_work_dir" +cp packaging/aur/LICENSE-MIT "$work_dir/LICENSE-MIT" +cp packaging/aur/LICENSE-MIT "$source_work_dir/LICENSE-MIT" bash scripts/render-aur-pkgbuild.sh \ - --version "0.0.0_smoke" \ + --package loopwire-bin \ + --version "0.0.0" \ + --pkgrel 1 \ --release-dir "$release_dir" \ --output "$work_dir/PKGBUILD" >/dev/null @@ -82,4 +87,35 @@ require_package_member "usr/bin/loopwire-detect-audio" require_package_member "usr/lib/loopwire/loopwire-gui" require_package_member "usr/lib/loopwire/scripts/restore-background.mjs" -echo "AUR local package smoke passed." +namcap_log="$tmp_dir/namcap-bin.log" +namcap "$work_dir/PKGBUILD" "$package_file" | tee "$namcap_log" +if grep -Fq " E: " "$namcap_log"; then + echo "namcap reported an error for loopwire-bin." >&2 + exit 1 +fi + +source_archive="$tmp_dir/loopwire-0.0.0.tar.gz" +mkdir -p "$tmp_dir/loopwire-0.0.0" +tar -czf "$source_archive" -C "$tmp_dir" loopwire-0.0.0 +cp "$source_archive" "$source_work_dir/loopwire-0.0.0.tar.gz" +bash scripts/render-aur-pkgbuild.sh \ + --package loopwire \ + --version "0.0.0" \ + --pkgrel 1 \ + --source-archive "$source_archive" \ + --output "$source_work_dir/PKGBUILD" >/dev/null +( + cd "$source_work_dir" + makepkg --printsrcinfo >.SRCINFO +) +grep -Fqx "pkgbase = loopwire" "$source_work_dir/.SRCINFO" +grep -Fqx $'\tconflicts = loopwire-bin' "$source_work_dir/.SRCINFO" +grep -Fqx $'\tmakedepends = pnpm' "$source_work_dir/.SRCINFO" +grep -Fqx $'\tmakedepends = rust' "$source_work_dir/.SRCINFO" +namcap "$source_work_dir/PKGBUILD" | tee "$tmp_dir/namcap-source-metadata.log" +if grep -Fq " E: " "$tmp_dir/namcap-source-metadata.log"; then + echo "namcap reported an error for the loopwire source PKGBUILD." >&2 + exit 1 +fi + +echo "AUR binary build and source metadata smokes passed." diff --git a/scripts/verify-aur-source-package.sh b/scripts/verify-aur-source-package.sh new file mode 100755 index 0000000..c209617 --- /dev/null +++ b/scripts/verify-aur-source-package.sh @@ -0,0 +1,116 @@ +#!/usr/bin/env bash +set -euo pipefail + +root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +version="" +source_archive="" + +usage() { + cat <<'USAGE' +Build and inspect the stable source-built Loopwire AUR package. + +Usage: + verify-aur-source-package.sh [--version VERSION] [--source-archive FILE] + +The default version is the newest v-prefixed tag reachable from HEAD. When no +archive is supplied, the matching immutable GitHub tag archive is downloaded. +USAGE +} + +while [ "$#" -gt 0 ]; do + case "$1" in + --) shift ;; + --version) version="${2:?missing value for --version}"; shift 2 ;; + --source-archive) source_archive="${2:?missing value for --source-archive}"; shift 2 ;; + -h | --help) usage; exit 0 ;; + *) echo "Unknown argument: $1" >&2; usage >&2; exit 2 ;; + esac +done + +if ! command -v makepkg >/dev/null 2>&1; then + echo "makepkg not found; source package verification requires an Arch Linux build environment." >&2 + exit 1 +fi +command -v namcap >/dev/null 2>&1 || { + echo "namcap not found; source package verification requires namcap." >&2 + exit 1 +} + +if [ -z "$version" ]; then + tag="$(git -C "$root" describe --tags --abbrev=0 --match 'v[0-9]*' 2>/dev/null)" || { + echo "No v-prefixed release tag is reachable from HEAD." >&2 + exit 1 + } + version="${tag#v}" +else + tag="v${version}" +fi +if [[ ! "$version" =~ ^[0-9]+([.][0-9]+)*$ ]]; then + echo "Version must contain dot-separated integers: $version" >&2 + exit 2 +fi + +tmp_dir="$(mktemp -d -t loopwire-aur-source.XXXXXXXX)" +cleanup() { + rm -rf "$tmp_dir" +} +trap cleanup EXIT + +if [ -z "$source_archive" ]; then + source_archive="$tmp_dir/loopwire-${version}.tar.gz" + curl --fail --location --retry 3 --silent --show-error \ + "https://github.com/sandwichfarm/loopwire/archive/refs/tags/${tag}.tar.gz" \ + --output "$source_archive" +fi +if [ ! -f "$source_archive" ]; then + echo "Source archive does not exist: $source_archive" >&2 + exit 1 +fi + +build_dir="$tmp_dir/build" +mkdir -p "$build_dir" +bash "$root/scripts/render-aur-pkgbuild.sh" \ + --package loopwire \ + --version "$version" \ + --pkgrel 1 \ + --source-archive "$source_archive" \ + --output "$build_dir/PKGBUILD" >/dev/null +cp "$source_archive" "$build_dir/loopwire-${version}.tar.gz" +cp "$root/packaging/aur/LICENSE-MIT" "$build_dir/LICENSE-MIT" + +( + cd "$build_dir" + makepkg --force --nodeps --noconfirm --cleanbuild --clean +) + +package_file="$(find "$build_dir" -maxdepth 1 -type f -name 'loopwire-*.pkg.tar.*' ! -name 'loopwire-debug-*' -print -quit)" +if [ -z "$package_file" ]; then + echo "makepkg did not produce a loopwire package archive." >&2 + exit 1 +fi + +namcap_log="$tmp_dir/namcap.log" +namcap "$build_dir/PKGBUILD" "$package_file" | tee "$namcap_log" +if grep -Fq " E: " "$namcap_log"; then + echo "namcap reported an error for the loopwire source package." >&2 + exit 1 +fi + +package_members="$tmp_dir/package-members.txt" +tar -tf "$package_file" >"$package_members" +for member in \ + usr/bin/loopwire \ + usr/bin/loopwire-dsp-provider \ + usr/bin/loopwire-jack-ports \ + usr/bin/loopwire-detect-audio \ + usr/lib/loopwire/loopwire-gui \ + usr/lib/loopwire/scripts/restore-background.mjs \ + usr/share/applications/loopwire.desktop \ + usr/share/icons/hicolor/scalable/apps/loopwire.svg; do + grep -Fxq "$member" "$package_members" || { + echo "AUR source package does not contain $member." >&2 + exit 1 + } +done + +echo "AUR source package build passed for ${version}." diff --git a/scripts/verify-docs.sh b/scripts/verify-docs.sh index f494c40..d4e9052 100644 --- a/scripts/verify-docs.sh +++ b/scripts/verify-docs.sh @@ -287,6 +287,12 @@ assert_contains "apps/docs/docs/guide/install.md" "loopwire-dsp-provider" assert_contains "apps/docs/docs/guide/install.md" 'The curl installer reports whether `node` is available' assert_contains "apps/docs/docs/guide/install.md" "AUR and Nix package" assert_contains "apps/docs/docs/guide/install.md" "paths declare or wrap that dependency" +assert_contains "apps/docs/docs/guide/install.md" "https://aur.archlinux.org/loopwire.git" +assert_contains "apps/docs/docs/guide/install.md" "packaging/aur/loopwire-bin/PKGBUILD.in" +assert_contains "apps/docs/docs/guide/support-matrix.md" 'AUR `loopwire`' +assert_contains "apps/docs/docs/guide/support-matrix.md" 'AUR `loopwire-bin`' +assert_contains "apps/docs/docs/developer/release.md" "pnpm verify:aur:source" +assert_contains "apps/docs/docs/developer/github-actions-setup.md" "AUR_SSH_PRIVATE_KEY" assert_contains "apps/docs/docs/guide/install.md" "fake" assert_contains "apps/docs/docs/guide/install.md" "VitePress public asset" assert_contains "apps/docs/docs/guide/install.md" "/install.sh" diff --git a/scripts/verify-github-workflows.sh b/scripts/verify-github-workflows.sh index 42951c4..48b06ff 100755 --- a/scripts/verify-github-workflows.sh +++ b/scripts/verify-github-workflows.sh @@ -98,6 +98,7 @@ workflows=( ".github/workflows/continuous-tests.yml" ".github/workflows/deploy-docs.yml" ".github/workflows/final-release-proof.yml" + ".github/workflows/publish-aur.yml" ".github/workflows/release.yml" ".github/workflows/vm-matrix.yml" ) @@ -118,6 +119,8 @@ assert_contains ".github/workflows/ci.yml" "fetch-depth: 0" assert_contains ".github/workflows/ci.yml" "libwebkit2gtk-4.1-dev" assert_contains ".github/workflows/ci.yml" "xauth" assert_contains ".github/workflows/ci.yml" "xvfb" +assert_contains ".github/workflows/ci.yml" "validate-aur-source:" +assert_contains ".github/workflows/ci.yml" "scripts/verify-aur-source-package.sh" assert_contains "package.json" '"verify:tauri": "bash scripts/verify-tauri.sh"' assert_contains "package.json" "pnpm verify:tauri" @@ -155,6 +158,15 @@ assert_contains ".github/workflows/deploy-docs.yml" "--dist dist/site" assert_contains "package.json" '"verify:docs-deployment": "node scripts/verify-docs-deployment-manifest.mjs"' assert_contains "package.json" '"verify:docs-live": "bash scripts/verify-docs-live.sh"' +assert_contains ".github/workflows/publish-aur.yml" "workflow_dispatch:" +assert_contains ".github/workflows/publish-aur.yml" "environment: aur" +assert_contains ".github/workflows/publish-aur.yml" "contents: read" +assert_contains ".github/workflows/publish-aur.yml" "AUR_SSH_PRIVATE_KEY" +assert_contains ".github/workflows/publish-aur.yml" "scripts/deploy-aur-package.sh" +assert_contains ".github/workflows/publish-aur.yml" "archlinux@sha256:" +assert_contains ".github/workflows/publish-aur.yml" "loopwire-bin" +assert_not_contains ".github/workflows/publish-aur.yml" "pull_request:" + assert_contains ".github/workflows/final-release-proof.yml" "workflow_dispatch:" assert_contains ".github/workflows/final-release-proof.yml" 'run-name: Final Release Proof ${{ inputs.tag }} @ ${{ inputs.git_head }}' assert_contains ".github/workflows/final-release-proof.yml" "actions: read" diff --git a/scripts/verify-packaging.sh b/scripts/verify-packaging.sh index b20ae97..715e542 100755 --- a/scripts/verify-packaging.sh +++ b/scripts/verify-packaging.sh @@ -11,15 +11,21 @@ require_contains() { fi } -require_contains packaging/aur/PKGBUILD.in "loopwire-linux-x86_64.tar.gz" -require_contains packaging/aur/PKGBUILD.in "loopwire-linux-aarch64.tar.gz" -require_contains packaging/aur/PKGBUILD.in "github.com/sandwichfarm/loopwire" -require_contains packaging/aur/PKGBUILD.in "install -Dm755 loopwire" -require_contains packaging/aur/PKGBUILD.in "install -Dm755 loopwire-dsp-provider" -require_contains packaging/aur/PKGBUILD.in "install -Dm755 loopwire-jack-ports" -require_contains packaging/aur/PKGBUILD.in "install -Dm755 loopwire-detect-audio" -require_contains packaging/aur/PKGBUILD.in "nodejs" -require_contains packaging/aur/PKGBUILD.in "usr/lib/loopwire" +require_contains packaging/aur/loopwire-bin/PKGBUILD.in "pkgname=loopwire-bin" +require_contains packaging/aur/loopwire-bin/PKGBUILD.in "provides=(\"loopwire=\${pkgver}\")" +require_contains packaging/aur/loopwire-bin/PKGBUILD.in "conflicts=(\"loopwire\")" +require_contains packaging/aur/loopwire-bin/PKGBUILD.in "loopwire-linux-x86_64.tar.gz" +require_contains packaging/aur/loopwire-bin/PKGBUILD.in "loopwire-linux-aarch64.tar.gz" +require_contains packaging/aur/loopwire-bin/PKGBUILD.in "install -Dm755 loopwire" +require_contains packaging/aur/loopwire/PKGBUILD.in "pkgname=loopwire" +require_contains packaging/aur/loopwire/PKGBUILD.in "archive/refs/tags/v\${pkgver}.tar.gz" +require_contains packaging/aur/loopwire/PKGBUILD.in "pnpm install --frozen-lockfile" +require_contains packaging/aur/loopwire/PKGBUILD.in "tauri build --no-bundle" +require_contains packaging/aur/loopwire/PKGBUILD.in "scripts/package-release.sh" +require_contains packaging/aur/loopwire/PKGBUILD.in "usr/share/applications/loopwire.desktop" +require_contains packaging/aur/loopwire/PKGBUILD.in "usr/share/icons/hicolor/scalable/apps/loopwire.svg" +require_contains scripts/deploy-aur-package.sh "--package loopwire|loopwire-bin|all" +require_contains packaging/aur/known_hosts "aur.archlinux.org ssh-ed25519" require_contains packaging/nix/loopwire-bin.nix "loopwire-linux-x86_64.tar.gz" require_contains packaging/nix/loopwire-bin.nix "loopwire-linux-aarch64.tar.gz" require_contains packaging/nix/loopwire-bin.nix "github.com/sandwichfarm/loopwire" diff --git a/scripts/verify-requirements.sh b/scripts/verify-requirements.sh index a382f0f..468356f 100644 --- a/scripts/verify-requirements.sh +++ b/scripts/verify-requirements.sh @@ -82,7 +82,10 @@ assert_contains "apps/desktop/src-tauri/tauri.conf.json" '"decorations": true' assert_contains "scripts/manage-autostart.sh" "systemd" assert_contains "scripts/install.sh" "detect_arch" assert_contains "scripts/install.sh" "loopwire-linux-aarch64.tar.gz" -assert_file "packaging/aur/PKGBUILD.in" +assert_file "packaging/aur/loopwire/PKGBUILD.in" +assert_file "packaging/aur/loopwire-bin/PKGBUILD.in" +assert_file "scripts/deploy-aur-package.sh" +assert_file "scripts/verify-aur-source-package.sh" assert_file "packaging/nix/loopwire-bin.nix" assert_file "flake.nix" assert_contains "flake.nix" "packages = forEachSystem" @@ -93,6 +96,7 @@ assert_file "scripts/verify-nix-release-package.sh" assert_script "package.json" "nix:render-release" "bash scripts/render-nix-release-package.sh" assert_script "package.json" "verify:nix-release" "bash scripts/verify-nix-release-package.sh" assert_script "package.json" "release:agent-ready" "bash scripts/verify-agent-release-ready.sh" +assert_script "package.json" "deploy:aur" "bash scripts/deploy-aur-package.sh" for requirement in DOCS-01 DOCS-02 DOCS-03 DOCS-04; do assert_requirement_checked "$requirement" diff --git a/scripts/verify-scripts.sh b/scripts/verify-scripts.sh index 47e1ae7..09736ee 100755 --- a/scripts/verify-scripts.sh +++ b/scripts/verify-scripts.sh @@ -9,6 +9,7 @@ bash -n \ scripts/verify-release-signature.sh \ scripts/stage-release-artifacts.sh \ scripts/deploy-docs-bunny.sh \ + scripts/deploy-aur-package.sh \ scripts/verify-docs-live.sh \ scripts/select-docs-deployment-run.sh \ scripts/fetch-docs-deployment-proof.sh \ @@ -46,6 +47,7 @@ bash -n \ scripts/collect-vm-evidence-ssh.sh \ scripts/collect-vm-matrix-evidence.sh \ scripts/verify-aur-package.sh \ + scripts/verify-aur-source-package.sh \ scripts/verify-packaging.sh \ scripts/verify-native-packaging.sh \ scripts/build-deb-package.sh \ @@ -100,6 +102,14 @@ bash scripts/build-portable-linux-binary.sh -- --help | grep -Fq -- "--output FI echo "verify-scripts: portable builder does not accept the package-script separator" >&2 exit 1 } +bash scripts/deploy-aur-package.sh --help | grep -Fq -- "--package loopwire|loopwire-bin|all" || { + echo "verify-scripts: AUR deploy helper does not advertise package selection" >&2 + exit 1 +} +bash scripts/verify-aur-source-package.sh --help | grep -Fq -- "--source-archive FILE" || { + echo "verify-scripts: AUR source verifier does not advertise local archive input" >&2 + exit 1 +} bash scripts/build-deb-package.sh -- --help | grep -Fq -- "--target ubuntu-24.04|debian-13" || { echo "verify-scripts: deb builder does not accept the package-script separator" >&2 exit 1