Repository navigation
feat(pkgdef): add package definition library - #3001
Open
mikeland73 wants to merge 1 commit into
Open
mikeland73 wants to merge 1 commit into
mikeland73 wants to merge 1 commit into
Conversation
Add internal/pkgdef, the library behind package definitions (see specs/package-definitions.md): parsing and validation of *.pkg.json files, pkg:<ref>@<version> reference parsing, loading local and remote definitions (remote ones cached and pinned by content hash), version resolution from static lists, JSON indexes (via gojq) and GitHub releases, per-system artifact locking with checksums, and idempotent installs into $XDG_CACHE_HOME/devbox/pkgs/<name>/<version>/<system>. The package is a leaf with no dependency on devpkg, lock or plugin so the wiring in a follow-up PR can build on it. The manager and script strategies defined by the spec return ErrNotImplemented for now. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Second PR of the package definitions stack (spec:
specs/package-definitions.md, added in the previous PR). Addsinternal/pkgdef, a leaf package with no dependency ondevpkg,lockorplugin:Parse/Validatefor*.pkg.json(hujson), with every error reported at once.ParseRefforpkg:<ref>@<version>(version split at the last@).Client.Loadfor path,https://andfile://refs. Remote definitions are cached by content hash and can be pinned to a hash from the lockfile (ErrDefinitionChangedwhen the server now serves something else).static,http_json(jq via gojq),github_releases(drafts and pre-releases skipped, token only ever sent to the GitHub API host).Client.Resolve/Lock: resolvelatest, a prefix or an exact version, then render the artifact URL and fetch its sha256 (http_jsonorsha256_url, which handles bare digests andSHASUMS-style lists) for every supported system.Client.Install: idempotent install into$XDG_CACHE_HOME/devbox/pkgs/<name>/<version>/<system>, serialized across processes with a file lock, verified against the lockfile digest, extracted with path and symlink sanitization (tar.{gz,xz,bz2,zst} and zip via mholt/archives, which the repo already uses),post_installhooks with their output kept for error messages.managerandscriptstrategies returnErrNotImplementedfor now, as the spec marks them planned.New direct dependency:
github.com/itchyny/gojq(vendor-hash refreshed).Test plan
go test ./internal/pkgdef/(unit tests against an httptest "vendor": resolve, lock, archive and binary installs, concurrent installs, checksum mismatch, trust on first use, GitHub releases, remote pinning, extraction safety)golangci-lintand gofumpt clean🤖 Generated with Claude Code