Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Do not rely on Python2 to install Cloud9 dependencies #111

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 27 additions & 68 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ else
exit 1
fi

# Specify the CDN URL using `PROD_CLOUDFRONT_URL=...`. Defaults to us-west-2 region url
PROD_CLOUDFRONT_URL=${PROD_CLOUDFRONT_URL:-'https://dhj20r2nmszcd.cloudfront.net/static'}
C9_DIR=$HOME/.c9
if [[ ${1-} == -d ]]; then
C9_DIR=$2
Expand All @@ -36,8 +38,7 @@ if [ ! -d "$C9_DIR" ]; then
fi

VERSION=1
NODE_VERSION=v6.3.1
NODE_VERSION_ARM_PI=v0.10.28
NODE_VERSION=v12.16.1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Node 16 has known security issues—see https://nodejs.org/en/blog/release/v12.20.1/. Can we instead add 12.20.1 to our CDN and use that here?

Suggested change
NODE_VERSION=v12.16.1
NODE_VERSION=v12.20.1

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm 12.20.1 has security issues too. Maybe it would be better to use 12.22.x. 12.22.9 is the version we current install at runtime.

Suggested change
NODE_VERSION=v12.16.1
NODE_VERSION=v12.22.9

NPM=$C9_DIR/node/bin/npm
NODE=$C9_DIR/node/bin/node

Expand Down Expand Up @@ -73,20 +74,14 @@ start() {
case "$arch" in
*arm64*) arch=arm64 ;;
*aarch64*) arch=arm64 ;;
*armv6l*) arch=armv6l ;;
*armv7l*) arch=armv7l ;;
*x86_64*) arch=x64 ;;
*i*86*) arch=x86 ;;
*)
echo "Unsupported Architecture: $os $arch" 1>&2
exit 1
;;
esac

if [ "$arch" == "x64" ] && [[ $HOSTTYPE == i*86 ]]; then
arch=x86 # check if 32 bit bash is installed on 64 bit kernel
fi

if [ "$os" != "linux" ] && [ "$os" != "darwin" ]; then
echo "Unsupported Platform: $os $arch" 1>&2
exit 1
Expand Down Expand Up @@ -115,10 +110,6 @@ start() {
echo "sass - Sass"
echo "typescript - TypeScript"
echo "stylus - Stylus"
# echo "go - Go"
# echo "heroku - Heroku"
# echo "rhc - RedHat OpenShift"
# echo "gae - Google AppEngine"
;;

"install" )
Expand Down Expand Up @@ -156,7 +147,7 @@ start() {
echo $VERSION > "$C9_DIR"/installed

cd "$C9_DIR"
DOWNLOAD https://raw.githubusercontent.com/c9/install/master/packages/license-notice.md "Third-Party Licensing Notices.md"
DOWNLOAD "$PROD_CLOUDFRONT_URL/license-notice.md" "Third-Party Licensing Notices.md"

echo :Done.
;;
Expand Down Expand Up @@ -209,16 +200,14 @@ check_deps() {
}

check_python() {
if type -P python2.7 &> /dev/null; then
PYTHONVERSION="2.7"
PYTHON="python2.7"
if type -P python3 &> /dev/null; then
PYTHON="python3"
elif type -P python &> /dev/null; then
PYTHONVERSION=`python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))'`
PYTHON="python"
fi

if [[ $PYTHONVERSION != "2.7" ]]; then
echo "Python version 2.7 is required to install pty.js. Please install python 2.7 and try again. You can find more information on how to install Python in the docs: https://docs.aws.amazon.com/cloud9/latest/user-guide/ssh-settings.html#ssh-settings-requirements"
if ! type -P "$PYTHON" &> /dev/null; then
echo "Python version is required to install pty.js. Please install python and try again. You can find more information on how to install Python in the docs: https://docs.c9.io/ssh_workspaces.html"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version reads a bit awkward here (2nd word). Can we remove it? Also, I think we should keep the original url.

Suggested change
echo "Python version is required to install pty.js. Please install python and try again. You can find more information on how to install Python in the docs: https://docs.c9.io/ssh_workspaces.html"
echo "Python is required to install pty.js. Please install python and try again. You can find more information on how to install Python in the docs: https://docs.aws.amazon.com/cloud9/latest/user-guide/ssh-settings.html#ssh-settings-requirements"

exit 100
fi
}
Expand All @@ -227,7 +216,7 @@ check_python() {

download_virtualenv() {
VIRTUALENV_VERSION="virtualenv-12.0.7"
DOWNLOAD "https://pypi.python.org/packages/source/v/virtualenv/$VIRTUALENV_VERSION.tar.gz" $VIRTUALENV_VERSION.tar.gz
DOWNLOAD "$PROD_CLOUDFRONT_URL/$VIRTUALENV_VERSION.tar.gz" $VIRTUALENV_VERSION.tar.gz
tar xzf $VIRTUALENV_VERSION.tar.gz
rm $VIRTUALENV_VERSION.tar.gz
mv $VIRTUALENV_VERSION virtualenv
Expand Down Expand Up @@ -269,7 +258,7 @@ node(){

echo :Installing Node $NODE_VERSION

DOWNLOAD https://nodejs.org/dist/"$NODE_VERSION/node-$NODE_VERSION-$1-$2.tar.gz" node.tar.gz
DOWNLOAD "$PROD_CLOUDFRONT_URL/node-$NODE_VERSION/node-$NODE_VERSION-$1-$2.tar.gz" node.tar.gz
tar xzf node.tar.gz
mv "node-$NODE_VERSION-$1-$2" node
rm -f node.tar.gz
Expand Down Expand Up @@ -323,12 +312,11 @@ tmux_download(){
echo ":N.B: This will take a while. To speed this up install tmux 2.2 manually on your machine and restart this process."

echo ":Downloading Libevent..."
DOWNLOAD https://raw.githubusercontent.com/c9/install/master/packages/tmux/libevent-2.1.8-stable.tar.gz libevent-2.1.8-stable.tar.gz
DOWNLOAD "$PROD_CLOUDFRONT_URL/libevent-2.1.8-stable.tar.gz" libevent-2.1.8-stable.tar.gz
echo ":Downloading Ncurses..."
DOWNLOAD https://github.com/c9/install/raw/master/packages/tmux/ncurses-6.0.tar.gz ncurses-6.0.tar.gz
DOWNLOAD "$PROD_CLOUDFRONT_URL/ncurses-6.0.tar.gz" ncurses-6.0.tar.gz
echo ":Downloading Tmux..."
# DOWNLOAD https://raw.githubusercontent.com/c9/install/master/packages/tmux/tmux-1.9.tar.gz
DOWNLOAD https://github.com/tmux/tmux/releases/download/2.2/tmux-2.2.tar.gz tmux-2.2.tar.gz
DOWNLOAD "$PROD_CLOUDFRONT_URL/tmux-2.2.tar.gz" tmux-2.2.tar.gz
}

check_tmux_version(){
Expand All @@ -340,7 +328,7 @@ check_tmux_version(){
return 1
fi

if [ "$("$PYTHON" -c "print 1.7<=$tmux_version and $tmux_version <= 2.2")" == "True" ]; then
if [ "$("$PYTHON" -c "print(1.7<=$tmux_version and $tmux_version <= 2.2)")" == "True" ]; then
return 0
else
return 1
Expand All @@ -361,26 +349,14 @@ tmux_install(){

# If tmux is not present or at the wrong version, we will install it
else
if [ $os = "darwin" ]; then
if ! has "brew"; then
# http://brew.sh/
DOWNLOAD https://raw.githubusercontent.com/Homebrew/install/master/install installbrew
ruby installbrew
fi
brew install tmux > /dev/null ||
(brew remove tmux &>/dev/null && brew install tmux >/dev/null)
ln -sf "$(which tmux)" "$C9_DIR"/bin/tmux
# Linux
else
if ! has "make"; then
echo ":Could not find make. Please install make and try again."
exit 100;
fi

tmux_download
compile_tmux
ln -sf "$C9_DIR"/local/bin/tmux "$C9_DIR"/bin/tmux
if ! has "make"; then
echo ":Could not find make. Please install make and try again."
exit 100;
fi

tmux_download
compile_tmux
ln -sf "$C9_DIR"/local/bin/tmux "$C9_DIR"/bin/tmux
fi

if ! check_tmux_version "$C9_DIR"/bin/tmux; then
Expand All @@ -391,12 +367,11 @@ tmux_install(){

collab(){
echo :Installing Collab Dependencies
"$NPM" cache clean
"$NPM" install [email protected]
"$NPM" install [email protected]
"$NPM" install [email protected]
mkdir -p "$C9_DIR"/lib
cd "$C9_DIR"/lib
DOWNLOAD https://raw.githubusercontent.com/c9/install/master/packages/sqlite3/linux/sqlite3.tar.gz sqlite3.tar.gz
DOWNLOAD "$PROD_CLOUDFRONT_URL/sqlite3.tar.gz" sqlite3.tar.gz
tar xzf sqlite3.tar.gz
rm sqlite3.tar.gz
ln -sf "$C9_DIR"/lib/sqlite3/sqlite3 "$C9_DIR"/bin/sqlite3
Expand All @@ -409,17 +384,17 @@ nak(){

ptyjs(){
echo :Installing pty.js
"$NPM" install node-pty-prebuilt@0.7.3
"$NPM" install @ionic/node-pty-prebuilt@0.9.1

if ! hasPty; then
echo "Unknown exception installing pty.js"
"$C9_DIR/node/bin/node" -e "console.log(require('node-pty-prebuilt'))"
"$C9_DIR/node/bin/node" -e "console.log(require('@ionic/node-pty-prebuilt'))"
exit 100
fi
}

hasPty() {
local HASPTY=$("$C9_DIR/node/bin/node" -p "typeof require('node-pty-prebuilt').createTerminal=='function'" 2> /dev/null)
local HASPTY=$("$C9_DIR/node/bin/node" -p "typeof require('@ionic/node-pty-prebuilt').createTerminal=='function'" 2> /dev/null)
if [ "$HASPTY" != true ]; then
return 1
fi
Expand Down Expand Up @@ -450,22 +425,6 @@ stylus(){
"$NPM" install stylus
}

# go(){

# }

# heroku(){

# }

# rhc(){

# }

# gae(){

# }

start "$@"

# cleanup tmp files
Expand Down