From 6b07501889a5480429776f1ae8f479ed715c1a2c Mon Sep 17 00:00:00 2001 From: Daniel Mikusa Date: Thu, 28 Mar 2024 23:41:03 -0400 Subject: [PATCH] Changes to support ARM64 Signed-off-by: Daniel Mikusa --- .github/pipeline-descriptor.yml | 22 +++- .../pb-update-rustup-init-gnu-arm-64.yml | 104 ++++++++++++++++++ .../workflows/pb-update-rustup-init-gnu.yml | 10 +- .../pb-update-rustup-init-musl-arm-64.yml | 104 ++++++++++++++++++ .../workflows/pb-update-rustup-init-musl.yml | 10 +- .gitignore | 4 +- buildpack.toml | 54 ++++++++- scripts/build.sh | 15 ++- 8 files changed, 301 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/pb-update-rustup-init-gnu-arm-64.yml create mode 100644 .github/workflows/pb-update-rustup-init-musl-arm-64.yml diff --git a/.github/pipeline-descriptor.yml b/.github/pipeline-descriptor.yml index 1b7b37f..51917a7 100644 --- a/.github/pipeline-descriptor.yml +++ b/.github/pipeline-descriptor.yml @@ -20,13 +20,31 @@ docker_credentials: password: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_PASSWORD }} dependencies: -- id: rustup-init-gnu +- name: Rustup Init GNU + id: rustup-init-gnu uses: docker://ghcr.io/paketo-buildpacks/actions/rustup-init-dependency:main with: target: x86_64-unknown-linux-gnu token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} -- id: rustup-init-musl +- name: Rustup Init MUSL + id: rustup-init-musl uses: docker://ghcr.io/paketo-buildpacks/actions/rustup-init-dependency:main with: target: x86_64-unknown-linux-musl token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} + +# ARM64 +- name: Rustup Init GNU ARM64 + id: rustup-init-gnu + uses: docker://ghcr.io/paketo-buildpacks/actions/rustup-init-dependency:main + with: + target: aarch64-unknown-linux-gnu + token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} + arch: arm64 +- name: Rustup Init MUSL ARM64 + id: rustup-init-musl + uses: docker://ghcr.io/paketo-buildpacks/actions/rustup-init-dependency:main + with: + target: aarch64-unknown-linux-musl + token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} + arch: arm64 diff --git a/.github/workflows/pb-update-rustup-init-gnu-arm-64.yml b/.github/workflows/pb-update-rustup-init-gnu-arm-64.yml new file mode 100644 index 0000000..c2ef00f --- /dev/null +++ b/.github/workflows/pb-update-rustup-init-gnu-arm-64.yml @@ -0,0 +1,104 @@ +name: Update Rustup Init GNU 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 + - uses: buildpacks/github-actions/setup-tools@v5.5.3 + with: + crane-version: 0.19.0 + yj-version: 5.1.0 + - uses: actions/checkout@v4 + - id: dependency + uses: docker://ghcr.io/paketo-buildpacks/actions/rustup-init-dependency:main + with: + arch: arm64 + target: aarch64-unknown-linux-gnu + token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} + - name: Update Buildpack Dependency + id: buildpack + run: | + #!/usr/bin/env bash + + set -euo pipefail + + VERSION_DEPS=$(yj -tj < buildpack.toml | jq -r ".metadata.dependencies[] | select( .id == env.ID ) | select( .version | test( env.VERSION_PATTERN ) )") + ARCH=${ARCH:-amd64} + OLD_VERSION=$(echo "$VERSION_DEPS" | jq -r 'select( .purl | contains( env.ARCH ) ) | .version') + + if [ -z "$OLD_VERSION" ]; then + ARCH="" # empty means noarch + OLD_VERSION=$(echo "$VERSION_DEPS" | jq -r ".version") + fi + + 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: arm64 + CPE: ${{ steps.dependency.outputs.cpe }} + CPE_PATTERN: "" + ID: rustup-init-gnu + 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@v6 + with: + author: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_USERNAME }} <${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_USERNAME }}@users.noreply.github.com> + body: Bumps `Rustup Init GNU ARM64` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`. + branch: update/buildpack/rustup-init-gnu-arm-64 + commit-message: |- + Bump Rustup Init GNU ARM64 from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }} + + Bumps Rustup Init GNU 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 Rustup Init GNU ARM64 from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }} + token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} diff --git a/.github/workflows/pb-update-rustup-init-gnu.yml b/.github/workflows/pb-update-rustup-init-gnu.yml index 8a218ee..8d39369 100644 --- a/.github/workflows/pb-update-rustup-init-gnu.yml +++ b/.github/workflows/pb-update-rustup-init-gnu.yml @@ -1,4 +1,4 @@ -name: Update rustup-init-gnu +name: Update Rustup Init GNU "on": schedule: - cron: 0 5 * * 1-5 @@ -90,14 +90,14 @@ jobs: - uses: peter-evans/create-pull-request@v6 with: author: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_USERNAME }} <${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_USERNAME }}@users.noreply.github.com> - body: Bumps `rustup-init-gnu` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`. + body: Bumps `Rustup Init GNU` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`. branch: update/buildpack/rustup-init-gnu commit-message: |- - Bump rustup-init-gnu from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }} + Bump Rustup Init GNU from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }} - Bumps rustup-init-gnu from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}. + Bumps Rustup Init GNU 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 rustup-init-gnu from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }} + title: Bump Rustup Init GNU from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }} token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} diff --git a/.github/workflows/pb-update-rustup-init-musl-arm-64.yml b/.github/workflows/pb-update-rustup-init-musl-arm-64.yml new file mode 100644 index 0000000..0025f35 --- /dev/null +++ b/.github/workflows/pb-update-rustup-init-musl-arm-64.yml @@ -0,0 +1,104 @@ +name: Update Rustup Init MUSL 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 + - uses: buildpacks/github-actions/setup-tools@v5.5.3 + with: + crane-version: 0.19.0 + yj-version: 5.1.0 + - uses: actions/checkout@v4 + - id: dependency + uses: docker://ghcr.io/paketo-buildpacks/actions/rustup-init-dependency:main + with: + arch: arm64 + target: aarch64-unknown-linux-musl + token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} + - name: Update Buildpack Dependency + id: buildpack + run: | + #!/usr/bin/env bash + + set -euo pipefail + + VERSION_DEPS=$(yj -tj < buildpack.toml | jq -r ".metadata.dependencies[] | select( .id == env.ID ) | select( .version | test( env.VERSION_PATTERN ) )") + ARCH=${ARCH:-amd64} + OLD_VERSION=$(echo "$VERSION_DEPS" | jq -r 'select( .purl | contains( env.ARCH ) ) | .version') + + if [ -z "$OLD_VERSION" ]; then + ARCH="" # empty means noarch + OLD_VERSION=$(echo "$VERSION_DEPS" | jq -r ".version") + fi + + 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: arm64 + CPE: ${{ steps.dependency.outputs.cpe }} + CPE_PATTERN: "" + ID: rustup-init-musl + 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@v6 + with: + author: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_USERNAME }} <${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_USERNAME }}@users.noreply.github.com> + body: Bumps `Rustup Init MUSL ARM64` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`. + branch: update/buildpack/rustup-init-musl-arm-64 + commit-message: |- + Bump Rustup Init MUSL ARM64 from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }} + + Bumps Rustup Init MUSL 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 Rustup Init MUSL ARM64 from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }} + token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} diff --git a/.github/workflows/pb-update-rustup-init-musl.yml b/.github/workflows/pb-update-rustup-init-musl.yml index 15bad08..8697827 100644 --- a/.github/workflows/pb-update-rustup-init-musl.yml +++ b/.github/workflows/pb-update-rustup-init-musl.yml @@ -1,4 +1,4 @@ -name: Update rustup-init-musl +name: Update Rustup Init MUSL "on": schedule: - cron: 0 5 * * 1-5 @@ -90,14 +90,14 @@ jobs: - uses: peter-evans/create-pull-request@v6 with: author: ${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_USERNAME }} <${{ secrets.PAKETO_BUILDPACKS_DOCKERHUB_USERNAME }}@users.noreply.github.com> - body: Bumps `rustup-init-musl` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`. + body: Bumps `Rustup Init MUSL` from `${{ steps.buildpack.outputs.old-version }}` to `${{ steps.buildpack.outputs.new-version }}`. branch: update/buildpack/rustup-init-musl commit-message: |- - Bump rustup-init-musl from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }} + Bump Rustup Init MUSL from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }} - Bumps rustup-init-musl from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }}. + Bumps Rustup Init MUSL 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 rustup-init-musl from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }} + title: Bump Rustup Init MUSL from ${{ steps.buildpack.outputs.old-version }} to ${{ steps.buildpack.outputs.new-version }} token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index d9a220c..2f65ee4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# Copyright 2018-2021 the original author or authors. +# Copyright 2018-2020 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. @@ -13,6 +13,8 @@ # limitations under the License. bin/ +linux/ dependencies/ package/ scratch/ + diff --git a/buildpack.toml b/buildpack.toml index ea9e6ab..bf6717f 100644 --- a/buildpack.toml +++ b/buildpack.toml @@ -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. @@ -28,7 +28,7 @@ api = "0.7" uri = "https://github.com/paketo-community/rustup/blob/main/LICENSE" [metadata] - include-files = ["LICENSE", "NOTICE", "README.md", "bin/build", "bin/detect", "bin/main", "buildpack.toml"] + include-files = ["LICENSE", "NOTICE", "README.md", "buildpack.toml", "linux/amd64/bin/build", "linux/amd64/bin/detect", "linux/amd64/bin/main", "linux/arm64/bin/build", "linux/arm64/bin/detect", "linux/arm64/bin/main"] pre-package = "scripts/build.sh" [[metadata.configurations]] @@ -75,7 +75,7 @@ api = "0.7" sha256 = "a3d541a5484c8fa2f1c21478a6f6c505a778d473c21d60a18a4df5185d320ef8" source = "https://github.com/rust-lang/rustup/archive/refs/tags/1.27.0.tar.gz" source-sha256 = "3d331ab97d75b03a1cc2b36b2f26cd0a16d681b79677512603f2262991950ad1" - stacks = ["io.buildpacks.stacks.bionic", "io.paketo.stacks.tiny", "*"] + stacks = ["*"] uri = "https://static.rust-lang.org/rustup/archive/1.27.0/x86_64-unknown-linux-gnu/rustup-init" version = "1.27.0" @@ -107,5 +107,53 @@ api = "0.7" type = "MIT" uri = "https://github.com/rust-lang/rustup/blob/master/LICENSE-MIT" + [[metadata.dependencies]] + cpes = ["cpe:2.3:a:rust:rustup:1.27.0:*:*:*:*:*:*:*"] + id = "rustup-init-gnu" + name = "Rustup (GNU libc)" + purl = "pkg:generic/rustup@1.27.0?arch=arm64" + sha256 = "76cd420cb8a82e540025c5f97bda3c65ceb0b0661d5843e6ef177479813b0367" + source = "https://github.com/rust-lang/rustup/archive/refs/tags/1.27.0.tar.gz" + source-sha256 = "3d331ab97d75b03a1cc2b36b2f26cd0a16d681b79677512603f2262991950ad1" + stacks = ["*"] + uri = "https://static.rust-lang.org/rustup/archive/1.27.0/aarch64-unknown-linux-gnu/rustup-init" + version = "1.27.0" + + [[metadata.dependencies.licenses]] + type = "Apache-2.0" + uri = "https://github.com/rust-lang/rustup/blob/master/LICENSE-APACHE" + + [[metadata.dependencies.licenses]] + type = "MIT" + uri = "https://github.com/rust-lang/rustup/blob/master/LICENSE-MIT" + + [[metadata.dependencies]] + cpes = ["cpe:2.3:a:rust:rustup:1.27.0:*:*:*:*:*:*:*"] + id = "rustup-init-musl" + name = "Rustup (musl libc)" + purl = "pkg:generic/rustup@1.27.0?arch=arm64" + sha256 = "841513f7599fcf89c71a62dea332337dfd4332216b60c17648d6effbeefe66a9" + source = "https://github.com/rust-lang/rustup/archive/refs/tags/1.27.0.tar.gz" + source-sha256 = "3d331ab97d75b03a1cc2b36b2f26cd0a16d681b79677512603f2262991950ad1" + stacks = ["*"] + uri = "https://static.rust-lang.org/rustup/archive/1.27.0/aarch64-unknown-linux-musl/rustup-init" + version = "1.27.0" + + [[metadata.dependencies.licenses]] + type = "Apache-2.0" + uri = "https://github.com/rust-lang/rustup/blob/master/LICENSE-APACHE" + + [[metadata.dependencies.licenses]] + type = "MIT" + uri = "https://github.com/rust-lang/rustup/blob/master/LICENSE-MIT" + [[stacks]] id = "*" + +[[targets]] + arch = "amd64" + os = "linux" + +[[targets]] + arch = "arm64" + os = "linux" diff --git a/scripts/build.sh b/scripts/build.sh index e454aa1..dc48240 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,16 +1,19 @@ #!/usr/bin/env bash - set -euo pipefail -GOOS="linux" go build -ldflags='-s -w' -o bin/main github.com/paketo-community/rustup/cmd/main +GOMOD=$(head -1 go.mod | awk '{print $2}') +GOOS="linux" go build -ldflags='-s -w' -o linux/amd64/bin/main "$GOMOD/cmd/main" +GOOS="linux" GOARCH="arm64" go build -ldflags='-s -w' -o linux/arm64/bin/main "$GOMOD/cmd/main" if [ "${STRIP:-false}" != "false" ]; then - strip bin/main + strip linux/amd64/bin/main linux/arm64/bin/main fi if [ "${COMPRESS:-none}" != "none" ]; then - $COMPRESS bin/main + $COMPRESS linux/amd64/bin/main linux/arm64/bin/main fi -ln -fs main bin/build -ln -fs main bin/detect +ln -fs main linux/amd64/bin/build +ln -fs main linux/arm64/bin/build +ln -fs main linux/amd64/bin/detect +ln -fs main linux/arm64/bin/detect \ No newline at end of file