Support creating tarball package for Linux and macOS (#5085)
* Support creating tarball package for Linux and macOS * Address comments
This commit is contained in:
parent
94a71b05d4
commit
a391998a25
1
.gitignore
vendored
1
.gitignore
vendored
@ -38,6 +38,7 @@ dotnet-uninstall-debian-packages.sh
|
|||||||
|
|
||||||
# Ignore packages
|
# Ignore packages
|
||||||
*.deb
|
*.deb
|
||||||
|
*.tar.gz
|
||||||
*.zip
|
*.zip
|
||||||
*.rpm
|
*.rpm
|
||||||
*.pkg
|
*.pkg
|
||||||
|
@ -20,7 +20,7 @@ function Start-PSPackage {
|
|||||||
[string]$Name = "powershell",
|
[string]$Name = "powershell",
|
||||||
|
|
||||||
# Ubuntu, CentOS, Fedora, macOS, and Windows packages are supported
|
# Ubuntu, CentOS, Fedora, macOS, and Windows packages are supported
|
||||||
[ValidateSet("deb", "osxpkg", "rpm", "msi", "zip", "AppImage", "nupkg", "deb-arm")]
|
[ValidateSet("deb", "osxpkg", "rpm", "msi", "zip", "AppImage", "nupkg", "tar")]
|
||||||
[string[]]$Type,
|
[string[]]$Type,
|
||||||
|
|
||||||
# Generate windows downlevel package
|
# Generate windows downlevel package
|
||||||
@ -35,6 +35,10 @@ function Start-PSPackage {
|
|||||||
[Switch] $SkipReleaseChecks
|
[Switch] $SkipReleaseChecks
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# The package type 'deb-arm' is current disabled for '-Type' parameter because 'New-UnixPackage' doesn't support
|
||||||
|
# creating package for 'deb-arm'. It should be added back to the ValidateSet of '-Type' once the implementation
|
||||||
|
# of creating 'deb-arm' package is done.
|
||||||
|
|
||||||
# Runtime and Configuration settings required by the package
|
# Runtime and Configuration settings required by the package
|
||||||
($Runtime, $Configuration) = if ($WindowsRuntime) {
|
($Runtime, $Configuration) = if ($WindowsRuntime) {
|
||||||
$WindowsRuntime, "Release"
|
$WindowsRuntime, "Release"
|
||||||
@ -151,15 +155,13 @@ function Start-PSPackage {
|
|||||||
Force = $Force
|
Force = $Force
|
||||||
}
|
}
|
||||||
|
|
||||||
if($pscmdlet.ShouldProcess("Create Zip Package"))
|
if ($PSCmdlet.ShouldProcess("Create Zip Package")) {
|
||||||
{
|
|
||||||
New-ZipPackage @Arguments
|
New-ZipPackage @Arguments
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"msi" {
|
"msi" {
|
||||||
$TargetArchitecture = "x64"
|
$TargetArchitecture = "x64"
|
||||||
if ($Runtime -match "-x86")
|
if ($Runtime -match "-x86") {
|
||||||
{
|
|
||||||
$TargetArchitecture = "x86"
|
$TargetArchitecture = "x86"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,14 +177,12 @@ function Start-PSPackage {
|
|||||||
Force = $Force
|
Force = $Force
|
||||||
}
|
}
|
||||||
|
|
||||||
if($pscmdlet.ShouldProcess("Create MSI Package"))
|
if ($PSCmdlet.ShouldProcess("Create MSI Package")) {
|
||||||
{
|
|
||||||
New-MSIPackage @Arguments
|
New-MSIPackage @Arguments
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"AppImage" {
|
"AppImage" {
|
||||||
if($IncludeSymbols.IsPresent)
|
if ($IncludeSymbols.IsPresent) {
|
||||||
{
|
|
||||||
throw "AppImage does not support packaging '-IncludeSymbols'"
|
throw "AppImage does not support packaging '-IncludeSymbols'"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,11 +207,22 @@ function Start-PSPackage {
|
|||||||
Force = $Force
|
Force = $Force
|
||||||
}
|
}
|
||||||
|
|
||||||
if($pscmdlet.ShouldProcess("Create NuPkg Package"))
|
if ($PSCmdlet.ShouldProcess("Create NuPkg Package")) {
|
||||||
{
|
|
||||||
New-NugetPackage @Arguments
|
New-NugetPackage @Arguments
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
'tar' {
|
||||||
|
$Arguments = @{
|
||||||
|
PackageSourcePath = $Source
|
||||||
|
Name = $Name
|
||||||
|
Version = $Version
|
||||||
|
Force = $Force
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($PSCmdlet.ShouldProcess("Create tar.gz Package")) {
|
||||||
|
New-TarballPackage @Arguments
|
||||||
|
}
|
||||||
|
}
|
||||||
'deb' {
|
'deb' {
|
||||||
$Arguments = @{
|
$Arguments = @{
|
||||||
Type = 'deb'
|
Type = 'deb'
|
||||||
@ -222,7 +233,9 @@ function Start-PSPackage {
|
|||||||
}
|
}
|
||||||
foreach ($Distro in $Script:DebianDistributions) {
|
foreach ($Distro in $Script:DebianDistributions) {
|
||||||
$Arguments["Distribution"] = $Distro
|
$Arguments["Distribution"] = $Distro
|
||||||
New-UnixPackage @Arguments
|
if ($PSCmdlet.ShouldProcess("Create DEB Package for $Distro")) {
|
||||||
|
New-UnixPackage @Arguments
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default {
|
default {
|
||||||
@ -234,14 +247,77 @@ function Start-PSPackage {
|
|||||||
Force = $Force
|
Force = $Force
|
||||||
}
|
}
|
||||||
|
|
||||||
if($pscmdlet.ShouldProcess("Create $_ Package"))
|
if ($PSCmdlet.ShouldProcess("Create $_ Package")) {
|
||||||
{
|
|
||||||
New-UnixPackage @Arguments
|
New-UnixPackage @Arguments
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function New-TarballPackage {
|
||||||
|
[CmdletBinding(SupportsShouldProcess=$true)]
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string] $PackageSourcePath,
|
||||||
|
|
||||||
|
# Must start with 'powershell' but may have any suffix
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[ValidatePattern("^powershell")]
|
||||||
|
[string]$Name,
|
||||||
|
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string]$Version,
|
||||||
|
|
||||||
|
[switch] $Force
|
||||||
|
)
|
||||||
|
|
||||||
|
$packageName = "$Name-$Version-{0}-x64.tar.gz"
|
||||||
|
if ($Environment.IsWindows) {
|
||||||
|
throw "Must be on Linux or macOS to build 'tar.gz' packages!"
|
||||||
|
} elseif ($Environment.IsLinux) {
|
||||||
|
$packageName = $packageName -f "linux"
|
||||||
|
} elseif ($Environment.IsMacOS) {
|
||||||
|
$packageName = $packageName -f "osx"
|
||||||
|
}
|
||||||
|
|
||||||
|
$packagePath = Join-Path -Path $PWD -ChildPath $packageName
|
||||||
|
Write-Verbose "Create package $packageName"
|
||||||
|
Write-Verbose "Package destination path: $packagePath"
|
||||||
|
|
||||||
|
if (Test-Path -Path $packagePath) {
|
||||||
|
if ($Force -or $PSCmdlet.ShouldProcess("Overwrite existing package file")) {
|
||||||
|
Write-Verbose "Overwrite existing package file at $packagePath" -Verbose
|
||||||
|
Remove-Item -Path $packagePath -Force -ErrorAction Stop -Confirm:$false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Get-Command -Name tar -CommandType Application -ErrorAction Ignore) {
|
||||||
|
if ($Force -or $PSCmdlet.ShouldProcess("Create tarball package")) {
|
||||||
|
$options = "-czf"
|
||||||
|
if ($PSBoundParameters.ContainsKey('Verbose') -and $PSBoundParameters['Verbose'].IsPresent) {
|
||||||
|
# Use the verbose mode '-v' if '-Verbose' is specified
|
||||||
|
$options = "-czvf"
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Push-Location -Path $PackageSourcePath
|
||||||
|
tar $options $packagePath .
|
||||||
|
} finally {
|
||||||
|
Pop-Location
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Test-Path -Path $packagePath) {
|
||||||
|
log "You can find the tarball package at $packagePath"
|
||||||
|
return $packagePath
|
||||||
|
} else {
|
||||||
|
throw "Failed to create $packageName"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw "Failed to create the package because the application 'tar' cannot be found"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function New-UnixPackage {
|
function New-UnixPackage {
|
||||||
[CmdletBinding(SupportsShouldProcess=$true)]
|
[CmdletBinding(SupportsShouldProcess=$true)]
|
||||||
param(
|
param(
|
||||||
|
@ -11,11 +11,13 @@ param (
|
|||||||
[ValidatePattern("^v\d+\.\d+\.\d+(-\w+\.\d+)?$")]
|
[ValidatePattern("^v\d+\.\d+\.\d+(-\w+\.\d+)?$")]
|
||||||
[ValidateNotNullOrEmpty()]
|
[ValidateNotNullOrEmpty()]
|
||||||
[string]$ReleaseTag,
|
[string]$ReleaseTag,
|
||||||
[switch]$AppImage
|
|
||||||
|
[ValidateSet("AppImage", "tar")]
|
||||||
|
[string[]]$ExtraPackage
|
||||||
)
|
)
|
||||||
|
|
||||||
$releaseTagParam = @{}
|
$releaseTagParam = @{}
|
||||||
if($ReleaseTag)
|
if ($ReleaseTag)
|
||||||
{
|
{
|
||||||
$releaseTagParam = @{ 'ReleaseTag' = $ReleaseTag }
|
$releaseTagParam = @{ 'ReleaseTag' = $ReleaseTag }
|
||||||
}
|
}
|
||||||
@ -25,14 +27,15 @@ try {
|
|||||||
Set-Location $location
|
Set-Location $location
|
||||||
Import-Module "$location/build.psm1"
|
Import-Module "$location/build.psm1"
|
||||||
Import-Module "$location/tools/packaging"
|
Import-Module "$location/tools/packaging"
|
||||||
|
|
||||||
Start-PSBootstrap -Package -NoSudo
|
Start-PSBootstrap -Package -NoSudo
|
||||||
Start-PSBuild -Crossgen -PSModuleRestore @releaseTagParam
|
Start-PSBuild -Crossgen -PSModuleRestore @releaseTagParam
|
||||||
|
|
||||||
Start-PSPackage @releaseTagParam
|
Start-PSPackage @releaseTagParam
|
||||||
if($AppImage.IsPresent)
|
switch ($ExtraPackage)
|
||||||
{
|
{
|
||||||
Start-PSPackage -Type AppImage @releaseTagParam
|
"AppImage" { Start-PSPackage -Type AppImage @releaseTagParam }
|
||||||
|
"tar" { Start-PSPackage -Type tar @releaseTagParam }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@ -40,18 +43,10 @@ finally
|
|||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
|
|
||||||
$linuxPackages = Get-ChildItem "$location/powershell*" -Include *.deb,*.rpm
|
$linuxPackages = Get-ChildItem "$location/powershell*" -Include *.deb,*.rpm,*.AppImage,*.tar.gz
|
||||||
|
foreach ($linuxPackage in $linuxPackages)
|
||||||
foreach($linuxPackage in $linuxPackages)
|
|
||||||
{
|
|
||||||
Copy-Item -Path $linuxPackage.FullName -Destination $destination -force
|
|
||||||
}
|
|
||||||
|
|
||||||
if($AppImage.IsPresent)
|
|
||||||
{
|
{
|
||||||
$appImages = Get-ChildItem -Path $location -Filter '*.AppImage'
|
$filePath = $linuxPackage.FullName
|
||||||
foreach($appImageFile in $appImages)
|
Write-Verbose "Copying $filePath to $destination" -Verbose
|
||||||
{
|
Copy-Item -Path $filePath -Destination $destination -force
|
||||||
Copy-Item -Path $appImageFile.FullName -Destination $destination -force
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
{
|
{
|
||||||
"Name": "ubuntu.14.04",
|
"Name": "ubuntu.14.04",
|
||||||
"RepoDestinationPath": "/PowerShell",
|
"RepoDestinationPath": "/PowerShell",
|
||||||
"BuildCommand": "/PowerShellPackage.ps1 -location _RepoDestinationPath_ -destination _DockerVolume_ -ReleaseTag _ReleaseTag_ -AppImage",
|
"BuildCommand": "/PowerShellPackage.ps1 -location _RepoDestinationPath_ -destination _DockerVolume_ -ReleaseTag _ReleaseTag_ -ExtraPackage AppImage",
|
||||||
"BuildDockerOptions": [
|
"BuildDockerOptions": [
|
||||||
"--cap-add",
|
"--cap-add",
|
||||||
"SYS_ADMIN",
|
"SYS_ADMIN",
|
||||||
@ -43,7 +43,7 @@
|
|||||||
"AdditionalContextFiles" :[ "./tools/releaseBuild/Images/GenericLinuxFiles/PowerShellPackage.ps1"],
|
"AdditionalContextFiles" :[ "./tools/releaseBuild/Images/GenericLinuxFiles/PowerShellPackage.ps1"],
|
||||||
"DockerImageName": "ps-ubunutu-14-04"
|
"DockerImageName": "ps-ubunutu-14-04"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "ubuntu.16.04",
|
"Name": "ubuntu.16.04",
|
||||||
"RepoDestinationPath": "/PowerShell",
|
"RepoDestinationPath": "/PowerShell",
|
||||||
"BuildCommand": "/PowerShellPackage.ps1 -location _RepoDestinationPath_ -destination _DockerVolume_ -ReleaseTag _ReleaseTag_",
|
"BuildCommand": "/PowerShellPackage.ps1 -location _RepoDestinationPath_ -destination _DockerVolume_ -ReleaseTag _ReleaseTag_",
|
||||||
@ -51,10 +51,10 @@
|
|||||||
"DockerFile": "./tools/releaseBuild/Images/microsoft_powershell_ubuntu16.04/Dockerfile",
|
"DockerFile": "./tools/releaseBuild/Images/microsoft_powershell_ubuntu16.04/Dockerfile",
|
||||||
"DockerImageName": "ps-ubunutu-16-04"
|
"DockerImageName": "ps-ubunutu-16-04"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "centos.7",
|
"Name": "centos.7",
|
||||||
"RepoDestinationPath": "/PowerShell",
|
"RepoDestinationPath": "/PowerShell",
|
||||||
"BuildCommand": "/PowerShellPackage.ps1 -location _RepoDestinationPath_ -destination _DockerVolume_ -ReleaseTag _ReleaseTag_",
|
"BuildCommand": "/PowerShellPackage.ps1 -location _RepoDestinationPath_ -destination _DockerVolume_ -ReleaseTag _ReleaseTag_ -ExtraPackage tar",
|
||||||
"AdditionalContextFiles" :[ "./tools/releaseBuild/Images/GenericLinuxFiles/PowerShellPackage.ps1"],
|
"AdditionalContextFiles" :[ "./tools/releaseBuild/Images/GenericLinuxFiles/PowerShellPackage.ps1"],
|
||||||
"DockerFile": "./tools/releaseBuild/Images/microsoft_powershell_centos7/Dockerfile",
|
"DockerFile": "./tools/releaseBuild/Images/microsoft_powershell_centos7/Dockerfile",
|
||||||
"DockerImageName": "ps-centos-7"
|
"DockerImageName": "ps-centos-7"
|
||||||
|
Loading…
Reference in New Issue
Block a user