diff --git a/PowerShellGitHubDev.psm1 b/PowerShellGitHubDev.psm1 index 9a0426e695..3cc1a739d7 100644 --- a/PowerShellGitHubDev.psm1 +++ b/PowerShellGitHubDev.psm1 @@ -262,35 +262,58 @@ 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)) { 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) { $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 ", + "--vendor", "Microsoft ", + "--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 " ` - --vendor "Microsoft " ` - --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 } diff --git a/package/powershell b/package/powershell deleted file mode 120000 index 61bd3470b7..0000000000 --- a/package/powershell +++ /dev/null @@ -1 +0,0 @@ -../share/powershell/powershell \ No newline at end of file