diff --git a/lib/binaries.sh b/lib/binaries.sh index 61f61e9e..2358c8ca 100644 --- a/lib/binaries.sh +++ b/lib/binaries.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Compiled from: https://github.com/heroku/buildpacks-nodejs/blob/main/common/nodejs-utils/src/bin/resolve_version.rs -RESOLVE="$BP_DIR/lib/vendor/resolve-version-$(get_os)" +RESOLVE="$BP_DIR/lib/vendor/resolve-version-$(get_platform)" resolve() { local binary="$1" @@ -90,7 +90,7 @@ install_nodejs() { echo "Downloading and installing node $number..." - if [[ "$number" == "22.5.0" ]]; then + if [[ "$number" == "22.5.0" ]]; then warn_about_node_version_22_5_0 fi fi diff --git a/lib/environment.sh b/lib/environment.sh index cb35339c..75828a4e 100644 --- a/lib/environment.sh +++ b/lib/environment.sh @@ -5,11 +5,19 @@ get_os() { } get_cpu() { - if [[ "$(uname -p)" = "i686" ]]; then - echo "x86" - else - echo "x64" - fi + arch=$(uname -p) + case $arch in + aarch64 | arm*) + echo "arm" + ;; + x86_64) + echo "x64" + ;; + *) + echo "Error: Unknown architecture: ${arch}" + exit 1 + ;; + esac } get_platform() { diff --git a/lib/vendor/resolve-version-darwin b/lib/vendor/resolve-version-darwin index 3a2c997f..116f07c1 100755 Binary files a/lib/vendor/resolve-version-darwin and b/lib/vendor/resolve-version-darwin differ diff --git a/lib/vendor/resolve-version-darwin-arm b/lib/vendor/resolve-version-darwin-arm new file mode 100755 index 00000000..5f032fe4 Binary files /dev/null and b/lib/vendor/resolve-version-darwin-arm differ diff --git a/lib/vendor/resolve-version-darwin-x64 b/lib/vendor/resolve-version-darwin-x64 new file mode 100755 index 00000000..116f07c1 Binary files /dev/null and b/lib/vendor/resolve-version-darwin-x64 differ diff --git a/lib/vendor/resolve-version-linux b/lib/vendor/resolve-version-linux index 95785a81..9351d257 100755 Binary files a/lib/vendor/resolve-version-linux and b/lib/vendor/resolve-version-linux differ diff --git a/lib/vendor/resolve-version-linux-arm b/lib/vendor/resolve-version-linux-arm new file mode 100755 index 00000000..20a059d4 Binary files /dev/null and b/lib/vendor/resolve-version-linux-arm differ diff --git a/lib/vendor/resolve-version-linux-x64 b/lib/vendor/resolve-version-linux-x64 new file mode 100755 index 00000000..9351d257 Binary files /dev/null and b/lib/vendor/resolve-version-linux-x64 differ diff --git a/lib/vendor/yq-darwin-arm b/lib/vendor/yq-darwin-arm new file mode 100755 index 00000000..54a3ad3d Binary files /dev/null and b/lib/vendor/yq-darwin-arm differ diff --git a/lib/vendor/yq-linux-arm b/lib/vendor/yq-linux-arm new file mode 100755 index 00000000..d64007b0 Binary files /dev/null and b/lib/vendor/yq-linux-arm differ diff --git a/lib/yarn-2.sh b/lib/yarn-2.sh index a095e7f7..3ddb7404 100644 --- a/lib/yarn-2.sh +++ b/lib/yarn-2.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -YQ="$BP_DIR/lib/vendor/yq-$(get_os)" +YQ="$BP_DIR/lib/vendor/yq-$(get_platform)" detect_yarn_2() { local uses_yarn="$1" @@ -54,7 +54,7 @@ use_yarn_app_cache() { node_modules_enabled() { local build_dir="$1" local node_linker - + node_linker=$($YQ r "$build_dir/.yarnrc.yml" nodeLinker 2>&1) [[ "$node_linker" == "node-modules" ]] diff --git a/makefile b/makefile index 4268fa7a..21d8d9a0 100644 --- a/makefile +++ b/makefile @@ -1,14 +1,24 @@ -build-resolvers: build-resolver-linux build-resolver-darwin +build-resolvers: build-resolver-linux build-resolver-darwin build-resolver-linux-arm build-resolver-darwin-arm .build: mkdir -p .build build-resolver-darwin: .build cargo install heroku-nodejs-utils --root .build --bin resolve_version --git https://github.com/heroku/buildpacks-nodejs --target x86_64-apple-darwin --profile release mv .build/bin/resolve_version lib/vendor/resolve-version-darwin + cp lib/vendor/resolve-version-darwin lib/vendor/resolve-version-darwin-x64 + +build-resolver-darwin-arm: .build + cargo install heroku-nodejs-utils --root .build --bin resolve_version --git https://github.com/heroku/buildpacks-nodejs --target aarch64-apple-darwin --profile release + mv .build/bin/resolve_version lib/vendor/resolve-version-darwin-arm build-resolver-linux: .build cargo install heroku-nodejs-utils --root .build --bin resolve_version --git https://github.com/heroku/buildpacks-nodejs --target x86_64-unknown-linux-musl --profile release mv .build/bin/resolve_version lib/vendor/resolve-version-linux + cp lib/vendor/resolve-version-linux lib/vendor/resolve-version-linux-x64 + +build-resolver-linux-arm: .build + cargo install heroku-nodejs-utils --root .build --bin resolve_version --git https://github.com/heroku/buildpacks-nodejs --target aarch64-unknown-linux-musl --profile release + mv .build/bin/resolve_version lib/vendor/resolve-version-linux-arm test: heroku-22-build heroku-20-build heroku-24-build