diff --git a/.vsts-ci/linux.yml b/.vsts-ci/linux.yml index 3f3281a..596d9e8 100644 --- a/.vsts-ci/linux.yml +++ b/.vsts-ci/linux.yml @@ -20,6 +20,8 @@ phases: buildName: ubuntu.16.04 Linux Native: buildName: centos.7 + Linux Alpine: + buildName: alpine steps: - powershell: | diff --git a/build.psm1 b/build.psm1 index 3f63aff..4b5a405 100644 --- a/build.psm1 +++ b/build.psm1 @@ -144,6 +144,7 @@ function Get-EnvironmentInformation $environment += @{'IsOpenSUSE42.1' = $Environment.IsOpenSUSE -and $LinuxInfo.VERSION_ID -match '42.1'} $environment += @{'IsRedHatFamily' = $Environment.IsCentOS -or $Environment.IsFedora} $environment += @{'IsSUSEFamily' = $Environment.IsSLES -or $Environment.IsOpenSUSE} + $environment += @{'IsAlpine' = $LinuxInfo.ID -match 'alpine'} # Workaround for temporary LD_LIBRARY_PATH hack for Fedora 24 # https://github.com/PowerShell/PowerShell/issues/2511 @@ -491,6 +492,10 @@ function Start-BuildPowerShellNativePackage [ValidateScript({Test-Path $_ -PathType Leaf})] [string] $LinuxARMZipPath, + [Parameter(Mandatory = $true)] + [ValidateScript({Test-Path $_ -PathType Leaf})] + [string] $LinuxAlpineZipPath, + [Parameter(Mandatory = $true)] [ValidateScript({Test-Path $_ -PathType Leaf})] [string] $macOSZipPath, @@ -520,6 +525,7 @@ function Start-BuildPowerShellNativePackage $BinFolderARM64 = Join-Path $tempExtractionPath "ARM64" $BinFolderLinux = Join-Path $tempExtractionPath "Linux" $BinFolderLinuxARM = Join-Path $tempExtractionPath "LinuxARM" + $BinFolderLinuxAlpine = Join-Path $tempExtractionPath "LinuxAlpine" $BinFolderMacOS = Join-Path $tempExtractionPath "MacOS" $BinFolderPSRP = Join-Path $tempExtractionPath "PSRP" @@ -528,13 +534,14 @@ function Start-BuildPowerShellNativePackage Expand-Archive -Path $WindowsARMZipPath -DestinationPath $BinFolderARM -Force Expand-Archive -Path $WindowsARM64ZipPath -DestinationPath $BinFolderARM64 -Force Expand-Archive -Path $LinuxZipPath -DestinationPath $BinFolderLinux -Force + Expand-Archive -Path $LinuxAlpineZipPath -DestinationPath $BinFolderLinuxAlpine -Force Expand-Archive -Path $LinuxARMZipPath -DestinationPath $BinFolderLinuxARM -Force Expand-Archive -Path $macOSZipPath -DestinationPath $BinFolderMacOS -Force Expand-Archive -Path $psrpZipPath -DestinationPath $BinFolderPSRP -Force PlaceWindowsNativeBinaries -PackageRoot $PackageRoot -BinFolderX64 $BinFolderX64 -BinFolderX86 $BinFolderX86 -BinFolderARM $BinFolderARM -BinFolderARM64 $BinFolderARM64 - PlaceUnixBinaries -PackageRoot $PackageRoot -BinFolderLinux $BinFolderLinux -BinFolderLinuxARM $BinFolderLinuxARM -BinFolderOSX $BinFolderMacOS -BinFolderPSRP $BinFolderPSRP + PlaceUnixBinaries -PackageRoot $PackageRoot -BinFolderLinux $BinFolderLinux -BinFolderLinuxARM $BinFolderLinuxARM -BinFolderOSX $BinFolderMacOS -BinFolderPSRP $BinFolderPSRP -BinFolderLinuxAlpine $BinFolderLinuxAlpine $Nuspec = @' @@ -599,6 +606,10 @@ function PlaceUnixBinaries [ValidateScript({Test-Path $_ -PathType Container})] $BinFolderLinuxARM, + [Parameter(Mandatory = $true)] + [ValidateScript({Test-Path $_ -PathType Container})] + $BinFolderLinuxAlpine, + [Parameter(Mandatory = $true)] [ValidateScript({Test-Path $_ -PathType Container})] $BinFolderOSX, @@ -610,10 +621,12 @@ function PlaceUnixBinaries $RuntimePathLinux = New-Item -ItemType Directory -Path (Join-Path $PackageRoot -ChildPath 'runtimes/linux-x64/native') -Force $RuntimePathLinuxARM = New-Item -ItemType Directory -Path (Join-Path $PackageRoot -ChildPath 'runtimes/linux-arm/native') -Force + $RuntimePathLinuxAlpine = New-Item -ItemType Directory -Path (Join-Path $PackageRoot -ChildPath 'runtimes/linux-musl-x64/native') -Force $RuntimePathOSX = New-Item -ItemType Directory -Path (Join-Path $PackageRoot -ChildPath 'runtimes/osx/native') -Force Copy-Item "$BinFolderLinux\*" -Destination $RuntimePathLinux -Verbose Copy-Item "$BinFolderLinuxARM\*" -Destination $RuntimePathLinuxARM -Verbose + Copy-Item "$BinFolderLinuxAlpine\*" -Destination $RuntimePathLinuxAlpine -Verbose Copy-Item "$BinFolderOSX\*" -Destination $RuntimePathOSX -Verbose ## LinuxARM is not supported by PSRP @@ -1979,6 +1992,12 @@ function Start-PSBootstrap { # Install patched version of curl Start-NativeExecution { brew install curl --with-openssl --with-gssapi } -IgnoreExitcode + } elseif ($Environment.IsAlpine) { + $Deps += "build-base", "gcc", "abuild", "binutils", "git", "python", "bash", "cmake" + + # Install dependencies + Start-NativeExecution { apk update } + Start-NativeExecution { apk add $Deps } } # Install [fpm](https://github.com/jordansissel/fpm) and [ronn](https://github.com/rtomayko/ronn) diff --git a/tools/releaseBuild/PowershellNative.ps1 b/tools/releaseBuild/PowershellNative.ps1 index 863d0a2..89411e3 100644 --- a/tools/releaseBuild/PowershellNative.ps1 +++ b/tools/releaseBuild/PowershellNative.ps1 @@ -6,7 +6,7 @@ param ( [Parameter(Mandatory, ParameterSetName = 'Build')] - [ValidateSet('x64', 'x86', 'x64_arm', 'x64_arm64', 'linux-x64', 'osx', 'linux-arm')] + [ValidateSet('x64', 'x86', 'x64_arm', 'x64_arm64', 'linux-x64', 'osx', 'linux-arm', 'linux-musl-x64')] [string] $Arch, @@ -31,7 +31,7 @@ end { $binOut = New-Item -Path $TargetLocation -ItemType Directory -Force Write-Verbose "Created output directory: $binOut" -Verbose - if ($Arch -eq 'linux-x64' -or $Arch -eq 'osx') { + if ($Arch -eq 'linux-x64' -or $Arch -eq 'osx' -or $Arch -eq 'linux-musl-x64') { Write-Verbose "Starting Build for: $Arch" -Verbose @@ -61,7 +61,6 @@ end { } else { Write-Verbose -Verbose "Skipping artifact upload since this is a PR." } - } else { Write-Verbose "Starting Start-PSBootstrap" -Verbose diff --git a/tools/releaseBuild/build.json b/tools/releaseBuild/build.json index 459fdbd..4520857 100644 --- a/tools/releaseBuild/build.json +++ b/tools/releaseBuild/build.json @@ -97,6 +97,18 @@ "DockerImageName": "ps-centos-7", "BinaryBucket": "release", "EnableFeature": [ "ArtifactAsFolder" ] + }, + { + "Name": "alpine", + "RepoDestinationPath": "/PowerShellNative", + "BuildCommand": "/PowerShellNative/tools/releaseBuild/PowershellNative.ps1 -RepoRoot _RepoDestinationPath_ -TargetLocation _DockerVolume_ -Arch linux-musl-x64 -Configuration Release", + "AdditionalContextFiles": [ + "./tools/releaseBuild/PowershellNative.ps1" + ], + "DockerFile": "./tools/releaseBuild/images/Alpine/Dockerfile", + "DockerImageName": "ps-alpine", + "BinaryBucket": "release", + "EnableFeature": [ "ArtifactAsFolder" ] } ] } diff --git a/tools/releaseBuild/images/Alpine/Dockerfile b/tools/releaseBuild/images/Alpine/Dockerfile new file mode 100644 index 0000000..64279c1 --- /dev/null +++ b/tools/releaseBuild/images/Alpine/Dockerfile @@ -0,0 +1,6 @@ +FROM mcr.microsoft.com/powershell:6.1.0-alpine-3.8 + +RUN apk update \ + && apk add build-base gcc abuild binutils git python bash cmake + +ENTRYPOINT [ "pwsh" ]