Re: [patch] New VM Selection Method
Attached to this message is the actual patch. =/
On Sat, 2005-05-07 at 23:41 -0500, Jerry Haltom wrote:
> In the 30 minutes I had to work on free software this week I put
> together this patch against java-common which implements the previously
> discussed new VM selection idea for wrapper scripts.
>
> Please evaluate and include in java-common.
>
> I recognize I used bash-syntax for these scripts. That is because I suck
> at sh scripting and don't know any better. =(
>
> Right now I have named the
> include /usr/share/java-common/java-common.sh. THis is arbitrary and
> could probably use some discussion on what we shoudl actually name this.
> The same goes for the functions inside it.
>
> --
> Jerry Haltom <wasabi@larvalstage.net>
>
>
--
Jerry Haltom <wasabi@larvalstage.net>
diff -urN java-common-0.22/debian/changelog java-common-0.22.new/debian/changelog
--- java-common-0.22/debian/changelog 2003-09-08 04:40:48.000000000 -0500
+++ java-common-0.22.new/debian/changelog 2005-05-07 23:30:06.119357448 -0500
@@ -1,3 +1,9 @@
+java-common (0.22ubuntu1) hoary; urgency=low
+
+ * Added the new JVM launcher support scripts.
+
+ -- Jerry Haltom <wasabi@larvalstage.net> Sat, 2 Apr 2005 14:44:30 -0600
+
java-common (0.22) unstable; urgency=low
* Changed Maintainer: to the Debian Java Mailing List and added myself
diff -urN java-common-0.22/debian/java-common.dirs java-common-0.22.new/debian/java-common.dirs
--- java-common-0.22/debian/java-common.dirs 2001-10-02 10:16:58.000000000 -0500
+++ java-common-0.22.new/debian/java-common.dirs 2005-05-07 23:30:06.110359433 -0500
@@ -1 +1,3 @@
usr/share/java
+usr/share/java-common
+etc/jvm.d
diff -urN java-common-0.22/debian/java-common.install java-common-0.22.new/debian/java-common.install
--- java-common-0.22/debian/java-common.install 1969-12-31 18:00:00.000000000 -0600
+++ java-common-0.22.new/debian/java-common.install 2005-05-07 23:30:06.164347522 -0500
@@ -0,0 +1,3 @@
+share/java-common.sh usr/share/java-common
+share/find_jvm.sh usr/share/java-common
+etc/jvm etc
diff -urN java-common-0.22/debian/rules java-common-0.22.new/debian/rules
--- java-common-0.22/debian/rules 2002-02-05 09:23:00.000000000 -0600
+++ java-common-0.22.new/debian/rules 2005-05-07 23:30:06.119357448 -0500
@@ -49,6 +49,7 @@
binary-indep: build install
dh_testdir -i
dh_testroot -i
+ dh_install -i
# dh_installdebconf -i
### dh_installdocs -i
dh_installexamples -i
diff -urN java-common-0.22/debian/usr/share/java-common/find_jvm.sh java-common-0.22.new/debian/usr/share/java-common/find_jvm.sh
--- java-common-0.22/debian/usr/share/java-common/find_jvm.sh 1969-12-31 18:00:00.000000000 -0600
+++ java-common-0.22.new/debian/usr/share/java-common/find_jvm.sh 2005-05-07 23:30:06.173345537 -0500
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+. java-common.sh
+
+JAVA_HOME="$(jvm_find "$@")"
+echo JAVA_HOME=$JAVA_HOME
diff -urN java-common-0.22/debian/usr/share/java-common/java-common.sh java-common-0.22.new/debian/usr/share/java-common/java-common.sh
--- java-common-0.22/debian/usr/share/java-common/java-common.sh 1969-12-31 18:00:00.000000000 -0600
+++ java-common-0.22.new/debian/usr/share/java-common/java-common.sh 2005-05-07 23:30:06.173345537 -0500
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+function jvm_scan_file() {
+ file="$1"
+
+ while read jvm; do
+ if [ -x "$jvm/bin/java" ]; then
+ echo $jvm
+ return
+ fi
+ done < <(grep -v '#' "$file")
+}
+
+function jvm_find() {
+ program_file="/etc/jvm.d/$1"
+ user_program_file="$HOME/.jvm.d/$1"
+
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -r "$user_program_file" ]; then
+ jvm="$(jvm_scan_file "$user_program_file")"
+ fi
+ fi
+
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -r "$HOME/.jvm" ]; then
+ jvm="$(jvm_scan_file "$HOME/.jvm")"
+ fi
+ fi
+
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -r "$program_file" ]; then
+ jvm="$(jvm_scan_file "$program_file")"
+ fi
+ fi
+
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -z "$jvm" ]; then
+ jvm="$(jvm_scan_file /etc/jvm)"
+ fi
+ fi
+
+ echo "$jvm"
+}
diff -urN java-common-0.22/etc/jvm java-common-0.22.new/etc/jvm
--- java-common-0.22/etc/jvm 1969-12-31 18:00:00.000000000 -0600
+++ java-common-0.22.new/etc/jvm 2005-05-07 23:30:06.766214735 -0500
@@ -0,0 +1,5 @@
+# This file defines the default system JVM search order. Each
+# JVM should list their JAVA_HOME compatible directory in this file.
+# The default system JVM is the first one available from top to
+# bottom.
+
diff -urN java-common-0.22/share/find_jvm.sh java-common-0.22.new/share/find_jvm.sh
--- java-common-0.22/share/find_jvm.sh 1969-12-31 18:00:00.000000000 -0600
+++ java-common-0.22.new/share/find_jvm.sh 2005-05-07 23:33:23.737757921 -0500
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+. /usr/share/java-common/java-common.sh
+
+JAVA_HOME="$(jvm_find "$@")"
+echo JAVA_HOME=$JAVA_HOME
diff -urN java-common-0.22/share/java-common.sh java-common-0.22.new/share/java-common.sh
--- java-common-0.22/share/java-common.sh 1969-12-31 18:00:00.000000000 -0600
+++ java-common-0.22.new/share/java-common.sh 2005-05-07 23:30:06.749218485 -0500
@@ -0,0 +1,41 @@
+function jvm_scan_file() {
+ file="$1"
+
+ while read jvm; do
+ if [ -x "$jvm/bin/java" ]; then
+ echo $jvm
+ return
+ fi
+ done < <(grep -v '#' "$file")
+}
+
+function jvm_find() {
+ program_file="/etc/jvm.d/$1"
+ user_program_file="$HOME/.jvm.d/$1"
+
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -r "$user_program_file" ]; then
+ jvm="$(jvm_scan_file "$user_program_file")"
+ fi
+ fi
+
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -r "$HOME/.jvm" ]; then
+ jvm="$(jvm_scan_file "$HOME/.jvm")"
+ fi
+ fi
+
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -r "$program_file" ]; then
+ jvm="$(jvm_scan_file "$program_file")"
+ fi
+ fi
+
+ if [ -z "$JAVA_HOME" ]; then
+ if [ -z "$jvm" ]; then
+ jvm="$(jvm_scan_file /etc/jvm)"
+ fi
+ fi
+
+ echo "$jvm"
+}
Reply to: