Commits

Ingo Schmidt  committed 2a42ee0

native330 #163564# fixing installation on Cent OS

  • Participants
  • Parent commits ca1b98f

Comments (0)

Files changed (3)

File javainstaller2/src/JavaSetup/org/openoffice/setup/InstallData.java

     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, ...              */
         isDebianSystem = value;
     }
 
+    public boolean useForceDebian() {
+    	return useForceDebian;
+    }
+
+    public void setUseForceDebian(boolean value) {
+        useForceDebian = value;
+    }
+
     public boolean databaseQueried() {
     	return databaseQueried;
     }

File javainstaller2/src/JavaSetup/org/openoffice/setup/Installer/LinuxInstaller.java

                 }
                 
                 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;
                     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);
             String databasePath = data.getDatabasePath();
             String databaseString = "";
             boolean useLocalDatabase = false;
-            String rpmCommand;
-            String[] rpmCommandArray;
         
             if (( databasePath != null ) && (! databasePath.equalsIgnoreCase("null"))) {
                 databaseString = "--dbpath";
             }
                 
             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() ) {
+            // 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);
+            }
             
-                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;
-                }            	
-            }
+            rpmCommand = rpmCommand.trim();
+
+            // Starting rpm process
 
             Vector returnVector = new Vector();
             Vector returnErrorVector = new Vector();

File javainstaller2/src/JavaSetup/org/openoffice/setup/InstallerHelper/LinuxHelper.java

   
     public void investigateDebian(InstallData data) {
         
-        // String rpmQuery = "rpm --help;
-        String[] rpmQueryArray = new String[2];
-        rpmQueryArray[0] = "rpm";
-        rpmQueryArray[1] = "--help";
+        // First check: Is this a Debian system?
+        
+        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);
+            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"
+            // 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);
+                }
             }
         }
     }