Skip to content

Update build and packaging for Alpine #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .vsts-ci/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ phases:
buildName: ubuntu.16.04
Linux Native:
buildName: centos.7
Linux Alpine:
buildName: alpine

steps:
- powershell: |
Expand Down
21 changes: 20 additions & 1 deletion build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"

Expand All @@ -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 = @'
<?xml version="1.0" encoding="utf-8"?>
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions tools/releaseBuild/PowershellNative.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand All @@ -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

Expand Down Expand Up @@ -61,7 +61,6 @@ end {
} else {
Write-Verbose -Verbose "Skipping artifact upload since this is a PR."
}

}
else {
Write-Verbose "Starting Start-PSBootstrap" -Verbose
Expand Down
12 changes: 12 additions & 0 deletions tools/releaseBuild/build.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
}
]
}
6 changes: 6 additions & 0 deletions tools/releaseBuild/images/Alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]