From 0a3e95b6c2f7cb629c23c0a34d34fd8b641394b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 5 Mar 2018 17:14:10 +0100 Subject: [PATCH 1/3] Fix installpsh-debian according to docs Related issue: #5700 --- tools/installpsh-debian.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/installpsh-debian.sh b/tools/installpsh-debian.sh index 83f27c93e74..37fc2002fc2 100755 --- a/tools/installpsh-debian.sh +++ b/tools/installpsh-debian.sh @@ -104,7 +104,7 @@ if [[ "$SUDO" -eq "sudo" && ! ("'$*'" =~ skip-sudo-check) ]]; then fi #Collect any variation details if required for this distro -REV=`cat /etc/lsb-release | grep '^DISTRIB_RELEASE' | awk -F= '{ print $2 }'` +REV=`cat /etc/lsb-release | grep '^DISTRIB_RELEASE' | sed 's/^[^"]*"//;s/\..*$//'` #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: @@ -126,7 +126,15 @@ echo "*** Setting up PowerShell Core repo..." # Import the public repository GPG keys curl https://packages.microsoft.com/keys/microsoft.asc | $SUDO apt-key add - #Add the Repo -curl https://packages.microsoft.com/config/ubuntu/$REV/prod.list | $SUDO tee /etc/apt/sources.list.d/microsoft.list +case $REV in + 8) $SUDO sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-jessie-prod jessie main" > /etc/apt/sources.list.d/microsoft.list' ;; + 9) $SUDO sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch main" > /etc/apt/sources.list.d/microsoft.list' ;; + *) + echo "ERROR: unsupported Debian version ($REV). Only versions 8 and 9 are supported." >&2 + exit 1 + ;; +esac + # Update apt-get $SUDO apt-get update # Install PowerShell From 83e9b9fa4ffbaeaf0e32f2bfd937e7715c450d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 5 Mar 2018 21:51:40 +0100 Subject: [PATCH 2/3] Support both Ubuntu and Debian in installpsh-debian.sh --- tools/installpsh-debian.sh | 41 ++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/tools/installpsh-debian.sh b/tools/installpsh-debian.sh index 37fc2002fc2..0b39d31fcb3 100755 --- a/tools/installpsh-debian.sh +++ b/tools/installpsh-debian.sh @@ -5,7 +5,7 @@ #bash <(wget -O - https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/installpsh-debian.sh) ARGUMENTS #bash <(curl -s https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/installpsh-debian.sh) -#Usage - if you do not have the ability to run scripts directly from the web, +#Usage - if you do not have the ability to run scripts directly from the web, # pull all files in this repo folder and execute, this script # automatically prefers local copies of sub-scripts @@ -25,7 +25,7 @@ thisinstallerdistro=debian repobased=true gitscriptname="installpsh-debian.psh" -echo ; +echo ; echo "*** PowerShell Core Development Environment Installer $VERSION for $thisinstallerdistro" echo "*** Current PowerShell Core Version: $currentpshversion" echo "*** Original script is at: $gitreposcriptroot/$gitscriptname" @@ -104,7 +104,8 @@ if [[ "$SUDO" -eq "sudo" && ! ("'$*'" =~ skip-sudo-check) ]]; then fi #Collect any variation details if required for this distro -REV=`cat /etc/lsb-release | grep '^DISTRIB_RELEASE' | sed 's/^[^"]*"//;s/\..*$//'` +. /etc/lsb-release +DISTRIB_ID=`lowercase $DISTRIB_ID` #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: @@ -126,11 +127,35 @@ echo "*** Setting up PowerShell Core repo..." # Import the public repository GPG keys curl https://packages.microsoft.com/keys/microsoft.asc | $SUDO apt-key add - #Add the Repo -case $REV in - 8) $SUDO sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-jessie-prod jessie main" > /etc/apt/sources.list.d/microsoft.list' ;; - 9) $SUDO sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch main" > /etc/apt/sources.list.d/microsoft.list' ;; +case $DISTRIB_ID in + ubuntu) + case $DISTRIB_RELEASE in + 17.10|17.04|16.10|16.04|15.10|14.04) + curl https://packages.microsoft.com/config/ubuntu/$DISTRIB_RELEASE/prod.list | $SUDO tee /etc/apt/sources.list.d/microsoft.list + ;; + *) + echo "ERROR: unsupported Ubuntu version ($DISTRIB_RELEASE)." >&2 + echo "Supported versions: 14.04, 15.10, 16.04, 16.10, 17.04, 17.10." >&2 + exit 1 + ;; + esac + ;; + debian) + DISTRIB_RELEASE=${DISTRIB_RELEASE%%.*} + case $DISTRIB_RELEASE in + 8|9) + curl https://packages.microsoft.com/config/debian/$DISTRIB_RELEASE/prod.list | $SUDO tee /etc/apt/sources.list.d/microsoft.list + ;; + *) + echo "ERROR: unsupported Debian version ($DISTRIB_RELEASE)." >&2 + echo "Supported versions: 8, 9." >&2 + exit 1 + ;; + esac + ;; *) - echo "ERROR: unsupported Debian version ($REV). Only versions 8 and 9 are supported." >&2 + echo "ERROR: unsupported Debian-based distribution ($DISTRIB_ID)." >&2 + echo "Supported distributions: Debian, Ubuntu." >&2 exit 1 ;; esac @@ -168,7 +193,7 @@ 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 + code ./testpowershell.ps1 fi if [[ "$repobased" == true ]] ; then From 9715927954ca9f31a201f82762b451636e3ce592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Mon, 5 Mar 2018 22:08:04 +0100 Subject: [PATCH 3/3] Remove support for Ubuntu 17.04 in installpsh-debian.sh --- tools/installpsh-debian.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/installpsh-debian.sh b/tools/installpsh-debian.sh index 0b39d31fcb3..39910d53f2b 100755 --- a/tools/installpsh-debian.sh +++ b/tools/installpsh-debian.sh @@ -130,12 +130,12 @@ curl https://packages.microsoft.com/keys/microsoft.asc | $SUDO apt-key add - case $DISTRIB_ID in ubuntu) case $DISTRIB_RELEASE in - 17.10|17.04|16.10|16.04|15.10|14.04) + 17.10|16.10|16.04|15.10|14.04) curl https://packages.microsoft.com/config/ubuntu/$DISTRIB_RELEASE/prod.list | $SUDO tee /etc/apt/sources.list.d/microsoft.list ;; *) echo "ERROR: unsupported Ubuntu version ($DISTRIB_RELEASE)." >&2 - echo "Supported versions: 14.04, 15.10, 16.04, 16.10, 17.04, 17.10." >&2 + echo "Supported versions: 14.04, 15.10, 16.04, 16.10, 17.10." >&2 exit 1 ;; esac