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; ...@@ -3,7 +3,6 @@ package installer;
import java.lang.String; import java.lang.String;
import java.io.*; import java.io.*;
import javax.swing.*; import javax.swing.*;
public class Register{ public class Register{
private static String[] singletonDefParams = { "drafts.com.sun.star.script.framework.theScriptRuntimeForJava=drafts.com.sun.star.script.framework.ScriptRuntimeForJava", 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", "drafts.com.sun.star.script.framework.storage.theScriptStorageManager=drafts.com.sun.star.script.framework.storage.ScriptStorageManager",
...@@ -17,28 +16,24 @@ public class Register{ ...@@ -17,28 +16,24 @@ public class Register{
} }
private static boolean regSingletons( String path, String progPath, String opSys, JLabel statusLabel ) { private static boolean regSingletons( String path, String progPath, String opSys, JLabel statusLabel ) {
try{ try{
int exitcode=0; boolean goodResult = false;
Runtime rt = Runtime.getRuntime();
Process p;
String[] env = new String[1]; String[] env = new String[1];
String regCmd = null; String regCmd = null;
ExecCmd command = new ExecCmd();
for ( int i=0; i<singletonDefParams.length; i++){ for ( int i=0; i<singletonDefParams.length; i++){
if ( opSys.indexOf( "Windows" ) == -1 ){ if ( opSys.indexOf( "Windows" ) == -1 ){
// Not windows // Not windows
env[0] = "LD_LIBRARY_PATH=" + progPath; env[0] = "LD_LIBRARY_PATH=" + progPath;
p=rt.exec("chmod a+x " + progPath + "regsingleton"); command.exec( "chmod a+x " + progPath + "regsingleton", null );
exitcode=p.waitFor();
regCmd = progPath + "regsingleton " + path + "user" + File.separator + "uno_packages" + File.separator + "cache" + File.separator + "services.rdb " + singletonDefParams[i]; 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 { else {
// Windows // Windows
regCmd = quotedString( progPath + "regsingleton.exe" ) + " " + quotedString( path + "user" + File.separator + "uno_packages" + File.separator + "cache" + File.separator + "services.rdb" ) + " " + quotedString( singletonDefParams[i] ); regCmd = quotedString( progPath + "regsingleton.exe" ) + " " + quotedString( path + "user" + File.separator + "uno_packages" + File.separator + "cache" + File.separator + "services.rdb" ) + " " + quotedString( singletonDefParams[i] );
goodResult = command.exec( regCmd,null );
p=rt.exec( regCmd );
} }
exitcode = p.waitFor(); if ( !goodResult ){
if ( exitcode != 0 ){
System.out.println("Regsingleton cmd failed, cmd: " + regCmd ); System.out.println("Regsingleton cmd failed, cmd: " + regCmd );
statusLabel.setText("Regsingleton ScriptRuntimeForJava Failed, please view SFrameworkInstall.log"); statusLabel.setText("Regsingleton ScriptRuntimeForJava Failed, please view SFrameworkInstall.log");
return false; return false;
...@@ -61,14 +56,13 @@ public class Register{ ...@@ -61,14 +56,13 @@ public class Register{
try { try {
String s=null; String s=null;
int exitcode=0; boolean goodResult = false;
String env[] = new String[1]; String env[] = new String[1];
Runtime rt = Runtime.getRuntime(); ExecCmd command = new ExecCmd();
boolean isWindows = boolean isWindows =
(System.getProperty("os.name").indexOf("Windows") != -1); (System.getProperty("os.name").indexOf("Windows") != -1);
String progpath = path.concat("program" + File.separator); String progpath = path.concat("program" + File.separator);
Process p;
statusLabel.setText("Registering Scripting Framework..."); statusLabel.setText("Registering Scripting Framework...");
...@@ -82,14 +76,13 @@ public class Register{ ...@@ -82,14 +76,13 @@ public class Register{
if (!isWindows) { if (!isWindows) {
env[0]="LD_LIBRARY_PATH=" + progpath; env[0]="LD_LIBRARY_PATH=" + progpath;
p = rt.exec("chmod a+x " + progpath + "pkgchk"); goodResult = command.exec("chmod a+x " + progpath + "pkgchk", null );
exitcode = p.waitFor();
if (exitcode == 0){ if ( goodResult ){
cmd = progpath + "pkgchk " + progpath + packages[i]; cmd = progpath + "pkgchk " + progpath + packages[i];
System.err.println(cmd); System.err.println(cmd);
p=rt.exec(cmd, env); goodResult = command.exec(cmd, env);
} }
} }
else { else {
...@@ -97,11 +90,10 @@ public class Register{ ...@@ -97,11 +90,10 @@ public class Register{
packages[i] + "\""; packages[i] + "\"";
System.err.println(cmd); 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"); System.err.println("\nPkgChk Failed");
if(!isWindows) 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