Add wrapper-script env var support for claude-code's self-update guard #2

Merged
schaefera merged 1 commit from worktree-add-wrapper-env-support into master 2026-09-20 07:32:11 +00:00
Collaborator

Summary

  • The previously-installed claude-code package (2.1.273-1, an AUR build) wraps its real binary in a /usr/bin/claude script that sets DISABLE_UPDATES=1/DISABLE_INSTALLATION_CHECKS=1 before exec-ing /opt/claude-code/bin/claude — almost certainly to stop Claude Code's own self-updater from fighting with a package manager already managing it, which applies just as much to a pkgwatch-managed install.
  • Add Package::env (sorted BTreeMap). When set and non-empty, builder.rs installs the real binary under /usr/lib/<pkgname>/ and generates a /usr/bin/<binary_name> wrapper that exports the declared vars before exec-ing it, written inline via a quoted heredoc (no bash expansion at PKGBUILD-build time).
  • The wrapper finds its sibling binary via $(dirname "$0") rather than a hardcoded absolute path — /bin/sh is bash on this box and sets $0 to the full resolved path when found via PATH (confirmed empirically), so the same wrapper resolves correctly both under sanity.rs's staging-directory pkgdir check and after a real pacman install.
  • Wired claude-code.toml to declare both vars.

Test plan

  • cargo test — 87/87 passing (added config + builder tests for the new env field, wrapper generation, and validation)
  • cargo clippy -- -D warnings clean, cargo fmt --check clean
  • Built end to end against a scratch repo (PKGWATCH_REPO_DIR): check -> fetch -> verify -> review claude-code --approve -> build -> sanity-check -> publish all pass, sanity check now runs through the wrapper (not the raw binary) and still passes
  • Manually confirmed the built package's wrapper genuinely exports both vars at runtime (substituted the exec line for an env dump and diffed)

🤖 Generated with Claude Code

## Summary - The previously-installed `claude-code` package (`2.1.273-1`, an AUR build) wraps its real binary in a `/usr/bin/claude` script that sets `DISABLE_UPDATES=1`/`DISABLE_INSTALLATION_CHECKS=1` before `exec`-ing `/opt/claude-code/bin/claude` — almost certainly to stop Claude Code's own self-updater from fighting with a package manager already managing it, which applies just as much to a pkgwatch-managed install. - Add `Package::env` (sorted `BTreeMap`). When set and non-empty, `builder.rs` installs the real binary under `/usr/lib/<pkgname>/` and generates a `/usr/bin/<binary_name>` wrapper that exports the declared vars before `exec`-ing it, written inline via a quoted heredoc (no bash expansion at PKGBUILD-build time). - The wrapper finds its sibling binary via `$(dirname "$0")` rather than a hardcoded absolute path — `/bin/sh` is `bash` on this box and sets `$0` to the full resolved path when found via `PATH` (confirmed empirically), so the same wrapper resolves correctly both under `sanity.rs`'s staging-directory `pkgdir` check and after a real `pacman` install. - Wired `claude-code.toml` to declare both vars. ## Test plan - [x] `cargo test` — 87/87 passing (added config + builder tests for the new `env` field, wrapper generation, and validation) - [x] `cargo clippy -- -D warnings` clean, `cargo fmt --check` clean - [x] Built end to end against a scratch repo (`PKGWATCH_REPO_DIR`): `check -> fetch -> verify -> review claude-code --approve -> build -> sanity-check -> publish` all pass, sanity check now runs through the wrapper (not the raw binary) and still passes - [x] Manually confirmed the built package's wrapper genuinely exports both vars at runtime (substituted the `exec` line for an env dump and diffed) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
claude-bot added 1 commit 2026-09-18 11:07:23 +00:00
Add wrapper-script env var support for claude-code's self-update guard
All checks were successful
CI / build (pull_request) Successful in 47s
CI / test (pull_request) Successful in 3m31s
CI / audit (pull_request) Successful in 14s
CI / coverage (pull_request) Successful in 6m59s
994cee65f5
The previously-installed claude-code package (2.1.273-1, an AUR build)
wraps its real binary in a /usr/bin/claude script that sets
DISABLE_UPDATES=1 and DISABLE_INSTALLATION_CHECKS=1 before exec-ing
/opt/claude-code/bin/claude — almost certainly to stop Claude Code's own
self-updater from fighting with a package manager already managing it,
which applies just as much to a pkgwatch-managed install. The generated
PKGBUILD had no way to replicate that: it only ever wrote one file.

Add Package::env (a sorted BTreeMap for deterministic output). When set
and non-empty, builder.rs now installs the real binary under
/usr/lib/<pkgname>/ and generates a /usr/bin/<binary_name> wrapper that
exports the declared vars before exec-ing it, written inline via a
quoted heredoc (no bash expansion at PKGBUILD-build time). The wrapper
finds its sibling binary via $(dirname "$0") rather than a hardcoded
absolute path, since /bin/sh is bash on this box and sets $0 to the
full resolved path when found via PATH (confirmed empirically) — so the
same wrapper resolves correctly both under sanity.rs's staging-directory
pkgdir check and after a real pacman install.

Wired claude-code.toml to declare both vars. Verified end to end against
a scratch repo: build succeeds, the sanity check (which now runs through
the wrapper, not the raw binary) passes, and the built package's wrapper
genuinely exports both vars at runtime before exec-ing the real binary
(confirmed by hand, substituting the exec line for an env dump).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
schaefera merged commit bf85160861 into master 2026-09-20 07:32:11 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: schaefera/pkgwatch#2
No description provided.