c577b12520
Make jruby binary not segfault if PATH isn't set correctly. Remove rubygems hacks, since they are no longer necessary now that the versions of rubygems for the other ruby interpreters are > 1.3.7. No longer ship the ri documentation files with JRuby. JRuby ships with a broken ri binary anyway (requires the rdoc gem to work), and almost all users of JRuby have MRI ruby installed and can use its ri binary.
63 lines
1.9 KiB
Plaintext
63 lines
1.9 KiB
Plaintext
$OpenBSD: patch-jruby-launcher_unixlauncher_cpp,v 1.2 2011/11/08 23:58:08 jeremy Exp $
|
|
|
|
Attempt to replicate the following shell code:
|
|
|
|
JAVA_HOME=$(javaPathHelper -h jruby)
|
|
|
|
Without this, if the JAVA_HOME environment variable is not
|
|
defined, bin/jruby will segfault when run.
|
|
|
|
--- jruby-launcher/unixlauncher.cpp.orig Wed Dec 31 16:00:00 1969
|
|
+++ jruby-launcher/unixlauncher.cpp Thu Nov 3 15:05:53 2011
|
|
@@ -1,4 +1,5 @@
|
|
#include <stdlib.h>
|
|
+#include <string.h>
|
|
#include "unixlauncher.h"
|
|
#include "utilsfuncs.h"
|
|
|
|
@@ -37,6 +38,44 @@ int UnixLauncher::run(int argc, char* argv[], char* en
|
|
prepareOptions();
|
|
|
|
string java("");
|
|
+
|
|
+ if (getenv("JAVA_HOME") == NULL) {
|
|
+ char *path;
|
|
+ FILE *java_home_pipe;
|
|
+ char java_home_path[256];
|
|
+
|
|
+ path = getenv("PATH");
|
|
+ if (path == NULL || strlen(path) == 0) {
|
|
+ setenv("PATH", "/usr/bin:${LOCALBASE}/bin:${LOCALBASE}/jdk-1.7.0/bin", 1);
|
|
+ } else {
|
|
+ char *paths[3] = {(char *)"/usr/bin", (char *)"${LOCALBASE}/bin", (char *)"${LOCALBASE}/jdk-1.7.0/bin"};
|
|
+ int modified = 0;
|
|
+ int i;
|
|
+
|
|
+ strlcpy(java_home_path, path, sizeof(java_home_path));
|
|
+ for (i = 0; i < 3; i++) {
|
|
+ if (strstr(path, paths[i]) == NULL) {
|
|
+ modified = 1;
|
|
+ strlcat(java_home_path, ":", sizeof(java_home_path));
|
|
+ strlcat(java_home_path, paths[i], sizeof(java_home_path));
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (modified == 1) {
|
|
+ setenv("PATH", java_home_path, 1);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if(java_home_pipe = popen("javaPathHelper -h jruby", "r")) {
|
|
+ size_t bytes_read;
|
|
+ bytes_read = fread(java_home_path, 1, 255, java_home_pipe);
|
|
+ if (bytes_read > 0) {
|
|
+ java_home_path[bytes_read-1] = '\0';
|
|
+ setenv("JAVA_HOME", java_home_path, 1);
|
|
+ }
|
|
+ pclose(java_home_pipe);
|
|
+ }
|
|
+ }
|
|
|
|
if (getenv("JAVACMD") != NULL) {
|
|
java = getenv("JAVACMD");
|