summaryrefslogtreecommitdiff
path: root/kernlab.sh
diff options
context:
space:
mode:
authorAndreas Maunz <andreas@maunz.de>2011-03-29 12:24:28 +0200
committerAndreas Maunz <andreas@maunz.de>2011-03-29 12:24:28 +0200
commit6ba25c9cc51c285fdd1443057f61213668bb4a1b (patch)
treee1f42ccc96b0d7d58e23d546b9362bfb7849a600 /kernlab.sh
parente53c4f70598e403ba38c27a4637d540a10ee2075 (diff)
Kernlab fix: Missing command
Diffstat (limited to 'kernlab.sh')
-rwxr-xr-xkernlab.sh49
1 files changed, 44 insertions, 5 deletions
diff --git a/kernlab.sh b/kernlab.sh
index 673c1f6..56f3168 100755
--- a/kernlab.sh
+++ b/kernlab.sh
@@ -25,16 +25,55 @@ fi
# Pkg
VER="0.9-11"
-DIR="`pwd`"
+# Dest
+R_CONF=$HOME/.bash_R_ot
+DEST="$HOME/r-packages"
+if [ -n "$1" ]; then
+ DEST="$1"
+fi
+
+
echo "This installs Kernlab."
echo "Press <Return> to continue, or <Ctrl+C> to abort."
read
-cd /tmp
-if ! $WGET -O - "http://cran.r-project.org/src/contrib/Archive/kernlab/kernlab_$VER.tar.gz">/dev/null 2>&1; then
- echo "Download failed! Aborting..."
+
+DIR="`pwd`"
+
+R_DONE=false
+mkdir "$DEST" >/dev/null 2>&1
+if [ ! -d "$DEST" ]; then
+ echo "Install directory '$DEST' is not available! Aborting..."
exit 1
+else
+ if ! rmdir "$DEST" >/dev/null 2>&1; then # if not empty this will fail
+ echo "Install directory '$DEST' is not empty. Skipping kernlab installation..."
+ R_DONE=true
+ fi
+fi
+if ! $R_DONE; then
+cd /tmp
+ if ! $WGET -O - "http://cran.r-project.org/src/contrib/Archive/kernlab/kernlab_$VER.tar.gz">/dev/null 2>&1; then
+ echo "Download failed! Aborting..."
+ exit 1
+ fi
+ export R_LIBS="$DEST"
+ $R CMD INSTALL "kernlab_$VER.tar.gz"
fi
-R CMD INSTALL kernlab_$VER.tar.gz
+
+echo
+echo "Preparing R..."
+if [ ! -f $R_CONF ]; then
+ echo "R_LIBS=\"$DEST\"" >> "$R_CONF"
+ echo "R package destination has been stored in '$R_CONF'."
+ echo -n "Decide if R configuration should be linked to your .bashrc ('y/n'): "
+ read ANSWER_R_CONF
+ if [ $ANSWER_R_CONF = "y" ]; then
+ echo "source \"$R_CONF\"" >> $HOME/.bashrc
+ fi
+else
+ echo "It seems R is already configured ('$R_CONF' exists)."
+fi
+
cd "$DIR"
echo