Drop support for C extensions (which were always expiremental). Use jruby.jar instead of jruby-complete.jar, for a more typical jruby installation.
64 lines
1.9 KiB
Plaintext
64 lines
1.9 KiB
Plaintext
$OpenBSD: patch-jruby-launcher_unixlauncher_cpp,v 1.3 2013/03/19 23:43:06 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 Mon May 21 14:43:20 2012
|
|
@@ -1,5 +1,6 @@
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
+#include <string.h>
|
|
#include "unixlauncher.h"
|
|
#include "utilsfuncs.h"
|
|
|
|
@@ -45,6 +46,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");
|