From e945acf089a2701dd8beba220633915e9f419fec Mon Sep 17 00:00:00 2001 From: Jonathan Yoder Date: Mon, 9 Sep 2019 08:55:54 -0400 Subject: [PATCH] Fixes per PR feedback --- README.md | 9 ++++----- install.sh | 48 +++++++++++++++++++++++++++--------------------- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 1cb4474..c776ee4 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,7 @@ R binaries are built for the following Linux operating systems: - openSUSE 42.3, 15.0 - SUSE Linux Enterprise 12, 15 -## Installation - -### Quick Installer +## Quick Installation To use our quick install script to install R, simply run the following command. To use the quick installer, you must have root or sudo privileges, @@ -36,6 +34,8 @@ and `curl` must be installed. bash -c "$(curl -L https://rstd.io/r-install)" ``` +## Manual Installation + ### Specify R version Define the version of R that you want to install. Available versions @@ -44,8 +44,7 @@ of R can be found here: https://cdn.rstudio.com/r/versions.json R_VERSION=3.5.3 ``` -### Download and install R Manually - +### Download and install R #### Ubuntu/Debian Linux Download the deb package: diff --git a/install.sh b/install.sh index f44da98..c224908 100755 --- a/install.sh +++ b/install.sh @@ -34,6 +34,9 @@ R_VERSIONS=$(curl -s ${VERSIONS_URL} | \ cut -f2 -d "[" | cut -f1 -d "]" | \ # Removes the quotes and commas from the values sed -e 's/\"//g' | sed -e 's/\,//g' | \ + # Appends a placeholder to the end of the string. Without an extra element at the + # end, the last version will be missing after we reverse the order. + { IFS= read -r vers; printf '%s placeholder' "$vers"; } | \ # Reverses the order of the list ( while read -d ' ' f;do g="$f${g+ }$g" ;done;echo "$g" )) @@ -43,19 +46,27 @@ detect_os () { distro=$($OS | grep DISTRIB_ID | cut -f2 -d "=") if test -f /etc/SuSE-release then - distro="SUSE" + distro="LEAP12" fi if [[ -f /etc/centos-release || -f /etc/redhat-release ]] then distro="RedHat" fi + if [[ $(cat /etc/os-release | grep -e "^CPE_NAME\=*" | cut -f 2 -d '=') =~ cpe:/o:suse:sles:12: ]] + then + distro="SLES12" + fi + if [[ $(cat /etc/os-release | grep -e "^CPE_NAME\=*" | cut -f 2 -d '=') =~ cpe:/o:opensuse:leap:42. ]] + then + distro="LEAP12" + fi if [[ $(cat /etc/os-release | grep -e "^CPE_NAME\=*" | cut -f 2 -d '=') == "\"cpe:/o:opensuse:leap:15.0\"" ]] then - distro="SUSE15" + distro="SLES15" fi if [[ $(cat /etc/os-release | grep -e "^CPE_NAME\=*" | cut -f 2 -d '=') == "\"cpe:/o:suse:sles:15\"" ]] then - distro="SUSE15" + distro="LEAP15" fi if [[ $(cat /etc/os-release | grep -e "^ID\=*" | cut -f 2 -d '=') == "debian" ]]; then distro="Debian" @@ -89,19 +100,14 @@ detect_os_version () { # Returns the installer type detect_installer_type () { os=$1 - if [ "${os}" = "SUSE" ]; then - echo "rpm" - else - if [ "${os}" = "SUSE15" ]; then + case $os in + "RedHat" | "CentOS" | "LEAP12" | "LEAP15" | "SLES12" | "SLES15") echo "rpm" - else - if [ "${os}" = "RedHat" ]; then - echo "rpm" - else - echo "deb" - fi - fi - fi + ;; + "Ubuntu" | "Debian") + echo "deb" + ;; + esac } # Lists available R versions @@ -131,7 +137,7 @@ download_name () { "Ubuntu" | "Debian") echo "r-${version}_1_amd64.deb" ;; - "SUSE" | "SUSE15") + "LEAP12" | "LEAP15" | "SLES12" | "SLES15") echo "R-${version}-1-1.x86_64.rpm" ;; esac @@ -159,10 +165,10 @@ download_url () { "Debian") echo "${CDN_URL}/debian-9/pkgs/${name}" ;; - "SUSE") + "LEAP12" | "SLES12") echo "${CDN_URL}/opensuse-42/pkgs/${name}" ;; - "SUSE15") + "LEAP15" | "SLES15") echo "${CDN_URL}/opensuse-15/pkgs/${name}" ;; esac @@ -251,7 +257,7 @@ install_rpm () { fi ${SUDO} yum install "${installer_name}" ;; - "SUSE" | "SUSE15") + "LEAP12" | "LEAP15" | "SLES12" | "SLES15") if ! has_sudo "zypper"; then echo "Must have sudo privileges to run zypper" exit 1 @@ -270,10 +276,10 @@ install_pre () { "RedHat" | "CentOS") install_epel "${ver}" ;; - "SUSE") + "SLES12") install_sci ;; - "SUSE15") + "LEAP12" | "LEAP15" | "SLES15") ;; esac }