Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ARM64 binaries #123

Merged
merged 1 commit into from
Jan 23, 2024
Merged
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
13 changes: 12 additions & 1 deletion .github/pipeline-descriptor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@ dependencies:
id: jattach
uses: docker://ghcr.io/paketo-buildpacks/actions/github-release-dependency:main
with:
glob: jattach
glob: jattach-linux-x64.tgz
owner: apangin
repository: jattach
tag_filter: v([\d.]*)
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}

# ARM64
- name: jattach ARM64
id: jattach
uses: docker://ghcr.io/paketo-buildpacks/actions/github-release-dependency:main
with:
glob: jattach-linux-arm64.tgz
owner: apangin
repository: jattach
tag_filter: v([\d.]*)
Expand Down
121 changes: 121 additions & 0 deletions .github/workflows/pb-update-jattach-arm-64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Update jattach ARM64
"on":
schedule:
- cron: 0 5 * * 1-5
workflow_dispatch: {}
jobs:
update:
name: Update Buildpack Dependency
runs-on:
- ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.20"
- name: Install update-buildpack-dependency
run: |
#!/usr/bin/env bash

set -euo pipefail

go install -ldflags="-s -w" github.com/paketo-buildpacks/libpak/cmd/update-buildpack-dependency@latest
- name: Install yj
run: |
#!/usr/bin/env bash

set -euo pipefail

echo "Installing yj ${YJ_VERSION}"

mkdir -p "${HOME}"/bin
echo "${HOME}/bin" >> "${GITHUB_PATH}"

curl \
--location \
--show-error \
--silent \
--output "${HOME}"/bin/yj \
"https://github.com/sclevine/yj/releases/download/v${YJ_VERSION}/yj-linux-amd64"

chmod +x "${HOME}"/bin/yj
env:
YJ_VERSION: 5.1.0
- uses: actions/checkout@v4
- id: dependency
uses: docker://ghcr.io/paketo-buildpacks/actions/github-release-dependency:main
with:
glob: jattach-linux-arm64.tgz
owner: apangin
repository: jattach
tag_filter: v([\d.]*)
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
- name: Update Buildpack Dependency
id: buildpack
run: |
#!/usr/bin/env bash

set -euo pipefail

if [ -z "${ARCH}" ]; then
ARCH="amd64"
fi

OLD_VERSION=$(yj -tj < buildpack.toml | \
jq -r ".metadata.dependencies[] | select( .id == env.ID ) | select( .version | test( env.VERSION_PATTERN ) ) | select( .purl | contains( env.ARCH ) ) | .version")

update-buildpack-dependency \
--buildpack-toml buildpack.toml \
--id "${ID}" \
--arch "${ARCH}" \
--version-pattern "${VERSION_PATTERN}" \
--version "${VERSION}" \
--cpe-pattern "${CPE_PATTERN:-}" \
--cpe "${CPE:-}" \
--purl-pattern "${PURL_PATTERN:-}" \
--purl "${PURL:-}" \
--uri "${URI}" \
--sha256 "${SHA256}" \
--source "${SOURCE_URI}" \
--source-sha256 "${SOURCE_SHA256}"

git add buildpack.toml
git checkout -- .

if [ "$(echo "$OLD_VERSION" | awk -F '.' '{print $1}')" != "$(echo "$VERSION" | awk -F '.' '{print $1}')" ]; then
LABEL="semver:major"
elif [ "$(echo "$OLD_VERSION" | awk -F '.' '{print $2}')" != "$(echo "$VERSION" | awk -F '.' '{print $2}')" ]; then
LABEL="semver:minor"
else
LABEL="semver:patch"
fi

echo "old-version=${OLD_VERSION}" >> "$GITHUB_OUTPUT"
echo "new-version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "version-label=${LABEL}" >> "$GITHUB_OUTPUT"
env:
ARCH: ""
CPE: ${{ steps.dependency.outputs.cpe }}
CPE_PATTERN: ""
ID: jattach
PURL: ${{ steps.dependency.outputs.purl }}
PURL_PATTERN: ""
SHA256: ${{ steps.dependency.outputs.sha256 }}
SOURCE_SHA256: ${{ steps.dependency.outputs.source_sha256 }}
SOURCE_URI: ${{ steps.dependency.outputs.source }}
URI: ${{ steps.dependency.outputs.uri }}
VERSION: ${{ steps.dependency.outputs.version }}
VERSION_PATTERN: '[\d]+\.[\d]+\.[\d]+'
- uses: peter-evans/create-pull-request@v5
with:
author: ${{ secrets.JAVA_GITHUB_USERNAME }} <${{ secrets.JAVA_GITHUB_USERNAME }}@users.noreply.github.com>
body: Bumps `jattach ARM64` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`.
branch: update/buildpack/jattach-arm-64
commit-message: |-
Bump jattach ARM64 from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}

Bumps jattach ARM64 from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}.
delete-branch: true
labels: ${{ steps.buildpack.outputs.version-label }}, type:dependency-upgrade
signoff: true
title: Bump jattach ARM64 from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/pb-update-jattach.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- id: dependency
uses: docker://ghcr.io/paketo-buildpacks/actions/github-release-dependency:main
with:
glob: jattach
glob: jattach-linux-x64.tgz
owner: apangin
repository: jattach
tag_filter: v([\d.]*)
Expand Down
26 changes: 18 additions & 8 deletions buildpack.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2018-2021 the original author or authors.
# Copyright 2018-2024 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -42,22 +42,32 @@ api = "0.7"
id = "jattach"
name = "JAttach"
purl = "pkg:generic/jattach@2.2.0?arch=amd64"
sha256 = "a08cb795a1e8d11ea6c2dd6adf8c9edead9a7c3bbca07681dad79cc3eaec0ef4"
sha256 = "acd9e17f15749306be843df392063893e97bfecc5260eef73ee98f06e5cfe02f"
source = "https://github.com/apangin/jattach/archive/refs/tags/v2.2.tar.gz"
source-sha256 = "dc29ebb4fe795a026698fd77d04072cfb39295276a541cfc5e77d20b1509a1cf"
stacks = ["io.buildpacks.stacks.bionic", "io.paketo.stacks.tiny", "*"]
uri = "https://github.com/jattach/jattach/releases/download/v2.2/jattach"
stacks = ["*"]
uri = "https://github.com/jattach/jattach/releases/download/v2.2/jattach-linux-x64.tgz"
version = "2.2.0"

[[metadata.dependencies.licenses]]
type = "Apache-2.0"
uri = "https://github.com/apangin/jattach/blob/master/LICENSE"

[[stacks]]
id = "io.buildpacks.stacks.bionic"
[[metadata.dependencies]]
cpes = ["cpe:2.3:a:apangin:jattach:2.2.0:*:*:*:*:*:*:*"]
id = "jattach"
name = "JAttach"
purl = "pkg:generic/jattach@2.2.0?arch=arm64"
sha256 = "288ae5ed87ee7fe0e608c06db5a23a096a6217c9878ede53c4e33710bdcaab51"
source = "https://github.com/apangin/jattach/archive/refs/tags/v2.2.tar.gz"
source-sha256 = "dc29ebb4fe795a026698fd77d04072cfb39295276a541cfc5e77d20b1509a1cf"
stacks = ["*"]
uri = "https://github.com/jattach/jattach/releases/download/v2.2/jattach-linux-arm64.tgz"
version = "2.2.0"

[[stacks]]
id = "io.paketo.stacks.tiny"
[[metadata.dependencies.licenses]]
type = "Apache-2.0"
uri = "https://github.com/apangin/jattach/blob/master/LICENSE"

[[stacks]]
id = "*"
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ require (
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/creack/pty v1.1.21 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/h2non/filetype v1.1.3 // indirect
github.com/heroku/color v0.0.6 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE=
github.com/h2non/filetype v1.1.3 h1:FKkx9QbD7HR/zjK1Ia5XiBsq9zdLi5Kf3zGyFTAFkGg=
github.com/h2non/filetype v1.1.3/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY=
github.com/heroku/color v0.0.6 h1:UTFFMrmMLFcL3OweqP1lAdp8i1y/9oHqkeHjQ/b/Ny0=
github.com/heroku/color v0.0.6/go.mod h1:ZBvOcx7cTF2QKOv4LbmoBtNl5uB17qWxGuzZrsi1wLU=
github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
Expand All @@ -36,6 +38,8 @@ github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
github.com/stretchr/objx v0.5.1 h1:4VhoImhV/Bm0ToFkXFi8hXNXwpDRZ/ynw3amt82mzq0=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down
39 changes: 7 additions & 32 deletions jattach/build_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2020 the original author or authors.
* Copyright 2018-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,8 +17,6 @@
package jattach_test

import (
"io/ioutil"
"os"
"testing"

"github.com/paketo-buildpacks/jattach/jattach"
Expand All @@ -39,50 +37,27 @@ func testBuild(t *testing.T, context spec.G, it spec.S) {
it.Before(func() {
var err error

ctx.Application.Path, err = ioutil.TempDir("", "build")
ctx.Application.Path = t.TempDir()
Expect(err).NotTo(HaveOccurred())

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

ctx.Plan.Entries = append(ctx.Plan.Entries, libcnb.BuildpackPlanEntry{Name: "jattach"})
ctx.Buildpack.Metadata = map[string]interface{}{
"dependencies": []map[string]interface{}{
{
"id": "jattach",
"version": "1.0.0",
"stacks": []interface{}{"test-stack-id"},
"cpes": []string{"cpe:2.3:a:jattach:jattach:1.0.0:*:*:*:*:*:*:*"},
"purl": "pkg:generic/jattach@1.0.0?arch=amd64",
},
},
}
ctx.StackID = "test-stack-id"
})

it.After(func() {
Expect(os.RemoveAll(ctx.Application.Path)).To(Succeed())
})

it("contributes JAttach for API <= 0.6", func() {
ctx.Buildpack.API = "0.6"

result, err := build.Build(ctx)
Expect(err).NotTo(HaveOccurred())

Expect(result.Layers).To(HaveLen(1))
Expect(result.Layers[0].Name()).To(Equal("jattach"))

Expect(result.BOM.Entries).To(HaveLen(1))
Expect(result.BOM.Entries[0].Name).To(Equal("jattach"))
})
it("contributes JAttach for API 0.7+", func() {
ctx.Buildpack.Metadata = map[string]interface{}{
"dependencies": []map[string]interface{}{
{
"id": "jattach",
"version": "1.0.0",
"stacks": []interface{}{"test-stack-id"},
"cpes": []string{"cpe:2.3:a:jattach:jattach:1.17.1:*:*:*:*:*:*:*"},
"purl": "pkg:generic/jattach@1.0.0?arch=amd64",
},
},
}
it("contributes JAttach", func() {
result, err := build.Build(ctx)
Expect(err).NotTo(HaveOccurred())

Expand Down
11 changes: 5 additions & 6 deletions jattach/jattach.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2020 the original author or authors.
* Copyright 2018-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,7 +21,7 @@ import (
"os"
"path/filepath"

"github.com/paketo-buildpacks/libpak/sherpa"
"github.com/paketo-buildpacks/libpak/crush"

"github.com/buildpacks/libcnb"
"github.com/paketo-buildpacks/libpak"
Expand All @@ -44,19 +44,18 @@ func (j JAttach) Contribute(layer libcnb.Layer) (libcnb.Layer, error) {
j.LayerContributor.Logger = j.Logger

return j.LayerContributor.Contribute(layer, func(artifact *os.File) (libcnb.Layer, error) {

binDir := filepath.Join(layer.Path, "bin")

if err := os.MkdirAll(binDir, 0755); err != nil {
return libcnb.Layer{}, fmt.Errorf("unable to mkdir\n%w", err)
}
j.Logger.Bodyf("Copying to %s", binDir)

file := filepath.Join(binDir, filepath.Base(artifact.Name()))
if err := sherpa.CopyFile(artifact, file); err != nil {
return libcnb.Layer{}, fmt.Errorf("unable to copy %s to %s\n%w", artifact.Name(), file, err)
if err := crush.Extract(artifact, binDir, 0); err != nil {
return libcnb.Layer{}, fmt.Errorf("unable to expand jattach\n%w", err)
}

file := filepath.Join(binDir, "jattach")
if err := os.Chmod(file, 0755); err != nil {
return libcnb.Layer{}, fmt.Errorf("unable to chmod %s\n%w", file, err)
}
Expand Down
14 changes: 4 additions & 10 deletions jattach/jattach_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2020 the original author or authors.
* Copyright 2018-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,8 +17,6 @@
package jattach_test

import (
"io/ioutil"
"os"
"path/filepath"
"testing"

Expand All @@ -41,18 +39,14 @@ func testJAttach(t *testing.T, context spec.G, it spec.S) {
it.Before(func() {
var err error

ctx.Layers.Path, err = ioutil.TempDir("", "jattach-layers")
ctx.Layers.Path = t.TempDir()
Expect(err).NotTo(HaveOccurred())
})

it.After(func() {
Expect(os.RemoveAll(ctx.Layers.Path)).To(Succeed())
})

it("contributes JAttach", func() {
dep := libpak.BuildpackDependency{
URI: "https://localhost/jattach",
SHA256: "24d462459f142b1e1465eca49989cad4389d66d7167c6d5f5b2ac89502cec380",
URI: "https://localhost/jattach.tgz",
SHA256: "61f13e4c60ad63295453a5e1c92e04ad34bab09871b622b5aac0e72236431000",
}
dc := libpak.DependencyCache{CachePath: "testdata"}

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
uri = "https://localhost/jattach.tgz"
sha256 = "61f13e4c60ad63295453a5e1c92e04ad34bab09871b622b5aac0e72236431000"
Binary file not shown.
Loading