diff options
Diffstat (limited to 'javainstaller2/src/JavaSetup/org/openoffice/setup/Util')
17 files changed, 3495 insertions, 0 deletions
diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/AbortInstaller.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/AbortInstaller.java new file mode 100755 index 000000000000..7df874a31fbc --- /dev/null +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/AbortInstaller.java @@ -0,0 +1,52 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.setup.Util; + +import org.openoffice.setup.InstallData; +import java.util.Vector; + +public class AbortInstaller { + + private AbortInstaller() { + } + + static public void abortInstallProcess() { + InstallData installData = InstallData.getInstance(); + installData.setIsAbortedInstallation(true); + + if ( installData.isInstallationMode() ) { + String log = "<b>Installation was aborted</b><br>"; + LogManager.addLogfileComment(log); + } else { + String log = "<b>Uninstallation was aborted</b><br>"; + LogManager.addLogfileComment(log); + } + + } + +} diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Calculator.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Calculator.java new file mode 100755 index 000000000000..2042cc738c52 --- /dev/null +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Calculator.java @@ -0,0 +1,88 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.setup.Util; + +import org.openoffice.setup.SetupData.PackageDescription; +import java.util.Vector; +import org.openoffice.setup.InstallData; +import org.openoffice.setup.ResourceManager; + +public class Calculator { + + private Calculator() { + } + + static private int calculateInstallSize(Vector allPackages) { + + int value = 0; + + for (int i = 0; i < allPackages.size(); i++) { + PackageDescription packageData = (PackageDescription)allPackages.get(i); + int size = packageData.getSize(); + value = value + size; + } + + return value; + } + + static private boolean missingDiscSpace(int required, int available) { + boolean missingDiscSpace = true; + + if ( required < available ) { + missingDiscSpace = false; + } + + // missingDiscSpace = true; // for testing reasons + return missingDiscSpace; + } + + static public boolean notEnoughDiscSpace(InstallData data) { + + Vector installPackages = data.getInstallPackages(); + // Calculate size of selected modules + int installationSize = calculateInstallSize(installPackages); + + // Compare with available space + int availableDiscSpace = data.getAvailableDiscSpace(); + + // Show warning and repeat dialog, if not sufficient disc space available + boolean insufficientDiscSpace = missingDiscSpace(installationSize, availableDiscSpace); + + if ( insufficientDiscSpace ) { + String message = ResourceManager.getString("String_Discspace_Insufficient") + "\n" + + ResourceManager.getString("String_Discspace_Required") + ": " + installationSize + " kB." + "\n" + + ResourceManager.getString("String_Discspace_Available") + ": " + availableDiscSpace + " kB." + "\n" + + ResourceManager.getString("String_Discspace_Tip"); + String title = ResourceManager.getString("String_Error"); + Informer.showErrorMessage(message, title); + } + + return insufficientDiscSpace; + } + +} diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Controller.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Controller.java new file mode 100755 index 000000000000..bbca464fd72a --- /dev/null +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Controller.java @@ -0,0 +1,291 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.setup.Util; + +import java.io.File; +import java.util.Vector; +import org.openoffice.setup.InstallData; +import org.openoffice.setup.ResourceManager; +import org.openoffice.setup.SetupData.SetupDataProvider; +import org.openoffice.setup.Util.LogManager; + +public class Controller { + + private Controller() { + } + + static public void checkPackagePathExistence(InstallData installData) { + String packagePath = installData.getPackagePath(); + if (( packagePath == null ) || ( packagePath.equals(""))) { + String message = ResourceManager.getString("String_InstallationOngoing_PackagePath_Not_Found"); + String title = ResourceManager.getString("String_Error"); + Informer.showErrorMessage(message, title); + System.exit(1); + } + } + + static public void checkPackageFormat(InstallData installData) { + String packageFormat = installData.getPackageFormat(); + String os = installData.getOSType(); + + boolean notSupportedPackageFormat = true; + + // Show warnings for currently not supported combinations of OS and package format. + // This has to be adapted if further OS or package formats are supported. + + if (( os.equalsIgnoreCase("SunOS") ) && ( packageFormat.equalsIgnoreCase("pkg") )) { + notSupportedPackageFormat = false; + } + + if (( os.equalsIgnoreCase("Linux") ) && ( packageFormat.equalsIgnoreCase("rpm") )) { + notSupportedPackageFormat = false; + } + + // Inform user about not supported package format and exit program + + if ( notSupportedPackageFormat ) { + System.err.println("Error: Package format not supported by this OS!"); + String mainmessage = ResourceManager.getString("String_Packageformat_Not_Supported"); + String osstring = ResourceManager.getString("String_Operating_System"); + String formatstring = ResourceManager.getString("String_Packageformat"); + String message = mainmessage + "\n" + osstring + ": " + os + "\n" + formatstring + ": " + packageFormat; + String title = ResourceManager.getString("String_Error"); + Informer.showErrorMessage(message, title); + System.exit(1); + } + } + + static public void collectSystemLanguages(InstallData installData) { + String pkgCommand = ""; + String[] pkgCommandArray; + String adminFileName = ""; + String log = ""; + Vector returnVector = new Vector(); + Vector returnErrorVector = new Vector(); + int returnValue; + + pkgCommand = "locale -a"; + pkgCommandArray = new String[2]; + pkgCommandArray[0] = "locale"; + pkgCommandArray[1] = "-a"; + returnValue = ExecuteProcess.executeProcessReturnVector(pkgCommandArray, returnVector, returnErrorVector); + + if ( returnValue == 0 ) { + log = pkgCommand + "<br><b>Returns: " + returnValue + " Successful command</b><br>"; + LogManager.addCommandsLogfileComment(log); + + // System.err.println("Available languages 1: "); + // for (int i = 0; i < returnVector.size(); i++) { + // System.err.println(returnVector.get(i)); + // } + + // Collecting "en-US" instead of "en-US.UTF8" + Vector realVector = new Vector(); + + for (int i = 0; i < returnVector.size(); i++) { + String oneLang = (String)returnVector.get(i); + int position = oneLang.indexOf("."); + if ( position > -1 ) { + oneLang = oneLang.substring(0, position); + } + if ( ! realVector.contains(oneLang)) { + realVector.add(oneLang); + } + } + + // System.err.println("Available languages 2: "); + // for (int i = 0; i < realVector.size(); i++) { + // System.err.println(realVector.get(i)); + // } + + installData.setSystemLanguages(realVector); + } else { // an error occured + log = pkgCommand + "<br><b>Returns: " + returnValue + " An error occured</b><br>"; + LogManager.addCommandsLogfileComment(log); + System.err.println("Error in command: " + pkgCommand); + for (int i = 0; i < returnErrorVector.size(); i++) { + LogManager.addCommandsLogfileComment((String)returnErrorVector.get(i)); + System.err.println(returnErrorVector.get(i)); + } + } + } + + static public boolean createdSubDirectory(String dir) { + boolean createdDirectory = false; + boolean errorShown = false; + String subDirName = "testdir"; + File testDir = new File(dir, subDirName); + try { + createdDirectory = SystemManager.create_directory(testDir.getPath()); + } + catch (SecurityException ex) { + String message = ResourceManager.getString("String_ChooseDirectory_No_Write_Access") + ": " + dir; + String title = ResourceManager.getString("String_Error"); + Informer.showErrorMessage(message, title); + errorShown = true; + } + + if (( ! createdDirectory ) && ( ! errorShown )) { + String message = ResourceManager.getString("String_ChooseDirectory_No_Write_Access") + ": " + dir; + String title = ResourceManager.getString("String_Error"); + Informer.showErrorMessage(message, title); + errorShown = true; + } + + if ( SystemManager.exists_directory(testDir.getPath()) ) { + testDir.delete(); + } + + return createdDirectory; + } + + static public boolean createdDirectory(String dir) { + boolean createdDirectory = false; + try { + createdDirectory = SystemManager.create_directory(dir); + } + catch (SecurityException ex) { + // message = ResourceManager.getString("String_ChooseDirectory_Not_Allowed") + ": " + dir; + // title = ResourceManager.getString("String_Error"); + // Informer.showErrorMessage(message, title); + } + + if ( ! createdDirectory ) { + String message = ResourceManager.getString("String_ChooseDirectory_No_Success") + ": " + dir; + String title = ResourceManager.getString("String_Error"); + Informer.showErrorMessage(message, title); + } + + return createdDirectory; + } + + static public boolean reducedRootWritePrivileges() { + Vector vec = new Vector(); + File dir = new File("/usr"); + vec.add(dir); + dir = new File("/etc"); + vec.add(dir); + + boolean restrictedWritePrivilges = false; + + // Check for zones. If "zonename" is successful and the name is not "global", + // this is a "sparse zone". + // Alternative: Simply always check, if root has write access in selected directories. + + for (int i = 0; i < vec.size(); i++) { + File directory = (File)vec.get(i); + if ( directory.exists() ) { + // do we have write privileges inside the directory + String tempDirName = "temptestdir"; + File tempDir = new File(directory, tempDirName); + + if ( SystemManager.createDirectory(tempDir) ) { + SystemManager.removeDirectory(tempDir); + } else { + restrictedWritePrivilges = true; + System.err.println("Restricted Root privileges. No write access in " + directory.getPath()); + break; + } + } + } + + return restrictedWritePrivilges; + } + + static public void checkForNewerVersion(InstallData installData) { + LogManager.setCommandsHeaderLine("Checking change installation"); + InstallChangeCtrl.checkInstallChange(installData); + + if ( installData.newerVersionExists() ) { + // Inform user about a newer version installed + SetupDataProvider.setNewMacro("DIR", installData.getInstallDefaultDir()); // important for string replacement + + System.err.println("Error: A newer version is already installed in " + installData.getInstallDefaultDir() + " !"); + String message1 = ResourceManager.getString("String_Newer_Version_Installed_Found") + + "\n" + installData.getInstallDefaultDir() + "\n"; + String message2 = ResourceManager.getString("String_Newer_Version_Installed_Remove"); + String message = message1 + "\n" + message2; + String title = ResourceManager.getString("String_Error"); + Informer.showErrorMessage(message, title); + System.exit(1); + } + } + + static public void checkForUidFile(InstallData installData) { + // check existence of getuid.so + File getuidFile = Controller.findUidFile(installData); + + if (( getuidFile == null ) || (! getuidFile.exists()) ) { + // Root privileges required -> abort installation + System.err.println("Root privileges required for installation!"); + String message = ResourceManager.getString("String_Root_Privileges_Required_1") + "\n" + + ResourceManager.getString("String_Root_Privileges_Required_2"); + String title = ResourceManager.getString("String_Error"); + Informer.showErrorMessage(message, title); + System.exit(1); + } else { + installData.setGetUidPath(getuidFile.getPath()); + } + } + + static private File findUidFile(InstallData data) { + + File getuidFile = null; + + if ( data.isInstallationMode()) { + String getuidpath = System.getProperty("GETUID_PATH"); + + if ( getuidpath != null ) { + getuidFile = new File(getuidpath); + + if (( getuidFile.isDirectory() ) && ( ! getuidFile.isFile() )) { + // Testing, if GETUID_PATH only contains the path, not the filename + String defaultfilename = "getuid.so"; + getuidFile = new File(getuidpath, defaultfilename); + + if ( ! getuidFile.exists() ) { + getuidFile = null; + } + } + } + + // File resourceRoot = data.getResourceRoot(); + // String getuidString = "getuid.so"; + // if ( resourceRoot != null ) { + // File getuidDir = new File (data.getInfoRoot(), "getuid"); + // getuidFile = new File(getuidDir, getuidString); + // } + + } else { + getuidFile = new File(data.getGetUidPath()); + } + + return getuidFile; + } + +} diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Converter.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Converter.java new file mode 100755 index 000000000000..411351b1139d --- /dev/null +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Converter.java @@ -0,0 +1,95 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.setup.Util; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Vector; + +public class Converter { + + private Converter() { + } + + static public String[] convertHashmapToStringArray(HashMap map) { + + int size = map.size(); + String[] myStringArray = new String[size]; + + Iterator m = map.entrySet().iterator(); + int counter = 0; + + while ( m.hasNext() ) { + Map.Entry entry = (Map.Entry) m.next(); + String env = entry.getKey() + "=" + entry.getValue(); + myStringArray[counter] = env; + counter = counter + 1; + } + + return myStringArray; + } + + static public HashMap convertVectorToHashmap(Vector vec) { + HashMap map = new HashMap(); + + for (int i = 0; i < vec.size(); i++) { + String key = null; + String value = null; + + String line = (String)vec.get(i); + int position = line.indexOf("="); + if ( position > -1 ) { + key = line.substring(0, position); + value = line.substring(position + 1, line.length()); + } else { + key = line; + value = null; + } + + map.put(key, value); + } + + return map; + } + + static public Vector convertHashMapToVector(HashMap hash) { + Vector vec = new Vector(); + + Iterator m = hash.entrySet().iterator(); + + while ( m.hasNext() ) { + Map.Entry entry = (Map.Entry) m.next(); + String line = entry.getKey() + "=" + entry.getValue(); + vec.add(line); + } + + return vec; + } + +} diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/DialogFocusTraversalPolicy.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/DialogFocusTraversalPolicy.java new file mode 100644 index 000000000000..ae9950841968 --- /dev/null +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/DialogFocusTraversalPolicy.java @@ -0,0 +1,115 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.setup.Util; + +import java.awt.FocusTraversalPolicy; +import javax.swing.JComponent; + +public class DialogFocusTraversalPolicy extends FocusTraversalPolicy { + + private JComponent order[]; + private java.util.List list; + + public DialogFocusTraversalPolicy(JComponent _order[]) { + order = _order; + list = java.util.Arrays.asList(order); + } + + public java.awt.Component getFirstComponent(java.awt.Container focusCycleRoot) { + return order[0]; + } + + public java.awt.Component getLastComponent(java.awt.Container focusCycleRoot) { + return order[order.length - 1]; + } + + public java.awt.Component getComponentAfter(java.awt.Container focusCycleRoot, java.awt.Component aComponent) { + int index = 0,x = -1; + index = list.indexOf(aComponent); + index++; // increasing automatically + if(!order[index % order.length].isEnabled() || + !order[index % order.length].isVisible()) { + x = index; + index = -1; + for (; x != order.length; x++) { + if(order[x].isEnabled() && order[x].isVisible()) { + index = x; + break; + } + } + if(index == -1) { + x = list.indexOf(aComponent); + for(int y = 0; y <= x; y++) { + if(order[y].isEnabled() && order[x].isVisible()) { + index = y; + break; + } + } + } + } + return order[ index % order.length]; + } + + public java.awt.Component getComponentBefore(java.awt.Container focusCycleRoot, java.awt.Component aComponent) { + int index = list.indexOf(aComponent), x = -1; + index--; + if(!order[(index + order.length) % order.length].isEnabled() || + !order[(index + order.length) % order.length].isVisible()) { + x = index; + index = -1; + for(; x >= 0; x--) { + if(order[x].isEnabled() && order[x].isVisible()) { + index = x; + break; + } + } + // if nothing has changed + if(index == -1) { + x = list.indexOf(aComponent); + for(int y = order.length -1; y >= x; y--) { + if(order[y].isEnabled() && order[x].isVisible()) { + index = y; + break; + } + } + } + } + return order[ (index + order.length) % order.length]; + } + + public java.awt.Component getDefaultComponent(java.awt.Container focusCycleRoot) { + return order[0]; + } + + public java.awt.Component getInitialComponent(java.awt.Window window) { + return order[0]; + } + +} + + diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Dumper.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Dumper.java new file mode 100755 index 000000000000..3024b0f1a676 --- /dev/null +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Dumper.java @@ -0,0 +1,202 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.setup.Util; + +import org.openoffice.setup.InstallData; +import org.openoffice.setup.SetupData.PackageDescription; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.Map; +import java.util.Properties; +import java.util.Vector; + + +public class Dumper { + + private Dumper() { + } + + static public void dumpPackageSettings(PackageDescription packageData) { + + if ( packageData.isLeaf() ) { + System.out.println("Name: " + packageData.getName() + + " State: " + packageData.getSelectionState() + + " " + packageData.getPackageName()); + } else { + System.out.println("Nod-Name: " + packageData.getName() + + " State: " + packageData.getSelectionState()); + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + dumpPackageSettings(child); + } + + } + + static public void dumpModuleStates(PackageDescription packageData) { + + System.err.println("Name: " + packageData.getName() + + " State: " + packageData.getSelectionState() + + " " + packageData.getPackageName()); + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + dumpModuleStates(child); + } + } + + static private String getStateString(int state) { + String stateString = null; + + if ( state == 0 ) { + stateString = "DONT_INSTALL"; + } else if ( state == 1 ) { + stateString = "INSTALL"; + } else if ( state == 2 ) { + stateString = "INSTALL_SOME"; + } else if ( state == 3 ) { + stateString = "REMOVE"; + } else if ( state == 4 ) { + stateString = "DONT_REMOVE"; + } else if ( state == 5 ) { + stateString = "REMOVE_SOME"; + } else if ( state == 6 ) { + stateString = "IGNORE"; + } else if ( state == 7 ) { + stateString = "DONT_KNOW"; + } else { + stateString = null; + } + + return stateString; + } + + static private void logModuleStatesHelper(PackageDescription packageData) { + int state = packageData.getSelectionState(); + String stateStr = getStateString(state); + + LogManager.addModulesLogfileComment("Name: " + packageData.getName() + + " State: " + stateStr + + " " + packageData.getPackageName()); + + // System.err.println("Name: " + packageData.getName() + + // " State: " + stateStr + + // " " + packageData.getPackageName()); + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + logModuleStatesHelper(child); + } + } + + static public void logModuleStates(PackageDescription packageData, String text) { + LogManager.setModulesLogFileHeaderLine(text); + logModuleStatesHelper(packageData); + } + + static public void logPackagesToInstall(Vector packages, String text) { + PackageDescription packageData = null; + LogManager.setModulesLogFileHeaderLine(text); + for (int i = 0; i < packages.size(); i++) { + packageData = (PackageDescription)packages.get(i); + LogManager.addModulesLogfileComment("Name: " + packageData.getName() + + " " + packageData.getPackageName()); + } + } + + static public void dumpInstallPackages(PackageDescription packageData) { + + if (( packageData.isLeaf() ) && ( packageData.getSelectionState() == packageData.INSTALL )) { + System.out.println("Now installing: " + packageData.getPackageName()); + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + dumpInstallPackages(child); + } + } + + static public void dumpUninstallPackages(PackageDescription packageData) { + + if (( packageData.isLeaf() ) && ( packageData.getSelectionState() == packageData.REMOVE )) { + System.out.println("Now uninstalling: " + packageData.getPackageName()); + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + dumpUninstallPackages(child); + } + } + + static public void dumpAllRpmInfo(PackageDescription packageData) { + + if (( packageData.getPackageName() != null ) && ( ! packageData.getPackageName().equals(""))) { + if ( packageData.pkgExists() ) { + System.err.println("RPM data: " + packageData.getPkgRealName() + " : " + + packageData.getPkgVersion() + " : " + + packageData.getPkgRelease() + " : " + + packageData.getPackageName() ); + } + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + dumpAllRpmInfo(child); + } + + } + + static public void dumpNewInstallData() { + InstallData data = InstallData.getInstance(); + System.err.println("PackagePath: " + data.getPackagePath()); + System.err.println("AdminFileReloc: " + data.getAdminFileNameReloc()); + System.err.println("AdminFileRelocNoDepends: " + data.getAdminFileNameRelocNoDepends()); + System.err.println("AdminFileNoReloc: " + data.getAdminFileNameNoReloc()); + System.err.println("AdminFileNoRelocNoDepends: " + data.getAdminFileNameNoRelocNoDepends()); + System.err.println("DatabasePath: " + data.getDatabasePath()); + System.err.println("InstallDir: " + data.getInstallDir()); + System.err.println("Original privileges: " + data.getStoredInstallationPrivileges()); + System.err.println("getuid.so File: " + data.getGetUidPath()); + } + + static public void dumpAllProperties() { + Properties properties = System.getProperties(); + + int size = properties.size(); + Iterator m = properties.entrySet().iterator(); + int counter = 0; + + while ( m.hasNext() ) { + Map.Entry entry = (Map.Entry) m.next(); + String env = entry.getKey() + "=" + entry.getValue(); + System.err.println(env); + } + } + +} diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/ExecuteProcess.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/ExecuteProcess.java new file mode 100755 index 000000000000..c86d4204fcc1 --- /dev/null +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/ExecuteProcess.java @@ -0,0 +1,114 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.setup.Util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Vector; + +public class ExecuteProcess { + + private ExecuteProcess() { + } + + static public int executeProcessReturnValue(String[] command) { + // usage of String arrays because of blanks in pathes + int returnValue = 0; + + try { + Process p = Runtime.getRuntime().exec(command); + p.waitFor(); + returnValue = p.exitValue(); + } catch ( IOException ioe ) { + System.err.println("IOError:" + ioe ); + } catch ( InterruptedException ie ) { + System.err.println("Interrupted Exception:" + ie ); + } + + return returnValue; + } + + static public int executeProcessReturnVector(String[] command, Vector returnVector, Vector returnErrorVector) { + // usage of String arrays because of blanks in pathes + int returnValue = -3; + + try { + Process p = Runtime.getRuntime().exec(command); + + BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); + BufferedReader errorIn = new BufferedReader(new InputStreamReader(p.getErrorStream())); + for ( String s; ( s = in.readLine()) != null; ) { + returnVector.add(s); + } + for ( String t; ( t = errorIn.readLine()) != null; ) { + returnErrorVector.add(t); + } + + p.waitFor(); + returnValue = p.exitValue(); + + } catch ( InterruptedException ioe ) { + System.err.println("Interrupted Exception Error: " + ioe ); + } catch ( IOException ioe ) { + System.err.println("IOError: " + ioe ); + } + + return returnValue; + } + + static public int executeProcessReturnVectorEnv(String[] command, String[] envP, Vector returnVector, Vector returnErrorVector) { + // usage of String arrays because of blanks in pathes + int returnValue = -3; + + try { + Process p = Runtime.getRuntime().exec(command, envP); + + // Solaris has to use the ErrorStream (do not log license texts), Linux the InputStream + BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); + BufferedReader errorIn = new BufferedReader(new InputStreamReader(p.getErrorStream())); + for ( String s; ( s = in.readLine()) != null; ) { + returnVector.add(s); + } + for ( String t; ( t = errorIn.readLine()) != null; ) { + returnErrorVector.add(t); + } + + p.waitFor(); + returnValue = p.exitValue(); + + } catch ( InterruptedException ioe ) { + System.err.println("Interrupted Exception Error: " + ioe ); + } catch ( IOException ioe ) { + System.err.println("IOError: " + ioe ); + } + + return returnValue; + } + +} diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/FileExtensionFilter.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/FileExtensionFilter.java new file mode 100755 index 000000000000..35a7c0b6dcbc --- /dev/null +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/FileExtensionFilter.java @@ -0,0 +1,53 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.setup.Util; + +import java.io.File; +import java.io.FilenameFilter; + +public class FileExtensionFilter implements FilenameFilter { + + private String fileExtension; + + public FileExtensionFilter(String extension) { + fileExtension = extension; + if ( ! fileExtension.startsWith(".") ) { + fileExtension = "." + fileExtension; + } + } + + public boolean accept(File dir, String name) { + if (name.endsWith(fileExtension)) { + File candidate = new File(dir, name); + if (candidate.isFile() && candidate.canRead()) { + return true; + } + } + return false; + } +}
\ No newline at end of file diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/InfoCtrl.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/InfoCtrl.java new file mode 100755 index 000000000000..d5e9023a821e --- /dev/null +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/InfoCtrl.java @@ -0,0 +1,163 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.setup.Util; + +import org.openoffice.setup.InstallData; +import org.openoffice.setup.SetupData.PackageDescription; +import org.openoffice.setup.SetupData.ProductDescription; +import java.util.Enumeration; +import java.util.Vector; + +public class InfoCtrl { + + private InfoCtrl() { + } + + static public String setHtmlFrame(String position, String htmlInfoText) { + if ( position.equals("header") ) { + htmlInfoText = "<HTML><BODY><FONT FACE=\"sans-serif\" SIZE=3>"; + } + else if ( position.equals("end")) { + htmlInfoText = htmlInfoText + "</FONT></BODY></HTML>"; + } + + return htmlInfoText; + } + + static public String setReadyToInstallInfoText(ProductDescription productData, String htmlInfoText) { + // String oneline = "-------------------------------------------------------------------"; + String oneline = "-------------------------------------------------------------"; + htmlInfoText = htmlInfoText + "<b>Product</b>: " + productData.get("product_fullname") + "<br>"; + InstallData data = InstallData.getInstance(); + htmlInfoText = htmlInfoText + "<b>Location</b>: " + data.getInstallDefaultDir() + "<br>"; + htmlInfoText = htmlInfoText + oneline + "<br>"; + + return htmlInfoText; + } + + static public String setReadyToInstallInfoText(PackageDescription packageData, String htmlInfoText) { + // setHtmlInfoText(packageData, 0); + InstallData data = InstallData.getInstance(); + if ( data.isInstallationMode() ) { + htmlInfoText = setReadyToInstallInfoText(packageData, "", htmlInfoText); + } else { + htmlInfoText = setReadyToUninstallInfoText(packageData, "", htmlInfoText); + } + return htmlInfoText; + } + + // private void setReadyToInstallInfoText(PackageDescription packageData, Integer indent) { + static private String setReadyToInstallInfoText(PackageDescription packageData, String indent, String htmlInfoText) { + // String spacer = "<spacer type=horizontal size=" + indent.toString() + ">"; + // System.out.println(ind); + if (( packageData.isLeaf() ) || ( packageData.isAllChildrenHidden() )) { + if ( ! packageData.isHidden() ) { + if ( packageData.getSelectionState() == packageData.INSTALL ) { + // htmlInfoText = htmlInfoText + spacer + packageData.getName() + "<br>"; + htmlInfoText = htmlInfoText + indent + packageData.getName() + "<br>"; + } + } + } + + if (( ! packageData.isLeaf() ) && ( ! packageData.isAllChildrenHidden() )) { + if ( ! packageData.isHidden() ) { + if (( packageData.getSelectionState() == packageData.INSTALL ) || + ( packageData.getSelectionState() == packageData.INSTALL_SOME )) { + // htmlInfoText = htmlInfoText + spacer + "<b>" + packageData.getName() + "</b>" + "<br>"; + // htmlInfoText = htmlInfoText + indent + "<b>" + packageData.getName() + "</b>" + "<br>"; + htmlInfoText = htmlInfoText + indent + packageData.getName() + "<br>"; + } + } + + indent = indent + ".."; + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + htmlInfoText = setReadyToInstallInfoText(child, indent, htmlInfoText); + } + } + + return htmlInfoText; + } + + // private void setReadyToUninstallInfoText(PackageDescription packageData, Integer indent, String htmlInfoText) { + static private String setReadyToUninstallInfoText(PackageDescription packageData, String indent, String htmlInfoText) { + // String spacer = "<spacer type=horizontal size=" + indent.toString() + ">"; + // System.out.println(ind); + if (( packageData.isLeaf() ) || ( packageData.isAllChildrenHidden() )) { + if ( ! packageData.isHidden() ) { + if ( packageData.getSelectionState() == packageData.REMOVE ) { + // htmlInfoText = htmlInfoText + spacer + packageData.getName() + "<br>"; + htmlInfoText = htmlInfoText + indent + packageData.getName() + "<br>"; + } + } + } + + if (( ! packageData.isLeaf() ) && ( ! packageData.isAllChildrenHidden() )) { + if ( ! packageData.isHidden() ) { + if (( packageData.getSelectionState() == packageData.REMOVE ) || + ( packageData.getSelectionState() == packageData.REMOVE_SOME )) { + // htmlInfoText = htmlInfoText + spacer + "<b>" + packageData.getName() + "</b>" + "<br>"; + // htmlInfoText = htmlInfoText + indent + "<b>" + packageData.getName() + "</b>" + "<br>"; + htmlInfoText = htmlInfoText + indent + packageData.getName() + "<br>"; + } + } + + indent = indent + ".."; + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + htmlInfoText = setReadyToUninstallInfoText(child, indent, htmlInfoText); + } + } + + return htmlInfoText; + } + + static public String setInstallLogInfoText(ProductDescription productData, String htmlInfoText) { + // String separatorline = "-------------------------------------------------------------------"; + String separatorline = "-------------------------------------------------------------"; + htmlInfoText = htmlInfoText + "<b>Product</b>: " + productData.get("product_fullname") + "<br>"; + InstallData data = InstallData.getInstance(); + htmlInfoText = htmlInfoText + "<b>Location</b>: " + data.getInstallDir() + "<br>"; + htmlInfoText = htmlInfoText + "<b>Operating system</b>: " + data.getOSType() + "<br>"; + if ( data.isUserInstallation() ) { + htmlInfoText = htmlInfoText + "<b>Installation type</b>: " + "User installation" + "<br>"; + } else { + htmlInfoText = htmlInfoText + "<b>Installation type</b>: " + "Root installation" + "<br>"; + } + + htmlInfoText = htmlInfoText + separatorline + "<br>"; + + htmlInfoText = LogManager.publishLogfileContent(htmlInfoText, separatorline); + htmlInfoText = LogManager.publishCommandsLogfileContent(htmlInfoText); + + return htmlInfoText; + } + +} diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/InfoDir.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/InfoDir.java new file mode 100755 index 000000000000..97b3073c3c32 --- /dev/null +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/InfoDir.java @@ -0,0 +1,319 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.setup.Util; + +import org.openoffice.setup.InstallData; +import org.openoffice.setup.ResourceManager; +import java.io.File; +import java.util.Vector; + +public class InfoDir { + + private InfoDir() { + } + + static private String copySourceFile(String fileName) { + InstallData data = InstallData.getInstance(); + File jarFile = data.getJarFilePath(); + String destFile = null; + + if ( jarFile != null ) { + String sourceDir = jarFile.getParent(); + File sourceFileFile = new File(sourceDir, fileName); + String sourceFile = sourceFileFile.getPath(); + + // String jarFileName = jarFile.getName(); + File destDir = new File(data.getInstallDefaultDir(), data.getProductDir()); + File destFileFile = new File(destDir, fileName); + destFile = destFileFile.getPath(); + + boolean success = SystemManager.copy(sourceFile, destFile); + } + + return destFile; + } + + static private void copyInstallDirectoryWithExtension(File destBaseDir, String subDirName, String fileExtension) { + InstallData data = InstallData.getInstance(); + File sourceDir = data.getInfoRoot(subDirName); + if ( sourceDir != null ) { + File destDir = new File(destBaseDir, subDirName); + destDir.mkdir(); + SystemManager.copyAllFiles(sourceDir, destDir, fileExtension); + } + } + + static private void copyInstallDirectoryWithExtension(File destBaseDir, String subDirName, String fileExtension, String unixRights) { + InstallData data = InstallData.getInstance(); + File sourceDir = data.getInfoRoot(subDirName); + if ( sourceDir != null ) { + File destDir = new File(destBaseDir, subDirName); + destDir.mkdir(); + SystemManager.copyAllFiles(sourceDir, destDir, fileExtension); + SystemManager.setUnixPrivilegesDirectory(destDir, fileExtension, unixRights); + } + } + + static private void copyInstallDirectoryDoubleSubdir(File destBaseDir, String dir1, String dir2) { + InstallData data = InstallData.getInstance(); + File sourceDir1 = data.getInfoRoot(dir1); + File sourceDir = new File(sourceDir1, dir2); + + destBaseDir.mkdir(); + File destDir1 = new File(destBaseDir, dir1); + destDir1.mkdir(); + File destDir = new File(destDir1, dir2); + destDir.mkdir(); + + SystemManager.copyAllFiles(sourceDir, destDir); + } + + static private File createUninstallDir() { + InstallData data = InstallData.getInstance(); + File baseDir = new File(data.getInstallDefaultDir(), data.getProductDir()); + baseDir = new File(baseDir, data.getUninstallDirName()); + baseDir.mkdir(); + return baseDir; + } + + static private void copyGetUidSoFile(File dir) { + InstallData data = InstallData.getInstance(); + String uidFileSource = data.getGetUidPath(); + if ( uidFileSource != null ) { + // Copying the "getuid.so" file into installation + String fileName = "getuid.so"; + File destFile = new File(dir, fileName); + String uidFileDest = destFile.getPath(); + boolean success = SystemManager.copy(uidFileSource, uidFileDest); + data.setGetUidPath(uidFileDest); + } + } + + static private void copyJreFile(File dir) { + InstallData data = InstallData.getInstance(); + String jrefilename = System.getProperty("JRE_FILE"); + + if ( jrefilename != null ) { + // For Solaris, JRE_FILE can already contain the complete path. + // Otherwise it contains only the filename + File jreFile = new File(jrefilename); + + if ( ! jreFile.exists()) { + jreFile = new File(data.getPackagePath(), jrefilename); + } + + if ( jreFile.exists() ) { + String jreFileSource = jreFile.getPath(); + File destDir = new File(dir, "jre"); + destDir.mkdir(); + String onlyFileName = jreFile.getName(); + File destFile = new File(destDir, onlyFileName); + + // In maintenance mode the file already exists + if ( ! destFile.exists() ) { + String jreFileDest = destFile.getPath(); + boolean success = SystemManager.copy(jreFileSource, jreFileDest); + } + } + } + } + + static private void moveAdminFiles(File dir) { + InstallData data = InstallData.getInstance(); + + if ( data.getAdminFileNameReloc() != null ) { + File sourceFile = new File(data.getAdminFileNameReloc()); + String fileName = sourceFile.getName(); + File destFile = new File(dir, fileName); + boolean success = SystemManager.copy(sourceFile.getPath(), destFile.getPath()); + data.setAdminFileNameReloc(destFile.getPath()); + sourceFile.delete(); + } + + if ( data.getAdminFileNameRelocNoDepends() != null ) { + File sourceFile = new File(data.getAdminFileNameRelocNoDepends()); + String fileName = sourceFile.getName(); + File destFile = new File(dir, fileName); + boolean success = SystemManager.copy(sourceFile.getPath(), destFile.getPath()); + data.setAdminFileNameRelocNoDepends(destFile.getPath()); + sourceFile.delete(); + } + + if ( data.getAdminFileNameNoReloc() != null ) { + File sourceFile = new File(data.getAdminFileNameNoReloc()); + String fileName = sourceFile.getName(); + File destFile = new File(dir, fileName); + boolean success = SystemManager.copy(sourceFile.getPath(), destFile.getPath()); + data.setAdminFileNameNoReloc(destFile.getPath()); + sourceFile.delete(); + } + + if ( data.getAdminFileNameNoRelocNoDepends() != null ) { + File sourceFile = new File(data.getAdminFileNameNoRelocNoDepends()); + String fileName = sourceFile.getName(); + File destFile = new File(dir, fileName); + boolean success = SystemManager.copy(sourceFile.getPath(), destFile.getPath()); + data.setAdminFileNameNoRelocNoDepends(destFile.getPath()); + sourceFile.delete(); + } + } + + static private void createInfoFile(File dir) { + Vector fileContent = new Vector(); + String line = null; + InstallData data = InstallData.getInstance(); + + line = "PackagePath=" + data.getPackagePath(); + fileContent.add(line); + line = "InstallationPrivileges=" + data.getInstallationPrivileges(); + fileContent.add(line); + line = "AdminFileReloc=" + data.getAdminFileNameReloc(); + fileContent.add(line); + line = "AdminFileRelocNoDepends=" + data.getAdminFileNameRelocNoDepends(); + fileContent.add(line); + line = "AdminFileNoReloc=" + data.getAdminFileNameNoReloc(); + fileContent.add(line); + line = "AdminFileNoRelocNoDepends=" + data.getAdminFileNameNoRelocNoDepends(); + fileContent.add(line); + line = "InstallationDir=" + data.getInstallDir(); + fileContent.add(line); + line = "DatabasePath=" + data.getDatabasePath(); + fileContent.add(line); + line = "GetUidFile=" + data.getGetUidPath(); + fileContent.add(line); + + String infoFileName = "infoFile"; + File infoFile = new File(dir, infoFileName); + SystemManager.saveCharFileVector(infoFile.getPath(), fileContent); + } + + static private void removeSpecialFiles() { + InstallData data = InstallData.getInstance(); + File jarFile = data.getJarFilePath(); + SystemManager.deleteFile(jarFile); + + String jarFilePath = jarFile.getParent(); + File setupFile = new File(jarFilePath, "setup"); + SystemManager.deleteFile(setupFile); + + if ( ! data.getAdminFileNameReloc().equals("null") ) { + SystemManager.deleteFile(new File(data.getAdminFileNameReloc())); + } + + if ( ! data.getAdminFileNameRelocNoDepends().equals("null") ) { + SystemManager.deleteFile(new File(data.getAdminFileNameRelocNoDepends())); + } + + if ( ! data.getAdminFileNameNoReloc().equals("null") ) { + SystemManager.deleteFile(new File(data.getAdminFileNameNoReloc())); + } + + if ( ! data.getAdminFileNameNoRelocNoDepends().equals("null") ) { + SystemManager.deleteFile(new File(data.getAdminFileNameNoRelocNoDepends())); + } + + if ( ! data.getGetUidPath().equals("null") ) { + SystemManager.deleteFile(new File(data.getGetUidPath())); + } + } + + static private void removeInforootSubdir(String dir1, String dir2) { + InstallData data = InstallData.getInstance(); + File subdir1 = data.getInfoRoot(dir1); + File subdir2 = new File(subdir1, dir2); + if (subdir2 != null) { + if ( subdir2.exists() ) { + SystemManager.removeDirectory(subdir2); + } + } + } + + static private void removeInforootSubdir(String dir) { + InstallData data = InstallData.getInstance(); + File subdir = data.getInfoRoot(dir); + if (subdir != null) { + if ( subdir.exists() ) { + SystemManager.removeDirectory(subdir); + } + } + } + + static private void removeInforoot() { + InstallData data = InstallData.getInstance(); + SystemManager.removeDirectory(data.getInfoRoot()); + } + + static public void prepareUninstallation() { + // additional tasks for uninstallation + // Directory destDir has to exist! + InstallData data = InstallData.getInstance(); + File destDir = new File(data.getInstallDefaultDir(), data.getProductDir()); + boolean directoryExists = true; + + if ( ! destDir.exists() ) { + try { + directoryExists = SystemManager.create_directory(destDir.getPath()); + } + catch (SecurityException ex) { + String message = ResourceManager.getString("String_ChooseDirectory_No_Write_Access") + ": " + destDir.getPath(); + String title = ResourceManager.getString("String_Error"); + Informer.showErrorMessage(message, title); + } + } + + if ( directoryExists ) { + String setupPath = copySourceFile("setup"); + SystemManager.setUnixPrivileges(setupPath, "775"); + File jarFile = data.getJarFilePath(); + copySourceFile(jarFile.getName()); + + File uninstallDir = createUninstallDir(); + copyInstallDirectoryWithExtension(uninstallDir, "xpd", "xpd"); + copyInstallDirectoryWithExtension(uninstallDir, "html", "html"); + copyInstallDirectoryWithExtension(uninstallDir, "images", "gif"); + copyInstallDirectoryDoubleSubdir(uninstallDir, "html", "images"); + copyGetUidSoFile(uninstallDir); + copyJreFile(uninstallDir); + moveAdminFiles(uninstallDir); + createInfoFile(uninstallDir); + } + } + + static public void removeUninstallationFiles() { + // removing selected File + removeSpecialFiles(); + // removing directories html/images, html and xpd + removeInforootSubdir("html", "images"); + removeInforootSubdir("html"); + removeInforootSubdir("xpd"); + removeInforootSubdir("images"); + removeInforootSubdir("jre"); + removeInforoot(); + } + +} diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Informer.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Informer.java new file mode 100755 index 000000000000..7a3046a1dda0 --- /dev/null +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Informer.java @@ -0,0 +1,45 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.setup.Util; + +import javax.swing.JOptionPane; + +public class Informer { + + private Informer() { + } + + static public void showErrorMessage(String message, String title) { + JOptionPane.showMessageDialog(null, message, title, JOptionPane.ERROR_MESSAGE ); + } + + static public void showInfoMessage(String message, String title) { + JOptionPane.showMessageDialog(null, message, title, JOptionPane.INFORMATION_MESSAGE ); + } + +} diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/InstallChangeCtrl.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/InstallChangeCtrl.java new file mode 100755 index 000000000000..55d2c0a8d0cb --- /dev/null +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/InstallChangeCtrl.java @@ -0,0 +1,137 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.setup.Util; + +import org.openoffice.setup.InstallData; +import org.openoffice.setup.Installer.Installer; +import org.openoffice.setup.Installer.InstallerFactory; +import org.openoffice.setup.Panel.ChooseDirectory; +import org.openoffice.setup.ResourceManager; +import org.openoffice.setup.SetupData.PackageDescription; +import org.openoffice.setup.SetupData.SetupDataProvider; +import java.util.Enumeration; + + +public class InstallChangeCtrl { + + private InstallChangeCtrl() { + } + + static private void setUpdatePackage(PackageDescription packageData, InstallData installData) { + if (( packageData.isUpdatePackage() == true )) { + installData.setUpdatePackage(packageData); + } else { + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + setUpdatePackage(child, installData); + } + } + } + + static private void setChangeInstallDir(InstallData installData, Installer installer) { + // setting the new install dir after analyzing the installation directory + // of the installed update package. + if ( installData.isRootInstallation() ) { + String changeInstallDir = "/"; + installData.setInstallDir(changeInstallDir); + } else { + String changeInstallDir = installer.getChangeInstallDir(installData.getUpdatePackage()); + installData.setInstallDir(changeInstallDir); + } + } + + // static public void checkInstallChange(InstallData data, ChooseDirectory panel) { + static public void checkInstallChange(InstallData data) { + + Installer installer = InstallerFactory.getInstance(); + PackageDescription packageData = SetupDataProvider.getPackageDescription(); + + if ( data.getUpdatePackage() == null ) { + setUpdatePackage(packageData, data); + } + + if ( data.getUpdatePackage() != null ) { + + // resetting values, if database was changed during user installation + data.setOlderVersionExists(false); + data.setNewerVersionExists(false); + data.setSameVersionExists(false); + + boolean packageIsInstalled = installer.isPackageInstalled(data.getUpdatePackage(), data); + if ( packageIsInstalled ) { + + // Checking version of installed package: + // If installed package is older: Force update mode, no selection of packages + // If installed package is equal: Force maintenance mode, only selection of packages + // If installed package is newer: Abort installation with message + + // Setting specific values for the different update scenarios + if ( installer.isInstalledPackageOlder(data.getUpdatePackage(), data) ) { + data.setOlderVersionExists(true); + // All installed packages will be updated -> determining which packages are installed + System.err.println("An older product is installed"); + // But if this is a kind of Major Upgrade with different Minor and therefore different package names, + // it is necessary to remove the old product. + if ( data.getProductMinor() > data.getInstalledProductMinor() ) + { + data.setMajorUpgrade(true); + System.err.println("Major Upgrade"); + } + } else if ( installer.isInstallSetPackageOlder(data.getUpdatePackage(), data) ) { + data.setNewerVersionExists(true); + System.err.println("A newer product is installed"); + } else { + data.setSameVersionExists(true); + System.err.println("Same product is installed"); + } + + // If installed package is older or equal, the installdir has to be fixed + // if this is a root installation + if ( data.isRootInstallation() ) { + setChangeInstallDir(data, installer); + data.setIsChangeInstallation(true); + } + + // Exit installation, if update is not wanted and this is a root installation. + // In installations without root privileges, the user can choose another installation + // directory (ChooseDirectoryCtrl.java). + if ( data.isRootInstallation() && data.dontUpdate() && data.olderVersionExists() ) { + System.err.println("Error: An older version is already installed in directory " + data.getInstallDir() + "!"); + String message1 = ResourceManager.getString("String_Older_Version_Installed_Found") + + "\n" + data.getInstallDir() + "\n"; + String message2 = ResourceManager.getString("String_Older_Version_Installed_Remove"); + String message = message1 + "\n" + message2; + String title = ResourceManager.getString("String_Error"); + Informer.showErrorMessage(message, title); + System.exit(1); + } + } + } + } + +} diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/LogManager.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/LogManager.java new file mode 100755 index 000000000000..3be95469b532 --- /dev/null +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/LogManager.java @@ -0,0 +1,105 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.setup.Util; + +import java.util.Vector; + +public class LogManager { + + static private Vector logfile; /* collects all logging information during installation */ + static private Vector commandsLogFile; /* collects all system commands information during installation */ + static private Vector saveLogFile; /* contains the content of the saved log file */ + static private Vector modulesLogFile; + + private LogManager() { + } + + static public Vector getSaveLogfile() { + return saveLogFile; + } + + static public void addLogfileComment(String text) { + logfile.add(text); + } + + static public void addCommandsLogfileComment(String text) { + commandsLogFile.add(text); + } + + static public void addModulesLogfileComment(String text) { + modulesLogFile.add(text); + } + + static public void setCommandsHeaderLine(String text) { + String line = "*************************************"; + commandsLogFile.add(""); + commandsLogFile.add(line); + commandsLogFile.add("<b>" + text + "</b>"); + commandsLogFile.add(line); + commandsLogFile.add(""); + } + + static public void setModulesLogFileHeaderLine(String text) { + String line = "*************************************"; + modulesLogFile.add(line); + modulesLogFile.add(text); + modulesLogFile.add(line); + } + + static public String publishLogfileContent(String text, String separatorline) { + for (int i = 0; i < logfile.size(); i++) { + text = text + logfile.get(i) + "<br>"; + } + + if ( ! logfile.isEmpty() ) { + text = text + separatorline + "<br>"; + } + + return text; + } + + static public String publishCommandsLogfileContent(String text) { + for (int i = 0; i < commandsLogFile.size(); i++) { + text = text + commandsLogFile.get(i) + "<br>"; + } + + return text; + } + + static public Vector getModulesLogFile() { + return modulesLogFile; + } + + static { + logfile = new Vector(); + commandsLogFile = new Vector(); + saveLogFile = new Vector(); + modulesLogFile = new Vector(); + } + +} diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/ModuleCtrl.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/ModuleCtrl.java new file mode 100755 index 000000000000..8d43fb4d01f1 --- /dev/null +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/ModuleCtrl.java @@ -0,0 +1,1004 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.setup.Util; + +import java.io.File; +import java.util.Enumeration; +import java.util.Vector; +import org.openoffice.setup.InstallData; +import org.openoffice.setup.Installer.Installer; +import org.openoffice.setup.Installer.InstallerFactory; +import org.openoffice.setup.Panel.ChooseDirectory; +import org.openoffice.setup.ResourceManager; +import org.openoffice.setup.SetupData.PackageDescription; +import org.openoffice.setup.SetupData.SetupDataProvider; +import org.openoffice.setup.Util.Informer; + +public class ModuleCtrl { + + private ModuleCtrl() { + } + + static public void setModuleSize(PackageDescription packageData) { + // Setting the package size for visible node modules, that have hidden children + // -> Java module has three hidden children and 0 byte size + + if (( ! packageData.isLeaf() ) && ( ! packageData.isHidden() )) { + boolean setNewSize = false; + int size = packageData.getSize(); + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + // if (( child.isHidden() ) && ( child.getSelectionState() == PackageDescription.DONT_KNOW )) { + if ( child.isHidden() ) { + setNewSize = true; + size = size + child.getSize(); + } + } + + if ( setNewSize ) { + packageData.setSize(size); + } + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + setModuleSize(child); + } + + } + + static public void setDefaultModuleSettings(PackageDescription data) { + // Setting default module settings for modules, that are not hidden + // Hidden modules do not get a defined state now + boolean isInstalled = false; + InstallData installdata = InstallData.getInstance(); + boolean isUninstall = installdata.isUninstallationMode(); + + if (isUninstall) { + isInstalled = true; + } + + if (isUninstall) { + if (isInstalled) { + data.setSelectionState(PackageDescription.REMOVE); + } else { + data.setSelectionState(PackageDescription.IGNORE); + System.err.println("NEVER"); + } + } else { + if (isInstalled) { + data.setSelectionState(PackageDescription.IGNORE); + System.err.println("NEVER"); + } else if (data.isDefault()) { + data.setSelectionState(PackageDescription.INSTALL); + } else if ( ! data.isDefault()) { + data.setSelectionState(PackageDescription.DONT_INSTALL); + } else { + data.setSelectionState(PackageDescription.DONT_INSTALL); + } + } + } + + static public void setParentDefaultModuleSettings(PackageDescription packageData) { + // Setting the module states of parent modules. + // Called after ChooseDirectoryCtrl.java, because + // the database has to be known. In user installation it is important, + // that the installation directory is known, to find the database. + // Called during uninstallation in UninstallationPrologueCtrl.java + + // Iteration before setting the module states. Because of this, all children + // get their final setting before the parent. + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + setParentDefaultModuleSettings(child); + } + + if ( ! packageData.isLeaf() ) { + // System.err.println("setParentDefaultModuleSettings: " + packageData.getName()); + int state = packageData.getSelectionState(); + InstallData installdata = InstallData.getInstance(); + boolean allChildrenIgnored = true; + boolean atLeastOneInstalled = false; + boolean allChildrenHidden = true; + + // System.err.println(" STATE before iterating over children: " + state); + + for (Enumeration e = packageData.children(); e.hasMoreElements();) { + PackageDescription child = (PackageDescription) e.nextElement(); + int childState = child.getSelectionState(); + + // System.err.println(" Child: " + child.getName() + " : " + childState); + + if ( childState != PackageDescription.IGNORE) { + allChildrenIgnored = false; + } + + if (( childState == PackageDescription.INSTALL) || ( childState == PackageDescription.INSTALL_SOME)) { + atLeastOneInstalled = true; + } + + if ( ! child.isHidden() ) { + allChildrenHidden = false; + } + + if ((state == PackageDescription.DONT_KNOW) || (state == PackageDescription.IGNORE)) { + state = childState; + // } else if ((state != childState) && (childState != PackageDescription.IGNORE)) { + } else if ((state != childState) && (childState != PackageDescription.IGNORE) && (childState != PackageDescription.DONT_KNOW)) { + if ( installdata.isUninstallationMode() ) { + state = PackageDescription.REMOVE_SOME; + } else { + state = PackageDescription.INSTALL_SOME; + } + } + + // System.err.println(" NEW state after child: " + state); + } + + if ( allChildrenIgnored ) { + state = PackageDescription.IGNORE; + } + + if ( installdata.isInstallationMode() ) { + if (( state == PackageDescription.INSTALL_SOME ) && ( ! atLeastOneInstalled )) { + state = PackageDescription.DONT_INSTALL; + } + } + + if ( allChildrenHidden ) { + packageData.setAllChildrenHidden(true); + // System.err.println("Setting allChildrenHidden for module " + packageData.getName() ); + } + + // If older version exist, only modules without packages shall be updated, + // because all packages are already determined by querying the database. + if ( installdata.olderVersionExists() ) { + if ( packageData.getPackageName().equals("") ) { + packageData.setSelectionState(state); + } + } else { + packageData.setSelectionState(state); + } + } + } + + static public void setHiddenModuleSettingsInstall(PackageDescription packageData) { + // update selection states for hidden modules during installation + if (( packageData.isHidden() ) && ( packageData.getSelectionState() != packageData.IGNORE )) { + PackageDescription parent = (PackageDescription)packageData.getParent(); + if ( parent != null ) { + packageData.setSelectionState(parent.getSelectionState()); + // hidden modules at root module always have to be installed, if they are not already installed + if ( parent.getName() == "" ) { + packageData.setSelectionState(packageData.INSTALL); + // System.err.println("Setting 1 INSTALL flag to: " + packageData.getName()); + } + } + + // INSTALL_SOME is not valid for leaves + if (( packageData.getSelectionState() == packageData.INSTALL_SOME ) && ( packageData.isLeaf() )) { + packageData.setSelectionState(packageData.INSTALL); + // System.err.println("Setting 2 INSTALL flag to: " + packageData.getName()); + } + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + setHiddenModuleSettingsInstall(child); + } + } + + static public void setHiddenModuleSettingsUninstall(PackageDescription packageData) { + InstallData data = InstallData.getInstance(); + // update selection states for hidden modules during uninstallation + if (( packageData.isHidden() ) && ( packageData.getSelectionState() != packageData.IGNORE )) { + // System.err.println("Package name: " + packageData.getName()); + // System.err.println("Selection: " + packageData.getSelectionState()); + + PackageDescription parent = (PackageDescription)packageData.getParent(); + if ( parent != null ) { + packageData.setSelectionState(parent.getSelectionState()); + // Hidden modules at root module have to be uninstalled at complete uninstallation + // In Uninstallation the complete is the typical installation type + if (( parent.getName() == "" ) && ( data.isTypicalInstallation() )) { + packageData.setSelectionState(packageData.REMOVE); + } + // Hidden modules at root module must not be uninstalled at custom uninstallation + // But if all visible modules are selected for uninstallation, this shall be handled + // as complete uninstallation. + if ( ! data.isMaskedCompleteUninstallation() ) + { + if (( parent.getName() == "" ) && ( data.isCustomInstallation() )) { + packageData.setSelectionState(packageData.IGNORE); + } + } + } + + // REMOVE_SOME is not valid for leaves + // if ( data.isTypicalInstallation() ) { + if (( packageData.getSelectionState() == packageData.REMOVE_SOME ) && ( packageData.isLeaf() )) { + packageData.setSelectionState(packageData.REMOVE); + } + // } + + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + setHiddenModuleSettingsUninstall(child); + } + } + + static private boolean checkRequiredCoreModule(PackageDescription packageData) { + + // This function uses a similar mechanism to determine + // core modules as function "setHiddenModuleSettingsInstall" + // -> only hidden parents, until there is a module without name (getName) + // Only searching until grandpa. + + boolean requiredCoreModule = false; + + // if packageData.getSelectionState() DONT_KNOW && parent auch DONT_KNOW + if (( packageData.isHidden() ) && + ( packageData.getSelectionState() != packageData.IGNORE ) && + ( packageData.getPackageName() != null )) { + //( packageData.isLeaf() )) { + PackageDescription parent = (PackageDescription)packageData.getParent(); + if ( parent != null ) { + if (( parent.getName().equals("") ) || ( parent.getName() == null )) { + requiredCoreModule = true; + } else { + if ( parent.isHidden() ) { + PackageDescription grandpa = (PackageDescription)parent.getParent(); + if ( grandpa != null ) { + if (( grandpa.getName().equals("") ) || ( grandpa.getName() == null )) { + requiredCoreModule = true; + } + } + } + } + } + } + + return requiredCoreModule; + } + + static public void setDatabaseSettings(PackageDescription packageData, InstallData installData, Installer installer) { + // Analyzing the system database and setting the module states. + // Called during installation in ChooseInstallationTypeCtrl.java, because + // the database has to be known. In user installation it is important, + // the the installation directory is known, to find the database. + // Called during uninstallation in UninstallationPrologueCtrl.java + + boolean isUninstall = installData.isUninstallationMode(); + boolean isInstalled = installer.isPackageInstalled(packageData, installData); + + if (isUninstall) { + if (isInstalled) { + packageData.setSelectionState(PackageDescription.REMOVE); + // The following is no longer required !? (IS, 06/05/08) + // PackageDescription parent = packageData.getParent(); + // if ( parent != null ) { + // if ( parent.getSelectionState() != PackageDescription.REMOVE ) { + // parent.setSelectionState(PackageDescription.REMOVE); + // System.err.println("Setting remove to " + parent.getName()); + // } + // } + } else { + // Attention: Setting all nodes to ignore! If a children gets REMOVE, + // then REMOVE is also set to the parent. Setting REMOVE happens after + // setting IGNORE, because children are evaluated after the parents. + // The default for uninstallation is set in setDefaultModuleSettings to REMOVE. + packageData.setSelectionState(PackageDescription.IGNORE); + } + } else { + boolean goodDepends = true; + if ( installData.getOSType().equalsIgnoreCase("SunOS") ) { + if (( installData.isRootInstallation() ) && ( packageData.getCheckSolaris() != null ) && ( ! packageData.getCheckSolaris().equals("") )) { + // the package has to be installed. Creating a new package with only packagename + if ( ! installer.isPackageNameInstalled(packageData.getCheckSolaris(), installData) ) { + goodDepends = false; + } + } + } + + if ( ! goodDepends ) { + // The package dependencies are not valid -> ignoring package. + packageData.setSelectionState(PackageDescription.IGNORE); + // too late to hide the module + // packageData.setIsHidden(true); + } + else { + if ( isInstalled ) { + if ( packageData.isJavaPackage() ) { // only selected checks, because of performance reasons + boolean installedPackageIsOlder = installer.isInstalledPackageOlder(packageData, installData); + if ( ! installedPackageIsOlder ) { + // The package is already installed in the same or in a newer version + packageData.setSelectionState(PackageDescription.IGNORE); + } else { + // This is also something like migrating feature states + packageData.setSelectionState(PackageDescription.INSTALL); + } + } else { // no version check done -> so what is a good setting for already installed packages? + if ( installData.olderVersionExists() ) { // should never be the case in this function + packageData.setSelectionState(PackageDescription.INSTALL); + } else { + packageData.setSelectionState(PackageDescription.IGNORE); + } + } + } + else { + // Special handling for core modules, which are required, but not installed. + // This can be deinstalled by hand for example. + boolean isRequiredCoreModule = checkRequiredCoreModule(packageData); + if ( isRequiredCoreModule ) { + if ( packageData.getSelectionState() != PackageDescription.INSTALL ) { + packageData.setSelectionState(PackageDescription.INSTALL); + LogManager.addLogfileComment("<b>Adding required package:</b> " + packageData.getPackageName() + "</br>"); + } + // This package has to exist! + if ( ! packageExists(packageData, installData) ) { + + String packagePath = installData.getPackagePath(); + if (( packageData.getPkgSubdir() != null ) && ( ! packageData.getPkgSubdir().equals("") )) { + File completePackageFile = new File(packagePath, packageData.getPkgSubdir()); + packagePath = completePackageFile.getPath(); + } + String packageName = packageData.getPackageName(); + File packageFile = new File(packagePath, packageName); + + String log = "<b>Error: Missing required package " + packageFile.getPath() + "</b><br>"; + System.err.println(log); + String message = ResourceManager.getString("String_File_Not_Found") + ": " + packageFile.getPath(); + String title = ResourceManager.getString("String_Error"); + Informer.showErrorMessage(message, title); + System.exit(1); + } + } + } + } + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + setDatabaseSettings(child, installData, installer); + } + } + + static public void setShowInUserInstallFlags(PackageDescription packageData) { + + // This function is not needed during deinstallation, because a + // module that could not be selected during installation, is always + // not installed during deinstallation and therefore gets "IGNORE" + // in function setDatabaseSettings + + if ( ! packageData.showInUserInstall() ) { + packageData.setSelectionState(PackageDescription.IGNORE); + // too late to hide the module + // packageData.setIsHidden(true); + // packageData.setAllChildrenHidden(true); + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + setShowInUserInstallFlags(child); + } + } + + static public void setForcedUpdateProductSettings(PackageDescription packageData) { + + if ( packageData.forceIntoUpdate() ) { + packageData.setSelectionState(PackageDescription.INSTALL); + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + setForcedUpdateProductSettings(child); + } + } + + static public void setShowInUserInstallOnlyFlags(PackageDescription packageData) { + + // This function is not needed during deinstallation, because a + // module that could not be selected during installation, is always + // not installed during deinstallation and therefore gets "IGNORE" + // in function setDatabaseSettings + + if ( packageData.showInUserInstallOnly() ) { + packageData.setSelectionState(PackageDescription.IGNORE); + // too late to hide the module + // packageData.setIsHidden(true); + // packageData.setAllChildrenHidden(true); + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + setShowInUserInstallOnlyFlags(child); + } + } + + static public void setIgnoreNonRelocatablePackages(PackageDescription packageData) { + if ( ! packageData.isRelocatable() ) { + packageData.setSelectionState(PackageDescription.IGNORE); + System.err.println("Ignoring package " + packageData.getName() + " " + packageData.getPackageName()); + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + setIgnoreNonRelocatablePackages(child); + } + } + + static public void setHiddenLanguageModuleDefaultSettings(PackageDescription packageData) { + + // This function is needed during installation for the language modules, + // if there is only one language in the installation set. In this case the language + // modules are hidden (no selection possible) and therefore get no value in + // setDefaultModuleSettings(). This default value is set now. + + if ( packageData.showMultiLingualOnly() ) { + packageData.setSelectionState(PackageDescription.INSTALL); + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + setHiddenLanguageModuleDefaultSettings(child); + } + } + + static private boolean packageExists(PackageDescription packageData, InstallData installData) { + boolean fileExists = false; + String packagePath = installData.getPackagePath(); + + if (( packageData.getPkgSubdir() != null ) && ( ! packageData.getPkgSubdir().equals("") )) { + File completePackageFile = new File(packagePath, packageData.getPkgSubdir()); + packagePath = completePackageFile.getPath(); + } + + String packageName = packageData.getPackageName(); + File packageFile = new File(packagePath, packageName); + + if ( packageFile.exists() ) { + fileExists = true; + } + + return fileExists; + } + + static public void disableNonExistingPackages(PackageDescription packageData, InstallData installData) { + if ((( packageData.getPackageName() == null ) || ( packageData.getPackageName().equals("") )) + && packageData.isLeaf() ) { + packageData.setSelectionState(PackageDescription.IGNORE); + } else if ( ! packageExists(packageData, installData) ) { + packageData.setSelectionState(PackageDescription.IGNORE); + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + disableNonExistingPackages(child, installData); + } + } + + static public void setDontUninstallFlags(PackageDescription packageData) { + if ( packageData.dontUninstall() ) { + packageData.setSelectionState(PackageDescription.IGNORE); + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + setDontUninstallFlags(child); + } + } + + static public void setDontUninstallUserInstallOnylFlags(PackageDescription packageData) { + if ( packageData.showInUserInstallOnly() ) { + packageData.setSelectionState(PackageDescription.IGNORE); + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + setDontUninstallUserInstallOnylFlags(child); + } + } + + static public void checkVisibleModulesInstall(PackageDescription packageData, InstallData data) { + boolean setToTrue = false; + + if (( ! packageData.isHidden() ) && ( packageData.getSelectionState() == packageData.INSTALL )) { + setToTrue = true; + data.setVisibleModulesChecked(true); + } + + if ( ! setToTrue ) { + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + checkVisibleModulesInstall(child, data); + } + } + } + + static public void checkApplicationSelection(PackageDescription packageData, InstallData data) { + boolean setToTrue = false; + + if (( packageData.isApplicationPackage() ) && + ( ! packageData.isHidden() ) && + ( packageData.getSelectionState() == packageData.INSTALL )) { + setToTrue = true; + data.setApplicationModulesChecked(true); + } + + if ( ! setToTrue ) { + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + checkApplicationSelection(child, data); + } + } + } + + static public void checkLanguageSelection(PackageDescription packageData, InstallData data) { + boolean setToTrue = false; + + if (( packageData.showMultiLingualOnly() ) && + ( ! packageData.isHidden() ) && + ( packageData.getSelectionState() == packageData.INSTALL )) { + setToTrue = true; + data.setLanguageModulesChecked(true); + } + + if ( ! setToTrue ) { + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + checkLanguageSelection(child, data); + } + } + } + + static public void checkVisibleModulesUninstall(PackageDescription packageData, InstallData data) { + boolean setToTrue = false; + + if (( ! packageData.isHidden() ) && ( packageData.getSelectionState() == packageData.REMOVE )) { + // ignoring the top level module, that has the state REMOVE (but no name) + if (( packageData.getName() != null ) && ( ! packageData.getName().equals("") )) { + setToTrue = true; + data.setVisibleModulesChecked(true); + } + } + + if ( ! setToTrue ) { + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + checkVisibleModulesUninstall(child, data); + } + } + } + + static public void checkApplicationModulesUninstall(PackageDescription packageData, InstallData data) { + boolean setToTrue = false; + + // At least one language module should not be uninstalled. Then this function returns true. + // An exeption is the complete uninstallation or the masked complete uninstallation. + + if (( packageData.isApplicationPackage() ) && + ( ! packageData.isHidden() ) && + ( packageData.getSelectionState() != packageData.IGNORE ) && + ( packageData.getSelectionState() != packageData.REMOVE )) { + setToTrue = true; + data.setApplicationModulesChecked(true); + } + + if ( ! setToTrue ) { + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + checkApplicationModulesUninstall(child, data); + } + } + } + + static public void checkLanguageModulesUninstall(PackageDescription packageData, InstallData data) { + boolean setToTrue = false; + + // At least one language module should not be uninstalled. Then this function returns true. + // An exeption is the complete uninstallation or the masked complete uninstallation. + + if (( packageData.showMultiLingualOnly() ) && + ( ! packageData.isHidden() ) && + ( packageData.getSelectionState() != packageData.IGNORE ) && + ( packageData.getSelectionState() != packageData.REMOVE )) { + setToTrue = true; + data.setLanguageModulesChecked(true); + } + + if ( ! setToTrue ) { + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + checkLanguageModulesUninstall(child, data); + } + } + } + + static public void checkMaskedCompleteUninstallation(PackageDescription packageData, InstallData data) { + boolean setToFalse = false; + + // If there is at least one visible module, that is not selected for removal + // this is no masked complete uninstallation + + if (( ! packageData.isHidden() ) + && ( packageData.getSelectionState() != packageData.REMOVE ) + && ( packageData.getSelectionState() != packageData.IGNORE )) { + // ignoring the top level module, that has no name + if (( packageData.getName() != null ) && ( ! packageData.getName().equals("") )) { + setToFalse = true; + data.setMaskedCompleteUninstallation(false); + // System.err.println("This is no masked complete uninstallation!"); + // System.err.println("Caused by: " + packageData.getName() + " with " + packageData.getSelectionState()); + } + } + + if ( ! setToFalse ) { + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + checkMaskedCompleteUninstallation(child, data); + } + } + } + + static public void saveTypicalSelectionStates(PackageDescription packageData) { + packageData.setTypicalSelectionState(packageData.getSelectionState()); + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + saveTypicalSelectionStates(child); + } + } + + static public void saveCustomSelectionStates(PackageDescription packageData) { + packageData.setCustomSelectionState(packageData.getSelectionState()); + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + saveCustomSelectionStates(child); + } + } + + static public void saveStartSelectionStates(PackageDescription packageData) { + packageData.setStartSelectionState(packageData.getSelectionState()); + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + saveStartSelectionStates(child); + } + } + + static public void restoreTypicalSelectionStates(PackageDescription packageData) { + packageData.setSelectionState(packageData.getTypicalSelectionState()); + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + restoreTypicalSelectionStates(child); + } + } + + static public void restoreCustomSelectionStates(PackageDescription packageData) { + packageData.setSelectionState(packageData.getCustomSelectionState()); + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + restoreCustomSelectionStates(child); + } + } + + static public void restoreStartSelectionStates(PackageDescription packageData) { + packageData.setSelectionState(packageData.getStartSelectionState()); + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + restoreStartSelectionStates(child); + } + } + + static public void setUpdateOlderProductSettings(PackageDescription packageData, InstallData data, Installer installer) { + if (( packageData.getPackageName() != null ) && ( ! packageData.getPackageName().equals(""))) { + if ( installer.isPackageInstalled(packageData, data) ) { + packageData.setSelectionState(PackageDescription.INSTALL); + + // Special handling for jre package, because this is not necessarily older, if an older product is updated. + if ( packageData.isJavaPackage() ) { + if ( ! installer.isInstalledPackageOlder(packageData, data) ) { + packageData.setSelectionState(PackageDescription.DONT_INSTALL); + } + } + } else { + packageData.setSelectionState(PackageDescription.DONT_INSTALL); + // Special handling for Major Upgrade + if ( data.isMajorUpgrade() ) { + String basis = "ooobasis3"; + if ( data.getOSType().equalsIgnoreCase("Linux") ) { basis = basis + "."; } + String search = basis + data.getProductMinor(); + String replacestring = basis + data.getInstalledProductMinor(); + int pos = packageData.getPackageName().indexOf(search); + if ( pos > -1 ) { + // Check if this package is installed with a lower product minor + // Creating new package for removal, very simple PackageDescription + PackageDescription localPackage = new PackageDescription(); + localPackage.setUninstallCanFail(true); + localPackage.setIsRelocatable(packageData.isRelocatable()); + String localName = packageData.getPackageName(); + localName = localName.replace(search, replacestring); + localPackage.setPackageName(localName); + + if ( ( packageData.getPkgRealName() != null ) && ( ! packageData.getPkgRealName().equals("") )) { + localName = packageData.getPkgRealName(); + localName = localName.replace(search, replacestring); + localPackage.setPkgRealName(localName); + } + + if (( packageData.getName() != null ) && ( ! packageData.getName().equals("") )) { + localName = packageData.getName(); + localName = localName.replace(search, replacestring); + localPackage.setName(localName); + } + + // saving also the order, needed for order of uninstallation + localPackage.setOrder(packageData.getOrder()); + + // If the old package is installed, the new package can be installed, too, + // and the old package can be marked for removal (with dependency check). + if ( installer.isPackageInstalled(localPackage, data) ) { + packageData.setSelectionState(PackageDescription.INSTALL); + + // Collecting all installed older packages for uninstallation + Vector oldPackages = data.getOldPackages(); + oldPackages.add(localPackage); + data.setOldPackages(oldPackages); + } + } + } + } + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + setUpdateOlderProductSettings(child, data, installer); + } + } + + static public void checkLanguagesPackages(PackageDescription packageData, InstallData installData) { + if (( packageData.getPkgLanguage() != null ) && ( ! packageData.getPkgLanguage().equals(""))) { + // This is a package with a specific language. + // pkgLanguage can be a comma separated list, for example "ja,ja_JP.PCK,ja_JP.UTF-8" + String allLang = packageData.getPkgLanguage(); + String[] allLangs = allLang.split(","); + + Vector systemLanguages = installData.getSystemLanguages(); + + boolean foundLang = false; + for (int i = 0; i < allLangs.length; i++) { + String oneLang = allLangs[i]; + oneLang = oneLang.trim(); + if ( systemLanguages.contains(oneLang)) { + foundLang = true; + int count = installData.getPreselectedLanguages(); + count++; + installData.setPreselectedLanguages(count); + break; + } + } + + if ( ! foundLang ) { + packageData.setSelectionState(PackageDescription.DONT_INSTALL); + } + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + checkLanguagesPackages(child, installData); + } + } + + static public void setLanguagesPackages(PackageDescription packageData) { + if (( packageData.getPkgLanguage() != null ) && ( ! packageData.getPkgLanguage().equals(""))) { + // This is a package with a specific language. + packageData.setSelectionState(PackageDescription.INSTALL); + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + setLanguagesPackages(child); + } + } + + static public void setRequiredNewCoreModules(PackageDescription packageData, InstallData installData) { + // Special handling for core modules, which are required, but not installed. + boolean isRequiredCoreModule = checkRequiredCoreModule(packageData); + if ( isRequiredCoreModule ) { + if ( packageData.getSelectionState() != PackageDescription.INSTALL ) { + packageData.setSelectionState(PackageDescription.INSTALL); + LogManager.addLogfileComment("<b>Adding required package:</b> " + packageData.getPackageName() + "</br>"); + } + // This package has to exist! + if ( ! packageExists(packageData, installData) ) { + + String packagePath = installData.getPackagePath(); + if (( packageData.getPkgSubdir() != null ) && ( ! packageData.getPkgSubdir().equals("") )) { + File completePackageFile = new File(packagePath, packageData.getPkgSubdir()); + packagePath = completePackageFile.getPath(); + } + String packageName = packageData.getPackageName(); + File packageFile = new File(packagePath, packageName); + + String log = "<b>Error: Missing required package " + packageFile.getPath() + "</b><br>"; + System.err.println(log); + String message = ResourceManager.getString("String_File_Not_Found") + ": " + packageFile.getPath(); + String title = ResourceManager.getString("String_Error"); + Informer.showErrorMessage(message, title); + System.exit(1); + } + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + setRequiredNewCoreModules(child, installData); + } + } + + static public void defaultDatabaseAnalysis(InstallData data) { + + PackageDescription packageData = SetupDataProvider.getPackageDescription(); + Installer installer = InstallerFactory.getInstance(); + + // restore default settings + if ( data.startSelectionStateSaved() ) { + // System.err.println("Restoring start selection states"); + ModuleCtrl.restoreStartSelectionStates(packageData); + } else { + ModuleCtrl.saveStartSelectionStates(packageData); + data.setStartSelectionStateSaved(true); + } + + // Special ToDos, if this is an update installation of an older product. + // In this case, "chooseInstallationType" and "chooseComponents" are not called. + // Is it necessary to call "analyzeDatabase" ? + if ( data.olderVersionExists() ) { + // Calculation of size is not necessary, because only + // already installed packages will be updated. + + if ( data.logModuleStates() ) { + Dumper.logModuleStates(packageData, "ChooseDirectory: Before setUpdateOlderProductSettings"); + } + + // Updating only those packages that are installed. + ModuleCtrl.setUpdateOlderProductSettings(packageData, data, installer); + + if ( data.logModuleStates() ) { + Dumper.logModuleStates(packageData, "ChooseDirectory: After setUpdateOlderProductSettings"); + } + + // Setting packages that are forced into update, because they did not exist in older version. + ModuleCtrl.setForcedUpdateProductSettings(packageData); + + if ( data.logModuleStates() ) { + Dumper.logModuleStates(packageData, "ChooseDirectory: After setForcedUpdateProductSettings"); + } + + // Setting required root module packages (that are new in the update product). + ModuleCtrl.setRequiredNewCoreModules(packageData, data); + + if ( data.logModuleStates() ) { + Dumper.logModuleStates(packageData, "ChooseDirectory: After setRequiredNewCoreModules"); + } + + // Checking, if all packages are available + ModuleCtrl.disableNonExistingPackages(packageData, data); + + if ( data.logModuleStates() ) { + Dumper.logModuleStates(packageData, "ChooseDirectory: After disableNonExistingPackages"); + } + + // disable packages, that are not valid in user installation + if ( data.isUserInstallation() ) { + ModuleCtrl.setShowInUserInstallFlags(packageData); + + if ( data.logModuleStates() ) { + Dumper.logModuleStates(packageData, "ChooseDirectory: After setShowInUserInstallFlags"); + } + } + else { // disable packages, that are not valid in root installation + ModuleCtrl.setShowInUserInstallOnlyFlags(packageData); + + if ( data.logModuleStates() ) { + Dumper.logModuleStates(packageData, "ChooseDirectory: After setShowInUserInstallOnlyFlags"); + } + } + + // Setting parent module settings. Only required for displaying correct module settings before starting installation. + ModuleCtrl.setParentDefaultModuleSettings(packageData); + + if ( data.logModuleStates() ) { + Dumper.logModuleStates(packageData, "ChooseDirectory: After setParentDefaultModuleSettings"); + } + + // Collecting packages to install + // This has to be done here, because "ChooseInstallationType" and "ChooseComponents" + // are not called. + Vector installPackages = new Vector(); + PackageCollector.collectInstallPackages(packageData, installPackages); + data.setInstallPackages(installPackages); + + } else { // same version exists or no version exists + + // database changed -> ignore saved states + data.setTypicalSelectionStateSaved(false); + data.setCustomSelectionStateSaved(false); + + if ( data.logModuleStates() ) { + Dumper.logModuleStates(packageData, "analyzeDatabase: Start"); + } + + // searching in the database for already installed packages + LogManager.setCommandsHeaderLine("Analyzing system database"); + ModuleCtrl.setDatabaseSettings(packageData, data, installer); + + if ( data.logModuleStates() ) { + Dumper.logModuleStates(packageData, "analyzeDatabase: After setDatabaseSettings"); + } + + // ModuleCtrl.analyzeDatabase(); + ModuleCtrl.disableNonExistingPackages(packageData, data); + + if ( data.logModuleStates() ) { + Dumper.logModuleStates(packageData, "ChooseDirectory: After disableNonExistingPackages"); + } + + // disable packages, that are not valid in user installation + if ( data.isUserInstallation() ) { + ModuleCtrl.setShowInUserInstallFlags(packageData); + + if ( data.logModuleStates() ) { + Dumper.logModuleStates(packageData, "ChooseDirectory: After setShowInUserInstallFlags"); + } + } else { // disable packages, that are not valid in root installation + ModuleCtrl.setShowInUserInstallOnlyFlags(packageData); + + if ( data.logModuleStates() ) { + Dumper.logModuleStates(packageData, "ChooseDirectory: After setShowInUserInstallOnlyFlags"); + } + } + + // Problem: If all submodules have flag IGNORE, the parent can also get IGNORE + // That is interesting for language packs with three submodules. + ModuleCtrl.setParentDefaultModuleSettings(packageData); + + if ( data.logModuleStates() ) { + Dumper.logModuleStates(packageData, "ChooseDirectory: After setParentDefaultModuleSettings"); + } + } + } + +} diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/PackageCollector.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/PackageCollector.java new file mode 100755 index 000000000000..4e1c4d5866e2 --- /dev/null +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/PackageCollector.java @@ -0,0 +1,179 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.setup.Util; + +import org.openoffice.setup.InstallData; +import org.openoffice.setup.SetupData.PackageDescription; +import java.util.Enumeration; +import java.util.Vector; + +public class PackageCollector { + + private PackageCollector() { + } + + static public void collectInstallPackages(PackageDescription packageData, Vector allPackages) { + + if (( packageData.isLeaf() ) && ( packageData.getSelectionState() == packageData.INSTALL )) { + allPackages.add(packageData); + // System.err.println("Adding to collector 1: " + packageData.getPackageName()); + } + + // also allowing packages at nodes! + if (( ! packageData.isLeaf() ) && + ( packageData.getPackageName() != null ) && + ( ! packageData.getPackageName().equals("")) && + (( packageData.getSelectionState() == packageData.INSTALL ) || + ( packageData.getSelectionState() == packageData.INSTALL_SOME ))) { + allPackages.add(packageData); + // System.err.println("Adding to collector 2: " + packageData.getPackageName()); + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + collectInstallPackages(child, allPackages); + } + + } + + static public void collectUninstallPackages(PackageDescription packageData, Vector allPackages) { + if (( packageData.isLeaf() ) && ( packageData.getSelectionState() == packageData.REMOVE )) { + allPackages.add(0, packageData); + } + + // also allowing packages at nodes! + if (( ! packageData.isLeaf() ) && + ( packageData.getPackageName() != null ) && + ( ! packageData.getPackageName().equals("")) && + ( packageData.getSelectionState() == packageData.REMOVE )) { + allPackages.add(0, packageData); + } + + for (Enumeration e = packageData.children(); e.hasMoreElements(); ) { + PackageDescription child = (PackageDescription) e.nextElement(); + collectUninstallPackages(child, allPackages); + } + } + + // Special handling for packages, that change their name, and therefore need to be uninstalled + + // static public void findOldPackages( InstallData installData ) { + // + // String basis = "ooobasis3"; + // if ( installData.getOSType().equalsIgnoreCase("Linux") ) { basis = basis + "."; } + // String search = basis + installData.getProductMinor(); + + // Vector allPackages = installData.getInstallPackages(); + // Vector oldPackages = new Vector(); + + // for (int i = 0; i < allPackages.size(); i++) { + // PackageDescription packageData = (PackageDescription) allPackages.get(i); + // int pos = packageData.getPackageName().indexOf(search); + + // if ( pos > -1 ) { + // String substring = packageData.getPackageName().substring(pos, pos + 1); + // for (int j = 0; j < installData.getProductMinor(); j++) { + // String replace = basis + j; + // // Creating new package for removal, very simple PackageDescription + // PackageDescription localPackage = new PackageDescription(); + // localPackage.setUninstallCanFail(true); + // localPackage.setIsRelocatable(packageData.isRelocatable()); + // String localName = packageData.getPackageName(); + // localName = localName.replace(search, replace); + // localPackage.setPackageName(localName); + + // if ( ( packageData.getPkgRealName() != null ) && ( ! packageData.getPkgRealName().equals("") )) { + // localName = packageData.getPkgRealName(); + // localName = localName.replace(search, replace); + // localPackage.setPkgRealName(localName); + // } + + // if (( packageData.getName() != null ) && ( ! packageData.getName().equals("") )) { + // localName = packageData.getName(); + // localName = localName.replace(search, replace); + // localPackage.setName(localName); + // } + + // oldPackages.add(localPackage); + // } + // } + // } + + // // reverse order for uninstallation + // int number = oldPackages.size(); + // for (int i = 0; i < number; i++) { + // if ( i > 0 ) { + // PackageDescription oldPackageData = (PackageDescription) oldPackages.remove(i); + // oldPackages.add(0,oldPackageData); + // } + // } + + // installData.setOldPackages(oldPackages); + // } + + static public void sortPackages(Vector allPackages, Vector sortedPackages, String mode) { + for (int i = 0; i < allPackages.size(); i++) { + boolean integrated = false; + PackageDescription packageData = (PackageDescription) allPackages.get(i); + + if ( i == 0 ) { + sortedPackages.add(packageData); + integrated = true; + } else { + int position = packageData.getOrder(); + for (int j = 0; j < sortedPackages.size(); j++) { + PackageDescription sortedPackageData = (PackageDescription) sortedPackages.get(j); + int compare = sortedPackageData.getOrder(); + + if ( position < compare ) { + sortedPackages.add(j, packageData); + integrated = true; + break; + } + } + + // no break used -> adding at the end + if ( ! integrated ) { + sortedPackages.add(packageData); + } + } + } + + // reverse order for uninstallation + if ( mode.equalsIgnoreCase("uninstall")) { + int number = sortedPackages.size(); + for (int i = 0; i < number; i++) { + if ( i > 0 ) { + PackageDescription sortPackageData = (PackageDescription) sortedPackages.remove(i); + sortedPackages.add(0,sortPackageData); + } + } + } + } + +} diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Parser.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Parser.java new file mode 100755 index 000000000000..6c22222fa27d --- /dev/null +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/Parser.java @@ -0,0 +1,49 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.setup.Util; + +public class Parser { + + private Parser() { + } + + static public boolean parseBoolean(String input) { + boolean value; + if ( input.equalsIgnoreCase("true")) { + value = true; + } else if ( input.equalsIgnoreCase("false")) { + value = false; + } else { + value = false; + System.err.println("Cannot convert String to boolean: " + input); + System.exit(1); + } + return value; + } + +} diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/SystemManager.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/SystemManager.java new file mode 100755 index 000000000000..f0a3619054bb --- /dev/null +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Util/SystemManager.java @@ -0,0 +1,484 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package org.openoffice.setup.Util; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URI; +import java.net.URL; +import java.util.HashMap; +import java.util.Properties; +import java.util.Vector; + +public class SystemManager { + + private SystemManager() { + } + + /* the installation root is where the classes reside */ + static public File getJarFilePath() { + + File jarFile = null; + + try { + Class c = Class.forName("org.openoffice.setup.ResourceManager"); + URL url = c.getResource("setupfiles.properties"); + + String urlString = url.toString(); + + if (urlString.startsWith("jar:")) { + /* ResourceManager.class resides in a jar file. Strip it down to the "file:" part */ + urlString = urlString.substring(4, urlString.lastIndexOf("!")); + jarFile = new File(new URI(urlString)); + } + + } catch (Exception ex) { + /* handle URISyntaxException and ClassNotFoundException */ + ex.printStackTrace(); + System.exit(1); + } + + if ( jarFile != null ) { + System.err.println("Jar file: " + jarFile.getPath()); + } else { + System.err.println("No jar file used for installation!"); + } + + return jarFile; + } + + /* the installation root is where the classes reside */ + static public File getResourceRoot() { + + File dir = null; + + try { + Class c = Class.forName("org.openoffice.setup.ResourceManager"); + URL url = c.getResource("setupfiles.properties"); + + String urlString = url.toString(); + + if (urlString.startsWith("jar:")) { + /* ResourceManager.class resides in a jar file. Strip it down to the "file:" part */ + urlString = urlString.substring(4, urlString.lastIndexOf("!")); + } else { + /* ResourceManager.class resides in a directory tree. */ + urlString = urlString.substring(0, urlString.lastIndexOf("/org/openoffice/setup/setupfiles.properties")); + } + + dir = new File(new URI(urlString)); + dir = dir.getParentFile(); + + } catch (Exception ex) { + /* handle URISyntaxException and ClassNotFoundException */ + ex.printStackTrace(); + System.exit(1); + } + // } + + if ( dir != null ) { + // System.err.println("Resource Root: " + dir.getPath()); + } else { + System.err.println("No resource root found!"); + } + + return dir; + } + + static public String getPackagePath(String subdir) { + + String path = null; + + File dir = getResourceRoot(); + if (dir != null) { + // System.err.println("Resource root: " + dir.getPath()); + dir = new File(dir, subdir); + if (! dir.exists()) { + System.err.println("Error: Directory \"" + subdir + "\" does not exist at resouce root"); + } else { + path = dir.getPath(); + } + } + + if ( path != null ) { + if ( ! path.endsWith("/")) { + path = path + "/"; + } + } + + if ( path != null ) { + System.err.println("Path to packages: " + path); + } else { + System.err.println("No path to packages found!"); + } + + return path; + } + + static public boolean find_file(String fileName) { + boolean found = false; + File file = new File(fileName); + found = file.exists(); + return found; + } + + static public boolean exists_directory(String directory) { + File dir = new File(directory); + return dir.exists(); + } + + static public boolean create_directory(String directory) throws SecurityException { + boolean created = false; + File dir = new File(directory); + try { + created = dir.mkdirs(); + } + catch (SecurityException ex) { + throw ex; + } + + return created; + } + + static public String getParentDirectory(String dir) { + File installFile = new File(dir); + String parentDir = installFile.getParent(); + if ( parentDir == null ) { + parentDir = "/"; + } + return parentDir; + } + + static public String getInstallationPrivileges() { + + String type = ""; + String user = java.lang.System.getProperty("user.name"); + // System.out.println("UserHome: " + java.lang.System.getProperty("user.home")); + + if ( user.equalsIgnoreCase("root")) { + type = "root"; + System.err.println("Root privileges"); + } else { + type = "user"; + System.err.println("User privileges"); + } + + return type; + } + + static public boolean isUserInstallation() { + + boolean isUserInstallation = false; + String user = java.lang.System.getProperty("user.name"); + + if ( user.equalsIgnoreCase("root")) { + isUserInstallation = false; + System.err.println("Root privileges"); + } else { + isUserInstallation = true; + System.err.println("User privileges"); + } + + return isUserInstallation; + } + + static public boolean isRootInstallation() { + + boolean isRootInstallation = false; + String user = java.lang.System.getProperty("user.name"); + + if ( user.equalsIgnoreCase("root")) { + isRootInstallation = true; + } else { + isRootInstallation = false; + } + + return isRootInstallation; + } + + static public String getOSType() { + String osVersion = java.lang.System.getProperty("os.name"); + System.err.println("OS: " + osVersion); + return osVersion; + } + + static public String getOSArchitecture() { + String osArchitecture = java.lang.System.getProperty("os.arch"); + System.out.println("OSArchitecture: " + osArchitecture); + return osArchitecture; + } + + static public String getOSVersion() { + String osVersion = java.lang.System.getProperty("os.version"); + System.out.println("OSVersion: " + osVersion); + return osVersion; + } + + static public HashMap getEnvironmentHashMap() { + // readonly map from getenv() + // System.getenv only supported in Java 1.5, properties have to be set in shell script + // Map map = java.lang.System.getenv(); + // HashMap myMap = new HashMap(map); + Properties props = System.getProperties(); + HashMap myMap = new HashMap(props); + return myMap; + } + + static public void dumpStringArray(String[] myStringArray) { + for (int i = 0; i < myStringArray.length; i++) { + System.out.println(myStringArray[i]); + } + } + + static public void dumpFile(String baseFileName, String dumpFileName) { + Vector fileContent = readCharFileVector(baseFileName); + saveCharFileVector(dumpFileName, fileContent); + } + + static public Vector readCharFileVector(String fileName) { + Vector fileContent = new Vector(); + + File file = new File(fileName); + if ( file.exists()) { + try { + FileInputStream fs = new FileInputStream(file); + BufferedReader bs = new BufferedReader(new InputStreamReader(fs)); + String zeile; + while((zeile = bs.readLine())!=null) { + fileContent.addElement(zeile); + } + } + catch (IOException e) { + System.out.println(e); + } + } else { + System.out.println( "Error: File not found: " + fileName); + } + + return fileContent; + } + + + static public void saveCharFileVector(String fileName, Vector fileContent) { + FileWriter fw = null; + try + { + fw = new FileWriter(fileName); + String fileContentStr = ""; + for (int i = 0; i < fileContent.size() ; i++) { + fileContentStr = fileContentStr + fileContent.get(i) + "\n"; + // System.out.println(fileContent.get(i)); + } + fw.write(fileContentStr); + } + catch ( IOException e ) { + System.out.println( "Could not create file: " + fileName); + } + finally { + try { + if ( fw != null ) fw.close(); + } catch (IOException e) {} + } + } + + static public void copyAllFiles(File source, File dest) { + File[] file = source.listFiles(); + if (file != null) { + for (int i = 0; i < file.length; i++) { + copy(file[i].getPath(), dest.getPath()); + } + } + } + + static public void copyAllFiles(File source, File dest, String ext) { + File[] file = source.listFiles(new FileExtensionFilter(ext)); + if (file != null) { + for (int i = 0; i < file.length; i++) { + copy(file[i].getPath(), dest.getPath()); + } + } + } + + // second parameter can be a complete file name or an existing directory + static public boolean copy(String source, String dest) { + + // is the second parameter a file name or a directory? + File dir = new File(dest); + if ( dir.isDirectory() ) { + File sourceFile = new File(source); + String fileName = sourceFile.getName(); + File destFile = new File(dest, fileName); + dest = destFile.getPath(); + } + + boolean file_copied = false; + FileInputStream fis; + BufferedInputStream bis; + FileOutputStream fos; + BufferedOutputStream bos; + byte[] b; + try { + fis = new FileInputStream(source); + fos = new FileOutputStream(dest); + } catch (FileNotFoundException ex) { + throw new Error("File not found"); + } + // put file into buffer + bis = new BufferedInputStream(fis); + bos = new BufferedOutputStream(fos); + try { // read file, write and close + b = new byte[bis.available()]; + bis.read(b); + bos.write(b); + bis.close(); + bos.close(); + file_copied = true; + } catch (IOException e) { + System.out.println("Dateien wurden nicht kopiert!"); + } + + return file_copied; + } + + static public boolean deleteFile(File file) { + boolean success = false; + if ( file.exists() && file != null ) { + success = file.delete(); + } + return success; + } + + static public boolean createDirectory(File dir) throws SecurityException { + boolean created = false; + try { + created = dir.mkdirs(); + } + catch (SecurityException ex) { + throw ex; + } + + return created; + } + + static public void removeDirectory(File dir) { + if ( dir.exists() && dir.isDirectory() ) { + File[] file = dir.listFiles(); + if (file != null) { + for (int i = 0; i < file.length; i++) { + deleteFile(file[i]); + } + } + dir.delete(); + } + } + + static public boolean logModuleStates() { + boolean logStates = false; + // System.getenv only supported in Java 1.5, property set in shell script + // String logStatesEnv = System.getenv("LOG_MODULE_STATES"); + String logStatesEnv = System.getProperty("LOG_MODULE_STATES"); + + if ( logStatesEnv != null ) { + logStates = true; + } + + return logStates; + } + + static public void setUnixPrivileges(String fileName, String unixRights) { + // String command = "chmod " + unixRights + " " + fileName; + String[] commandArray = new String[3]; + commandArray[0] = "chmod"; + commandArray[1] = unixRights; + commandArray[2] = fileName; + int value = ExecuteProcess.executeProcessReturnValue(commandArray); + } + + static public void setUnixPrivilegesDirectory(File directoryName, String ext, String unixRights) { + File[] file = directoryName.listFiles(new FileExtensionFilter(ext)); + if (file != null) { + for (int i = 0; i < file.length; i++) { + setUnixPrivileges(file[i].getPath(), unixRights); + } + } + } + + static public int calculateDiscSpace(String directory) { + String command = "df -k " + directory; + String[] commandArray = new String[3]; + commandArray[0] = "df"; + commandArray[1] = "-k"; + commandArray[2] = directory; + + int size = 0; + Vector returnVector = new Vector(); + Vector returnErrorVector = new Vector(); + int returnValue = ExecuteProcess.executeProcessReturnVector(commandArray, returnVector, returnErrorVector); + if ( returnValue == 0) { + int max = returnVector.size(); + if ( max > 0 ) { + String returnLine = (String) returnVector.get(max-1); + + // The fourth value is the available disc space (if the first value is a path) + // Otherwise it can also be the third value, if the first is not a path. + // If the first value is not a path, the string starts with white spaces. + + int position = 3; + if ( returnLine.startsWith(" ")) { + position = 2; + } + + returnLine = returnLine.trim(); + String[] returnArray = returnLine.split("\\s+"); + + if ( returnArray.length > 3 ) { + String sizeString = returnArray[position]; + + // Special handling for very large hard discs that cannot be converted to int + if ( sizeString.length() >= Integer.toString(Integer.MAX_VALUE).length() ) { + sizeString = Integer.toString(Integer.MAX_VALUE); + } + + // Converting from String to int + size = Integer.parseInt(sizeString); + } + } + } + + return size; + } + +} |