mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Make install-powershell.sh autodetect if it should use wget or curl (#8225)
install-powershell.sh now autodetects whether curl or wget is installed to download secondary script when it is not found locally.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
name: PR-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr)
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- master
|
||||
- release*
|
||||
paths:
|
||||
include:
|
||||
- /tools/install-powershell.sh
|
||||
- /tools/installpsh-amazonlinux.sh
|
||||
- /tools/installpsh-debian.sh
|
||||
- /tools/installpsh-osx.sh
|
||||
- /tools/installpsh-redhat.sh
|
||||
- /tools/installpsh-suse.sh
|
||||
pr:
|
||||
branches:
|
||||
include:
|
||||
- master
|
||||
- release*
|
||||
paths:
|
||||
include:
|
||||
- /tools/install-powershell.sh
|
||||
- /tools/installpsh-amazonlinux.sh
|
||||
- /tools/installpsh-debian.sh
|
||||
- /tools/installpsh-osx.sh
|
||||
- /tools/installpsh-redhat.sh
|
||||
- /tools/installpsh-suse.sh
|
||||
|
||||
variables:
|
||||
DOTNET_CLI_TELEMETRY_OPTOUT: 1
|
||||
POWERSHELL_TELEMETRY_OPTOUT: 1
|
||||
|
||||
resources:
|
||||
- repo: self
|
||||
clean: true
|
||||
phases:
|
||||
- template: templates/install-ps-phase.yml
|
||||
parameters:
|
||||
scriptName: ./tools/install-powershell.sh
|
||||
jobName: InstallPowerShellUbuntu
|
||||
pool: Hosted Ubuntu 1604
|
||||
|
||||
- template: templates/install-ps-phase.yml
|
||||
parameters:
|
||||
scriptName: ./tools/install-powershell.sh
|
||||
jobName: InstallPowerShellMacOS
|
||||
pool: Hosted macOS
|
||||
@@ -0,0 +1,29 @@
|
||||
parameters:
|
||||
pool: 'Hosted Ubuntu 1604'
|
||||
jobName: 'none'
|
||||
scriptName: ''
|
||||
|
||||
jobs:
|
||||
- job: ${{ parameters.jobName }}
|
||||
variables:
|
||||
scriptName: ${{ parameters.scriptName }}
|
||||
|
||||
pool:
|
||||
name: ${{ parameters.pool }}
|
||||
|
||||
displayName: ${{ parameters.jobName }}
|
||||
|
||||
steps:
|
||||
- powershell: |
|
||||
Get-ChildItem -Path env:
|
||||
displayName: Capture environment
|
||||
condition: succeededOrFailed()
|
||||
|
||||
- powershell: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))"
|
||||
displayName: Set Build Name for Non-PR
|
||||
condition: ne(variables['Build.Reason'], 'PullRequest')
|
||||
|
||||
- bash: |
|
||||
$(scriptName)
|
||||
displayName: Run Script - $(scriptName)
|
||||
condition: succeededOrFailed()
|
||||
+32
-18
@@ -1,10 +1,12 @@
|
||||
#!/bin/bash
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License.
|
||||
|
||||
install(){
|
||||
#Companion code for the blog https://cloudywindows.com
|
||||
|
||||
#call this code direction from the web with:
|
||||
#bash <(wget -O - https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh) <ARGUMENTS>
|
||||
#bash <(wget -qO - https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh) <ARGUMENTS>
|
||||
#wget -O - https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh | bash -s <ARGUMENTS>
|
||||
#bash <(curl -s https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh) <ARGUMENTS>
|
||||
|
||||
@@ -123,29 +125,41 @@ install(){
|
||||
|
||||
if [[ "'$*'" =~ appimage ]] ; then
|
||||
if [ -f $SCRIPTFOLDER/appimage.sh ]; then
|
||||
#Script files were copied local - use them
|
||||
. $SCRIPTFOLDER/appimage.sh
|
||||
#Script files were copied local - use them
|
||||
. $SCRIPTFOLDER/appimage.sh
|
||||
else
|
||||
#Script files are not local - pull from remote
|
||||
echo "Could not find \"appimage.sh\" next to this script..."
|
||||
echo "Pulling it from \"$gitreposcriptroot/appimage.sh\""
|
||||
bash <(wget -qO- $gitreposcriptroot/appimage.sh) $@
|
||||
fi
|
||||
#Script files are not local - pull from remote
|
||||
echo "Could not find \"appimage.sh\" next to this script..."
|
||||
echo "Pulling and executing it from \"$gitreposcriptroot/appimage.sh\""
|
||||
if [ -n "$(command -v curl)" ]; then
|
||||
echo "found and using curl"
|
||||
bash <(curl -s $gitreposcriptroot/appimage.sh) $@
|
||||
elif [ -n "$(command -v wget)" ]; then
|
||||
echo "found and using wget"
|
||||
bash <(wget -qO- $gitreposcriptroot/appimage.sh) $@
|
||||
else
|
||||
echo "Could not find curl or wget, install one of these or manually download \"$gitreposcriptroot/appimage.sh\""
|
||||
fi
|
||||
fi
|
||||
elif [ "$DistroBasedOn" == "redhat" ] || [ "$DistroBasedOn" == "debian" ] || [ "$DistroBasedOn" == "osx" ] || [ "$DistroBasedOn" == "suse" ] || [ "$DistroBasedOn" == "amazonlinux" ]; then
|
||||
echo "Configuring PowerShell Core Environment for: $DistroBasedOn $DIST $REV"
|
||||
if [ -f $SCRIPTFOLDER/installpsh-$DistroBasedOn.sh ]; then
|
||||
#Script files were copied local - use them
|
||||
. $SCRIPTFOLDER/installpsh-$DistroBasedOn.sh
|
||||
#Script files were copied local - use them
|
||||
. $SCRIPTFOLDER/installpsh-$DistroBasedOn.sh
|
||||
else
|
||||
#Script files are not local - pull from remote
|
||||
echo "Could not find \"installpsh-$DistroBasedOn.sh\" next to this script..."
|
||||
echo "Pulling it from \"$gitreposcriptroot/installpsh-$DistroBasedOn.sh\""
|
||||
if [ "$OS" == "osx" ]; then
|
||||
bash <(curl -s $gitreposcriptroot/installpsh-$DistroBasedOn.sh) $@
|
||||
else
|
||||
bash <(wget -qO- $gitreposcriptroot/installpsh-$DistroBasedOn.sh) $@
|
||||
#Script files are not local - pull from remote
|
||||
echo "Could not find \"installpsh-$DistroBasedOn.sh\" next to this script..."
|
||||
echo "Pulling and executing it from \"$gitreposcriptroot/installpsh-$DistroBasedOn.sh\""
|
||||
if [ -n "$(command -v curl)" ]; then
|
||||
echo "found and using curl"
|
||||
bash <(curl -s $gitreposcriptroot/installpsh-$DistroBasedOn.sh) $@
|
||||
elif [ -n "$(command -v wget)" ]; then
|
||||
echo "found and using wget"
|
||||
bash <(wget -qO- $gitreposcriptroot/installpsh-$DistroBasedOn.sh) $@
|
||||
else
|
||||
echo "Could not find curl or wget, install one of these or manually download \"$gitreposcriptroot/installpsh-$DistroBasedOn.sh\""
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "Sorry, your operating system is based on $DistroBasedOn and is not supported by PowerShell Core or this installer at this time."
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user