From 6687bcae2b28e4fa1fcf79f6e057a83cab61eb57 Mon Sep 17 00:00:00 2001 From: Darwin Date: Sat, 29 Sep 2018 08:45:45 -0400 Subject: [PATCH 1/5] install-powershell.sh: Adding autodetection of curl / wget --- tools/install-powershell.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/tools/install-powershell.sh b/tools/install-powershell.sh index 673a861dc85..967a4f8733d 100755 --- a/tools/install-powershell.sh +++ b/tools/install-powershell.sh @@ -4,7 +4,7 @@ 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) + #bash <(wget -qO - https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh) #wget -O - https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh | bash -s #bash <(curl -s https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh) @@ -128,9 +128,16 @@ install(){ 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 + 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 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 @@ -139,13 +146,16 @@ install(){ 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 + 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) $@ - else + 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 else echo "Sorry, your operating system is based on $DistroBasedOn and is not supported by PowerShell Core or this installer at this time." fi From 97c715bc47179dd8219e3e24c936f5a067530fa4 Mon Sep 17 00:00:00 2001 From: Darwin Date: Sat, 29 Sep 2018 09:05:59 -0400 Subject: [PATCH 2/5] copyright message --- tools/install-powershell.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/install-powershell.sh b/tools/install-powershell.sh index 967a4f8733d..64e2211a706 100755 --- a/tools/install-powershell.sh +++ b/tools/install-powershell.sh @@ -1,4 +1,6 @@ #!/bin/bash +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. install(){ #Companion code for the blog https://cloudywindows.com From 92ceac427166692937905035568f019c138c2e37 Mon Sep 17 00:00:00 2001 From: Darwin Date: Mon, 1 Oct 2018 21:34:26 -0400 Subject: [PATCH 3/5] fix missing fi's --- tools/install-powershell.sh | 54 +++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/tools/install-powershell.sh b/tools/install-powershell.sh index 64e2211a706..ab22c01994e 100755 --- a/tools/install-powershell.sh +++ b/tools/install-powershell.sh @@ -125,38 +125,40 @@ 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 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\"" + #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 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\"" + #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 else echo "Sorry, your operating system is based on $DistroBasedOn and is not supported by PowerShell Core or this installer at this time." From 935313876a446361a87bf30246839733a7c8e4e2 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Tue, 13 Nov 2018 13:39:07 -0800 Subject: [PATCH 4/5] Add CI for the install-*.sh scripts --- .vsts-ci/install-ps.yml | 47 +++++++++++++++++++++++++ .vsts-ci/templates/install-ps-phase.yml | 34 ++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 .vsts-ci/install-ps.yml create mode 100644 .vsts-ci/templates/install-ps-phase.yml diff --git a/.vsts-ci/install-ps.yml b/.vsts-ci/install-ps.yml new file mode 100644 index 00000000000..04331a01741 --- /dev/null +++ b/.vsts-ci/install-ps.yml @@ -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 diff --git a/.vsts-ci/templates/install-ps-phase.yml b/.vsts-ci/templates/install-ps-phase.yml new file mode 100644 index 00000000000..87418a9e0ee --- /dev/null +++ b/.vsts-ci/templates/install-ps-phase.yml @@ -0,0 +1,34 @@ +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') + + - powershell: | + Get-ChildItem -Path env: + displayName: Capture environment + condition: succeededOrFailed() + + - bash: | + $(scriptName) + displayName: Run Script - $(scriptName) + condition: succeededOrFailed() From e6c3e25226facfb54c74c1af43dcb404c3310412 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Tue, 13 Nov 2018 18:28:22 -0800 Subject: [PATCH 5/5] Address Paul's PR comment --- .vsts-ci/templates/install-ps-phase.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.vsts-ci/templates/install-ps-phase.yml b/.vsts-ci/templates/install-ps-phase.yml index 87418a9e0ee..22149640e48 100644 --- a/.vsts-ci/templates/install-ps-phase.yml +++ b/.vsts-ci/templates/install-ps-phase.yml @@ -23,11 +23,6 @@ jobs: displayName: Set Build Name for Non-PR condition: ne(variables['Build.Reason'], 'PullRequest') - - powershell: | - Get-ChildItem -Path env: - displayName: Capture environment - condition: succeededOrFailed() - - bash: | $(scriptName) displayName: Run Script - $(scriptName)