Update 'installpsh-suse.sh' and remove 'download.sh' (#5309)

- Update `installpsh-suse.sh` to work with the .tar.gz binary archive.
- Remove `download.sh` as it's not used anywhere now. (checked with PowerShellGet and OneGet, they are using a local copy of download.sh).
This commit is contained in:
Dongbo Wang 2017-11-03 08:47:26 -07:00 committed by GitHub
parent c9f83fecfc
commit da5a1a6015
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 49 additions and 173 deletions

View file

@ -406,11 +406,6 @@ u
- demos/DSC/readme.md
#endregion
#region demos/install/README.md Overrides
- demos/install/README.md
download.sh
#endregion
#region demos/python/README.md Overrides
- demos/python/README.md
_script.ps1

View file

@ -1,5 +1,5 @@
## Install demo
# Install demo
For Windows refer to the [installation instructions](https://github.com/PowerShell/PowerShell/blob/master/docs/installation/windows.md)
For Windows refer to the [installation instructions](https://github.com/PowerShell/PowerShell/blob/master/docs/installation/windows.md).
For Linux, using [download.sh](https://github.com/PowerShell/PowerShell/blob/master/tools/download.sh) is the best way to deploy PowerShell bits
For Linux, using [`install-powershell.sh`](https://github.com/PowerShell/PowerShell/blob/master/tools/install-powershell-readme.md) is the best way to deploy PowerShell bits.

View file

@ -25,7 +25,7 @@ Installing the toolchain is as easy as running `Start-PSBootstrap` in PowerShell
Of course, this requires a self-hosted copy of PowerShell on Linux.
Fortunately, this is as easy as [downloading and installing the package](../installation/linux.md).
The `./tools/download.sh` script will also install the PowerShell package.
The `./tools/install-powershell.sh` script will also install the PowerShell package.
In Bash:

View file

@ -1,151 +0,0 @@
#!/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
echo "https://github.com/$fork/PowerShell/releases/download/$3/$1"
}
fork="PowerShell"
release=v6.0.0-beta.9
# 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
powershell-6.0.0_beta.9-1.rhel.7.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.9-1.ubuntu.14.04_amd64.deb
;;
16.04)
package=powershell_6.0.0-beta.9-1.ubuntu.16.04_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)
package=powershell-6.0.0_beta.6-1.suse.42.1.x86_64.rpm
release=v6.0.0-beta.6
;;
*)
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.9-osx.10.12-x64.pkg
;;
*)
echo "$OSTYPE is not supported!" >&2
exit 2
;;
esac
curl -L -o "$package" $(get_url "$package" "$fork" "$release")
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*)
patched=0
if hash brew 2>/dev/null; then
if [[ ! -d $(brew --prefix openssl) ]]; then
echo "Installing OpenSSL with brew..."
if ! brew install openssl; then
echo "ERROR: OpenSSL failed to install! Crypto functions will not work..." >&2
# Don't abort because it is not fatal
elif ! brew install curl --with-openssl; then
echo "ERROR: curl failed to build against OpenSSL; SSL functions will not work..." >&2
# Still not fatal
else
# OpenSSL installation succeeded; remember to patch System.Net.Http after PowerShell installation
patched=1
fi
fi
else
echo "ERROR: brew not found! OpenSSL may not be available..." >&2
# Don't abort because it is not fatal
fi
echo "Installing $package with sudo ..."
sudo installer -pkg "./$package" -target /
if [[ $patched -eq 1 ]]; then
echo "Patching System.Net.Http for libcurl and OpenSSL..."
find /usr/local/microsoft/powershell -name System.Net.Http.Native.dylib | xargs sudo install_name_tool -change /usr/lib/libcurl.4.dylib /usr/local/opt/curl/lib/libcurl.4.dylib
fi
;;
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

View file

@ -132,7 +132,9 @@ $SUDO apt-get update
# Install PowerShell
$SUDO apt-get install -y powershell
pwsh -noprofile -c '"Congratulations! PowerShell is installed at $PSHOME"'
pwsh -noprofile -c '"Congratulations! PowerShell is installed at $PSHOME.
Run `"pwsh`" to start a PowerShell session."'
success=$?
if [[ "$success" != 0 ]]; then

View file

@ -165,7 +165,9 @@ if [[ "'$*'" =~ includeide ]] ; then
code --install-extension ms-vscode.PowerShell
fi
pwsh -noprofile -c '"Congratulations! PowerShell is installed at $PSHOME"'
pwsh -noprofile -c '"Congratulations! PowerShell is installed at $PSHOME.
Run `"pwsh`" to start a PowerShell session."'
success=$?
if [[ "$success" != 0 ]]; then

View file

@ -129,7 +129,9 @@ echo "*** Setting up PowerShell Core repo..."
$SUDO curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/microsoft.repo
$SUDO yum install -y powershell
pwsh -noprofile -c '"Congratulations! PowerShell is installed at $PSHOME"'
pwsh -noprofile -c '"Congratulations! PowerShell is installed at $PSHOME.
Run `"pwsh`" to start a PowerShell session."'
success=$?
if [[ "$success" != 0 ]]; then

View file

@ -22,7 +22,7 @@ VERSION="1.1.2"
gitreposubpath="PowerShell/PowerShell/master"
gitreposcriptroot="https://raw.githubusercontent.com/$gitreposubpath/tools"
thisinstallerdistro=suse
repobased=true
repobased=false
gitscriptname="installpsh-suse.psh"
echo
@ -116,15 +116,22 @@ fi
#END Verify The Installer Choice
echo
echo "*** Installing prerequisites for PowerShell Core..."
$SUDO zypper --non-interactive install \
glibc-locale \
glibc-i18ndata \
tar \
curl \
libunwind \
libicu \
openssl \
&& zypper --non-interactive clean --all
##END Check requirements and prerequisites
echo
echo "*** Installing PowerShell Core for $DistroBasedOn..."
if ! hash curl 2>/dev/null; then
echo "curl not found, installing..."
$SUDO zypper install -y curl
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//g | sed s/,//g | sed s/\ //g`
#REPO BASED (Not ready yet)
@ -140,8 +147,8 @@ release=`curl https://api.github.com/repos/powershell/powershell/releases/latest
#$SUDO zypper --non-interactive install powershell
#DIRECT DOWNLOAD
packagerel=`echo $release | sed 's/-/_/'`
package=powershell-${packagerel}-1.suse.42.1.x86_64.rpm
pwshlink=/usr/bin/pwsh
package=powershell-${release}-linux-x64.tar.gz
downloadurl=https://github.com/PowerShell/PowerShell/releases/download/v$release/$package
echo "Destination file: $package"
@ -154,10 +161,29 @@ if [[ ! -r "$package" ]]; then
exit 1
fi
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo zypper --non-interactive install "./$package"
## Create the target folder where powershell will be placed
$SUDO mkdir -p /opt/microsoft/powershell/$release
## Expand powershell to the target folder
$SUDO tar zxf $package -C /opt/microsoft/powershell/$release
## Change the mode of 'pwsh' to 'rwxr-xr-x' to allow execution
$SUDO chmod 755 /opt/microsoft/powershell/$release/pwsh
## Create the symbolic link that points to powershell
$SUDO ln -s /opt/microsoft/powershell/$release/pwsh $pwshlink
## Add the symbolic link path to /etc/shells
if [ ! -f /etc/shells ] ; then
echo $pwshlink | $SUDO tee /etc/shells ;
else
grep -q "^${pwshlink}$" /etc/shells || echo $pwshlink | $SUDO tee --append /etc/shells > /dev/null ;
fi
## Remove the downloaded package file
rm -f $package
pwsh -noprofile -c '"Congratulations! PowerShell is installed at $PSHOME.
Run `"pwsh`" to start a PowerShell session."'
powershell -noprofile -c '"Congratulations! PowerShell is installed at $PSHOME"'
success=$?
if [[ "$success" != 0 ]]; then