install-powershell.sh filter prereleases (when available), params documentation (#6849)

Fixed #6815 by adding -allowprereleases parameter
Fixed #6405 by adding -allowprereleases parameter
Added parameters to documentation
Ready for prerelease repositories if Microsoft starts providing them
Added -skip-sudo-check for all distros
Fixed -interactivetesting should do nothing if -includeide was not used
This commit is contained in:
Darwin 2018-06-25 14:44:43 -04:00 committed by Travis Plunk
parent ffca008726
commit 53e6ec6ead
8 changed files with 124 additions and 118 deletions

View file

@ -1066,3 +1066,8 @@ NTLM
NumberBytes
ResponseHeaders
#endregion
includeide
interactivetesting
allowprerelease
prereleases
url

View file

@ -19,6 +19,13 @@
* native package manager available
* `curl` (auto-installed if missing)
## Parameters
* -includeide - installs vscode and vscode powershell extension (only relevant to machines with desktop environment)
* -interactivetesting - do a quick launch test of vscode - only relevant when used with -includeide
* -skip-sudo-check - use sudo without verifying it's availability (hard to accurately do on some distros)
* -allowprerelease - includes prereleases of powershell core when selection allows this. Repository based installs take the latest on the repo url regardless of this switch.
## Usage
### Direct from Github
@ -55,12 +62,6 @@ bash <(wget -O - https://raw.githubusercontent.com/PowerShell/PowerShell/master/
bash <(wget -O - https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh) -includeide -interactivetesting
```
### Install AppImage
```bash
bash <(wget -O - https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh) -appimage
```
### Installation To do list
* Detect and wait when package manager is busy/locked? - at least Ubuntu (CentOS does this internally)
* Detect and wait when package manager is busy/locked? - at least Ubuntu (CentOS does this internally)

View file

@ -22,7 +22,7 @@ install(){
#gitrepo paths are overrideable to run from your own fork or branch for testing or private distribution
local VERSION="1.1.1"
local VERSION="1.2.0"
local gitreposubpath="PowerShell/PowerShell/master"
local gitreposcriptroot="https://raw.githubusercontent.com/$gitreposubpath/tools"
local gitscriptname="install-powershell.psh"

View file

@ -18,7 +18,7 @@
#gitrepo paths are overrideable to run from your own fork or branch for testing or private distribution
VERSION="1.1.2"
VERSION="1.2.0"
gitreposubpath="PowerShell/PowerShell/master"
gitreposcriptroot="https://raw.githubusercontent.com/$gitreposubpath/tools"
thisinstallerdistro=amazonlinux
@ -120,19 +120,20 @@ fi
## Check requirements and prerequisites
#Only do SUDO if we are not root
SUDO=''
if (( $EUID != 0 )); then
SUDO='sudo'
#Check for sudo if not root
if [[ "${CI}" == "true" ]]; then
echo "Running on CI (as determined by env var CI set to true), skipping SUDO check."
set -- "$@" '-skip-sudo-check'
fi
#Check that sudo is available
if [[ "$SUDO" -eq "sudo" ]]; then
$SUDO -v
if [ $? -ne 0 ]; then
echo "ERROR: You must either be root or be able to use sudo" >&2
exit 5
SUDO=''
if (( $EUID != 0 )); then
#Check that sudo is available
if [[ ("'$*'" =~ skip-sudo-check) && ("$(whereis sudo)" == *'/'* && "$(sudo -nv 2>&1)" != 'Sorry, user'*) ]]; then
SUDO='sudo'
else
echo "ERROR: You must either be root or be able to use sudo" >&2
#exit 5
fi
fi
@ -155,7 +156,17 @@ $SUDO yum install -y \
echo
echo "*** Installing PowerShell Core for $DistroBasedOn..."
release=`curl https://api.github.com/repos/powershell/powershell/releases/latest | sed '/tag_name/!d' | sed s/\"tag_name\"://g | sed s/\"//g | sed s/v// | sed s/,//g | sed s/\ //g`
echo "ATTENTION: As of version 1.2.0 this script no longer uses pre-releases unless the '-allowprereleases' switch is used"
if [[ "'$*'" =~ allowprerelease ]] ; then
echo
echo "-allowprerelease was used, prereleases will be included in the retrieval of the latest version"
release=`curl https://api.github.com/repos/powershell/powershell/releases/latest | sed '/tag_name/!d' | sed s/\"tag_name\"://g | sed s/\"//g | sed s/v// | sed s/,//g | sed s/\ //g`
else
echo "Finding the latest release production release"
release=$(curl https://api.github.com/repos/PowerShell/PowerShell/releases | grep -Po '"tag_name":(\d*?,|.*?[^\\]",)' | grep -Po '\d+.\d+.\d+[\da-z.-]*' | grep -v '[a-z]' | sort | tail -n1)
if
#DIRECT DOWNLOAD
pwshlink=/usr/bin/pwsh
@ -210,7 +221,7 @@ fi
if [[ "'$*'" =~ -interactivetesting ]] ; then
echo
echo "Amazon Linux does not have a desktop manager to support vscode, ignoring -includeide"
echo "Amazon Linux does not have a desktop manager to support vscode, ignoring -interactivetesting"
fi
if [[ "$repobased" == true ]] ; then

View file

@ -18,7 +18,7 @@
#gitrepo paths are overrideable to run from your own fork or branch for testing or private distribution
VERSION="1.1.2"
VERSION="1.2.0"
gitreposubpath="PowerShell/PowerShell/master"
gitreposcriptroot="https://raw.githubusercontent.com/$gitreposubpath/tools"
thisinstallerdistro=debian
@ -87,19 +87,20 @@ fi
## Check requirements and prerequisites
#Only do SUDO if we are not root
SUDO=''
if (( $EUID != 0 )); then
SUDO='sudo'
#Check for sudo if not root
if [[ "${CI}" == "true" ]]; then
echo "Running on CI (as determined by env var CI set to true), skipping SUDO check."
set -- "$@" '-skip-sudo-check'
fi
#Check that sudo is available
if [[ "$SUDO" == "sudo" && ! ("'$*'" =~ skip-sudo-check) ]]; then
$SUDO -v
if [ $? -ne 0 ]; then
echo "ERROR: You must either be root or be able to use sudo" >&2
exit 5
SUDO=''
if (( $EUID != 0 )); then
#Check that sudo is available
if [[ ("'$*'" =~ skip-sudo-check) && ("$(whereis sudo)" == *'/'* && "$(sudo -nv 2>&1)" != 'Sorry, user'*) ]]; then
SUDO='sudo'
else
echo "ERROR: You must either be root or be able to use sudo" >&2
#exit 5
fi
fi
@ -120,6 +121,12 @@ if ! hash curl 2>/dev/null; then
echo "curl not found, installing..."
$SUDO apt-get install -y curl
fi
if [[ "'$*'" =~ allowprerelease ]] ; then
echo
echo "-allowprerelease was used, but since $DistroBasedOn uses repositories - selection of releases will depend on the repository contents."
fi
release=`curl https://api.github.com/repos/powershell/powershell/releases/latest | sed '/tag_name/!d' | sed s/\"tag_name\"://g | sed s/\"//g | sed s/v// | sed s/,//g | sed s/\ //g`
echo "*** Current version on git is: $currentversion, repo version may differ slightly..."
@ -188,12 +195,11 @@ if [[ "'$*'" =~ includeide ]] ; then
echo
echo "*** Installing VS Code PowerShell Extension"
code --install-extension ms-vscode.PowerShell
fi
if [[ "'$*'" =~ -interactivetesting ]] ; then
echo "*** Loading test code in VS Code"
curl -O ./testpowershell.ps1 https://raw.githubusercontent.com/DarwinJS/CloudyWindowsAutomationCode/master/pshcoredevenv/testpowershell.ps1
code ./testpowershell.ps1
if [[ "'$*'" =~ -interactivetesting ]] ; then
echo "*** Loading test code in VS Code"
curl -O ./testpowershell.ps1 https://raw.githubusercontent.com/DarwinJS/CloudyWindowsAutomationCode/master/pshcoredevenv/testpowershell.ps1
code ./testpowershell.ps1
fi
fi
if [[ "$repobased" == true ]] ; then

View file

@ -86,32 +86,12 @@ fi
## Check requirements and prerequisites
#Only do SUDO if we are not root
SUDO=''
if (( $EUID != 0 )); then
SUDO='sudo'
fi
#Check that sudo is available
#if [[ "$SUDO" -eq "sudo" ]]; then
# $SUDO -v
# if [ $? -ne 0 ]; then
# echo "ERROR: You must either be root or be able to use sudo" >&2
# exit 5
# fi
#fi
#END Collect any variation details if required for this distro
#If there are known incompatible versions of this distro, put the test, message and script exit here:
#END Verify The Installer Choice
##END Check requirements and prerequisites
echo "*** Installing PowerShell Core for $DistroBasedOn..."
#release=`curl https://api.github.com/repos/powershell/powershell/releases/latest | sed '/tag_name/!d' | sed s/\"tag_name\"://g | sed s/\"//g | sed s/v// | sed s/,//g | sed s/\ //g`
if [[ "'$*'" =~ allowprerelease ]] ; then
echo
echo "-allowprerelease was used, but since $DistroBasedOn uses repositories - selection of releases will depend on the repository contents."
fi
if ! hash brew 2>/dev/null; then
echo "Homebrew is not found, installing..."
@ -176,8 +156,14 @@ if [[ "'$*'" =~ includeide ]] ; then
echo "*** Installing VS Code PowerShell Extension"
code --install-extension ms-vscode.PowerShell
if [[ "'$*'" =~ -interactivetesting ]] ; then
echo "*** Loading test code in VS Code"
curl -O ./testpowershell.ps1 https://raw.githubusercontent.com/DarwinJS/CloudyWindowsAutomationCode/master/pshcoredevenv/testpowershell.ps1
code ./testpowershell.ps1
fi
fi
pwsh -noprofile -c '"Congratulations! PowerShell is installed at $PSHOME.
Run `"pwsh`" to start a PowerShell session."'
@ -188,12 +174,6 @@ if [[ "$success" != 0 ]]; then
exit "$success"
fi
if [[ "'$*'" =~ -interactivetesting ]] ; then
echo "*** Loading test code in VS Code"
$SUDO curl -O ./testpowershell.ps1 https://raw.githubusercontent.com/DarwinJS/CloudyWindowsAutomationCode/master/pshcoredevenv/testpowershell.ps1
code ./testpowershell.ps1
fi
if [[ "$repobased" == true ]] ; then
echo "*** NOTE: Run your regular package manager update cycle to update PowerShell Core"
fi

View file

@ -19,7 +19,7 @@
#gitrepo paths are overrideable to run from your own fork or branch for testing or private distribution
VERSION="1.1.2"
VERSION="1.2.0"
gitreposubpath="PowerShell/PowerShell/master"
gitreposcriptroot="https://raw.githubusercontent.com/$gitreposubpath/tools"
thisinstallerdistro=redhat
@ -90,33 +90,29 @@ fi
## Check requirements and prerequisites
#Only do SUDO if we are not root
SUDO=''
if (( $EUID != 0 )); then
SUDO='sudo'
#Check for sudo if not root
if [[ "${CI}" == "true" ]]; then
echo "Running on CI (as determined by env var CI set to true), skipping SUDO check."
set -- "$@" '-skip-sudo-check'
fi
#Check that sudo is available
if [[ "$SUDO" == "sudo" && ! ("'$*'" =~ skip-sudo-check) ]]; then
$SUDO -v
if [ $? -ne 0 ]; then
echo "ERROR: You must either be root or be able to use sudo" >&2
exit 5
SUDO=''
if (( $EUID != 0 )); then
#Check that sudo is available
if [[ ("'$*'" =~ skip-sudo-check) && ("$(whereis sudo)" == *'/'* && "$(sudo -nv 2>&1)" != 'Sorry, user'*) ]]; then
SUDO='sudo'
else
echo "ERROR: You must either be root or be able to use sudo" >&2
#exit 5
fi
fi
#Collect any variation details if required for this distro
if [[ "'$*'" =~ allowprerelease ]] ; then
echo
echo "-allowprerelease was used, but since $DistroBasedOn uses repositories - selection of releases will depend on the repository contents."
fi
#END Collect any variation details if required for this distro
#If there are known incompatible versions of this distro, put the test, message and script exit here:
#END Verify The Installer Choice
##END Check requirements and prerequisites
echo
release=`curl https://api.github.com/repos/powershell/powershell/releases/latest | sed '/tag_name/!d' | sed s/\"tag_name\"://g | sed s/\"//g | sed s/v// | sed s/,//g | sed s/\ //g`echo
echo "*** Installing PowerShell Core for $DistroBasedOn..."
if ! hash curl 2>/dev/null; then
echo "curl not found, installing..."
@ -152,12 +148,11 @@ if [[ "'$*'" =~ includeide ]] ; then
echo
echo "*** Installing VS Code PowerShell Extension"
code --install-extension ms-vscode.PowerShell
fi
if [[ "'$*'" =~ -interactivetesting ]] ; then
echo "*** Loading test code in VS Code"
curl -O ./testpowershell.ps1 https://raw.githubusercontent.com/DarwinJS/CloudyWindowsAutomationCode/master/pshcoredevenv/testpowershell.ps1
code ./testpowershell.ps1
if [[ "'$*'" =~ -interactivetesting ]] ; then
echo "*** Loading test code in VS Code"
curl -O ./testpowershell.ps1 https://raw.githubusercontent.com/DarwinJS/CloudyWindowsAutomationCode/master/pshcoredevenv/testpowershell.ps1
code ./testpowershell.ps1
fi
fi
if [[ "$repobased" == true ]] ; then

View file

@ -19,7 +19,7 @@
#gitrepo paths are overrideable to run from your own fork or branch for testing or private distribution
VERSION="1.1.2"
VERSION="1.2.0"
gitreposubpath="PowerShell/PowerShell/master"
gitreposcriptroot="https://raw.githubusercontent.com/$gitreposubpath/tools"
thisinstallerdistro=suse
@ -88,19 +88,20 @@ fi
## Check requirements and prerequisites
#Only do SUDO if we are not root
SUDO=''
if (( $EUID != 0 )); then
SUDO='sudo'
#Check for sudo if not root
if [[ "${CI}" == "true" ]]; then
echo "Running on CI (as determined by env var CI set to true), skipping SUDO check."
set -- "$@" '-skip-sudo-check'
fi
#Check that sudo is available
if [[ "$SUDO" == "sudo" && ! ("'$*'" =~ skip-sudo-check) ]]; then
$SUDO -v
if [ $? -ne 0 ]; then
echo "ERROR: You must either be root or be able to use sudo" >&2
exit 5
SUDO=''
if (( $EUID != 0 )); then
#Check that sudo is available
if [[ ("'$*'" =~ skip-sudo-check) && ("$(whereis sudo)" == *'/'* && "$(sudo -nv 2>&1)" != 'Sorry, user'*) ]]; then
SUDO='sudo'
else
echo "ERROR: You must either be root or be able to use sudo" >&2
#exit 5
fi
fi
@ -137,8 +138,17 @@ $SUDO zypper --non-interactive install \
echo
echo "*** Installing PowerShell Core for $DistroBasedOn..."
release=`curl https://api.github.com/repos/powershell/powershell/releases/latest | sed '/tag_name/!d' | sed s/\"tag_name\"://g | sed s/\"//g | sed s/v// | sed s/,//g | sed s/\ //g`
echo "ATTENTION: As of version 1.2.0 this script no longer uses pre-releases unless the '-allowprereleases' switch is used"
if [[ "'$*'" =~ allowprerelease ]] ; then
echo
echo "-allowprerelease was used, prereleases will be included in the retrieval of the latest version"
release=`curl https://api.github.com/repos/powershell/powershell/releases/latest | sed '/tag_name/!d' | sed s/\"tag_name\"://g | sed s/\"//g | sed s/v// | sed s/,//g | sed s/\ //g`
else
echo "Finding the latest release production release"
release=$(curl https://api.github.com/repos/PowerShell/PowerShell/releases | grep -Po '"tag_name":(\d*?,|.*?[^\\]",)' | grep -Po '\d+.\d+.\d+[\da-z.-]*' | grep -v '[a-z]' | sort | tail -n1)
if
#REPO BASED (Not ready yet)
#echo "*** Setting up PowerShell Core repo..."
#echo "*** Current version on git is: $release, repo version may differ slightly..."
@ -208,13 +218,11 @@ if [[ "'$*'" =~ includeide ]] ; then
echo
echo "*** Installing VS Code PowerShell Extension"
code --install-extension ms-vscode.PowerShell
fi
if [[ "'$*'" =~ -interactivetesting ]] ; then
echo "*** Loading test code in VS Code"
curl -O ./testpowershell.ps1 https://raw.githubusercontent.com/DarwinJS/CloudyWindowsAutomationCode/master/pshcoredevenv/testpowershell.ps1
code ./testpowershell.ps1
if [[ "'$*'" =~ -interactivetesting ]] ; then
echo "*** Loading test code in VS Code"
curl -O ./testpowershell.ps1 https://raw.githubusercontent.com/DarwinJS/CloudyWindowsAutomationCode/master/pshcoredevenv/testpowershell.ps1
code ./testpowershell.ps1
fi
fi
if [[ "$repobased" == true ]] ; then