diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2008-02-05 12:37:13 +0000 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2008-02-05 12:37:13 +0000 |
commit | e7d8b2f094d16a0b92462629f153faf029c3c1e7 (patch) | |
tree | 2a344d0b9ba3a77f0c873aa50753cd5c072a6729 /javainstaller2 | |
parent | 0eff8d0c57d84edd8c3edfd4bba0aa1f05c99183 (diff) |
INTEGRATION: CWS native127 (1.3.44); FILE MERGED
2008/01/28 16:00:44 is 1.3.44.1: #i85281# improve performance
Diffstat (limited to 'javainstaller2')
-rwxr-xr-x | javainstaller2/src/JavaSetup/org/openoffice/setup/Installer/LinuxInstaller.java | 104 |
1 files changed, 100 insertions, 4 deletions
diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Installer/LinuxInstaller.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Installer/LinuxInstaller.java index fd63ae3eb6b7..38a9e6a5ea10 100755 --- a/javainstaller2/src/JavaSetup/org/openoffice/setup/Installer/LinuxInstaller.java +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Installer/LinuxInstaller.java @@ -4,9 +4,9 @@ * * $RCSfile: LinuxInstaller.java,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: rt $ $Date: 2007-07-03 11:54:15 $ + * last change: $Author: ihi $ $Date: 2008-02-05 13:37:13 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -46,6 +46,8 @@ import org.openoffice.setup.Util.ExecuteProcess; import org.openoffice.setup.Util.Informer; import org.openoffice.setup.Util.LogManager; import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; import java.util.Vector; public class LinuxInstaller extends Installer { @@ -105,6 +107,7 @@ public class LinuxInstaller extends Installer { // not analyzed before (when going back in installation wizard) if ( ! databasePath.equals(oldDatabasePath) ) { data.setDatabaseAnalyzed(false); + data.setDatabaseQueried(false); } } } @@ -349,7 +352,7 @@ public class LinuxInstaller extends Installer { } } - public boolean isPackageInstalled(PackageDescription packageData, InstallData installData) { + public boolean isPackageInstalledClassic(PackageDescription packageData, InstallData installData) { boolean isInstalled = false; boolean doCheck = false; @@ -366,6 +369,7 @@ public class LinuxInstaller extends Installer { } if (( rpmPackageName != null ) && ( doCheck )) { + String databaseString = ""; String databasePath = null; String packageName = packageData.getPkgRealName(); @@ -413,9 +417,101 @@ public class LinuxInstaller extends Installer { String log = rpmCommand + "<br><b>Returns: " + returnValue + " Package is not installed" + "</b><br>"; LogManager.addCommandsLogfileComment(log); } + } + } + + return isInstalled; + } + + private void queryAllDatabase(InstallData installData) { + + String databaseString = ""; + String databasePath = null; + HashMap map = new HashMap();; + boolean useLocalDatabase = false; + + if (installData.isUserInstallation()) { + databasePath = installData.getDatabasePath(); + } + + if (( databasePath != null ) && (! databasePath.equals("null"))) { + databaseString = "--dbpath"; + useLocalDatabase = true; + } + + String rpmCommand; + String[] rpmCommandArray; + if (useLocalDatabase) { + rpmCommand = "rpm" + " " + databaseString + " " + databasePath + " --query" + " -a"; + rpmCommandArray = new String[5]; + rpmCommandArray[0] = "rpm"; + rpmCommandArray[1] = databaseString; + rpmCommandArray[2] = databasePath; + rpmCommandArray[3] = "--query"; + rpmCommandArray[4] = "-a"; + } else { + rpmCommand = "rpm" + " --query" + " -a"; + rpmCommandArray = new String[3]; + rpmCommandArray[0] = "rpm"; + rpmCommandArray[1] = "--query"; + rpmCommandArray[2] = "-a"; + } + + Vector returnVector = new Vector(); + Vector returnErrorVector = new Vector(); + int returnValue = ExecuteProcess.executeProcessReturnVector(rpmCommandArray, returnVector, returnErrorVector); + + String log = rpmCommand + "<br><b>Returns: " + returnValue + "</b><br>"; + LogManager.addCommandsLogfileComment(log); + String value = "1"; + + if ( ! returnVector.isEmpty()) { + for (int i = 0; i < returnVector.size(); i++) { + String onePackage = (String)returnVector.get(i); + int pos1 = onePackage.lastIndexOf("-"); + int pos2 = onePackage.substring(0, pos1).lastIndexOf("-"); + map.put(onePackage.substring(0, pos2), value); + } + } + + installData.setDatabaseQueried(true); + installData.setDatabaseMap(map); + } + + public boolean isPackageInstalled(PackageDescription packageData, InstallData installData) { + + boolean isInstalled = false; + boolean doCheck = false; + + // only checking existing packages (and always at uninstallation) + if ( (packageData.pkgExists()) || (installData.isUninstallationMode()) ) { + doCheck = true; + } + + String rpmPackageName = packageData.getPackageName(); + + if ( rpmPackageName.equals("") ) { + rpmPackageName = null; + } + + if (( rpmPackageName != null ) && ( doCheck )) { + String packageName = packageData.getPkgRealName(); + + if (packageName != null) { + + HashMap map = null; + if ( ! installData.databaseQueried() ) { + queryAllDatabase(installData); + } + + map = installData.getDatabaseMap(); + + if ( map.containsKey(packageName)) { + isInstalled = true; + } } else { - System.err.println("Error: No packageName defined for package: " + rpmPackageName); + System.err.println("Error: No packageName defined for package: " + packageData.getPackageName()); } } |