#!/bin/bash OS=`uname` arch=$(uname -i) archarchlinux=$(uname -m) if [ $# -lt 1 ] then echo "Not enough arguments - exiting" exit 1 fi if [ ${1} != "install-deps" ] && [ ${1} != "build-package" ] && [ ${1} != "update-repo" ] && [ ${1} != "clone-repo" ] then echo "Invalid mode - exiting" exit 1 fi if [[ $arch == unknown ]]; then if [[ $archarchlinux == x86_64* ]]; then echo "X64 Architecture detected" elif [[ $archarchlinux == i*86 ]]; then echo "X32 Architecture detected" elif [[ $archarchlinux == armhf ]]; then echo "ARM Architecture detected" elif [[ $archarchlinux == arm64 ]]; then echo "64 bit ARM Architecture detected" else if [[ $arch == x86_64* ]]; then echo "X64 Architecture detected" elif [[ $arch == i*86 ]]; then echo "X32 Architecture detected" elif [[ $arch == armhf ]]; then echo "ARM Architecture detected" elif [[ $arch == arm64 ]]; then echo "64 bit ARM Architecture detected" else echo "Unsupported architecture" exit 1 fi fi fi if [ ${1} = "install-deps" ] then if test "$OS" = Linux ; then [ -f /etc/lsb-release ] && source /etc/lsb-release if [ -z "${NO_PPA}" -a "${DISTRIB_ID}" == "Ubuntu" ]; then if [[ $arch == armhf ]]; then echo "Ubuntu is experimental if ran this script on a Raspberry Pi computer, as this tends to issues regarding compiling failures." echo "DO THIS AT YOUR OWN RISK IF YOU WANT TO CONTINUE" read -n1 -r -p "CTRL-C to exit, or any other key to continue" echo "" exit 0 elif [[ $arch == arm64 ]]; then echo "Ubuntu is experimental if ran this script on a Raspberry Pi computer, as this tends to issues regarding compiling failures." echo "DO THIS AT YOUR OWN RISK IF YOU WANT TO CONTINUE" read -n1 -r -p "CTRL-C to exit, or any other key to continue" echo "" codename=$(lsb_release -a | grep Codename | cut -c 11-) echo "Checking if dependencies are installed" # Get the installed Node.js version node_version=$(node -v 2>/dev/null) # Check if Node.js is installed if [ $? -ne 0 ]; then echo "Node.js is not installed, installing latest 20 LTS version" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 nvm use 20 echo "restart your shell and rerun the script" exit 0 fi # Remove the 'v' prefix from the version (e.g., v18.17.0 -> 18.17.0) node_version=${node_version#v} # Minimum and maximum versions min_version="18.17.0" max_version="21.0.0" # Compare versions if [[ "$(printf '%s\n' "$min_version" "$node_version" | sort -V | head -n1)" != "$min_version" ]]; then echo "Node.js version is too old. Upgrading to latest 20 LTS version." curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 nvm use 20 echo "restart your shell and rerun the script" exit 0 elif [[ "$(printf '%s\n' "$max_version" "$node_version" | sort -V | head -n1)" == "$max_version" ]]; then echo "Node.js version is too new. Downgrading to latest 20 LTS version." curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 nvm use 20 echo "restart your shell and rerun the script" exit 0 else echo "Node.js version $node_version is within the acceptable range." fi # Check for installed deps from apt command_name="apt list make gcc pkg-config build-essential libx11-dev libxkbfile-dev libsecret-1-dev git python3 --installed" # Search the man page for the string if $command_name | grep "pkg-config/$codename"; then echo "pkg-config is installed" else echo "pkg-config is not installed" install1="pkg-config" fi if $command_name | grep "make/$codename"; then echo "make is installed" else echo "make is not installed" install2="make" fi if $command_name | grep "gcc/$codename"; then echo "gcc is installed" else echo "gcc is not installed" install3="gcc g++" fi if $command_name | grep "build-essential/$codename"; then echo "build-essential is installed" else echo "build-essential is not installed" install4="build-essential" fi if $command_name | grep "libx11-dev/$codename"; then echo "libx11-dev is installed" else echo "libx11-dev is not installed" install5="libx11-dev" fi if $command_name | grep "libxkbfile-dev/$codename"; then echo "libxkbfile-dev is installed" else echo "libxkbfile-dev is not installed" install6="libxkbfile-dev" fi if $command_name | grep "libsecret-1-dev/$codename"; then echo "libsecret-1-dev is installed" else echo "libsecret-1-dev is not installed" install7="libsecret-1-dev" fi if $command_name | grep "git/$codename"; then echo "git is installed" else echo "git is not installed" install8="git" fi if type yarn &> /dev/null; then echo "yarn is installed" else echo "yarn is not installed" install9="yarn --global" fi if $command_name | grep "python3/$codename"; then echo "python3 is installed" else echo "python3 is not installed" install10="python3" fi echo "Installing dependencies" set -eE trap '(\ echo;\ echo \!\!\! An error happened during installing packages.;\ echo \!\!\! Please check console output for errors regarding package installation.,;\ echo\ )' ERR sudo apt update && sudo apt install $install1 $install2 $install3 $install4 $install5 $install6 $install7 $install8 $install10 -y if [[ $install9 = "yarn --global" ]]; then npm install $install9 else install9="" fi else echo "Running on Ubuntu" codename=$(lsb_release -a | grep Codename | cut -c 11-) echo "Checking if dependencies are installed" # Check if Node.js is installed # Get the installed Node.js version node_version=$(node -v 2>/dev/null) # Check if Node.js is installed if [ $? -ne 0 ]; then echo "Node.js is not installed, installing latest 20 LTS version" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 nvm use 20 echo "restart your shell and rerun the script" exit 0 fi # Remove the 'v' prefix from the version (e.g., v18.17.0 -> 18.17.0) node_version=${node_version#v} # Minimum and maximum versions min_version="18.17.0" max_version="21.0.0" # Compare versions if [[ "$(printf '%s\n' "$min_version" "$node_version" | sort -V | head -n1)" != "$min_version" ]]; then echo "Node.js version is too old. Upgrading to latest 20 LTS version." curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 nvm use 20 echo "restart your shell and rerun the script" exit 0 elif [[ "$(printf '%s\n' "$max_version" "$node_version" | sort -V | head -n1)" == "$max_version" ]]; then echo "Node.js version is too new. Downgrading to latest 20 LTS version." curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 nvm use 20 echo "restart your shell and rerun the script" exit 0 else echo "Node.js version $node_version is within the acceptable range." fi # Check for installed deps from apt command_name="apt list make gcc pkg-config build-essential libx11-dev libxkbfile-dev libsecret-1-dev git python3 --installed" # Search the man page for the string if $command_name | grep "pkg-config/$codename"; then echo "pkg-config is installed" else echo "pkg-config is not installed" install1="pkg-config" fi if $command_name | grep "make/$codename"; then echo "make is installed" else echo "make is not installed" install2="make" fi if $command_name | grep "gcc/$codename"; then echo "gcc is installed" else echo "gcc is not installed" install3="gcc g++" fi if $command_name | grep "build-essential/$codename"; then echo "build-essential is installed" else echo "build-essential is not installed" install4="build-essential" fi if $command_name | grep "libx11-dev/$codename"; then echo "libx11-dev is installed" else echo "libx11-dev is not installed" install5="libx11-dev" fi if $command_name | grep "libxkbfile-dev/$codename"; then echo "libxkbfile-dev is installed" else echo "libxkbfile-dev is not installed" install6="libxkbfile-dev" fi if $command_name | grep "libsecret-1-dev/$codename"; then echo "libsecret-1-dev is installed" else echo "libsecret-1-dev is not installed" install7="libsecret-1-dev" fi if $command_name | grep "git/$codename"; then echo "git is installed" else echo "git is not installed" install8="git" fi if type yarn &> /dev/null; then echo "yarn is installed" else echo "yarn is not installed" install9="yarn --global" fi if $command_name | grep "python3/$codename"; then echo "python3 is installed" else echo "python3 is not installed" install10="python3" fi echo "Installing dependencies" set -eE trap '(\ echo;\ echo \!\!\! An error happened during installing packages.;\ echo \!\!\! Please check console output for errors regarding package installation.,;\ echo\ )' ERR sudo apt update && sudo apt install $install1 $install2 $install3 $install4 $install5 $install6 $install7 $install8 $install10 -y if [[ $install9 = "yarn --global" ]]; then npm install $install9 else install9="" fi fi elif [ -z "${NO_PPA}" -a "${DISTRIB_ID}" == "Debian" ]; then echo "Running on Debian" echo "Installing dependencies" codename=$(lsb_release -a | grep Codename | cut -c 11-) echo "Checking if depenencies are installed" # Get the installed Node.js version node_version=$(node -v 2>/dev/null) # Check if Node.js is installed if [ $? -ne 0 ]; then echo "Node.js is not installed, installing latest 20 LTS version" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 nvm use 20 echo "restart your shell and rerun the script" exit 0 fi # Remove the 'v' prefix from the version (e.g., v18.17.0 -> 18.17.0) node_version=${node_version#v} # Minimum and maximum versions min_version="18.17.0" max_version="21.0.0" # Compare versions if [[ "$(printf '%s\n' "$min_version" "$node_version" | sort -V | head -n1)" != "$min_version" ]]; then echo "Node.js version is too old. Upgrading to latest 20 LTS version." curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 nvm use 20 echo "restart your shell and rerun the script" exit 0 elif [[ "$(printf '%s\n' "$max_version" "$node_version" | sort -V | head -n1)" == "$max_version" ]]; then echo "Node.js version is too new. Downgrading to latest 20 LTS version." curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 nvm use 20 echo "restart your shell and rerun the script" exit 0 else echo "Node.js version $node_version is within the acceptable range." fi # Check for installed deps from apt command_name="apt list make gcc pkg-config build-essential libx11-dev libxkbfile-dev libsecret-1-dev git python3 --installed" # Search the man page for the string if $command_name | grep "pkg-config/$codename"; then echo "pkg-config is installed" else echo "pkg-config is not installed" install1="pkg-config" fi if $command_name | grep "make/$codename"; then echo "make is installed" else echo "make is not installed" install2="make" fi if $command_name | grep "gcc/$codename"; then echo "gcc is installed" else echo "gcc is not installed" install3="gcc g++" fi if $command_name | grep "build-essential/$codename"; then echo "build-essential is installed" else echo "build-essential is not installed" install4="build-essential" fi if $command_name | grep "libx11-dev/$codename"; then echo "libx11-dev is installed" else echo "libx11-dev is not installed" install5="libx11-dev" fi if $command_name | grep "libxkbfile-dev/$codename"; then echo "libxkbfile-dev is installed" else echo "libxkbfile-dev is not installed" install6="libxkbfile-dev" fi if $command_name | grep "libsecret-1-dev/$codename"; then echo "libsecret-1-dev is installed" else echo "libsecret-1-dev is not installed" install7="libsecret-1-dev" fi if $command_name | grep "git/$codename"; then echo "git is installed" else echo "git is not installed" install8="git" fi if type yarn &> /dev/null; then echo "yarn is installed" else echo "yarn is not installed" install9="yarn --global" fi if $command_name | grep "python3/$codename"; then echo "python3 is installed" else echo "python3 is not installed" install10="python3" fi echo "Installing dependencies" set -eE trap '(\ echo;\ echo \!\!\! An error happened during installing packages.;\ echo \!\!\! Please check console output for errors regarding package installation.,;\ echo\ )' ERR sudo apt update && sudo apt install $install1 $install2 $install3 $install4 $install5 $install6 $install7 $install8 $install10 -y if [[ $install9 = "yarn --global" ]]; then npm install $install9 else install9="" fi elif [ -z "${NO_PPA}" -a "${DISTRIB_ID}" == "Arch Linux" ]; then echo "Running on Arch, DEB packaging might not be supported" echo "Checking if dependencies are installed" # Get the installed Node.js version node_version=$(node -v 2>/dev/null) # Check if Node.js is installed if [ $? -ne 0 ]; then echo "Node.js is not installed, installing latest 20 LTS version" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 nvm use 20 echo "restart your shell and rerun the script" exit 0 fi # Remove the 'v' prefix from the version (e.g., v18.17.0 -> 18.17.0) node_version=${node_version#v} # Minimum and maximum versions min_version="18.17.0" max_version="21.0.0" # Compare versions if [[ "$(printf '%s\n' "$min_version" "$node_version" | sort -V | head -n1)" != "$min_version" ]]; then echo "Node.js version is too old. Upgrading to latest 20 LTS version." curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 nvm use 20 echo "restart your shell and rerun the script" exit 0 elif [[ "$(printf '%s\n' "$max_version" "$node_version" | sort -V | head -n1)" == "$max_version" ]]; then echo "Node.js version is too new. Downgrading to latest 20 LTS version." curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 nvm use 20 echo "restart your shell and rerun the script" exit 0 else echo "Node.js version $node_version is within the acceptable range." fi # Check for installed deps from pacman LC_ALL=C.UTF-8 command_name="pacman -Qi" # Search the man page for the string if $command_name | awk '/^Name/{name=$3} /^Installed Size/{print $4$5, name}' | sort -h | grep "pkgconf"; then echo "pkg-config is installed" else echo "pkg-config is not installed" install1="pkg-config" fi if $command_name | grep "make"; then echo "make is installed" else echo "make is not installed" install2="make" fi if $command_name | grep "gcc"; then echo "gcc is installed" else echo "gcc is not installed" install3="gcc g++" fi if $command_name | grep "base-devel"; then echo "base-devel is installed" else echo "base-devel is not installed" install4="base-devel" fi if $command_name | grep "libx11"; then echo "libx11 is installed" else echo "libx11 is not installed" install5="libx11" fi if $command_name | grep "libxkbfile"; then echo "libxkbfile is installed" else echo "libxkbfile is not installed" install6="libxkbfile" fi if $command_name | grep "libsecret"; then echo "libsecret is installed" else echo "libsecret is not installed" install7="libsecret" fi if $command_name | grep "git"; then echo "git is installed" else echo "git is not installed" install8="git" fi if type yarn &> /dev/null; then echo "yarn is installed" else echo "yarn is not installed" install9="yarn --global" fi if $command_name | grep "python"; then echo "python is installed" else echo "python is not installed" install10="python" fi echo "Installing dependencies" set -eE trap '(\ echo;\ echo \!\!\! An error happened during installing packages.;\ echo \!\!\! Please check console output for errors regarding package installation.,;\ echo\ )' ERR if [[ $install1 = "pkgconf" || $install2 = "make" || $install3 = "gcc" || $install4 = "base-devel" || $install5 = "libx11" || $install6 = "libxkbfile" || $install7 = "libsecret" || $install8 = "git" || $install10 = "python" ]]; then sudo pacman -Sy && sudo pacman -S $install1 $install2 $install3 $install4 $install5 $install6 $install7 $install8 $install10 --no-confirm else install9="" fi if [[ $install9 = "yarn --global" ]]; then npm install $install9 else install9="" fi elif [ -z "${NO_PPA}" -a "${DISTRIB_ID}" == "cachyos" ]; then echo "Running on Arch based distro, DEB packaging might not be supported" echo "Checking if dependencies are installed" # Get the installed Node.js version node_version=$(node -v 2>/dev/null) # Check if Node.js is installed if [ $? -ne 0 ]; then echo "Node.js is not installed, installing latest 20 LTS version" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 nvm use 20 echo "restart your shell and rerun the script" exit 0 fi # Remove the 'v' prefix from the version (e.g., v18.17.0 -> 18.17.0) node_version=${node_version#v} # Minimum and maximum versions min_version="18.17.0" max_version="21.0.0" # Compare versions if [[ "$(printf '%s\n' "$min_version" "$node_version" | sort -V | head -n1)" != "$min_version" ]]; then echo "Node.js version is too old. Upgrading to latest 20 LTS version." curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 nvm use 20 echo "restart your shell and rerun the script" exit 0 elif [[ "$(printf '%s\n' "$max_version" "$node_version" | sort -V | head -n1)" == "$max_version" ]]; then echo "Node.js version is too new. Downgrading to latest 20 LTS version." curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 nvm use 20 echo "restart your shell and rerun the script" exit 0 else echo "Node.js version $node_version is within the acceptable range." fi # Check for installed deps from pacman LC_ALL=C.UTF-8 command_name="pacman -Qi" # Search the man page for the string if $command_name | awk '/^Name/{name=$3} /^Installed Size/{print $4$5, name}' | sort -h | grep "pkgconf"; then echo "pkg-config is installed" else echo "pkg-config is not installed" install1="pkg-config" fi if $command_name | grep "make"; then echo "make is installed" else echo "make is not installed" install2="make" fi if $command_name | grep "gcc"; then echo "gcc is installed" else echo "gcc is not installed" install3="gcc g++" fi if $command_name | grep "base-devel"; then echo "base-devel is installed" else echo "base-devel is not installed" install4="base-devel" fi if $command_name | grep "libx11"; then echo "libx11 is installed" else echo "libx11 is not installed" install5="libx11" fi if $command_name | grep "libxkbfile"; then echo "libxkbfile is installed" else echo "libxkbfile is not installed" install6="libxkbfile" fi if $command_name | grep "libsecret"; then echo "libsecret is installed" else echo "libsecret is not installed" install7="libsecret" fi if $command_name | grep "git"; then echo "git is installed" else echo "git is not installed" install8="git" fi if type yarn &> /dev/null; then echo "yarn is installed" else echo "yarn is not installed" install9="yarn --global" fi if $command_name | grep "python"; then echo "python is installed" else echo "python is not installed" install10="python" fi echo "Installing dependencies" set -eE trap '(\ echo;\ echo \!\!\! An error happened during installing packages.;\ echo \!\!\! Please check console output for errors regarding package installation.,;\ echo\ )' ERR if [[ $install1 = "pkgconf" || $install2 = "make" || $install3 = "gcc" || $install4 = "base-devel" || $install5 = "libx11" || $install6 = "libxkbfile" || $install7 = "libsecret" || $install8 = "git" || $install10 = "python" ]]; then sudo pacman -Sy && sudo pacman -S $install1 $install2 $install3 $install4 $install5 $install6 $install7 $install8 $install10 --no-confirm else install9="" fi if [[ $install9 = "yarn --global" ]]; then npm install $install9 else install9="" fi else echo "Running on generic Linux, DEB packaging will depend on distro" echo "To install host system packages/libraries, refer to your distro package manager on how to install them. Node.js will still be installed." echo "For a libraries list, check out https://github.com/eclipse-theia/theia/blob/master/doc/Developing.md#prerequisites and find out your install method." echo "Checking if Node.js is installed" # Get the installed Node.js version node_version=$(node -v 2>/dev/null) # Check if Node.js is installed if [ $? -ne 0 ]; then echo "Node.js is not installed, installing latest 20 LTS version" curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 nvm use 20 echo "restart your shell and rerun the script" exit 0 fi # Remove the 'v' prefix from the version (e.g., v18.17.0 -> 18.17.0) node_version=${node_version#v} # Minimum and maximum versions min_version="18.17.0" max_version="21.0.0" # Compare versions if [[ "$(printf '%s\n' "$min_version" "$node_version" | sort -V | head -n1)" != "$min_version" ]]; then echo "Node.js version is too old. Upgrading to latest 20 LTS version." curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 nvm use 20 echo "restart your shell and rerun the script" exit 0 elif [[ "$(printf '%s\n' "$max_version" "$node_version" | sort -V | head -n1)" == "$max_version" ]]; then echo "Node.js version is too new. Downgrading to latest 20 LTS version." curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion nvm install 20 nvm use 20 echo "restart your shell and rerun the script" exit 0 else echo "Node.js version $node_version is within the acceptable range." exit 0 fi fi else echo "Unsupported OS [$OS]. Only Linux is supported for building packages. (for now)" echo "FAILURE, exiting." exit 1 fi fi if [ ${1} = "build-package" ] then echo "building package" # Abort early on error set -eE trap '(\ echo;\ echo \!\!\! An error happened during script execution;\ echo \!\!\! Please check console output for bad sync,;\ echo \!\!\! failed patch application, OOM killer messages, etc.;\ echo\ )' ERR echo "installing node dependencies" yarn install echo "building" yarn build:dev yarn --cwd electron-app rebuild echo "running watch command for up to 40 seconds then exiting, disabling temporarily error trap" set +e trap - ERR timeout --preserve-status 40s yarn --cwd ./electron-app watch echo "timed out, re-enabling error trap" set -eE trap '(\ echo;\ echo \!\!\! An error happened during script execution;\ echo \!\!\! Please check console output for bad sync,;\ echo \!\!\! failed patch application, OOM killer messages, etc.;\ echo\ )' ERR if [[ $arch == unknown ]]; then arch=$archarchlinux fi echo "You are about to build the IDE for your target architecture ($arch)" echo "If you don't want to build for $arch, then modify package.json in electron-app folder to include:" echo '"linux": { "target": [ "zip", "AppImage" ], "arch": [ "x64" ^^^^^^^^ your desired arch goes here like x64 or arm64 ], ^^^^^^^^^^^ this entire arch structure "category": "Development", "icon": "resources/icons" },' echo "Also, if you are building a DEB package then modify package.json in electron-app folder to also include in package.json inside of electron-app:" echo ' "author": "Arduino SA (https://arduino.cc/)", ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this part "description": "Arduino IDE",' echo "aswell as make sure that fpm (ruby program as a binary) is compatible with your architecture that you are building on" echo "otherwaise if both changes are not made, building for DEB target will fail." read -n1 -r -p "CTRL-C to exit and cancel building (you can relaunch building at any time using yarn --cwd electron-app package), or any other key to continue building anyways" yarn --cwd electron-app build yarn --cwd electron-app package fi if [ ${1} = "clone-repo" ] then echo "cloning repo of arduino-ide" git clone https://github.com/arduino/arduino-ide $HOME/arduino-ide cd arduino-ide git pull git merge echo "from now on copy the script to the root of the arduino-ide source code to build it" exit 0 fi if [ ${1} = "update-repo" ] then echo "updating repo of arduino-ide" cd $HOME/arduino-ide git pull git merge fi