Author: kve
Date: Tue Feb 28 15:26:17 2012
New Revision: 1294689

URL: http://svn.apache.org/viewvc?rev=1294689&view=rev
Log:
Use update-alternatives for installing /usr/bin/java (and fix the fallback 
method (ln -sf))


Modified:
    
whirr/branches/branch-0.7/core/src/main/resources/functions/install_openjdk.sh
    
whirr/branches/branch-0.7/core/src/main/resources/functions/install_oracle_jdk6.sh
    
whirr/branches/branch-0.7/core/src/main/resources/functions/install_oracle_jdk7.sh

Modified: 
whirr/branches/branch-0.7/core/src/main/resources/functions/install_openjdk.sh
URL: 
http://svn.apache.org/viewvc/whirr/branches/branch-0.7/core/src/main/resources/functions/install_openjdk.sh?rev=1294689&r1=1294688&r2=1294689&view=diff
==============================================================================
--- 
whirr/branches/branch-0.7/core/src/main/resources/functions/install_openjdk.sh 
(original)
+++ 
whirr/branches/branch-0.7/core/src/main/resources/functions/install_openjdk.sh 
Tue Feb 28 15:26:17 2012
@@ -21,7 +21,8 @@ function install_openjdk_deb() {
   export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
   echo "export JAVA_HOME=$JAVA_HOME" >> /etc/profile
   echo "export JAVA_HOME=$JAVA_HOME" >> ~root/.bashrc
-  # TODO: update-alternatives?
+  update-alternatives --install /usr/bin/java java $JAVA_HOME/bin/java 17000
+  update-alternatives --set java $JAVA_HOME/bin/java # TODO: 
update-alternatives?
   java -version
   
 }

Modified: 
whirr/branches/branch-0.7/core/src/main/resources/functions/install_oracle_jdk6.sh
URL: 
http://svn.apache.org/viewvc/whirr/branches/branch-0.7/core/src/main/resources/functions/install_oracle_jdk6.sh?rev=1294689&r1=1294688&r2=1294689&view=diff
==============================================================================
--- 
whirr/branches/branch-0.7/core/src/main/resources/functions/install_oracle_jdk6.sh
 (original)
+++ 
whirr/branches/branch-0.7/core/src/main/resources/functions/install_oracle_jdk6.sh
 Tue Feb 28 15:26:17 2012
@@ -42,8 +42,16 @@ function install_oracle_jdk6() {
   (cd $tmpdir; mv jdk1* $target_dir)
   rm -rf $tmpdir
   
-  # FIXME: detect if there is an alternatives mechanism and use that instead
-  ln -sf "$target_dir/bin/java /usr/bin/java"
+  if which dpkg &> /dev/null; then
+    update-alternatives --install /usr/bin/java java $target_dir/bin/java 17000
+    update-alternatives --set java $target_dir/bin/java
+  elif which rpm &> /dev/null; then
+    alternatives --install /usr/bin/java java $target_dir/bin/java 17000
+    alternatives --set java $target_dir/bin/java
+  else
+    # Assume there is no alternatives mechanism, create our own symlink
+    ln -sf "$target_dir/bin/java" /usr/bin/java
+  fi
 
   # Try to set JAVA_HOME in a number of commonly used locations
   export JAVA_HOME=$target_dir

Modified: 
whirr/branches/branch-0.7/core/src/main/resources/functions/install_oracle_jdk7.sh
URL: 
http://svn.apache.org/viewvc/whirr/branches/branch-0.7/core/src/main/resources/functions/install_oracle_jdk7.sh?rev=1294689&r1=1294688&r2=1294689&view=diff
==============================================================================
--- 
whirr/branches/branch-0.7/core/src/main/resources/functions/install_oracle_jdk7.sh
 (original)
+++ 
whirr/branches/branch-0.7/core/src/main/resources/functions/install_oracle_jdk7.sh
 Tue Feb 28 15:26:17 2012
@@ -42,8 +42,16 @@ function install_oracle_jdk7() {
   (cd $tmpdir; mv jdk1* $target_dir)
   rm -rf $tmpdir
   
-  # FIXME: detect if there is an alternatives mechanism and use that instead
-  ln -sf "$target_dir/bin/java /usr/bin/java"
+  if which dpkg &> /dev/null; then
+    update-alternatives --install /usr/bin/java java $target_dir/bin/java 17000
+    update-alternatives --set java $target_dir/bin/java
+  elif which rpm &> /dev/null; then
+    alternatives --install /usr/bin/java java $target_dir/bin/java 17000
+    alternatives --set java $target_dir/bin/java
+  else
+    # Assume there is no alternatives mechanism, create our own symlink
+    ln -sf "$target_dir/bin/java" /usr/bin/java
+  fi
 
   # Try to set JAVA_HOME in a number of commonly used locations
   export JAVA_HOME=$target_dir


Reply via email to