diff options
author | Ingo Schmidt <is@openoffice.org> | 2010-09-13 17:33:53 +0200 |
---|---|---|
committer | Ingo Schmidt <is@openoffice.org> | 2010-09-13 17:33:53 +0200 |
commit | 2cab1ad00d080b85294350ed02a3d39e0522a15c (patch) | |
tree | 6ddff3727bd3a477d77ad3f391987afed06a900b | |
parent | e8b8fec48b3ad2464b6ce6744e419190efeb45b3 (diff) |
native330 #163564# fixing installation on Cent OS
3 files changed, 129 insertions, 182 deletions
diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallData.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallData.java index d3ba4abc5..e472d2b72 100755 --- a/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallData.java +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallData.java @@ -76,6 +76,7 @@ public class InstallData static private boolean useRtl = false; static private boolean installedProductMinorSet = false; static private boolean isDebianSystem = false; + static private boolean useForceDebian = false; static private boolean debianInvestigated = false; static private String installType; /* custom or typical installation */ static private String osType; /* Linux, SunOS, ... */ @@ -667,6 +668,14 @@ public class InstallData isDebianSystem = value; } + public boolean useForceDebian() { + return useForceDebian; + } + + public void setUseForceDebian(boolean value) { + useForceDebian = value; + } + public boolean databaseQueried() { return databaseQueried; } diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/Installer/LinuxInstaller.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/Installer/LinuxInstaller.java index c66c84a56..2906f7a05 100755 --- a/javainstaller2/src/JavaSetup/org/openoffice/setup/Installer/LinuxInstaller.java +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/Installer/LinuxInstaller.java @@ -202,12 +202,13 @@ public class LinuxInstaller extends Installer { } if ( data.isDebianSystem() ) { - forceDebianString = "--force-debian"; nodepsString = "--nodeps"; + + if ( data.useForceDebian() ) { + forceDebianString = "--force-debian"; + } } - String rpmCommand = ""; - String[] rpmCommandArray; String databasePath = null; String databaseString = ""; boolean useLocalDatabase = false; @@ -225,130 +226,57 @@ public class LinuxInstaller extends Installer { useLocalDatabase = true; } - if (useForce) { - if (useLocalDatabase) { - if ( relocations != null ) { - rpmCommand = "rpm --upgrade --ignoresize --force " + forceDebianString + " " + nodepsString + " -vh " + - "--relocate " + relocations + " " + databaseString + - " " + databasePath + " " + packageName; - rpmCommandArray = new String[12]; - rpmCommandArray[0] = "rpm"; - rpmCommandArray[1] = "--upgrade"; - rpmCommandArray[2] = "--ignoresize"; - rpmCommandArray[3] = "--force"; - rpmCommandArray[4] = forceDebianString; - rpmCommandArray[5] = nodepsString; - rpmCommandArray[6] = "-vh"; - rpmCommandArray[7] = "--relocate"; - rpmCommandArray[8] = relocations; - rpmCommandArray[9] = databaseString; - rpmCommandArray[10] = databasePath; - rpmCommandArray[11] = packageName; - } else { - rpmCommand = "rpm --upgrade --ignoresize --force " + forceDebianString + " " + nodepsString + " -vh " + - databaseString + " " + databasePath + " " + packageName; - rpmCommandArray = new String[10]; - rpmCommandArray[0] = "rpm"; - rpmCommandArray[1] = "--upgrade"; - rpmCommandArray[2] = "--ignoresize"; - rpmCommandArray[3] = "--force"; - rpmCommandArray[4] = forceDebianString; - rpmCommandArray[5] = nodepsString; - rpmCommandArray[6] = "-vh"; - rpmCommandArray[7] = databaseString; - rpmCommandArray[8] = databasePath; - rpmCommandArray[9] = packageName; - } - } else { - if ( relocations != null ) - { - rpmCommand = "rpm --upgrade --ignoresize --force " + forceDebianString + " " + nodepsString + " -vh " + - "--relocate " + relocations + " " + packageName; - rpmCommandArray = new String[10]; - rpmCommandArray[0] = "rpm"; - rpmCommandArray[1] = "--upgrade"; - rpmCommandArray[2] = "--ignoresize"; - rpmCommandArray[3] = "--force"; - rpmCommandArray[4] = forceDebianString; - rpmCommandArray[5] = nodepsString; - rpmCommandArray[6] = "-vh"; - rpmCommandArray[7] = "--relocate"; - rpmCommandArray[8] = relocations; - rpmCommandArray[9] = packageName; - } else { - rpmCommand = "rpm --upgrade --ignoresize --force " + forceDebianString + " " + nodepsString + " -vh " + packageName; - rpmCommandArray = new String[8]; - rpmCommandArray[0] = "rpm"; - rpmCommandArray[1] = "--upgrade"; - rpmCommandArray[2] = "--ignoresize"; - rpmCommandArray[3] = "--force"; - rpmCommandArray[4] = forceDebianString; - rpmCommandArray[5] = nodepsString; - rpmCommandArray[6] = "-vh"; - rpmCommandArray[7] = packageName; - } - } - } else { - if (useLocalDatabase) { - if ( relocations != null ) { - rpmCommand = "rpm --upgrade --ignoresize " + forceDebianString + " " + nodepsString + " -vh " + - "--relocate " + relocations + " " + databaseString + - " " + databasePath + " " + packageName; - rpmCommandArray = new String[11]; - rpmCommandArray[0] = "rpm"; - rpmCommandArray[1] = "--upgrade"; - rpmCommandArray[2] = "--ignoresize"; - rpmCommandArray[3] = forceDebianString; - rpmCommandArray[4] = nodepsString; - rpmCommandArray[5] = "-vh"; - rpmCommandArray[6] = "--relocate"; - rpmCommandArray[7] = relocations; - rpmCommandArray[8] = databaseString; - rpmCommandArray[9] = databasePath; - rpmCommandArray[10] = packageName; - } else { - rpmCommand = "rpm --upgrade --ignoresize " + forceDebianString + " " + nodepsString + " -vh " + - databaseString + " " + databasePath + " " + packageName; - rpmCommandArray = new String[9]; - rpmCommandArray[0] = "rpm"; - rpmCommandArray[1] = "--upgrade"; - rpmCommandArray[2] = "--ignoresize"; - rpmCommandArray[3] = forceDebianString; - rpmCommandArray[4] = nodepsString; - rpmCommandArray[5] = "-vh"; - rpmCommandArray[6] = databaseString; - rpmCommandArray[7] = databasePath; - rpmCommandArray[8] = packageName; - } - } else { - if ( relocations != null ) - { - rpmCommand = "rpm --upgrade --ignoresize " + forceDebianString + " " + nodepsString + " -vh " + - "--relocate " + relocations + " " + packageName; - rpmCommandArray = new String[9]; - rpmCommandArray[0] = "rpm"; - rpmCommandArray[1] = "--upgrade"; - rpmCommandArray[2] = "--ignoresize"; - rpmCommandArray[3] = forceDebianString; - rpmCommandArray[4] = nodepsString; - rpmCommandArray[5] = "-vh"; - rpmCommandArray[6] = "--relocate"; - rpmCommandArray[7] = relocations; - rpmCommandArray[8] = packageName; - } else { - rpmCommand = "rpm --upgrade --ignoresize " + forceDebianString + " " + nodepsString + " -vh " + packageName; - rpmCommandArray = new String[7]; - rpmCommandArray[0] = "rpm"; - rpmCommandArray[1] = "--upgrade"; - rpmCommandArray[2] = "--ignoresize"; - rpmCommandArray[3] = forceDebianString; - rpmCommandArray[4] = nodepsString; - rpmCommandArray[5] = "-vh"; - rpmCommandArray[6] = packageName; - } - } + // Defining a Vector that contains the full rpm command. Then the string array can be + // created dynamically. + + Vector rpmVector = new Vector(); + + rpmVector.add("rpm"); + rpmVector.add("--upgrade"); + rpmVector.add("--ignoresize"); + + if ( useForce ) { + rpmVector.add("--force"); } - + + if ( ! forceDebianString.equals("") ) { + rpmVector.add(forceDebianString); + } + + if ( ! nodepsString.equals("") ) { + rpmVector.add(nodepsString); + } + + rpmVector.add("-vh"); + + if ( relocations != null ) { + rpmVector.add("--relocate"); + rpmVector.add(relocations); + } + + if ( useLocalDatabase ) { + rpmVector.add(databaseString); + rpmVector.add(databasePath); + } + + rpmVector.add(packageName); + + // Creating String and StringArray for rpm command + + int capacity = rpmVector.size(); + + String rpmCommand = ""; + String[] rpmCommandArray = new String[capacity]; + + for (int i = 0; i < rpmVector.size(); i++) { + rpmCommandArray[i] = (String)rpmVector.get(i); + rpmCommand = rpmCommand + " " + (String)rpmVector.get(i); + } + + rpmCommand = rpmCommand.trim(); + + // Staring rpm process + Vector returnVector = new Vector(); Vector returnErrorVector = new Vector(); // int returnValue = SystemManager.executeProcessReturnVector(rpmCommand, returnVector, returnErrorVector); @@ -407,8 +335,6 @@ public class LinuxInstaller extends Installer { String databasePath = data.getDatabasePath(); String databaseString = ""; boolean useLocalDatabase = false; - String rpmCommand; - String[] rpmCommandArray; if (( databasePath != null ) && (! databasePath.equalsIgnoreCase("null"))) { databaseString = "--dbpath"; @@ -427,51 +353,52 @@ public class LinuxInstaller extends Installer { } if ( data.isDebianSystem() ) { - forceDebianString = "--force-debian"; nodepsString = "--nodeps"; + + if ( data.useForceDebian() ) { + forceDebianString = "--force-debian"; + } } - - // Code duplication for isDebianSystem is necessary, because there is no valid position - // for forceDebianString, if it is empty. This is no problem in installPackage. - if ( data.isDebianSystem() ) { - - if (useLocalDatabase) { - rpmCommand = "rpm " + forceDebianString + " " + nodepsString + " -ev" + " " + databaseString + " " + databasePath + " " + packageName; - rpmCommandArray = new String[7]; - rpmCommandArray[0] = "rpm"; - rpmCommandArray[1] = forceDebianString; - rpmCommandArray[2] = nodepsString; - rpmCommandArray[3] = "-ev"; - rpmCommandArray[4] = databaseString; - rpmCommandArray[5] = databasePath; - rpmCommandArray[6] = packageName; - } else { - rpmCommand = "rpm " + forceDebianString + " " + nodepsString + " -ev" + " " + packageName; - rpmCommandArray = new String[5]; - rpmCommandArray[0] = "rpm"; - rpmCommandArray[1] = forceDebianString; - rpmCommandArray[2] = nodepsString; - rpmCommandArray[3] = "-ev"; - rpmCommandArray[4] = packageName; - } - } else { - if (useLocalDatabase) { - rpmCommand = "rpm -ev" + " " + databaseString + " " + databasePath + " " + packageName; - rpmCommandArray = new String[5]; - rpmCommandArray[0] = "rpm"; - rpmCommandArray[1] = "-ev"; - rpmCommandArray[2] = databaseString; - rpmCommandArray[3] = databasePath; - rpmCommandArray[4] = packageName; - } else { - rpmCommand = "rpm -ev" + " " + packageName; - rpmCommandArray = new String[3]; - rpmCommandArray[0] = "rpm"; - rpmCommandArray[1] = "-ev"; - rpmCommandArray[2] = packageName; - } + // Defining a Vector that contains the full rpm command. Then the string array can be + // created dynamically. + + Vector rpmVector = new Vector(); + + rpmVector.add("rpm"); + + if ( ! forceDebianString.equals("") ) { + rpmVector.add(forceDebianString); } + + if ( ! nodepsString.equals("") ) { + rpmVector.add(nodepsString); + } + + rpmVector.add("-ev"); + + if ( useLocalDatabase ) { + rpmVector.add(databaseString); + rpmVector.add(databasePath); + } + + rpmVector.add(packageName); + + // Creating String and StringArray for rpm command + + int capacity = rpmVector.size(); + + String rpmCommand = ""; + String[] rpmCommandArray = new String[capacity]; + + for (int i = 0; i < rpmVector.size(); i++) { + rpmCommandArray[i] = (String)rpmVector.get(i); + rpmCommand = rpmCommand + " " + (String)rpmVector.get(i); + } + + rpmCommand = rpmCommand.trim(); + + // Starting rpm process Vector returnVector = new Vector(); Vector returnErrorVector = new Vector(); diff --git a/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallerHelper/LinuxHelper.java b/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallerHelper/LinuxHelper.java index 9ce41daf2..b21123cb2 100755 --- a/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallerHelper/LinuxHelper.java +++ b/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallerHelper/LinuxHelper.java @@ -383,21 +383,32 @@ import java.util.Vector;public class LinuxHelper { public void investigateDebian(InstallData data) { - // String rpmQuery = "rpm --help; - String[] rpmQueryArray = new String[2]; - rpmQueryArray[0] = "rpm"; - rpmQueryArray[1] = "--help"; - - Vector returnVector = new Vector(); - Vector returnErrorVector = new Vector(); - int returnValue = ExecuteProcess.executeProcessReturnVector(rpmQueryArray, returnVector, returnErrorVector); + // First check: Is this a Debian system? - // Checking if the return vector contains the string "force-debian" + String dpkgFile = "/usr/bin/dpkg"; + + if ( new File(dpkgFile).exists() ) { + + data.setIsDebianSystem(true); + + // Second check: If this is a Debian system, is "--force-debian" required? + + // String rpmQuery = "rpm --help; + String[] rpmQueryArray = new String[2]; + rpmQueryArray[0] = "rpm"; + rpmQueryArray[1] = "--help"; + + Vector returnVector = new Vector(); + Vector returnErrorVector = new Vector(); + int returnValue = ExecuteProcess.executeProcessReturnVector(rpmQueryArray, returnVector, returnErrorVector); + + // Checking if the return vector contains the string "force-debian" - for (int i = 0; i < returnVector.size(); i++) { - String line = (String) returnVector.get(i); - if ( line.indexOf("force-debian") > -1 ) { - data.setIsDebianSystem(true); + for (int i = 0; i < returnVector.size(); i++) { + String line = (String) returnVector.get(i); + if ( line.indexOf("force-debian") > -1 ) { + data.setUseForceDebian(true); + } } } } |