mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Merge pull request #805 from PowerShell/andschwa/pspackage
Improve Start-PSPackage
This commit is contained in:
commit
5e0528ffe9
2 files changed
+69
-41
No files matched your search
+69
-40
@@ -70,7 +70,7 @@ function Start-PSBuild {
|
||||
}
|
||||
|
||||
$precheck = $precheck -and (precheck 'msbuild' 'msbuild not found. Install Visual Studio 2015.')
|
||||
} elseif ($IsLinux -Or $IsOSX) {
|
||||
} elseif ($IsLinux -or $IsOSX) {
|
||||
$InstallCommand = if ($IsLinux) {
|
||||
'apt-get'
|
||||
} elseif ($IsOSX) {
|
||||
@@ -82,14 +82,14 @@ function Start-PSBuild {
|
||||
}
|
||||
}
|
||||
|
||||
if (-Not $Runtime) {
|
||||
if (-not $Runtime) {
|
||||
$Runtime = dotnet --info | % {
|
||||
if ($_ -match "RID") {
|
||||
$_ -split "\s+" | Select-Object -Last 1
|
||||
}
|
||||
}
|
||||
|
||||
if (-Not $Runtime) {
|
||||
if (-not $Runtime) {
|
||||
Write-Warning "Could not determine Runtime Identifier, please update dotnet"
|
||||
$precheck = $false
|
||||
} else {
|
||||
@@ -111,7 +111,7 @@ function Start-PSBuild {
|
||||
$Framework = 'netstandardapp1.5'
|
||||
}
|
||||
|
||||
if ($IsLinux -Or $IsOSX) {
|
||||
if ($IsLinux -or $IsOSX) {
|
||||
$Configuration = "Linux"
|
||||
$Executable = "powershell"
|
||||
} else {
|
||||
@@ -132,7 +132,7 @@ function Start-PSBuild {
|
||||
# Build the Output path in script scope
|
||||
$script:Output = [IO.Path]::Combine($Top, "bin", $Configuration, $Framework)
|
||||
# FullCLR only builds a library, so there is no runtime component
|
||||
if (-Not $FullCLR) {
|
||||
if (-not $FullCLR) {
|
||||
$script:Output = [IO.Path]::Combine($script:Output, $Runtime)
|
||||
}
|
||||
# Publish injects the publish directory
|
||||
@@ -144,7 +144,7 @@ function Start-PSBuild {
|
||||
Write-Verbose "script:Output is $script:Output"
|
||||
|
||||
# handle Restore
|
||||
if ($Restore -Or -Not (Test-Path "$Top/project.lock.json")) {
|
||||
if ($Restore -or -not (Test-Path "$Top/project.lock.json")) {
|
||||
log "Run dotnet restore"
|
||||
|
||||
$RestoreArguments = @("--verbosity")
|
||||
@@ -160,7 +160,7 @@ function Start-PSBuild {
|
||||
}
|
||||
|
||||
# Build native components
|
||||
if ($IsLinux -Or $IsOSX) {
|
||||
if ($IsLinux -or $IsOSX) {
|
||||
$Ext = if ($IsLinux) {
|
||||
"so"
|
||||
} elseif ($IsOSX) {
|
||||
@@ -180,7 +180,7 @@ function Start-PSBuild {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
if (-Not (Test-Path $Lib)) {
|
||||
if (-not (Test-Path $Lib)) {
|
||||
throw "Compilation of $Lib failed"
|
||||
}
|
||||
} elseif ($FullCLR) {
|
||||
@@ -217,7 +217,7 @@ function Start-PSBuild {
|
||||
|
||||
function Get-PSOutput {
|
||||
[CmdletBinding()]param()
|
||||
if (-Not $Output) {
|
||||
if (-not $Output) {
|
||||
throw '$script:Output is not defined, run Start-PSBuild'
|
||||
}
|
||||
|
||||
@@ -262,37 +262,60 @@ function Start-PSxUnit {
|
||||
}
|
||||
|
||||
function Start-PSPackage {
|
||||
# PowerShell packages use Semantic Versioning http://semver.org/
|
||||
#
|
||||
# Ubuntu and OS X packages are supported.
|
||||
[CmdletBinding()]param(
|
||||
# PowerShell packages use Semantic Versioning http://semver.org/
|
||||
[string]$Version,
|
||||
# Package iteration version (rarely changed)
|
||||
[int]$Iteration = 1,
|
||||
# Ubuntu, CentOS, and OS X packages are supported
|
||||
[ValidateSet("deb", "osxpkg", "rpm")]
|
||||
[string]$Type
|
||||
)
|
||||
|
||||
$Description = @"
|
||||
Open PowerShell on .NET Core
|
||||
PowerShell is an open-source, cross-platform, scripting language and rich object shell.
|
||||
Built upon .NET Core, it is also a C# REPL.
|
||||
"@
|
||||
|
||||
if ($IsWindows) { throw "Building Windows packages is not yet supported!" }
|
||||
|
||||
if (-Not (Get-Command "fpm" -ErrorAction SilentlyContinue)) {
|
||||
if (-not (Get-Command "fpm" -ErrorAction SilentlyContinue)) {
|
||||
throw "Build dependency 'fpm' not found in PATH! See: https://github.com/jordansissel/fpm"
|
||||
}
|
||||
|
||||
if (-Not(Test-Path "$PSScriptRoot/bin/powershell")) {
|
||||
throw "Please Start-PSBuild with the corresponding runtime for the package"
|
||||
$Source = Split-Path -Parent (Get-PSOutput)
|
||||
if ((Split-Path -Leaf $Source) -ne "publish") {
|
||||
throw "Please Start-PSBuild -Package with the corresponding runtime for the package"
|
||||
}
|
||||
|
||||
# Change permissions for packaging
|
||||
chmod -R go=u "$PSScriptRoot/bin"
|
||||
|
||||
# Decide package output type
|
||||
if (-Not($Type)) {
|
||||
if (-not $Type) {
|
||||
$Type = if ($IsLinux) { "deb" } elseif ($IsOSX) { "osxpkg" }
|
||||
Write-Warning "-Type was not specified, continuing with $Type"
|
||||
}
|
||||
|
||||
# Follow the Filesystem Hierarchy Standard for Linux and OS X
|
||||
$Destination = if ($IsLinux) {
|
||||
"/opt/microsoft/powershell"
|
||||
} elseif ($IsOSX) {
|
||||
"/usr/local/microsoft/powershell"
|
||||
}
|
||||
|
||||
# Destination for symlink to powershell executable
|
||||
$Link = if ($IsLinux) {
|
||||
"/usr/bin"
|
||||
} elseif ($IsOSX) {
|
||||
"/usr/local/bin"
|
||||
}
|
||||
|
||||
New-Item -Force -ItemType SymbolicLink -Path /tmp/powershell -Target $Destination/powershell >$null
|
||||
|
||||
# Change permissions for packaging
|
||||
chmod -R go=u $Source /tmp/powershell
|
||||
|
||||
# Use Git tag if not given a version
|
||||
if (-Not($Version)) {
|
||||
if (-not $Version) {
|
||||
$Version = (git --git-dir="$PSScriptRoot/.git" describe) -Replace '^v'
|
||||
}
|
||||
|
||||
@@ -306,26 +329,32 @@ function Start-PSPackage {
|
||||
"rpm" { "libicu" }
|
||||
}
|
||||
|
||||
|
||||
$Arguments = @(
|
||||
"--force", "--verbose",
|
||||
"--name", "powershell",
|
||||
"--version", $Version,
|
||||
"--iteration", $Iteration,
|
||||
"--maintainer", "Andrew Schwartzmeyer <andschwa@microsoft.com>",
|
||||
"--vendor", "Microsoft <mageng@microsoft.com>",
|
||||
"--url", "https://github.com/PowerShell/PowerShell",
|
||||
"--license", "Unlicensed",
|
||||
"--description", $Description,
|
||||
"--category", "shells",
|
||||
"--rpm-os", "linux",
|
||||
"--depends", $libunwind,
|
||||
"--depends", $libicu,
|
||||
"--deb-build-depends", "dotnet",
|
||||
"--deb-build-depends", "cmake",
|
||||
"--deb-build-depends", "g++",
|
||||
"-t", $Type,
|
||||
"-s", "dir",
|
||||
"$Source/=$Destination/",
|
||||
"/tmp/powershell=$Link"
|
||||
)
|
||||
|
||||
# Build package
|
||||
fpm --force --verbose `
|
||||
--name "powershell" `
|
||||
--version $Version `
|
||||
--iteration $Iteration `
|
||||
--maintainer "Andrew Schwartzmeyer <andschwa@microsoft.com>" `
|
||||
--vendor "Microsoft <mageng@microsoft.com>" `
|
||||
--url "https://github.com/PowerShell/PowerShell" `
|
||||
--license "Unlicensed" `
|
||||
--description "Open PowerShell on .NET Core\nPowerShell is an open-source, cross-platform, scripting language and rich object shell. Built upon .NET Core, it is also a C# REPL.\n" `
|
||||
--category "shells" `
|
||||
--depends $libunwind `
|
||||
--depends $libicu `
|
||||
--deb-build-depends "dotnet" `
|
||||
--deb-build-depends "cmake" `
|
||||
--deb-build-depends "g++" `
|
||||
-t $Type `
|
||||
-s dir `
|
||||
"$PSScriptRoot/bin/=/usr/local/share/powershell/" `
|
||||
"$PSScriptRoot/package/powershell=/usr/local/bin"
|
||||
fpm $Arguments
|
||||
}
|
||||
|
||||
|
||||
@@ -348,7 +377,7 @@ function Start-DevPSGitHub {
|
||||
$env:COMPLUS_ZapDisable = 1
|
||||
}
|
||||
|
||||
if (-Not (Test-Path $binDir\powershell.exe.config)) {
|
||||
if (-not (Test-Path $binDir\powershell.exe.config)) {
|
||||
$configContents = @"
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
../share/powershell/powershell
|
||||
Reference in new issue
Block a user