-
Notifications
You must be signed in to change notification settings - Fork 510
Update Travis to PowerShell Core 6.0.2 #1373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,127 +1 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Let's quit on interrupt of subcommands | ||
trap ' | ||
trap - INT # restore default INT handler | ||
echo "Interrupted" | ||
kill -s INT "$$" | ||
' INT | ||
|
||
get_url() { | ||
fork=$2 | ||
release=v6.0.0-beta.1 | ||
echo "https://github.com/$fork/PowerShell/releases/download/$release/$1" | ||
} | ||
|
||
fork="PowerShell" | ||
# Get OS specific asset ID and package name | ||
case "$OSTYPE" in | ||
linux*) | ||
source /etc/os-release | ||
# Install curl and wget to download package | ||
case "$ID" in | ||
centos*) | ||
if ! hash curl 2>/dev/null; then | ||
echo "curl not found, installing..." | ||
sudo yum install -y curl | ||
fi | ||
|
||
package=powershell-6.0.0_beta.1-1.el7.centos.x86_64.rpm | ||
;; | ||
ubuntu) | ||
if ! hash curl 2>/dev/null; then | ||
echo "curl not found, installing..." | ||
sudo apt-get install -y curl | ||
fi | ||
|
||
case "$VERSION_ID" in | ||
14.04) | ||
package=powershell_6.0.0-beta.1-1ubuntu1.14.04.1_amd64.deb | ||
;; | ||
16.04) | ||
package=powershell_6.0.0-beta.1-1ubuntu1.16.04.1_amd64.deb | ||
;; | ||
*) | ||
echo "Ubuntu $VERSION_ID is not supported!" >&2 | ||
exit 2 | ||
esac | ||
;; | ||
opensuse) | ||
if ! hash curl 2>/dev/null; then | ||
echo "curl not found, installing..." | ||
sudo zypper install -y curl | ||
fi | ||
|
||
|
||
case "$VERSION_ID" in | ||
42.1) | ||
# TODO during next release remove fork and fix package name | ||
fork=TravisEz13 | ||
package=powershell-6.0.0_beta.1-1.suse.42.1.x86_64.rpm | ||
;; | ||
*) | ||
echo "OpenSUSE $VERSION_ID is not supported!" >&2 | ||
exit 2 | ||
esac | ||
;; | ||
*) | ||
echo "$NAME is not supported!" >&2 | ||
exit 2 | ||
esac | ||
;; | ||
darwin*) | ||
# We don't check for curl as macOS should have a system version | ||
package=powershell-6.0.0-beta.1-osx.10.12-x64.pkg | ||
;; | ||
*) | ||
echo "$OSTYPE is not supported!" >&2 | ||
exit 2 | ||
;; | ||
esac | ||
|
||
curl -L -o "$package" $(get_url "$package" "$fork") | ||
|
||
if [[ ! -r "$package" ]]; then | ||
echo "ERROR: $package failed to download! Aborting..." >&2 | ||
exit 1 | ||
fi | ||
|
||
# Installs PowerShell package | ||
case "$OSTYPE" in | ||
linux*) | ||
source /etc/os-release | ||
# Install dependencies | ||
echo "Installing PowerShell with sudo..." | ||
case "$ID" in | ||
centos) | ||
# yum automatically resolves dependencies for local packages | ||
sudo yum install "./$package" | ||
;; | ||
ubuntu) | ||
# dpkg does not automatically resolve dependencies, but spouts ugly errors | ||
sudo dpkg -i "./$package" &> /dev/null | ||
# Resolve dependencies | ||
sudo apt-get install -f | ||
;; | ||
opensuse) | ||
# Install the Microsoft public key so that zypper trusts the package | ||
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc | ||
# zypper automatically resolves dependencies for local packages | ||
sudo zypper --non-interactive install "./$package" &> /dev/null | ||
;; | ||
*) | ||
esac | ||
;; | ||
darwin*) | ||
echo "Installing $package with sudo ..." | ||
sudo installer -pkg "./$package" -target / | ||
;; | ||
esac | ||
|
||
powershell -noprofile -c '"Congratulations! PowerShell is installed at $PSHOME"' | ||
success=$? | ||
|
||
if [[ "$success" != 0 ]]; then | ||
echo "ERROR: PowerShell failed to install!" >&2 | ||
exit "$success" | ||
fi | ||
bash <(curl -s https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we still want the shebang on the first line? And if we do that, then we don't need to invoke bash here - just curl. Then again, my *nix skills have atrophied over the years. Is there an advantage to doing it this way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we still need to invoke bash here because curl will just give you a string of the script - then you need to actually invoke it.
I can add the shebang :) alternatively... we could just delete this download.sh script and put that line in the travis.yml! I kinda like that better.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simpler is usually better. I say go for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did it :)