Skip to content

Commit

Permalink
Merge pull request #10294 from filecoin-project/mikers/buildReleaseOv…
Browse files Browse the repository at this point in the history
…errides

fix: pack: support network name overrides in bundle git tags
  • Loading branch information
arajasek authored Feb 17, 2023
2 parents 30615a4 + f41435d commit 7a35a73
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ actors-gen: actors-code-gen fiximports
.PHONY: actors-gen

bundle-gen:
$(GOCC) run ./gen/bundle $(RELEASE)
$(GOCC) run ./gen/bundle $(VERSION) $(RELEASE) $(RELEASE_OVERRIDES)
$(GOCC) fmt ./build/...
.PHONY: bundle-gen

Expand Down
2 changes: 1 addition & 1 deletion build/actors/pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ popd

echo "Generating metadata..."

make -C ../../ RELEASE="$RELEASE" bundle-gen
make -C ../../ VERSION="$VERSION" RELEASE="$RELEASE" RELEASE_OVERRIDES="${RELEASE_OVERRIDES[*]}" bundle-gen
57 changes: 50 additions & 7 deletions gen/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package main

import (
"os"
"strconv"
"strings"
"text/template"

"github.com/filecoin-project/lotus/build"
Expand Down Expand Up @@ -32,19 +34,49 @@ var EmbeddedBuiltinActorsMetadata []*BuiltinActorsMetadata = []*BuiltinActorsMet
}
`))

func splitOverride(override string) (string, string) {
x := strings.Split(override, "=")
return x[0], x[1]
}

func main() {
// read metadata from the embedded bundle, includes all info except git tags
metadata, err := build.ReadEmbeddedBuiltinActorsMetadata()
if err != nil {
panic(err)
}

// TODO: Re-enable this when we can set the tag for ONLY the appropriate version
// https://github.com/filecoin-project/lotus/issues/10185#issuecomment-1422864836
//if len(os.Args) > 1 {
// for _, m := range metadata {
// m.BundleGitTag = os.Args[1]
// }
//}
// IF args have been provided, extract git tag info from them, otherwise
// rely on previously embedded metadata for git tags.
if len(os.Args) > 1 {
// see ./build/actors/pack.sh
// (optional) expected args are:
// $(GOCC) run ./gen/bundle $(VERSION) $(RELEASE) $(RELEASE_OVERRIDES)
// overrides are in the format network_name=override
gitTag := os.Args[2]
packedActorsVersion, err := strconv.Atoi(os.Args[1][1:])
if err != nil {
panic(err)
}

overrides := map[string]string{}
for _, override := range os.Args[3:] {
k, v := splitOverride(override)
overrides[k] = v
}
for _, m := range metadata {
if int(m.Version) == packedActorsVersion {
override, ok := overrides[m.Network]
if ok {
m.BundleGitTag = override
} else {
m.BundleGitTag = gitTag
}
} else {
m.BundleGitTag = getOldGitTagFromEmbeddedMetadata(m)
}
}
}

fi, err := os.Create("./build/builtin_actors_gen.go")
if err != nil {
Expand All @@ -57,3 +89,14 @@ func main() {
panic(err)
}
}

func getOldGitTagFromEmbeddedMetadata(m *build.BuiltinActorsMetadata) string {
for _, v := range build.EmbeddedBuiltinActorsMetadata {
// if we agree on the manifestCid for the previously embedded metadata, use the previously set tag
if m.Version == v.Version && m.Network == v.Network && m.ManifestCid == v.ManifestCid {
return m.BundleGitTag
}
}

return ""
}

0 comments on commit 7a35a73

Please sign in to comment.