Kaydet (Commit) 5b92c2d5 authored tarafından Noel Power's avatar Noel Power

Added new class ExecCmd, this class flushes io from execed programs (ensures…

Added new class ExecCmd, this class flushes io from execed programs (ensures they do not hang), Register modified to use ExecCmd. Installer works on windows again.
üst c6a56226
package installer;
import java.util.*;
import java.io.*;
public class ExecCmd
{
public boolean exec( String cmd, String[] env )
{
System.out.println("About to exectute " + cmd);
final Process p;
boolean result = false;
try
{
Runtime rt = Runtime.getRuntime();
p=rt.exec( cmd, env );
new Thread(new Runnable() {
public void run()
{
try
{
BufferedReader br_in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String buff = null;
while ((buff = br_in.readLine()) != null)
{
System.out.println("Process out :" + buff);
/*try
{
Thread.sleep(100);
}
catch(Exception e) {}*/
}
br_in.close();
System.out.println("finished reading out");
}
catch (IOException ioe)
{
System.out.println("Exception caught printing javac result");
ioe.printStackTrace();
}
} } ).start();
new Thread(new Runnable() {
public void run() {
try {
BufferedReader br_err = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String buff = null;
while ((buff = br_err.readLine()) != null) {
System.out.println("Process err :" + buff);
/*try {Thread.sleep(100); } catch(Exception e) {}*/
}
br_err.close();
System.out.println("finished reading err");
} catch (IOException ioe) {
System.out.println("Exception caught printing javac result");
ioe.printStackTrace();
}
} }).start();
int exitcode = p.waitFor();
if ( exitcode != 0 )
{
System.out.println("cmd [" + cmd + "] failed" );
result= false;
}
else
{
System.out.println("cmd [" + cmd + "] completed successfully");
result= true;
}
}
catch (Exception e) {
System.out.println("Exception");
e.printStackTrace();
}
System.out.println("command complete");
return result;
}
}
......@@ -3,7 +3,6 @@ package installer;
import java.lang.String;
import java.io.*;
import javax.swing.*;
public class Register{
private static String[] singletonDefParams = { "drafts.com.sun.star.script.framework.theScriptRuntimeForJava=drafts.com.sun.star.script.framework.ScriptRuntimeForJava",
"drafts.com.sun.star.script.framework.storage.theScriptStorageManager=drafts.com.sun.star.script.framework.storage.ScriptStorageManager",
......@@ -17,28 +16,24 @@ public class Register{
}
private static boolean regSingletons( String path, String progPath, String opSys, JLabel statusLabel ) {
try{
int exitcode=0;
Runtime rt = Runtime.getRuntime();
Process p;
boolean goodResult = false;
String[] env = new String[1];
String regCmd = null;
ExecCmd command = new ExecCmd();
for ( int i=0; i<singletonDefParams.length; i++){
if ( opSys.indexOf( "Windows" ) == -1 ){
// Not windows
env[0] = "LD_LIBRARY_PATH=" + progPath;
p=rt.exec("chmod a+x " + progPath + "regsingleton");
exitcode=p.waitFor();
command.exec( "chmod a+x " + progPath + "regsingleton", null );
regCmd = progPath + "regsingleton " + path + "user" + File.separator + "uno_packages" + File.separator + "cache" + File.separator + "services.rdb " + singletonDefParams[i];
p=rt.exec( regCmd, env );
goodResult = command.exec( regCmd, env );
}
else {
// Windows
regCmd = quotedString( progPath + "regsingleton.exe" ) + " " + quotedString( path + "user" + File.separator + "uno_packages" + File.separator + "cache" + File.separator + "services.rdb" ) + " " + quotedString( singletonDefParams[i] );
p=rt.exec( regCmd );
goodResult = command.exec( regCmd,null );
}
exitcode = p.waitFor();
if ( exitcode != 0 ){
if ( !goodResult ){
System.out.println("Regsingleton cmd failed, cmd: " + regCmd );
statusLabel.setText("Regsingleton ScriptRuntimeForJava Failed, please view SFrameworkInstall.log");
return false;
......@@ -61,14 +56,13 @@ public class Register{
try {
String s=null;
int exitcode=0;
boolean goodResult = false;
String env[] = new String[1];
Runtime rt = Runtime.getRuntime();
ExecCmd command = new ExecCmd();
boolean isWindows =
(System.getProperty("os.name").indexOf("Windows") != -1);
String progpath = path.concat("program" + File.separator);
Process p;
statusLabel.setText("Registering Scripting Framework...");
......@@ -82,14 +76,13 @@ public class Register{
if (!isWindows) {
env[0]="LD_LIBRARY_PATH=" + progpath;
p = rt.exec("chmod a+x " + progpath + "pkgchk");
exitcode = p.waitFor();
goodResult = command.exec("chmod a+x " + progpath + "pkgchk", null );
if (exitcode == 0){
if ( goodResult ){
cmd = progpath + "pkgchk " + progpath + packages[i];
System.err.println(cmd);
p=rt.exec(cmd, env);
goodResult = command.exec(cmd, env);
}
}
else {
......@@ -97,11 +90,10 @@ public class Register{
packages[i] + "\"";
System.err.println(cmd);
p=rt.exec(cmd);
}
goodResult =command.exec(cmd,null);
exitcode = p.waitFor();
if (exitcode != 0) {
}
if (!goodResult) {
System.err.println("\nPkgChk Failed");
if(!isWindows)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment