Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/create-draft-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
name: Unit Tests
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 'stable'
- name: Checkout
uses: actions/checkout@v3
go-version-file: go.mod
- name: Setup Docker Multi-Platform Builds
run: |
docker run --privileged --rm docker/binfmt:a7996909642ee92942dcd6cff44b9b95f08dad64
Expand All @@ -37,12 +37,12 @@ jobs:
runs-on: ubuntu-22.04
needs: unit
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: 'stable'
- name: Checkout
uses: actions/checkout@v3
go-version-file: go.mod
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* || true
- name: Reset Draft Release
id: reset
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:
name: lint
runs-on: ubuntu-22.04
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 'stable'

- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ jobs:
name: Unit Tests
runs-on: ubuntu-22.04
steps:
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 'stable'

- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Setup Docker Multi-Platform Builds
run: |
docker run --privileged --rm docker/binfmt:a7996909642ee92942dcd6cff44b9b95f08dad64
Expand Down
49 changes: 48 additions & 1 deletion commands/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"os"
"path/filepath"
"runtime"
"strings"

"github.com/paketo-buildpacks/jam/v2/internal"
Expand Down Expand Up @@ -124,8 +125,54 @@ func packRun(flags packFlags) error {
return fmt.Errorf("failed to cache dependencies: %s", err)
}

// linux/amd64 will be the default target dir when dependencies don't specify os and arch
defaultTargetDir := "linux/amd64"
runtimeTargetDir := filepath.Join(runtime.GOOS, runtime.GOARCH)

for _, dependency := range config.Metadata.Dependencies {
config.Metadata.IncludeFiles = append(config.Metadata.IncludeFiles, strings.TrimPrefix(dependency.URI, "file:///"))
var targetPlatformDir string
shouldMoveToPlatformDir := false
checkTargetDirPaths := []string{}
if dependency.OS != "" && dependency.Arch != "" {
checkTargetDirPaths = append(checkTargetDirPaths, filepath.Join(dependency.OS, dependency.Arch))
}
checkTargetDirPaths = append(checkTargetDirPaths, runtimeTargetDir, defaultTargetDir)

for _, dir := range checkTargetDirPaths {
info, err := os.Stat(filepath.Join(tmpDir, dir))
if err == nil && info.IsDir() && !os.IsNotExist(err) {
shouldMoveToPlatformDir = true
targetPlatformDir = dir
break
}
}

if shouldMoveToPlatformDir {
// This is a multi-arch buildpack and dependencies need to be moved into the platform-specific directory because
// `pack buildpack package` will be called with `--target <os>/<arch>` and files outside the path will not be included
offlinePath := strings.TrimPrefix(dependency.URI, "file:///")
dependenciesDir := filepath.Dir(offlinePath)
offlineFilename := filepath.Base(offlinePath)

info, err := os.Stat(filepath.Join(tmpDir, dependenciesDir))
if err != nil || os.IsNotExist(err) || !info.IsDir() {
return fmt.Errorf("expected dependencies directory does not exist: %s", err)
}

err = os.MkdirAll(filepath.Join(tmpDir, targetPlatformDir, dependenciesDir), os.ModePerm)
if err != nil {
return fmt.Errorf("failed to create platform specific dependencies directory: %s", err)
}

err = os.Rename(filepath.Join(tmpDir, offlinePath), filepath.Join(tmpDir, targetPlatformDir, dependenciesDir, offlineFilename))
if err != nil {
return fmt.Errorf("failed to move offline dependency to platform specific directory: %s", err)
}

config.Metadata.IncludeFiles = append(config.Metadata.IncludeFiles, filepath.Join(targetPlatformDir, dependenciesDir, offlineFilename))
} else {
config.Metadata.IncludeFiles = append(config.Metadata.IncludeFiles, strings.TrimPrefix(dependency.URI, "file:///"))
}
}
}

Expand Down
Loading
Loading