Changeset 15980 for release-kits/lirk2/wrapper/mywrapper.c
- Timestamp:
- 2008-06-13T12:38:22+12:00 (16 years ago)
- Location:
- release-kits/lirk2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
release-kits/lirk2
- Property svn:externals
-
old new 1 1 lib http://svn.greenstone.org/release-kits/shared/lib 2 2 search4j http://svn.greenstone.org/release-kits/shared/search4j 3 linux http://svn.greenstone.org/release-kits/shared/linux 3 4
-
- Property svn:externals
-
release-kits/lirk2/wrapper/mywrapper.c
r15205 r15980 12 12 13 13 string tempdir = (string)argv[0] + ".tmp"; //temporary directory where we will store extracted files 14 string jarfile = tempdir + "/greenstone 3.jar"; //where we will store the jar file14 string jarfile = tempdir + "/greenstone2.jar"; //where we will store the jar file 15 15 string search4jfile = tempdir + "/search4j"; //where we will store the jar file 16 string javafile = tempdir + "/@java.installer@"; //where we will store the java tar file 16 17 bool succeeded = false; 17 18 18 19 //create the temp folder 19 cout << "Creating temp directory " << endl;20 cout << "Creating temp directory..." << endl; 20 21 succeeded = ( 0 == system( ("mkdir " + tempdir).c_str() ) ); 21 22 if ( !succeeded ) { … … 28 29 //extract files 29 30 cout << "Extracting installer jar..." << endl; 30 succeeded = extract_bundled_file( greenstone3jar, sizeof(greenstone3jar), (char*)jarfile.c_str(), false); 31 succeeded = extract_bundled_file( greenstone2jar, sizeof(greenstone2jar), (char*)jarfile.c_str(), false); 32 33 cout << "Extracting search4j tool..." << endl; 34 succeeded = extract_bundled_file( search4j, sizeof(search4j), (char*)search4jfile.c_str(), true ) && succeeded; 35 36 #ifdef java_is_bundled 37 cout << "Extracting bundled java..." << endl; 38 succeeded = extract_bundled_file( java, sizeof(java), (char*)javafile.c_str(), true ) && succeeded; 39 #endif 40 31 41 if ( !succeeded ) { 32 cout << "failed" << endl; 33 cout << "Failed to extract the JAR file to '" << jarfile << "'" << endl; 34 cout << "The file may be corrupt or missing" << endl; 35 cout << "Or this installer may not have sufficient file permissions to write it to disk" << endl; 42 cout << "Failed to extract one or more resources" << endl; 43 cout << "This installer may not have sufficient file permissions to write it to disk" << endl; 44 cout << "Or, the files may be corrupt or missing from this executable" << endl; 36 45 cout << "Exiting" << endl; 37 46 return 1; 38 47 } 39 48 40 cout << "Extracting search4j tool..." << endl; 41 succeeded = extract_bundled_file( search4j, sizeof(search4j), (char*)search4jfile.c_str(), true ); 49 //change to the temp directory 50 chdir( tempdir.c_str() ); 51 52 #ifdef java_is_bundled 53 succeeded = (system( "tar -xzf @java.installer@" ) == 0); 42 54 if ( !succeeded ) { 43 cout << "failed" << endl; 44 cout << "Failed to extract the search4j tool to '" << jarfile << "'" << endl; 45 cout << "The file may be corrupt or missing" << endl; 46 cout << "Or this installer may not have sufficient file permissions to write it to disk" << endl; 55 cout << "Failed to extract the bundled java archive to the temp directory" << endl; 56 cout << "You need the tar program on your PATH" << endl; 47 57 cout << "Exiting" << endl; 48 58 return 1; 49 59 } 50 51 52 //change to the temp directory 53 chdir( tempdir.c_str() ); 54 60 #endif 55 61 56 62 //check if an appropriate java is found 57 63 bool jvmFound = (system( "./search4j -m @java.min.version@ -h ./@java.extracted@" ) == 0); 58 64 59 //if the jvm was not found, try to fix it and find it65 //if the jvm was not found, report not found 60 66 if ( !jvmFound ) { 67 61 68 //did not find a good java 62 cout << "Greenstone requires java @java.min.version@ or greater " << endl;69 cout << "Greenstone requires java @java.min.version@ or greater." << endl; 63 70 64 71 //tell them if java is absent or just too old 65 72 if ( system( "./search4j -h ./@java.extracted@" ) == 0 ) { 66 cout << "You r javais too old." << endl;73 cout << "You have java, but it is too old." << endl; 67 74 } else { 68 75 cout << "Could not find java on your system." << endl; 69 76 } 70 71 //is this an installer with the bundled JRE?72 73 #ifdef java_is_bundled74 //yes, JRE is bundled75 /*76 cout77 << "This installer comes bundled with a suitible version of java: " << endl78 << " @java.installer@" << endl79 << "Do you want to install this java? (y/n)" << endl;80 char r[1024]; cin >> r;81 if ( strcmp( r, "y" ) == 0 || strcmp( r, "Y" ) == 0) {82 */83 77 84 cout << "Using bundled java." << endl; 85 extract_bundled_file( java, sizeof(java), (char*)"@java.installer@", true ); 86 system( "tar -xzf @java.installer@" ); 87 jvmFound = true; //assume the java installation went well 88 89 /*}*/ 78 cout << "Install java (@java.min.version@ or greater) and set JAVA_HOME or JRE_HOME, and try again" << endl; 79 #ifndef java_is_bundled 80 cout << "Or, download a greentsone3 installer with bundled java and use that instead of this one" << endl; 90 81 #endif 91 82 92 #ifndef java_is_bundled 93 //no, JRE is not bundled 94 cout << "Install java (@java.min.version@ or greater) and set JAVA_HOME or JRE_HOME, and try again" << endl; 95 cout << "Or, download a greentsone3 installer with bundled java and use that instead of this one" << endl; 96 #endif 97 } 83 //if we have found it, launch the installer 84 } else { 98 85 99 //if we have found it by now, launch the installer100 if ( jvmFound ) {101 86 cout << "Launching Installer ..." << endl; 102 87 int launch_exit_code = 0; 103 launch_exit_code = system("./search4j -m @java.min.version@ -l greenstone 3.jar -h ./@java.extracted@");88 launch_exit_code = system("./search4j -m @java.min.version@ -l greenstone2.jar -h ./@java.extracted@"); 104 89 105 90 //report how it went … … 107 92 cout << "Setup complete" << endl; 108 93 } else { 109 cout << " Still could not find a suitible version of java" << endl;110 cout << " Please install java, set JAVA_HOME or JRE_HOME, and try again" << endl;94 cout << "The installer exited with an error" << endl; 95 cout << "Greenstone may not be correctly installed" << endl; 111 96 } 112 97 … … 119 104 cout << "Deleting the temp directory" << endl; 120 105 system( ("rm -rf " + tempdir).c_str() ); 121 122 106 123 107 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.