Kaydet (Commit) b979c91b authored tarafından Tomas O'Connor's avatar Tomas O'Connor

IssueZilla 9783 - allow framework to be installed from the command line and from…

IssueZilla 9783 - allow framework to be installed from the command line and from outside of the program directory of an office installation
üst dbae842f
...@@ -37,6 +37,9 @@ public class IdeUpdater extends Thread { ...@@ -37,6 +37,9 @@ public class IdeUpdater extends Thread {
public IdeUpdater(String installPath, JLabel statusLabel, JProgressBar pBar) { public IdeUpdater(String installPath, JLabel statusLabel, JProgressBar pBar) {
if (installPath.endsWith(File.separator) == false)
installPath += File.separator;
File jeditLauncher = new File( installPath + "jedit.jar" ); File jeditLauncher = new File( installPath + "jedit.jar" );
File netbeansLauncher = new File( installPath + "bin" ); File netbeansLauncher = new File( installPath + "bin" );
...@@ -49,7 +52,6 @@ public class IdeUpdater extends Thread { ...@@ -49,7 +52,6 @@ public class IdeUpdater extends Thread {
installPath = installPath + "jars" + File.separator; installPath = installPath + "jars" + File.separator;
} }
System.out.println( "IdeUpdater installPath is " + installPath + " isNetbeansPath is " + isNetbeansPath ); System.out.println( "IdeUpdater installPath is " + installPath + " isNetbeansPath is " + isNetbeansPath );
this.installPath = installPath; this.installPath = installPath;
this.statusLabel = statusLabel; this.statusLabel = statusLabel;
......
...@@ -48,7 +48,7 @@ public class InstallWizard extends javax.swing.JFrame implements ActionListener ...@@ -48,7 +48,7 @@ public class InstallWizard extends javax.swing.JFrame implements ActionListener
//InstUtil.copy(backup, destination); //Restore typedetection.xml //InstUtil.copy(backup, destination); //Restore typedetection.xml
} }
//System.out.println( "ShutdownHook" ); System.out.println( "ShutdownHook" );
} }
InstUtil.removeTmpDir(); InstUtil.removeTmpDir();
...@@ -64,24 +64,22 @@ public class InstallWizard extends javax.swing.JFrame implements ActionListener ...@@ -64,24 +64,22 @@ public class InstallWizard extends javax.swing.JFrame implements ActionListener
public InstallWizard() { public InstallWizard() {
super("Office Scripting Framework Installer - Early Developer Release"); super("Office Scripting Framework Installer - Early Developer Release");
try {
try { System.out.print("All diagnostic output is being redirected to SFrameworkInstall.log\n");
System.out.print("All diagnostic output is being redirected to SFrameworkInstall.log\n"); System.out.print("Location: "+ System.getProperty( "user.dir" ) +
System.out.print("Location: "+ System.getProperty( "user.dir" ) + File.separator + "SFrameworkInstall.log\n");
File.separator + "SFrameworkInstall.log\n");
LogStream log = new LogStream( "SFrameworkInstall.log" );
System.setErr(log);
System.setOut(log);
}
catch( FileNotFoundException fnfe ) {
System.err.println("Office Scripting Framework Installer - Error: ");
System.err.println("Unable to create log file for installation.");
exitForm(null);
}
LogStream log = new LogStream( "SFrameworkInstall.log" );
System.setErr(log);
System.setOut(log);
}
catch( FileNotFoundException fnfe ) {
System.err.println("Office Scripting Framework Installer - Error: ");
System.err.println("Unable to create log file for installation.");
exitForm(null);
}
//setBackground(Color.WHITE); //setBackground(Color.WHITE);
setBackground(new Color(0,0,0)); setBackground(new Color(0,0,0));
locations = new ArrayList(); locations = new ArrayList();
...@@ -221,7 +219,67 @@ public class InstallWizard extends javax.swing.JFrame implements ActionListener ...@@ -221,7 +219,67 @@ public class InstallWizard extends javax.swing.JFrame implements ActionListener
* @param args the command line arguments * @param args the command line arguments
*/ */
public static void main(String args[]) { public static void main(String args[]) {
new InstallWizard().show(); String officePath = null;
String netbeansPath = null;
String jeditPath = null;
int i = 0;
while (i < args.length) {
if (args[i].equals("-help")) {
printUsage();
System.exit(0);
}
if (args[i].equals("-office"))
officePath = args[++i];
if (args[i].equals("-netbeans"))
netbeansPath = args[++i];
if (args[i].equals("-jedit"))
jeditPath = args[++i];
i++;
}
if (officePath == null && netbeansPath == null && jeditPath == null)
new InstallWizard().show();
JLabel label = new JLabel();
JProgressBar progressbar = new JProgressBar();
try {
System.out.println("Log file is: " +
System.getProperty("user.dir") +
File.separator + "SFrameworkInstall.log");
LogStream log = new LogStream( "SFrameworkInstall.log" );
System.setErr(log);
System.setOut(log);
}
catch( FileNotFoundException fnfe ) {
System.err.println("Error: Unable to create log file: "
+ fnfe.getMessage());
System.exit(-1);
}
if (officePath != null) {
XmlUpdater xud = new XmlUpdater(officePath, label, progressbar);
xud.run();
}
if (netbeansPath != null) {
IdeUpdater ideup = new IdeUpdater(netbeansPath, label, progressbar);
ideup.run();
}
if (jeditPath != null) {
IdeUpdater ideup = new IdeUpdater(jeditPath, label, progressbar);
ideup.run();
}
}
private static void printUsage() {
System.err.println("java -jar SFrameworkInstall.jar");
System.err.println("\t[-office <path_to_office_installation]");
System.err.println("\t[-netbeans <path_to_netbeans_installation]");
System.err.println("\t[-jedit <path_to_jedit_installation]");
} }
public static synchronized boolean isPatchedTypes() public static synchronized boolean isPatchedTypes()
......
...@@ -6,30 +6,23 @@ import javax.swing.*; ...@@ -6,30 +6,23 @@ import javax.swing.*;
public class Register{ public class Register{
private static JProgressBar progressBar; public static boolean register(String path, JLabel statusLabel) {
private static boolean runCommands(String url,String path, javax.swing.JLabel statusLabel){
try { try {
String s=null; String s=null;
String classpath="";
int exitcode=0; int exitcode=0;
boolean passed=true;
String env[] = new String[1]; String env[] = new String[1];
Runtime rt= Runtime.getRuntime(); Runtime rt = Runtime.getRuntime();
//String progpath=path.concat(File.separator+"program"+File.separator);
String progpath=path.concat("program"+File.separator); String progpath = path.concat("program" + File.separator);
BufferedReader stdInput;
Process p; Process p;
statusLabel.setText("Registering Scripting Framework..."); statusLabel.setText("Registering Scripting Framework...");
progressBar.setString("Registering Scripting Framework"); String opSys = System.getProperty("os.name");
progressBar.setValue(7);
String opSys =System.getProperty("os.name");
// pkgchk Scripting Framework Components // pkgchk Scripting Framework Components
statusLabel.setText("Registering Scripting Framework Components..."); statusLabel.setText("Registering Scripting Framework Components...");
System.out.println("Registering Scripting Framework Components..."); System.out.println("Registering Scripting Framework Components...");
if (opSys.indexOf("Windows") == -1){ if (opSys.indexOf("Windows") == -1){
//System.out.println( "Not Windows"); //System.out.println( "Not Windows");
env[0]="LD_LIBRARY_PATH="+progpath; env[0]="LD_LIBRARY_PATH="+progpath;
...@@ -59,7 +52,6 @@ public class Register{ ...@@ -59,7 +52,6 @@ public class Register{
System.out.println("\nPkgChk Failed \nCommand: \""+progpath+"pkgchk.exe\" \""+progpath+"ooscriptframe.zip\""); System.out.println("\nPkgChk Failed \nCommand: \""+progpath+"pkgchk.exe\" \""+progpath+"ooscriptframe.zip\"");
} }
statusLabel.setText("PkgChk Failed, please view SFrameworkInstall.log"); statusLabel.setText("PkgChk Failed, please view SFrameworkInstall.log");
passed=false;
return false; return false;
} }
...@@ -93,7 +85,6 @@ public class Register{ ...@@ -93,7 +85,6 @@ public class Register{
System.out.println("\nRegsingleton ScriptRuntimeForJava Failed.\nCommand: \""+progpath+"regsingleton.exe\" \""+path+"user"+File.separator+"uno_packages"+File.separator+"cache"+File.separator+"services.rdb\" \"drafts.com.sun.star.script.framework.theScriptRuntimeForJava=drafts.com.sun.star.script.framework.ScriptRuntimeForJava\""); System.out.println("\nRegsingleton ScriptRuntimeForJava Failed.\nCommand: \""+progpath+"regsingleton.exe\" \""+path+"user"+File.separator+"uno_packages"+File.separator+"cache"+File.separator+"services.rdb\" \"drafts.com.sun.star.script.framework.theScriptRuntimeForJava=drafts.com.sun.star.script.framework.ScriptRuntimeForJava\"");
} }
statusLabel.setText("Regsingleton ScriptRuntimeForJava Failed. please view SFrameworkInstall.log"); statusLabel.setText("Regsingleton ScriptRuntimeForJava Failed. please view SFrameworkInstall.log");
passed=false;
return false; return false;
} }
...@@ -125,7 +116,6 @@ public class Register{ ...@@ -125,7 +116,6 @@ public class Register{
System.out.println("\nRegsingleton ScriptRuntimeForJava Failed.\nCommand: \""+progpath+"regsingleton.exe\" \""+path+"user"+File.separator+"uno_packages"+File.separator+"cache"+File.separator+"services.rdb\" \"drafts.com.sun.star.script.framework.storage.theScriptStorageManager=drafts.com.sun.star.script.framework.storage.ScriptStorageManager\""); System.out.println("\nRegsingleton ScriptRuntimeForJava Failed.\nCommand: \""+progpath+"regsingleton.exe\" \""+path+"user"+File.separator+"uno_packages"+File.separator+"cache"+File.separator+"services.rdb\" \"drafts.com.sun.star.script.framework.storage.theScriptStorageManager=drafts.com.sun.star.script.framework.storage.ScriptStorageManager\"");
} }
statusLabel.setText("Regsingleton ScriptRuntimeForJava Failed, please view SFrameworkInstall.log"); statusLabel.setText("Regsingleton ScriptRuntimeForJava Failed, please view SFrameworkInstall.log");
passed=false;
return false; return false;
} }
...@@ -161,43 +151,6 @@ public class Register{ ...@@ -161,43 +151,6 @@ public class Register{
return false; return false;
} }
return true; return true;
}// windows
public static boolean register(String path, javax.swing.JLabel statusLabel,JProgressBar pBar){
progressBar=pBar;
boolean win =false;
String newString= "file://";
if (path.indexOf(":")==1){
newString=newString.concat("/");
win=true;
}
String tmpStr1="";
String tmpStr2="";
newString=newString.concat(path.replace('\\','/'));
int i=0;
if (newString.indexOf(" ")>0){
tmpStr1=tmpStr1.concat(newString.substring(i,newString.indexOf(" ")));
tmpStr1=tmpStr1.concat("\\ ");
newString=newString.substring(newString.indexOf(" ")+1,newString.length());
}
tmpStr1=tmpStr1.concat(newString);
//System.out.println(""+tmpStr1);
char url[]=path.toCharArray();
char test[]=new char[path.length()*2];
int j=0;
path = path.substring (0,path.length()-1);
//runCommands(tmpStr1,path, statusLabel);
if( !runCommands(tmpStr1, path, statusLabel) ){
return false;
}
return true;
}// register }// register
}//Register }//Register
...@@ -39,6 +39,7 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table ...@@ -39,6 +39,7 @@ public class Version extends javax.swing.JPanel implements ActionListener, Table
JPanel versionPanel = new JPanel(); JPanel versionPanel = new JPanel();
setLayout(new BorderLayout()); setLayout(new BorderLayout());
System.out.println("Initialising versions");
File fileVersions = null; File fileVersions = null;
try try
......
...@@ -44,7 +44,7 @@ public class Welcome extends javax.swing.JPanel implements ActionListener { ...@@ -44,7 +44,7 @@ public class Welcome extends javax.swing.JPanel implements ActionListener {
//area.setText("\n \t Please ensure that you have exited from Office"); //area.setText("\n \t Please ensure that you have exited from Office");
String message = "\n \t Please ensure that you have exited from Office"; String message = "\n \t Please ensure that you have exited from Office";
String userDir = (String) System.getProperty( "user.dir" ); /* String userDir = (String) System.getProperty( "user.dir" );
boolean isValid = validateCurrentUserDir(userDir); boolean isValid = validateCurrentUserDir(userDir);
if( !isValid ) { if( !isValid ) {
nextButtonEnable = false; nextButtonEnable = false;
...@@ -57,7 +57,7 @@ public class Welcome extends javax.swing.JPanel implements ActionListener { ...@@ -57,7 +57,7 @@ public class Welcome extends javax.swing.JPanel implements ActionListener {
String offInstallPth = null; String offInstallPth = null;
offInstallPth = userDir.substring( 0, programPosition ); offInstallPth = userDir.substring( 0, programPosition );
wizard.storeLocation(offInstallPth); wizard.storeLocation(offInstallPth); */
setUpWelcomePanel(message); setUpWelcomePanel(message);
}//GEN-END:initComponents }//GEN-END:initComponents
...@@ -66,7 +66,7 @@ public class Welcome extends javax.swing.JPanel implements ActionListener { ...@@ -66,7 +66,7 @@ public class Welcome extends javax.swing.JPanel implements ActionListener {
area.setText( message ); area.setText( message );
welcomePanel.add(area, java.awt.BorderLayout.CENTER); welcomePanel.add(area, java.awt.BorderLayout.CENTER);
add(welcomePanel, java.awt.BorderLayout.CENTER); add(welcomePanel, java.awt.BorderLayout.CENTER);
NavPanel nav = new NavPanel(wizard, false, nextButtonEnable, true, "", InstallWizard.FINAL); NavPanel nav = new NavPanel(wizard, false, nextButtonEnable, true, "", InstallWizard.VERSIONS);
nav.setNextListener(this); nav.setNextListener(this);
add(nav, java.awt.BorderLayout.SOUTH); add(nav, java.awt.BorderLayout.SOUTH);
......
...@@ -330,8 +330,9 @@ public class XmlUpdater extends Thread { ...@@ -330,8 +330,9 @@ public class XmlUpdater extends Thread {
//-------------------------------- //--------------------------------
//System.out.println("About to call register"); progressBar.setString("Registering Scripting Framework");
if(!Register.register(installPath+File.separator, statusLabel, progressBar) ) progressBar.setValue(7);
if(!Register.register(installPath+File.separator, statusLabel) )
{ {
onInstallComplete(); onInstallComplete();
return; return;
......
...@@ -9,108 +9,85 @@ import javax.swing.*; ...@@ -9,108 +9,85 @@ import javax.swing.*;
public class ZipData public class ZipData
{ {
private static String zipfile=null; public ZipData(String file) {
public ZipData(String file){
zipfile=file;
} }
public static boolean extractEntry(String entry, String destination, javax.swing.JLabel statusLabel){ public boolean extractEntry(String entry, String destination,
boolean status = false; JLabel statusLabel) {
System.err.println("Copying: "+entry);
System.err.println("in: "+zipfile); OutputStream out = null;
System.err.println(" to: "+destination); InputStream in = null;
System.out.println("Copying: " + entry);
System.out.println("To: " + destination);
if (statusLabel != null) { if (statusLabel != null) {
statusLabel.setText("Copying " + entry); statusLabel.setText("Copying " + entry);
System.out.println("Copying " + entry); System.out.println("Copying " + entry);
} }
try{
ZipFile zip = new ZipFile(zipfile); if (entry.lastIndexOf("/") != -1) {
ZipEntry zentry = zip.getEntry(entry); String name = entry.substring(entry.lastIndexOf("/") + 1);
InputStream is =zip.getInputStream(zentry); destination = destination.concat(name);
if (entry.lastIndexOf("/")!=-1){
entry=entry.substring(entry.lastIndexOf("/")+1,entry.length());
destination = destination.concat(entry);
} }
else{ else {
destination = destination.concat(entry); destination = destination.concat(entry);
} }
System.out.println("\n Unzipping "+zentry.getName()+" to "+destination); System.out.println("Unzipping " + entry + " to " + destination);
FileOutputStream fos = new FileOutputStream(destination);
int bytesread=0,offset=0;
byte[] bytearr = new byte[10000];
bytesread= is.read(bytearr);
while (bytesread!=-1){
fos.write(bytearr, 0,bytesread);
bytesread= is.read(bytearr);
offset=offset+bytesread;
}
fos.close();
is.close();
status = true;
} try {
catch(Exception e){ out = new FileOutputStream(destination);
System.out.println("\nZip Error: File not found");
System.out.println(e.getMessage());
e.printStackTrace();
status = false;
if (statusLabel != null) {
statusLabel.setText("Failed extracting " + entry + " , please view SFramework.log");
System.out.println("Failed extracting " + entry + " to " + destination);
} }
} catch (IOException ioe) {
return status; System.err.println("Error opening " + destination +
} ": " + ioe.getMessage());
if (statusLabel != null)
statusLabel.setText("Error opening" + destination +
"see SFramework.log for more information");
public static void getContents(){ return false;
try }
{
ZipFile zip = new ZipFile(zipfile);
ZipEntry entry = null; if (entry.startsWith("/") == false)
entry = "/" + entry;
Object ObjArray[] =new Object[zip.size()]; in = this.getClass().getResourceAsStream(entry);
int i =0; if (in == null) {
for (Enumeration e = zip.entries(); e.hasMoreElements(); entry = (ZipEntry)e.nextElement()) System.err.println("File " + entry + " not found in jar file");
{
if (entry != null){
//System.out.println(entry.getName()+"\n");
ObjArray[i]=entry.getName();
i++;
}
} if (statusLabel != null)
statusLabel.setText("Failed extracting " + entry +
"see SFramework.log for more information");
return false;
} }
catch (IOException e)
{
System.err.println(e);
}
}
public static void getContents(String zipfile){ try {
try byte[] bytes = new byte[1024];
{ int len;
ZipFile zip = new ZipFile(zipfile);
ZipEntry entry = null; while ((len = in.read(bytes)) != -1)
for (Enumeration e = zip.entries(); e.hasMoreElements(); entry = (ZipEntry)e.nextElement()) out.write(bytes, 0, len);
{
//System.out.println(entry);
}
} }
catch (IOException e) catch (IOException ioe) {
{ System.err.println("Error writing " + destination + ": " +
System.err.println(e); ioe.getMessage());
if (statusLabel != null)
statusLabel.setText("Failed writing " + destination +
"see SFramework.log for more information");
return false;
} }
} finally {
try {
in.close();
public static void main(String args[]) out.close();
{ }
getContents(args[0]); catch (IOException ioe) {
}
}
return true;
} }
} }
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