From 8ef8f9fada7148e41154111779d997f97be3d4d3 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 18 Jul 2016 10:00:46 -0700 Subject: [PATCH 1/6] Add GitHub token as insecure environment variable This should enable building via PR from forks. This token has read-only access to download the installer packages, but should nonetheless be revoked and replaced with a wget download when the repository goes public. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 70c605a7c7..60dfd420ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,8 @@ matrix: - os: osx osx_image: xcode8 language: generic +env: + - GITHUB_TOKEN=a27573e27bea23fb05393ead69511b09e3b224be cache: directories: - $HOME/.dotnet From 0f7748a70bf37b417408c40edaee5f871d32f0a0 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 18 Jul 2016 10:48:13 -0700 Subject: [PATCH 2/6] Add CentOS support --- tools/download.sh | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/tools/download.sh b/tools/download.sh index 8403642ca2..a632610cef 100755 --- a/tools/download.sh +++ b/tools/download.sh @@ -16,15 +16,27 @@ get_info() { # Get OS specific asset ID and package name case "$OSTYPE" in linux*) + source /etc/os-release + echo $ID # Install curl and wget to download package - sudo apt-get install -y curl wget - info=$(get_info deb) + case "$ID" in + centos*) + sudo yum install -y curl wget + info=$(get_info rpm) + ;; + ubuntu) + sudo apt-get install -y curl wget + info=$(get_info deb) + ;; + *) + exit 2 >&2 "$NAME is not supported!" + esac ;; darwin*) info=$(get_info pkg) ;; *) - exit 2 >&2 "$OSTYPE not supported!" + exit 2 >&2 "$OSTYPE is not supported!" ;; esac @@ -38,9 +50,19 @@ curl_ -H 'Accept: application/octet-stream' https://api.github.com/repos/PowerSh # Installs PowerShell package case "$OSTYPE" in linux*) + source /etc/os-release # Install dependencies - sudo apt-get install -y libunwind8 libicu52 - sudo dpkg -i ./$package + case "$ID" in + centos) + sudo yum install -y libicu libunwind + sudo yum install "./$package" + ;; + ubuntu) + sudo apt-get install -y libunwind8 libicu52 + sudo dpkg -i "./$package" + ;; + *) + esac ;; darwin*) sudo installer -pkg ./$package -target / From 49bd13b64221c42465e6f04e433018854ae93b35 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 18 Jul 2016 10:11:04 -0700 Subject: [PATCH 3/6] Use os instead of matrix Travis is being picky about how this is specified. --- .travis.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 60dfd420ea..036ff22a6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,12 @@ language: cpp -matrix: - include: - - os: linux - dist: trusty - sudo: required - - os: osx - osx_image: xcode8 - language: generic + +os: + - linux + - osx +sudo: required +dist: trusty +osx_image: xcode8 + env: - GITHUB_TOKEN=a27573e27bea23fb05393ead69511b09e3b224be cache: From ea930d3346286c4511b30fa0df7d9a29cf6b8919 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 18 Jul 2016 12:13:46 -0700 Subject: [PATCH 4/6] Remove Slack CI notifications --- .travis.yml | 3 --- appveyor.yml | 5 ----- 2 files changed, 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 036ff22a6f..9f559ae7e6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,3 @@ install: - (cd tools && ./download.sh) script: - ulimit -n 4096; powershell -c "Import-Module ./build.psm1; Start-PSBootstrap -Package; Start-PSBuild -Publish; Start-PSPackage; Start-PSPester; Start-PSxUnit" -notifications: - slack: - secure: sKYd4n61+ZFzGZuWGUl8V1kN0NM16wRVOFVlNhlFCwnkrEsKROb++EvXf5uwnKuzxkhEjvPWO+UFgeshQDoR93y4s5YLfhC5JupK4nUzjPzWs208KTrh8u/x9MY8X6Ojxi85EEAiku5GzMoMlkucSStZUYwbIfnelzqdw8uoRwmm2MW4XCPwsuEuDUVghyiva0Mdx1G6MopCrK8T96WywJXT3chhfZQgVt+sQCBt9g+2kjDaObKrzG0P07IVK43ZpDgnu6AoxlyBzIx9mJH2Oa/tki3/kTO72Wcp3ps3qvmiStADamzVKR9p1VlWCLWAd6VOehxuByCGEyujpzk135Wud2DZYO+8LD6inZVhFe3Wt5pCU9BDXZppiATfMCqgXEH7nK54pEn79yHcjthRJ2+Z9ot7As2fu3RSBmTAi8nRP0fxRyX/jctR3S6P0qt0y1ynx9nzBfhmhPQW0PMVazWS/nruQIvK/3iiYXjZxM5bBwIvabmwV00EYeTdbL6ufXWNgQcG1ZWkDsi2I3vst/ytUbHwaFYg83bXWpxg9DCzJeWLVUvE5/3NfBxRAuCTot/fgTEA9IYScvrlL7Q/bT0cOt0vEM98MPf1UO+WP85uxhsRgHtwDEo+jMaL6ZFkPhlV6mmmED4NdY2//a571cLNXdnuMAze5O3TWGBG53g= diff --git a/appveyor.yml b/appveyor.yml index 477221cf72..c33a35031e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,11 +10,6 @@ environment: priv_key: secure: -notifications: - - provider: Slack - incoming_webhook: - secure: bwwXBTeJBtRFea6FSQKzVENLwL0AOeusUSUFIh/TeHA4y0UFk7bC9+OcxgZW+YfIC0VZyTpZClJHlPFFHSgiQs4g9om17RxzJEeq4EjsW5g= - install: - ps: $fileContent = "-----BEGIN RSA PRIVATE KEY-----`n" - ps: $fileContent += $env:priv_key.Replace(' ', "`n") From af9c4cb6737144af02f26dc4e18b5265da4f162a Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 18 Jul 2016 12:21:55 -0700 Subject: [PATCH 5/6] Don't build packages for pull requests Since we don't want to build packages for pull requests (as they cannot get archived as artifacts), we need a slightly different build command, and moving it to a script was cleaner. --- .travis.yml | 8 ++++++-- tools/travis.sh | 7 +++++++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100755 tools/travis.sh diff --git a/.travis.yml b/.travis.yml index 9f559ae7e6..b4b2f1717e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,19 +9,23 @@ osx_image: xcode8 env: - GITHUB_TOKEN=a27573e27bea23fb05393ead69511b09e3b224be + cache: directories: - $HOME/.dotnet - $HOME/.nuget + addons: artifacts: s3_region: "us-west-2" paths: $(ls powershell*{deb,pkg} | tr "\n" ":") + git: submodules: false + install: - git config --global url.git@github.com:.insteadOf https://github.com/ - git submodule update --init - (cd tools && ./download.sh) -script: - - ulimit -n 4096; powershell -c "Import-Module ./build.psm1; Start-PSBootstrap -Package; Start-PSBuild -Publish; Start-PSPackage; Start-PSPester; Start-PSxUnit" + +script: ./tools/travis.sh diff --git a/tools/travis.sh b/tools/travis.sh new file mode 100755 index 0000000000..bcbc560a11 --- /dev/null +++ b/tools/travis.sh @@ -0,0 +1,7 @@ +ulimit -n 4096 +# Only build packages for branches, not pull requests +if [[ $TRAVIS_PULL_REQUEST == false ]]; then + powershell -c "Import-Module ./build.psm1; Start-PSBootstrap -Package; Start-PSBuild -Publish; Start-PSPackage; Start-PSPester; Start-PSxUnit" +else + powershell -c "Import-Module ./build.psm1; Start-PSBootstrap; Start-PSBuild; Start-PSPester; Start-PSxUnit" +fi From 8dbf74028f47bb4d793ab8584ae2212088df7937 Mon Sep 17 00:00:00 2001 From: "Raghu Shantha [MSFT]" Date: Mon, 18 Jul 2016 14:31:55 -0700 Subject: [PATCH 6/6] Install script for *nix platforms --- demos/0-Install.sh.ps1 | 17 ------- demos/Install.sh | 102 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 17 deletions(-) delete mode 100644 demos/0-Install.sh.ps1 create mode 100644 demos/Install.sh diff --git a/demos/0-Install.sh.ps1 b/demos/0-Install.sh.ps1 deleted file mode 100644 index c5fb4c3639..0000000000 --- a/demos/0-Install.sh.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -#region Download the package from GitHub to Ubuntu (14/16) -# TODO: Update the url -# TODO: Update to apt-get, if that is available -curl https://github.com/PowerShell/PowerShell/releases/download/v0.5.0/powershell_0.5.0-1_amd64.deb -#endregion - -#region Install PowerShell and its dependencies -# TODO: Fix the version -sudo apt-get install libunwind8 libicu52 -sudo dpkg -i powershell_0.5.0-1_amd64.deb -#endregion - -#region Launch PowerShell -# TODO: Launch a new terminal -clear -PowerShell -#endregion diff --git a/demos/Install.sh b/demos/Install.sh new file mode 100644 index 0000000000..b89b97ca48 --- /dev/null +++ b/demos/Install.sh @@ -0,0 +1,102 @@ +#!/usr/bin/env bash + +clear +echo "Script to download latest release of PowerShell on *nix platforms" + +echo "Verify if GITHUB_TOKEN variable is defined" +[[ -n $GITHUB_TOKEN ]] || { echo >&2 "GITHUB_TOKEN variable is undefined, Generate one using https://help.github.com/articles/creating-an-access-token-for-command-line-use/"; exit 1; } + +# Authorizes with read-only access to GitHub API +curl_() { + curl -s -i -H "Authorization: token $GITHUB_TOKEN" "$@" +} + +# Retrieves asset ID and package name of asset ending in argument +# $info looks like: "id": 1698239, "name": "powershell_0.4.0-1_amd64.deb", +get_info() { + curl_ https://api.github.com/repos/PowerShell/PowerShell/releases/latest | grep -B 1 "name.*$1" +} + +echo "Get OS specific asset ID and package name" +case "$OSTYPE" in + linux*) + source /etc/os-release + echo $ID + # Install curl and wget to download package + case "$ID" in + centos*) + sudo yum install -y curl wget + info=$(get_info rpm) + ;; + ubuntu) + sudo apt-get install -y curl wget + info=$(get_info deb) + ;; + *) + exit 2 >&2 "Package $NAME is not supported on $OSTYPE!" + esac + ;; + darwin*) + info=$(get_info pkg) + ;; + *) + exit 2 >&2 "$OSTYPE is not supported!" + ;; +esac + +# Parses $info for asset ID and package name +read asset package <<< $(echo $info | sed 's/[,"]//g' | awk '{ print $2; print $4 }') + +# Downloads asset to file +curl_ -H 'Accept: application/octet-stream' https://api.github.com/repos/PowerShell/PowerShell/releases/assets/$asset | + grep location | sed 's/location: //g' | wget -i - -O $package + +# Installs PowerShell package +case "$OSTYPE" in + linux*) + source /etc/os-release + # Install dependencies + case "$ID" in + centos) + sudo yum install -y libicu libunwind + sudo yum install "./$package" + ;; + ubuntu) + sudo apt-get install -y libunwind8 libicu52 + sudo dpkg -i "./$package" + ;; + *) + esac + ;; + darwin*) + sudo installer -pkg ./$package -target / + ;; +esac + +get_smadll_location() { + dpkg-query --listfiles PowerShell | grep "System.Management.Automation.dll" +} + +get_powershell_location() { + dirname $(get_smadll_location) +} + +get_powershell_symlink() { + dir /usr/bin/powershell +} + +install_location=$(get_powershell_location) +powershell_symlink=$(get_powershell_symlink) + +if [ $install_location ] +then + echo "Congratulations! PowerShell \"$package\" is installed @ \"$install_location\"" +fi + +if [ $powershell_symlink ] +then + echo "Symlink is available @ \"$powershell_symlink\"" +else + echo "PowerShell install failed! Check this script's output for information" + exit -1 +fi \ No newline at end of file