Changeset 19765

Show
Ignore:
Timestamp:
09.06.2009 11:23:49 (10 years ago)
Author:
oranfry
Message:

cdrom installer: added david's function to return the path of a java that will work, copying java off the cd onto disk to make it work where necessary. used it in the wrapper.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • release-kits/shared/linux/wrapper.cpp

    r19720 r19765  
    1111#include "libsearch4j.h" 
    1212bool extract_bundled_file( const char[], int, char*, bool ); 
     13#else 
     14string get_full_java( string wd ); 
    1315#endif 
    1416 
     
    176178    } 
    177179    #else 
    178         string cmd = wd + "/Java/Linux/jre/bin/java -Dorig.dir=\"" + wd + "\" -jar " + wd + "/Java/Jars/linux.jar" + (text_mode?" text":""); 
     180        string java_executable = get_full_java( wd ); 
     181        string cmd = java_executable + " -Dorig.dir=\"" + wd + "\" -jar " + wd + "/Java/Jars/linux.jar" + (text_mode?" text":""); 
    179182        system( cmd.c_str() ); 
    180183    #endif 
     
    227230 
    228231} 
     232#else 
     233 
     234string get_full_java( string wd ) { 
     235  string full_java = ""; 
     236 
     237  string cdrom_java = "/Java/Linux/jre/bin/java"; 
     238 
     239  full_java = wd + cdrom_java; 
     240   
     241  string j1cmd = "\""+full_java+"\" -version >/dev/null 2>&1"; 
     242  int j1status = system(j1cmd.c_str()); 
     243   
     244  if (WEXITSTATUS(j1status)!=0) { 
     245    cerr << "Unable to run Java executable from CD-ROM." << endl; 
     246    cerr << "This is probably because your CD-ROM was mounted with 'noexec'." << endl; 
     247    cerr << "It can be changed by a system administrator" << endl << endl; 
     248    cerr << "Copying Java to local disk so it can be run" << endl; 
     249     
     250    string cdtar_home = wd + "/Java/Linux/"; 
     251    string tcmd = "(cd \"" + cdtar_home + "\" ; tar cf - jre )"; 
     252    tcmd += "| tar xvf - "; 
     253    tcmd += "| awk 'BEGIN{C=0}{C++; printf(\".\"); if (C%70==0) printf(\"\\n\");}END{printf(\"\\n\")}'"; 
     254 
     255    int tstatus = system(tcmd.c_str()); 
     256     
     257    if (WEXITSTATUS(tstatus)!=0) { 
     258      cerr << "Failed to copy Java to disk" << endl; 
     259      cerr << "Please make sure you have write permissions in the directory where you run the installer" << endl; 
     260    } 
     261    else { 
     262      full_java = "./jre/bin/java"; 
     263      string j2cmd = full_java +" -version >/dev/null 2>&1"; 
     264 
     265      int j2status = system(j2cmd.c_str()); 
     266 
     267          if (WEXITSTATUS(j2status)!=0) { 
     268        cerr << "Unable to run copied Java" << endl; 
     269        system("/bin/rm -rf jre"); 
     270        exit(-1); 
     271      } 
     272    } 
     273  } 
     274 
     275  // to get to here, full_java must be set (and working) 
     276 
     277  return full_java; 
     278} 
     279 
    229280#endif