Repository navigation
Add an RPM repository client #141
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 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 7e7d550
Add an RPM repository client
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 26f26d4
Merge the Debian client's review fixes
simonchrz 720dfd6
Bound the xz dictionary where blocks are decoded
simonchrz c6bc8cf
Merge the Debian client's xz reader
simonchrz de645a1
Hold a block to the sizes its header declares
simonchrz 636df94
Merge branch 'feat/deb-client' into feat/rpm-client
simonchrz 6fdf189
Merge branch 'main' into feat/rpm-client
simonchrz d167a40
Keep every RPM requirement constraint and refuse primary.xml without …
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| //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/rpm" | ||
| "github.com/git-pkgs/registries/safehttp" | ||
| ) | ||
|
|
||
| // rpmRepository serves a repository with one version of curl for two | ||
| // architectures, over TLS: the resolver only hands out https download URLs. | ||
| func rpmRepository(t *testing.T) (string, *registries.Client) { | ||
| t.Helper() | ||
| files := map[string]string{ | ||
| "/os/repodata/repomd.xml": `<repomd><data type="primary"><location href="repodata/primary.xml"/></data></repomd>`, | ||
| "/os/repodata/primary.xml": `<metadata> | ||
| <package type="rpm"><name>curl</name><arch>x86_64</arch><version epoch="0" ver="8.15.0" rel="4.fc43"/> | ||
| <checksum type="sha256">aa</checksum><size package="3"/><location href="Packages/c/curl-8.15.0-4.fc43.x86_64.rpm"/></package> | ||
| <package type="rpm"><name>curl</name><arch>aarch64</arch><version epoch="0" ver="8.15.0" rel="4.fc43"/> | ||
| <checksum type="sha256">bb</checksum><size package="4"/><location href="Packages/c/curl-8.15.0-4.fc43.aarch64.rpm"/></package> | ||
| </metadata>`, | ||
| } | ||
| server := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| body, ok := files[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 + "/os", client | ||
| } | ||
|
|
||
| func TestResolveRPMByQualifiers(t *testing.T) { | ||
| base, client := rpmRepository(t) | ||
| reg, err := registries.New("rpm", base+"?distro=fedora-43", client) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| r := NewResolver(WithAddressPolicy(safehttp.Options{AllowLoopback: true})) | ||
| r.RegisterRegistry(reg) | ||
|
|
||
| info, err := r.ResolveWithOptions(context.Background(), "rpm", "fedora/curl", "8.15.0-4.fc43", | ||
| ResolveOptions{Qualifiers: map[string]string{"arch": "aarch64", "distro": "fedora-43"}}) | ||
| if err != nil { | ||
| t.Fatalf("Resolve: %v", err) | ||
| } | ||
| if want := base + "/Packages/c/curl-8.15.0-4.fc43.aarch64.rpm"; info.URL != want || info.Integrity != "sha256-bb" || info.Size != 4 { | ||
| t.Errorf("info = %+v, want %s", info, want) | ||
| } | ||
|
|
||
| _, err = r.ResolveWithOptions(context.Background(), "rpm", "fedora/curl", "8.15.0-4.fc43", | ||
| ResolveOptions{Qualifiers: map[string]string{"arch": "x86_64", "distro": "fedora-42"}}) | ||
| 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Qualify the primary-metadata size check in the README.
The README says the client checks the
primaryfile against the checksum and size listed inrepodata/repomd.xml. The client performs the size check only whenrepomd.xmllists a checksum forprimary. When it lists a size but no checksum, the client accepts the file without comparing the listed size. A zero size is also not compared. Revise the sentence so the size check is conditional on a listed checksum.Suggested fix
LanguageTool
[style] ~212-~212: To strengthen your wording, consider replacing the phrasal verb “leave out”.
Context: ...re the requirements that name packages, leaving out file paths, sonames and capabilities in...
(OMIT_EXCLUDE)