Skip to content

Commit

Permalink
Adjust behavior of noarch PURLs
Browse files Browse the repository at this point in the history
If a PURL does not have an arch= key, then we will assume it applies to any arch. This would be for JAR files or other non-architecture dependent packages. This behavior is slightly different than when there is no PURL at all. If there is no PURL at all, then we assume x86. This is for backwards compatibility, for buildpacks that do not include PURLs.

Signed-off-by: Daniel Mikusa <[email protected]>
  • Loading branch information
dmikusa committed Oct 30, 2023
1 parent 763ed5b commit aeb0932
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion buildpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ func archFromPURL(rawPURL string) (string, error) {
return arch[0], nil
}

return "amd64", nil
return archFromSystem(), nil
}

func archFromSystem() string {
Expand Down
27 changes: 27 additions & 0 deletions buildpack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,33 @@ func testBuildpack(t *testing.T, context spec.G, it spec.S) {
}))
})

it("filters by arch where arch should match any", func() {
resolver.Dependencies = []libpak.BuildpackDependency{
{
ID: "test-id-1",
Name: "test-name",
Version: "1.0",
URI: "test-uri",
SHA256: "test-sha256",
Stacks: []string{"test-stack-1", "test-stack-2"},
PURL: "pkg:generic/[email protected]",
},
}
resolver.StackID = "test-stack-1"

t.Setenv("BP_ARCH", "arm64")

Expect(resolver.Resolve("test-id-1", "1.0")).To(Equal(libpak.BuildpackDependency{
ID: "test-id-1",
Name: "test-name",
Version: "1.0",
URI: "test-uri",
SHA256: "test-sha256",
Stacks: []string{"test-stack-1", "test-stack-2"},
PURL: "pkg:generic/[email protected]",
}))
})

it("filters by version constraint", func() {
resolver.Dependencies = []libpak.BuildpackDependency{
{
Expand Down

0 comments on commit aeb0932

Please sign in to comment.