From 5439d5071026555bfa8bdb60f6821c94ac1b5f72 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 19 Sep 2016 16:23:40 -0700 Subject: [PATCH 1/5] Add all dependencies to New-UnixPackage Now that I finally have a decent list of dependencies (though it may still be too many), I have expanded the dependencies of the package so that users get better error messages. I've removed ca-certificates as that's not *necessarily* required (but needed on Docker to download over HTTPS). This may be true of other packages too. --- build.psm1 | 50 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/build.psm1 b/build.psm1 index 0bee2ed8a4d..81bf045cda1 100644 --- a/build.psm1 +++ b/build.psm1 @@ -1194,17 +1194,40 @@ esac chmod 755 "$Staging/$Name" # only the executable should be executable } - $libunwind = switch ($Type) { - "deb" { "libunwind8" } - "rpm" { "libunwind" } - } - - $libicu = switch ($Type) { - "deb" { - if ($IsUbuntu14) { "libicu52" } - elseif ($IsUbuntu16) { "libicu55" } - } - "rpm" { "libicu" } + # Setup package dependencies + # These should match those in the Dockerfiles, but exclude tools like Git, which, and curl + $Dependencies = @() + if ($IsUbuntu) { + $Dependencies = @( + "libc6", + "libcurl3", + "libgcc1", + "libssl1.0.0", + "libstdc++6", + "libtinfo5", + "libunwind8", + "libuuid1", + "zlib1g" + ) + # Please note the different libicu package dependency! + if ($IsUbuntu14) { + $Dependencies += "libicu52" + } elseif ($IsUbuntu16) { + $Dependencies += "libicu55" + } + } elseif ($IsCentOS) { + $Dependencies = @( + "glibc", + "libcurl", + "libgcc", + "libicu", + "openssl", + "libstdc++", + "ncurses-base", + "libunwind", + "uuid", + "zlib" + ) } # iteration is "debian_revision" @@ -1232,11 +1255,12 @@ esac "--description", $Description, "--category", "shells", "--rpm-os", "linux", - "--depends", $libunwind, - "--depends", $libicu, "-t", $Type, "-s", "dir" ) + foreach ($Dependency in $Dependencies) { + $Arguments += @("--depends", $Dependency) + } if ($AfterInstallScript) { $Arguments += @("--after-install", $AfterInstallScript) } From e5d35807bb7224b31f0f589d1159d4edac4f7581 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 19 Sep 2016 16:34:12 -0700 Subject: [PATCH 2/5] Update download.sh to install all dependencies --- tools/download.sh | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/tools/download.sh b/tools/download.sh index 7e1d7700508..26f0c4bfd4f 100755 --- a/tools/download.sh +++ b/tools/download.sh @@ -71,24 +71,17 @@ case "$OSTYPE" in linux*) source /etc/os-release # Install dependencies + echo "Installing PowerShell with sudo..." case "$ID" in centos) - echo "Installing libicu, libunwind, and $package with sudo ..." - sudo yum install -y libicu libunwind + # yum automatically resolves dependencies for local packages sudo yum install "./$package" ;; ubuntu) - case "$VERSION_ID" in - 14.04) - icupackage=libicu52 - ;; - 16.04) - icupackage=libicu55 - ;; - esac - echo "Installing $libicupackage, libunwind8, and $package with sudo ..." - sudo apt-get install -y libunwind8 "$icupackage" - sudo dpkg -i "./$package" + # dpkg does not automatically resolve dependencies, but spouts ugly errors + sudo dpkg -i "./$package" &> /dev/null + # Resolve dependencies + sudo apt-get install -f ;; *) esac From 153ff43b50774f231f9e12633ab1ee2cab31cd37 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 19 Sep 2016 16:34:23 -0700 Subject: [PATCH 3/5] Update Linux installation docs to resolve dependencies Use `dpkg -i` followed by `apt-get install -f`. Alternatives considered included using `apt install`, which does not work, and copying the PowerShell package to `/var/cache/apt/archives` which is just as messy as this. At least this follows the same steps as `download.sh`. --- docs/installation/linux.md | 44 ++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/docs/installation/linux.md b/docs/installation/linux.md index 44035d40a25..2fffd34a841 100644 --- a/docs/installation/linux.md +++ b/docs/installation/linux.md @@ -23,16 +23,19 @@ from the [releases][] page onto the Ubuntu machine. Then execute the following in the terminal: ```sh -sudo apt-get install libunwind8 libicu52 sudo dpkg -i powershell_6.0.0-alpha.10-1ubuntu1.14.04.1_amd64.deb +sudo apt-get install -f ``` -**Uninstallation** -`sudo apt-get remove powershell` +> Please note that `dpkg -i` will fail with unmet dependencies; +> the next command, `apt-get install -f` resolves these +> and then finishes configuring the PowerShell package. -or +**Uninstallation** -`sudo dpkg -r powershell` +```sh +sudo apt-get remove powershell +``` [Ubuntu 14.04]: http://releases.ubuntu.com/14.04/ @@ -45,19 +48,20 @@ from the [releases][] page onto the Ubuntu machine. Then execute the following in the terminal: -> Please note the different libicu package dependency! - ```sh -sudo apt-get install libunwind8 libicu55 sudo dpkg -i powershell_6.0.0-alpha.10-1ubuntu1.16.04.1_amd64.deb +sudo apt-get install -f ``` -**Uninstallation** -`sudo apt-get remove powershell` +> Please note that `dpkg -i` will fail with unmet dependencies; +> the next command, `apt-get install -f` resolves these +> and then finishes configuring the PowerShell package. -or +**Uninstallation** -`sudo dpkg -r powershell` +```sh +sudo apt-get remove powershell +``` [Ubuntu 16.04]: http://releases.ubuntu.com/16.04/ @@ -73,13 +77,11 @@ from the [releases][] page onto the CentOS machine. Then execute the following in the terminal: ```sh -sudo yum install powershell-6.0.0_alpha.10-1.el7.centos.x86_64.rpm +sudo yum install ./powershell-6.0.0_alpha.10-1.el7.centos.x86_64.rpm ``` You can also install the RPM without the intermediate step of downloading it: - - ```sh sudo yum install https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-alpha.10/powershell-6.0.0_alpha.10-1.el7.centos.x86_64.rpm ``` @@ -88,7 +90,9 @@ sudo yum install https://github.com/PowerShell/PowerShell/releases/download/v6.0 **Uninstallation** -`sudo yum remove powershell` +```sh +sudo yum remove powershell +``` [CentOS 7]: https://www.centos.org/download/ @@ -111,10 +115,14 @@ sudo installer -pkg powershell-6.0.0-alpha.10.pkg -target / PowerShell on MacOS must be removed manually. To remove the installed package: + ```sh -sudo rm -rf /usr/local/bin/powershell usr/local/microsoft/powershell +sudo rm -rf /usr/local/bin/powershell /usr/local/microsoft/powershell ``` -To uninstall the additional PowerShell paths (such as the user profile path) please see the [paths][paths] section below in this document and remove the desired the paths with `sudo rm`. + +To uninstall the additional PowerShell paths (such as the user profile path) +please see the [paths][paths] section below in this document +and remove the desired the paths with `sudo rm`. OpenSSL ------- From 1b0a99fc13358138e808a3c4155ba1f2f68cc37c Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Tue, 20 Sep 2016 14:10:40 -0700 Subject: [PATCH 4/5] Add one-line installation instruction --- docs/installation/linux.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/installation/linux.md b/docs/installation/linux.md index 2fffd34a841..0a48a724956 100644 --- a/docs/installation/linux.md +++ b/docs/installation/linux.md @@ -5,13 +5,22 @@ Supports [Ubuntu 14.04][u14], [Ubuntu 16.04][u16], [CentOS 7][cos], and [macOS 10.11][osx]. All packages are available on our GitHub [releases][] page. +All of these steps can be down automatically by the [`download.sh`][download] script. +You should *never* run a script without reading it first! + +Please **read the [download][] script first**, and then if you want to run it, use: + +```sh +bash <(curl -fsSL https://raw.githubusercontent.com/PowerShell/PowerShell/v6.0.0-alpha.10/tools/download.sh) +``` + Once the package is installed, run `powershell` from a terminal. [u14]: #ubuntu-1404 [u16]: #ubuntu-1604 [cos]: #centos-7 [osx]: #os-x-1011 -[paths]:#paths +[download]: https://github.com/PowerShell/PowerShell/blob/v6.0.0-alpha.10/tools/download.sh Ubuntu 14.04 ============ @@ -124,6 +133,8 @@ To uninstall the additional PowerShell paths (such as the user profile path) please see the [paths][paths] section below in this document and remove the desired the paths with `sudo rm`. +[paths]:#paths + OpenSSL ------- From 8a24d26e8d96afae3e137c2cec4b1d00e5e258ea Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Tue, 20 Sep 2016 14:26:07 -0700 Subject: [PATCH 5/5] Patch System.Net.Http.Native.dylib Again, .NET Core expects users to forcibly link the third party OpenSSL libraries into system directories, which the Homebrew team advises strongly against (and attempts to prevent). This also affects the System.Net.Http library, and results in runtime errors during SSL certificate validation. So instead, we patch what we can, when we can. --- build.psm1 | 6 +++++- docs/installation/linux.md | 2 ++ tools/download.sh | 12 ++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/build.psm1 b/build.psm1 index 81bf045cda1..e4cf5d0d322 100644 --- a/build.psm1 +++ b/build.psm1 @@ -222,6 +222,7 @@ function Start-PSBuild { # This is allowed to fail since the user may have already restored Write-Warning ".NET Core links the incorrect OpenSSL, correcting NuGet package libraries..." find $env:HOME/.nuget -name System.Security.Cryptography.Native.dylib | xargs sudo install_name_tool -add_rpath /usr/local/opt/openssl/lib + find $env:HOME/.nuget -name System.Net.Http.Native.dylib | xargs sudo install_name_tool -change /usr/lib/libcurl.4.dylib /usr/local/opt/curl/lib/libcurl.4.dylib } } @@ -820,13 +821,16 @@ function Start-PSBootstrap { precheck 'brew' "Bootstrap dependency 'brew' not found, must install Homebrew! See http://brew.sh/" # Build tools - $Deps += "curl", "cmake" + $Deps += "cmake" # .NET Core required runtime libraries $Deps += "openssl" # Install dependencies Start-NativeExecution { brew install $Deps } + + # Install patched version of curl + Start-NativeExecution { brew install curl --with-openssl } } # Install [fpm](https://github.com/jordansissel/fpm) and [ronn](https://github.com/rtomayko/ronn) diff --git a/docs/installation/linux.md b/docs/installation/linux.md index 0a48a724956..4c6933e3499 100644 --- a/docs/installation/linux.md +++ b/docs/installation/linux.md @@ -142,6 +142,7 @@ Also install [Homebrew's OpenSSL][openssl]: ``` brew install openssl +brew install curl --with-openssl ``` [Homebrew][brew] is the missing package manager for macOS. @@ -167,6 +168,7 @@ To patch .NET Core's cryptography libraries, we use `install_name_tool`: ``` find ~/.nuget -name System.Security.Cryptography.Native.dylib | xargs sudo install_name_tool -add_rpath /usr/local/opt/openssl/lib +find ~/.nuget -name System.Net.Http.Native.dylib | xargs sudo install_name_tool -change /usr/lib/libcurl.4.dylib /usr/local/opt/curl/lib/libcurl.4.dylib ``` This updates .NET Core's library to look in Homebrew's OpenSSL installation location instead of the system library location. diff --git a/tools/download.sh b/tools/download.sh index 26f0c4bfd4f..d0ba82e560f 100755 --- a/tools/download.sh +++ b/tools/download.sh @@ -87,14 +87,22 @@ case "$OSTYPE" in esac ;; darwin*) + patched=0 if hash brew 2>/dev/null; then if [[ ! -d $(brew --prefix openssl) ]]; then echo "Installing OpenSSL with brew..." if ! brew install openssl; then echo "ERROR: OpenSSL failed to install! Crypto functions will not work..." >&2 # Don't abort because it is not fatal + elif ! brew install curl --with-openssl; then + echo "ERROR: curl failed to build against OpenSSL; SSL functions will not work..." >&2 + # Still not fatal + else + # OpenSSL installation succeeded; remember to patch System.Net.Http after PowerShell installation + patched=1 fi fi + else echo "ERROR: brew not found! OpenSSL may not be available..." >&2 # Don't abort because it is not fatal @@ -102,6 +110,10 @@ case "$OSTYPE" in echo "Installing $package with sudo ..." sudo installer -pkg "./$package" -target / + if [[ $patched -eq 1 ]]; then + echo "Patching System.Net.Http for libcurl and OpenSSL..." + find /usr/local/microsoft/powershell -name System.Net.Http.Native.dylib | xargs sudo install_name_tool -change /usr/lib/libcurl.4.dylib /usr/local/opt/curl/lib/libcurl.4.dylib + fi ;; esac