From 4ec9fdae13222a0b2b278ae1ddcdc9e8b44901ed Mon Sep 17 00:00:00 2001 From: ilia-shipitsin <125650415+ilia-shipitsin@users.noreply.github.com> Date: Mon, 7 Aug 2023 11:53:07 +0200 Subject: [PATCH] [macos] use unxip if available for XCode unpacking (#7992) --- images/macos/helpers/Common.Helpers.psm1 | 9 +++++++++ images/macos/helpers/Xcode.Installer.psm1 | 7 ++++++- images/macos/toolsets/toolset-12.json | 3 ++- images/macos/toolsets/toolset-13.json | 3 ++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/images/macos/helpers/Common.Helpers.psm1 b/images/macos/helpers/Common.Helpers.psm1 index 457793276..638899dca 100644 --- a/images/macos/helpers/Common.Helpers.psm1 +++ b/images/macos/helpers/Common.Helpers.psm1 @@ -166,3 +166,12 @@ function Get-Architecture { return $arch } + +function Test-CommandExists { + param + ( + [Parameter(Mandatory)] [string] $Command + ) + + [boolean] (Get-Command $Command -ErrorAction 'SilentlyContinue') +} diff --git a/images/macos/helpers/Xcode.Installer.psm1 b/images/macos/helpers/Xcode.Installer.psm1 index e23982940..25eaeef1a 100644 --- a/images/macos/helpers/Xcode.Installer.psm1 +++ b/images/macos/helpers/Xcode.Installer.psm1 @@ -1,3 +1,4 @@ +Import-Module "$PSScriptRoot/Common.Helpers.psm1" Import-Module "$PSScriptRoot/Xcode.Helpers.psm1" function Install-XcodeVersion { @@ -86,7 +87,11 @@ function Expand-XcodeXipArchive { Write-Host "Extracting Xcode from '$xcodeXipPath'" Push-Location $DownloadDirectory - Invoke-ValidateCommand "xip -x $xcodeXipPath" + if(Test-CommandExists 'unxip') { + Invoke-ValidateCommand "unxip $xcodeXipPath" + } else { + Invoke-ValidateCommand "xip -x $xcodeXipPath" + } Pop-Location if (Test-Path "$DownloadDirectory/Xcode-beta.app") { diff --git a/images/macos/toolsets/toolset-12.json b/images/macos/toolsets/toolset-12.json index dd135ac0a..a417d9b73 100644 --- a/images/macos/toolsets/toolset-12.json +++ b/images/macos/toolsets/toolset-12.json @@ -202,7 +202,8 @@ "tcl-tk", "r", "yq", - "imagemagick" + "imagemagick", + "unxip" ], "cask_packages": [ "julia", diff --git a/images/macos/toolsets/toolset-13.json b/images/macos/toolsets/toolset-13.json index 5067ee2de..c1da99980 100644 --- a/images/macos/toolsets/toolset-13.json +++ b/images/macos/toolsets/toolset-13.json @@ -74,7 +74,8 @@ "zstd", "gmp", "r", - "yq" + "yq", + "unxip" ], "cask_packages": [ "julia",