Repository navigation
Add a Debian repository client #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
simonchrz
wants to merge
6
commits into
git-pkgs:main
Choose a base branch
from
simonchrz:feat/deb-client
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5ca248c
Add a Debian repository client
simonchrz d027262
Carry the archive configuration in the deb PURL
simonchrz b19b320
Walk .xz files as the decoder does, and four index fixes
simonchrz b4dced4
Keep the xz test constants within a 32-bit int
simonchrz 720dfd6
Bound the xz dictionary where blocks are decoded
simonchrz de645a1
Hold a block to the sizes its header declares
simonchrz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| //go:build !tinygo | ||
|
|
||
| package fetch | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
| "net/http" | ||
| "net/http/httptest" | ||
| "testing" | ||
|
|
||
| "github.com/git-pkgs/registries" | ||
| _ "github.com/git-pkgs/registries/internal/deb" | ||
| "github.com/git-pkgs/registries/safehttp" | ||
| ) | ||
|
|
||
| // debArchive serves bookworm amd64 and arm64 plain Packages indexes with no | ||
| // Release, over TLS: the resolver only hands out https download URLs. | ||
| func debArchive(t *testing.T) (string, *registries.Client) { | ||
| t.Helper() | ||
| indexes := map[string]string{ | ||
| "/debian/dists/bookworm/main/binary-amd64/Packages": "Package: curl\nVersion: 7.88.1-10\nArchitecture: amd64\n" + | ||
| "Filename: pool/main/c/curl/curl_7.88.1-10_amd64.deb\nSize: 3\nSHA256: aa\n", | ||
| "/debian/dists/bookworm/main/binary-arm64/Packages": "Package: curl\nVersion: 7.88.1-10\nArchitecture: arm64\n" + | ||
| "Filename: pool/main/c/curl/curl_7.88.1-10_arm64.deb\nSize: 4\nSHA256: bb\n", | ||
| } | ||
| server := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| body, ok := indexes[r.URL.Path] | ||
| if !ok { | ||
| http.NotFound(w, r) | ||
| return | ||
| } | ||
| _, _ = w.Write([]byte(body)) | ||
| })) | ||
| t.Cleanup(server.Close) | ||
| client := registries.DefaultClient() | ||
| client.HTTPClient = server.Client() | ||
| return server.URL + "/debian", client | ||
| } | ||
|
|
||
| func TestResolveDebByQualifiers(t *testing.T) { | ||
| base, client := debArchive(t) | ||
| reg, err := registries.New("deb", base+"?suites=bookworm&architectures=amd64,arm64", client) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| r := NewResolver(WithAddressPolicy(safehttp.Options{AllowLoopback: true})) | ||
| r.RegisterRegistry(reg) | ||
|
|
||
| info, err := r.ResolveWithOptions(context.Background(), "deb", "debian/curl", "7.88.1-10", | ||
| ResolveOptions{Qualifiers: map[string]string{"arch": "arm64", "distro": "bookworm"}}) | ||
| if err != nil { | ||
| t.Fatalf("Resolve: %v", err) | ||
| } | ||
| if want := base + "/pool/main/c/curl/curl_7.88.1-10_arm64.deb"; info.URL != want || info.Integrity != "sha256-bb" || info.Size != 4 { | ||
| t.Errorf("info = %+v, want %s", info, want) | ||
| } | ||
|
|
||
| _, err = r.ResolveWithOptions(context.Background(), "deb", "debian/curl", "7.88.1-10", | ||
| ResolveOptions{Qualifiers: map[string]string{"arch": "amd64", "distro": "trixie"}}) | ||
| if !errors.Is(err, ErrNoMatchingArtifact) { | ||
| t.Errorf("other distro: err = %v, want ErrNoMatchingArtifact", err) | ||
| } | ||
| } | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.