From 5671a1113d8b744e059acf2c8cb4471764a8a80c Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 26 Feb 2016 18:49:11 -0800 Subject: [PATCH 1/5] Add CentOS 7.1 runtime --- src/Microsoft.PowerShell.Linux.Host/project.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.PowerShell.Linux.Host/project.json b/src/Microsoft.PowerShell.Linux.Host/project.json index 7c49543265..048b170cbb 100644 --- a/src/Microsoft.PowerShell.Linux.Host/project.json +++ b/src/Microsoft.PowerShell.Linux.Host/project.json @@ -46,6 +46,7 @@ "runtimes": { "ubuntu.14.04-x64": { }, + "centos.7.1-x64": { }, "win7-x64": { }, "win10-x64": { }, "osx.10.10-x64": { }, From e1c0f680983dc624cf190164bfd3ff391f5292e6 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 26 Feb 2016 18:49:51 -0800 Subject: [PATCH 2/5] Add switch to Start-PSBuild any specific -Runtime Much better argument passing to CLI. Thanks @vors. --- PowerShellGitHubDev.psm1 | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/PowerShellGitHubDev.psm1 b/PowerShellGitHubDev.psm1 index 0f28bb92b6..91f0a4eff9 100644 --- a/PowerShellGitHubDev.psm1 +++ b/PowerShellGitHubDev.psm1 @@ -21,7 +21,8 @@ function Start-PSBuild { param( [switch]$Restore, - [string]$Output = "$PSScriptRoot/bin" + [string]$Output = "$PSScriptRoot/bin", + [string]$Runtime ) if (-Not (Get-Command "dotnet" -ErrorAction SilentlyContinue)) { @@ -63,11 +64,15 @@ function Start-PSBuild Write-Host "Building PowerShell" - $Configuration = - if ($IsLinux -Or $IsOSX) { "Linux" } - elseif ($IsWindows) { "Debug" } + $Arguments = "--framework", "netstandardapp1.5", "--output", $Output - dotnet publish -o $Output -c $Configuration -f "netstandardapp1.5" $Top + if ($IsLinux -Or $IsOSX) { $Arguments += "--configuration", "Linux" } + + if ($Runtime) { $Arguments += "--runtime", $Runtime } + + $Arguments += $Top + + dotnet publish $Arguments } function Start-PSPackage From e349704fa1b5797682d3094cf16e99dbdb2d9af8 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 26 Feb 2016 18:51:13 -0800 Subject: [PATCH 3/5] Add Start-PSPackage -Type switch to build any output If not specified, "deb" is used as default on Linux. This should be updated to check the distribution and required package build dependencies. Dependency names switched per package type, since specific package names are different. Should check if this causes an issue on OS X when the names are empty. --- PowerShellGitHubDev.psm1 | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/PowerShellGitHubDev.psm1 b/PowerShellGitHubDev.psm1 index 91f0a4eff9..0c090c58e6 100644 --- a/PowerShellGitHubDev.psm1 +++ b/PowerShellGitHubDev.psm1 @@ -82,7 +82,9 @@ function Start-PSPackage # Ubuntu and OS X packages are supported. param( [string]$Version, - [int]$Iteration = 1 + [int]$Iteration = 1, + [ValidateSet("deb", "osxpkg", "rpm")] + [string]$Type ) if ($IsWindows) { throw "Building Windows packages is not yet supported!" } @@ -99,13 +101,26 @@ function Start-PSPackage chmod -R go=u "$PSScriptRoot/bin" # Decide package output type - $Output = if ($IsLinux) { "deb" } elseif ($IsOSX) { "osxpkg" } + if (-Not($Type)) { + $Type = if ($IsLinux) { "deb" } elseif ($IsOSX) { "osxpkg" } + Write-Warning "-Type was not specified, continuing with $Type" + } # Use Git tag if not given a version if (-Not($Version)) { $Version = (git --git-dir="$PSScriptRoot/.git" describe) -Replace '^v' } + $libunwind = switch ($Type) { + "deb" { "libunwind8" } + "rpm" { "libunwind" } + } + + $libicu = switch ($Type) { + "deb" { "libicu52" } + "rpm" { "libicu" } + } + # Build package fpm --force --verbose ` --name "powershell" ` @@ -117,12 +132,12 @@ function Start-PSPackage --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 "libunwind8" ` - --depends "libicu52" ` + --depends $libunwind ` + --depends $libicu ` --deb-build-depends "dotnet" ` --deb-build-depends "cmake" ` --deb-build-depends "g++" ` - -t $Output ` + -t $Type ` -s dir ` "$PSScriptRoot/bin/=/usr/local/share/powershell/" ` "$PSScriptRoot/package/powershell=/usr/local/bin" From 4e76a6261f93f8a03524603d7ad25a3ad7cb9dc3 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Thu, 3 Mar 2016 15:54:52 -0800 Subject: [PATCH 4/5] Validate -Runtime --- PowerShellGitHubDev.psm1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/PowerShellGitHubDev.psm1 b/PowerShellGitHubDev.psm1 index 0c090c58e6..0d4ce06b1e 100644 --- a/PowerShellGitHubDev.psm1 +++ b/PowerShellGitHubDev.psm1 @@ -22,6 +22,14 @@ function Start-PSBuild param( [switch]$Restore, [string]$Output = "$PSScriptRoot/bin", + # These runtimes must match those in project.json + # We do not use ValidateScript since we want tab completion + [ValidateSet("ubuntu.14.04-x64", + "centos.7.1-x64", + "win7-x64", + "win10-x64", + "osx.10.10-x64", + "osx.10.11-x64")] [string]$Runtime ) @@ -94,7 +102,7 @@ function Start-PSPackage } if (-Not(Test-Path "$PSScriptRoot/bin/powershell")) { - throw "Please Start-PSBuild to publish PowerShell" + throw "Please Start-PSBuild with the corresponding runtime for the package" } # Change permissions for packaging From 05ef79784995da6e85097228331ea6c19d9c1e4b Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 7 Mar 2016 16:12:50 -0800 Subject: [PATCH 5/5] Add -Clean switch to Start-PSBuild And use full names of cmdlets. --- PowerShellGitHubDev.psm1 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/PowerShellGitHubDev.psm1 b/PowerShellGitHubDev.psm1 index 0d4ce06b1e..488cba6e01 100644 --- a/PowerShellGitHubDev.psm1 +++ b/PowerShellGitHubDev.psm1 @@ -21,6 +21,7 @@ function Start-PSBuild { param( [switch]$Restore, + [switch]$Clean, [string]$Output = "$PSScriptRoot/bin", # These runtimes must match those in project.json # We do not use ValidateScript since we want tab completion @@ -37,6 +38,10 @@ function Start-PSBuild throw "Build dependency 'dotnet' not found in PATH! See: https://dotnet.github.io/getting-started/" } + if ($Clean) { + Remove-Item -Force -Recurse $Output + } + New-Item -Force -Type Directory $Output | Out-Null $Top = "$PSScriptRoot/src/Microsoft.PowerShell.Linux.Host" @@ -58,16 +63,16 @@ function Start-PSBuild Write-Host "Building $Lib" try { - pushd $Native + Push-Location $Native cmake -DCMAKE_BUILD_TYPE=Debug . make -j make test } finally { - popd + Pop-Location } if (-Not (Test-Path $Lib)) { throw "Compilation of $Lib failed" } - cp $Lib $Output + Copy-Item $Lib $Output } Write-Host "Building PowerShell"