From: <prn...@us...> - 2012-07-08 18:08:39
|
Revision: 10736 http://octave.svn.sourceforge.net/octave/?rev=10736&view=rev Author: prnienhuis Date: 2012-07-08 18:08:33 +0000 (Sun, 08 Jul 2012) Log Message: ----------- pre_install.m checks JAVA_HOME before trying to compile Java pkg. Works in *nix & Windows; Mac OSX will follow later Added Paths: ----------- trunk/octave-forge/extra/java/pre_install.m Added: trunk/octave-forge/extra/java/pre_install.m =================================================================== --- trunk/octave-forge/extra/java/pre_install.m (rev 0) +++ trunk/octave-forge/extra/java/pre_install.m 2012-07-08 18:08:33 UTC (rev 10736) @@ -0,0 +1,81 @@ +## Copyright (C) 2012 Philip Nienhuis <prn...@us...> +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## Check for JAVA_HOME setting and JDK presence before attempting to +## install the Java package + +## Author: Philip Nienhuis +## Created: 2012-06-24 + +function [ ret ] = pre_install () + + jdk_ok = false; + ## Get JAVA_HOME contents + jh = getenv ("JAVA_HOME"); + + ## Check if has been set at all + if (isempty (jh)) + 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"]); + + 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 + 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"); + endif + endif + + if (! jdk_ok); + printf (" Hint:\n"); + 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 (" <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"); + error ("Aborting pkg install"); + endif + +endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |