Skip to content

Commit

Permalink
Merge pull request #65 from pomodorox/main
Browse files Browse the repository at this point in the history
Reconfigure the RPM URLs if checksum changed.
  • Loading branch information
rmohr authored Oct 9, 2023
2 parents 6ce8d7f + 18edcd6 commit bf38400
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/bazel/bazel.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,17 @@ func AddWorkspaceRPMs(workspace *build.File, pkgs []*api.Package, arch string) e
rpms[pkgName] = rule
}
rule.SetName(pkgName)
rule.SetSHA256(pkg.Checksum.Text)
urls := rule.URLs()
if len(urls) == 0 {
// Configure/re-configure the URLs when
// 1) no URLs are set, or
// 2) the checksum changed.
if len(urls) == 0 || (rule.SHA256() != pkg.Checksum.Text) {
err := rule.SetURLs(pkg.Repository.Mirrors, pkg.Location.Href)
if err != nil {
return err
}
}
rule.SetSHA256(pkg.Checksum.Text)
}

rules := []*RPMRule{}
Expand Down
9 changes: 9 additions & 0 deletions pkg/bazel/testdata/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ rpm(
name = "test.rpm",
urls = ["http://something.rpm"],
)

rpm(
name = "a-0__2.3.4.myarch",
sha256 = "0000",
urls = [
"old/url/1",
"old/url/2",
],
)

0 comments on commit bf38400

Please sign in to comment.