Skip to content

Commit

Permalink
feat: allow occam to cope with pack limitations
Browse files Browse the repository at this point in the history
pack seems to be very limited in the options it will
accept when building for multi-arch. It does not
seem to accept a path with a tgz as input and only
works properly if you build in an exploded directory.
Otherwise it appears to have built the cnb file but
the structure of the bin directory is incorrect and
the executables cannot be found.

Update the jam packager to work around this by exploding
the tgz after creating it and then build in that
exploded directory.

It is still a good idea to build the tgz as that
filters the files based on what is specified in the
buildpack.toml.

Signed-off-by: Michael Dawson <[email protected]>
  • Loading branch information
mhdawson authored and ForestEckhardt committed Nov 19, 2024
1 parent eebbe41 commit 9b665d9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
27 changes: 25 additions & 2 deletions packagers/jam.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,40 @@ func (j Jam) Execute(buildpackDir, output, version string, offline bool) error {
return err
}

tmpDir, _ := os.MkdirTemp("", "build")
if _, err := os.Stat(buildpackTarballPath); err == nil {
doUnzip := pexec.NewExecutable("tar")
args = []string{
"-xvf",
buildpackTarballPath,
}
err = doUnzip.Execute(pexec.Execution{
Dir: tmpDir,
Args: args,
Stdout: os.Stdout,
Stderr: os.Stderr,
})
if err != nil {
return err
}

}

args = []string{
"buildpack", "package",
output,
"--path", buildpackTarballPath,
"--format", "file",
"--target", fmt.Sprintf("linux/%s", runtime.GOARCH),
}

return j.pack.Execute(pexec.Execution{
err = j.pack.Execute(pexec.Execution{
Dir: tmpDir,
Args: args,
Stdout: os.Stdout,
Stderr: os.Stderr,
})

os.RemoveAll(tmpDir)

return err
}
3 changes: 0 additions & 3 deletions packagers/jam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func testJam(t *testing.T, context spec.G, it spec.S) {
Expect(pack.ExecuteCall.Receives.Execution.Args).To(Equal([]string{
"buildpack", "package",
"some-output",
"--path", filepath.Join("some-jam-output", "some-version.tgz"),
"--format", "file",
"--target", fmt.Sprintf("linux/%s", runtime.GOARCH),
}))
Expand All @@ -75,7 +74,6 @@ func testJam(t *testing.T, context spec.G, it spec.S) {
Expect(pack.ExecuteCall.Receives.Execution.Args).To(Equal([]string{
"buildpack", "package",
"some-output",
"--path", filepath.Join("some-jam-output", "some-version.tgz"),
"--format", "file",
"--target", fmt.Sprintf("linux/%s", runtime.GOARCH),
}))
Expand Down Expand Up @@ -113,7 +111,6 @@ func testJam(t *testing.T, context spec.G, it spec.S) {
Expect(pack.ExecuteCall.Receives.Execution.Args).To(Equal([]string{
"buildpack", "package",
"some-output",
"--path", filepath.Join("some-jam-output", "some-version.tgz"),
"--format", "file",
"--target", fmt.Sprintf("linux/%s", runtime.GOARCH),
}))
Expand Down

0 comments on commit 9b665d9

Please sign in to comment.