From: <prn...@us...> - 2012-07-20 19:34:05
|
Revision: 10755 http://octave.svn.sourceforge.net/octave/?rev=10755&view=rev Author: prnienhuis Date: 2012-07-20 19:33:59 +0000 (Fri, 20 Jul 2012) Log Message: ----------- Added stanzas that check for Java executables (javac, ..) in the PATH Modified Paths: -------------- trunk/octave-forge/extra/java/pre_install.m Modified: trunk/octave-forge/extra/java/pre_install.m =================================================================== --- trunk/octave-forge/extra/java/pre_install.m 2012-07-19 03:22:00 UTC (rev 10754) +++ trunk/octave-forge/extra/java/pre_install.m 2012-07-20 19:33:59 UTC (rev 10755) @@ -31,36 +31,70 @@ printf ("\nError while trying to install Java package:\n"); printf ("environment variable 'JAVA_HOME' has not been set.\n"); printf (" use 'setenv (\"JAVA_HOME\", \"/full/path/to/javaJDK\")'\n"); + else - ## Check if JAVA_HOME points to a jvm (that is, given the variety of ## Java installations in the wild, merely check JAVA_HOME/jre/lib) - jhd = dir ([jh filesep "jre" filesep "lib"]); + ## and the executables are in the PATH + if (ismac) + ## Look in <jh>/../Libraries/ + if (exist ([jh filesep ".." filesep "Libraries" filesep "libclient.dylib"], "file") == 2) + jdk_ok = true; + endif - if (! isempty (jhd)) - ## Search for a subdir (hopefully <arch>/) containing a - ## subdir client/ (*nix) or a file jvm.cfg (Windows) - ijhd = find (cell2mat ({jhd.isdir})); - ii = 3; # Ignore current and parent dirs - while ii < numel (ijhd) - jhsd = dir ([jh filesep "jre" filesep "lib" filesep jhd(ijhd(ii)).name]); - ## Check if client is a subdir (hopefully of <arch>/) - id = strmatch ("client", {jhsd.name}); - if ((! isempty (id)) && jhsd(id).isdir) - cl_dir = [jh filesep "jre" filesep "lib" filesep jhd(ijhd(ii)).name filesep "client"]; - jhcsd = dir (cl_dir); - ## Check for a libjvm* file inside. Should work if it's a link too. - jdk_ok = ! isempty (strmatch ("libjvm", {jhcsd.name})); - if (! jdk_ok); - printf (" No libjvm library found in %s\n", cl_dir); + else + jhd = dir ([jh filesep "jre" filesep "lib"]); + if (! isempty (jhd)) + + ## Search for a subdir (hopefully <arch>/) containing a + ## subdir client/ (*nix) or a file jvm.cfg (Windows) + ijhd = find (cell2mat ({jhd.isdir})); + ii = 3; # Ignore current and parent dirs + while ii < numel (ijhd) + jhsd = dir ([jh filesep "jre" filesep "lib" filesep jhd(ijhd(ii)).name]); + ## Check if client is a subdir (hopefully of <arch>/) + id = strmatch ("client", {jhsd.name}); + if ((! isempty (id)) && jhsd(id).isdir) + cl_dir = [jh filesep "jre" filesep "lib" filesep jhd(ijhd(ii)).name filesep "client"]; + jhcsd = dir (cl_dir); + ## Check for a libjvm* file inside. Should work if it's a link too. + jdk_ok = ! isempty (strmatch ("libjvm", {jhcsd.name})); + if (! jdk_ok); + printf (" No libjvm library found in %s\n", cl_dir); + endif endif + ## Below line especially for Windows installations + jdk_ok = jdk_ok || (! isempty (strmatch ("JVM.CFG", upper ({jhsd.name})))); + if (jdk_ok); ii += numel (ijhd); endif + ++ii; + endwhile + + ## Try the Java executables. If we find javac we're probably OK + if (ispc) + jtst = (system ('javac -version 2> nul')); + else + jtst = (system ('javac -version 2> /dev/null')); endif - ## Below line especially for Windows installations - jdk_ok = jdk_ok || (! isempty (strmatch ("JVM.CFG", upper ({jhsd.name})))); - if (jdk_ok); ii += numel (ijhd); endif - ++ii; - endwhile + if (jtst) ## Should be zero if command returned normally + ## OK, found Java compiler & it works. + elseif (jdk_ok) + ## Apparently javac is not in the PATH (as usual on e.g., Windows). + ## Try to find it tru JAVA_HOME, if found add JAVA_HOME/bin to the + ## environment PATH + jpth = [jh filesep "bin"]; + if (ispc) + jtst = (system ([ jpth filesep 'javac -version 2> nul' ])); + else + jtst = (system ([ jpth filesep 'javac -version 2> /dev/null' ])); + endif + if (! jtst) + setenv ("PATH", [ jpth pathsep getenv("PATH") ]); + ## Do we need EXPORT on *nix? + endif + endif + endif endif + if (! jdk_ok); printf ("\nError while trying to install Java package:\n"); printf ("JAVA_HOME environment variable does not properly point to a JDK\n"); @@ -72,9 +106,12 @@ printf (" JAVA_HOME should usually be set such that either:\n"); printf (" (on *nix:)\n"); printf (" <JAVA_HOME>/jre/lib/<arch>/client/ contains libjvm.so (file or symlink)\n"); - printf (" (on Windows:) \n"); + printf (" (on OSX:)\n"); + printf (" <JAVA_HOME>/../Libraries/ contains a file libclient.dylib\n"); + printf (" (on Windows:)\n"); printf (" <JAVA_HOME>/jre/lib/<arch>/ contains a file jvm.cfg\n"); printf (" (<arch> depends on your system hardware, can be i386, x86_64, alpha, arm, ...)\n\n"); + printf (" Use forward slashes as path separator, also on Windows\n"); error ("Aborting pkg install"); endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |