mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Improve Start-PSPackage
- Now checks that previous Start-PSBuild was with -Publish - Uses $script:Output automatically - Uses /opt/microsoft/powershell on Linux per FHS - Uses /usr/local/microsoft/powershell on OS X per FHS - Specifies "--rpm-os linux" for RPM packages built elsewhere - Creates symlink on demand for packaging - Puts symlink in /usr/(local)/bin as it is expected to be in PATH - Uses $Arguments array for better syntax - Resolves #800 Note that if the target of the powershell symlink exists, `fpm` aborts with a `utime` error on OS X.
This commit is contained in:
1 parent
865f174e22
commit
0afd4c2f98
2 files changed
+57
-29
No files matched your search
+57
-28
@@ -262,35 +262,58 @@ function Start-PSxUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Start-PSPackage {
|
function Start-PSPackage {
|
||||||
# PowerShell packages use Semantic Versioning http://semver.org/
|
|
||||||
#
|
|
||||||
# Ubuntu and OS X packages are supported.
|
|
||||||
[CmdletBinding()]param(
|
[CmdletBinding()]param(
|
||||||
|
# PowerShell packages use Semantic Versioning http://semver.org/
|
||||||
[string]$Version,
|
[string]$Version,
|
||||||
|
# Package iteration version (rarely changed)
|
||||||
[int]$Iteration = 1,
|
[int]$Iteration = 1,
|
||||||
|
# Ubuntu, CentOS, and OS X packages are supported
|
||||||
[ValidateSet("deb", "osxpkg", "rpm")]
|
[ValidateSet("deb", "osxpkg", "rpm")]
|
||||||
[string]$Type
|
[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 ($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"
|
throw "Build dependency 'fpm' not found in PATH! See: https://github.com/jordansissel/fpm"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-Not(Test-Path "$PSScriptRoot/bin/powershell")) {
|
$Source = Split-Path -Parent (Get-PSOutput)
|
||||||
throw "Please Start-PSBuild with the corresponding runtime for the package"
|
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
|
# Decide package output type
|
||||||
if (-Not($Type)) {
|
if (-not $Type) {
|
||||||
$Type = if ($IsLinux) { "deb" } elseif ($IsOSX) { "osxpkg" }
|
$Type = if ($IsLinux) { "deb" } elseif ($IsOSX) { "osxpkg" }
|
||||||
Write-Warning "-Type was not specified, continuing with $Type"
|
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
|
# Use Git tag if not given a version
|
||||||
if (-not $Version) {
|
if (-not $Version) {
|
||||||
$Version = (git --git-dir="$PSScriptRoot/.git" describe) -Replace '^v'
|
$Version = (git --git-dir="$PSScriptRoot/.git" describe) -Replace '^v'
|
||||||
@@ -306,26 +329,32 @@ function Start-PSPackage {
|
|||||||
"rpm" { "libicu" }
|
"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
|
# Build package
|
||||||
fpm --force --verbose `
|
fpm $Arguments
|
||||||
--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"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
../share/powershell/powershell
|
|
||||||
Reference in new issue
Block a user