Skip to content

Commit

Permalink
fix(jib): make native arm maven usable on ARM macs (#4968)
Browse files Browse the repository at this point in the history
The native aarch64 build of maven has not been used before this commit,
because the arch was wrongly specified as "aarch64" in the tool spec,
instead of the correct "arm64".

This commit also prevents similar mistakes in the future by improving
the types.

We are allowing platforms and architectures that are not technically supported right now here–
this can be adressed in a future PR if needed.
  • Loading branch information
stefreak committed Aug 22, 2023
1 parent 45d0236 commit 491fe88
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
5 changes: 3 additions & 2 deletions core/src/plugin/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
import { createSchema, joi, joiIdentifier } from "../config/common"
import { deline } from "../util/string"
import { PluginTool } from "../util/ext-tools"
import { Architecture, Platform } from "../util/util"

export interface ToolBuildSpec {
platform: string
architecture: string
platform: Platform
architecture: Architecture
url: string
sha256: string
extract?: {
Expand Down
7 changes: 5 additions & 2 deletions core/src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ export function isSubdir(path: string, ofPath: string): boolean {

// Used to make the platforms more consistent with other tools
const platformMap = {
win32: "windows",
win32: "windows" as const,
}

const archMap = {
Expand All @@ -626,8 +626,11 @@ const archMap = {
}

export type Architecture = Exclude<NodeJS.Architecture, keyof typeof archMap> | (typeof archMap)[keyof typeof archMap]
export type Platform =
| Exclude<NodeJS.Platform, keyof typeof platformMap>
| (typeof platformMap)[keyof typeof platformMap]

export function getPlatform() {
export function getPlatform(): Platform {
return platformMap[process.platform] || process.platform
}

Expand Down
10 changes: 5 additions & 5 deletions plugins/jib/mavend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const mvndSpec = {
sha256: "64acc68f2a3e25a0662eb62bf87cf2641706245505572ca1d20f933c7190f148",
targetPath: `maven-mvnd-${mvndVersion}-linux-amd64/bin/mvnd`,
},
darwin_aarch64: {
darwin_arm64: {
filename: `maven-mvnd-${mvndVersion}-darwin-aarch64.tar.gz`,
sha256: "bca67a44cc3716a7da46926acff41b3864d62e5da6982b9e998eca42d2f9bfac",
targetPath: `maven-mvnd-${mvndVersion}-darwin-aarch64/bin/mvnd`,
Expand Down Expand Up @@ -71,12 +71,12 @@ export const mavendSpec: PluginToolSpec = {
},
{
platform: "darwin",
architecture: "aarch64",
sha256: mvndSpec.darwin_aarch64.sha256,
url: `${mvndSpec.baseUrl}${mvndSpec.darwin_aarch64.filename}`,
architecture: "arm64",
sha256: mvndSpec.darwin_arm64.sha256,
url: `${mvndSpec.baseUrl}${mvndSpec.darwin_arm64.filename}`,
extract: {
format: "tar",
targetPath: mvndSpec.darwin_aarch64.targetPath,
targetPath: mvndSpec.darwin_arm64.targetPath,
},
},
{
Expand Down
3 changes: 2 additions & 1 deletion plugins/jib/openjdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { ToolBuildSpec } from "@garden-io/core/src/plugin/tools"
import { PluginToolSpec } from "@garden-io/sdk/types"
import { posix } from "path"

Expand Down Expand Up @@ -123,7 +124,7 @@ const jdk17Version: JdkVersion = {
}

function openJdkSpec(jdkVersion: JdkVersion): PluginToolSpec {
const macBuilds = [
const macBuilds: ToolBuildSpec[] = [
{
platform: "darwin",
architecture: "amd64",
Expand Down

0 comments on commit 491fe88

Please sign in to comment.