[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Re: [patch] New VM Selection Method



Great code :) 
I bloated the regex a bit to take care not to trash " code # comment "
in line comments.
This regex is a BRE posix
(http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_03 )

and replaced "$@" by  ${1+"$@"} (though i don't know what this hack was
for ... only that it was "a thing to do" :-/


About the posix compliance i confirm it except for the three area i
don't know well : "source or ." , return for each function (and that
would be great to return the type of error though there s not much point
in doing it for a patch per se) and "test" switches ( -r ...).
Well most corner cases :)


Regards
Alban

Fixes :
- java-common-0.22.new/debian/usr/share/java-common/java-common.sh	: add support for end of line comment
- java-common-0.22.new/share/java-common.sh : idem
- portability fix ${1+"$@"} stolen from mozilla . I cannot remenber the rationale :(

Alban Browaeys <prahal@yahoo.com> Thursday, 26 May 2005 23:48

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 ${1+"$@")}"
+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 '^\([[:space:]]\)*#' "$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 ${1+"$@"})"
+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 '^\([[:space:]]\)*#' "$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: