1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package org.openoffice.setup.Installer;
25 
26 import java.io.File;
27 import org.openoffice.setup.InstallData;
28 import org.openoffice.setup.InstallerHelper.LinuxHelper;
29 import org.openoffice.setup.ResourceManager;
30 import org.openoffice.setup.SetupData.PackageDescription;
31 import org.openoffice.setup.SetupData.ProductDescription;
32 import org.openoffice.setup.SetupData.SetupDataProvider;
33 import org.openoffice.setup.Util.ExecuteProcess;
34 import org.openoffice.setup.Util.Informer;
35 import org.openoffice.setup.Util.LogManager;
36 import java.util.HashMap;
37 import java.util.Iterator;
38 import java.util.Map;
39 import java.util.Vector;
40 
41 public class LinuxInstaller extends Installer {
42 
43     LinuxHelper helper = new LinuxHelper();
44 
LinuxInstaller()45     public LinuxInstaller() {
46         super();
47     }
48 
preInstall(PackageDescription packageData)49     public void preInstall(PackageDescription packageData) {
50         InstallData installData = InstallData.getInstance();
51         // Collecting package names
52         helper.getLinuxPackageNamesFromRpmquery(packageData, installData);
53         helper.getLinuxFileInfo(packageData);
54         // Dumper.dumpAllRpmInfo(packageData);
55     }
56 
postInstall(PackageDescription packageData)57     public void postInstall(PackageDescription packageData) {
58         InstallData data = InstallData.getInstance();
59 
60         if ( ! data.isAbortedInstallation() ) {
61             data.setStillRunning(true);
62             // Collecting information about installed packages
63             // Creating a list containing pairs of package names and rpm file names
64             // that has to be used during uninstallation.
65             helper.createPackageNameFileAtPostinstall(data, packageData);
66             helper.saveModulesLogFile(data);
67             data.setStillRunning(false);
68         }
69     }
70 
preUninstall(PackageDescription packageData)71     public void preUninstall(PackageDescription packageData) {
72         // Collecting information about installed packages
73         HashMap packageNames = helper.readPackageNamesFile();
74         helper.setFullPackageNameAtUninstall(packageData, packageNames);
75         helper.getLinuxFileInfo(packageData);
76         // Dumper.dumpAllRpmInfo(packageData);
77     }
78 
defineDatabasePath()79     public void defineDatabasePath() {
80 
81         InstallData data = InstallData.getInstance();
82         String oldDatabasePath = data.getDatabasePath();
83         data.setDatabasePath(null);
84 
85         // Determining the database path (only for user installation).
86         // Important if a user installation is done into an existing
87         // user installation -> this methode can only be called after
88         // determination of installation directory.
89 
90         if ( data.isUserInstallation() ) {
91             String databasePath = helper.getLinuxDatabasePath(data); // the file does not need to exist!
92             data.setDatabasePath(databasePath);
93 
94             // If this is a new path to the database, then this database was
95             // not analyzed before (when going back in installation wizard)
96             if ( ! databasePath.equals(oldDatabasePath) ) {
97                 data.setDatabaseAnalyzed(false);
98                 data.setDatabaseQueried(false);
99             }
100         }
101     }
102 
getChangeInstallDir(PackageDescription packageData)103     public String getChangeInstallDir(PackageDescription packageData) {
104         String installDir = null;
105         InstallData installData = InstallData.getInstance();
106 
107         String packageName = packageData.getPkgRealName();
108 
109         if ( packageName != null ) {
110             String rpmCommand = "rpm -q --queryformat %{INSTALLPREFIX} " + packageName;
111             String[] rpmCommandArray = new String[5];
112             rpmCommandArray[0] = "rpm";
113             rpmCommandArray[1] = "-q";
114             rpmCommandArray[2] = "--queryformat";
115             rpmCommandArray[3] = "%{INSTALLPREFIX}";
116             rpmCommandArray[4] = packageName;
117 
118             Vector returnVector = new Vector();
119             Vector returnErrorVector = new Vector();
120             int returnValue = ExecuteProcess.executeProcessReturnVector(rpmCommandArray, returnVector, returnErrorVector);
121             String returnString = (String) returnVector.get(0);
122             returnString = returnString.replaceAll("//","/");
123 
124             String log = rpmCommand + "<br><b>Returns: " + returnString + "</b><br>";
125             LogManager.addCommandsLogfileComment(log);
126 
127             installDir = returnString;
128         }
129 
130         return installDir;
131     }
132 
installPackage(PackageDescription packageData)133     public void installPackage(PackageDescription packageData) {
134         // get ProductDescription for logging mechanism
135         ProductDescription productData = SetupDataProvider.getProductDescription();
136         InstallData data = InstallData.getInstance();
137 
138         // String log = "<br><b>Package: " + packageData.getName() + "</b>";
139         // LogManager.addCommandsLogfileComment(log);
140         String log = "";
141 
142         // setting installDir
143         String installDir = data.getInstallDir();
144         String packagePath = data.getPackagePath();
145 
146         if (( packageData.getPkgSubdir() != null ) && ( ! packageData.getPkgSubdir().equals("") )) {
147             File completePackageFile = new File(packagePath, packageData.getPkgSubdir());
148             packagePath = completePackageFile.getPath();
149         }
150 
151         String packageName = packageData.getPackageName();
152 
153         if (( packageName.equals("")) || ( packageName == null )) {
154             log = "<b>No package name specified. Nothing to do</b>";
155             LogManager.addCommandsLogfileComment(log);
156         } else {
157             log = "<b>Package Name: " + packageName + "</b>";
158             LogManager.addCommandsLogfileComment(log);
159 
160             File completePackage = new File(packagePath, packageName);
161             packageName = completePackage.getPath();
162             packageName = "\"" + packageName + "\""; // Quoting is necessary, if the path to the packages contains white spaces.
163 
164             if ( completePackage.exists() ) {
165                 String relocations = helper.getRelocationString(packageData, packageName);
166                 if ( relocations != null ) {
167                     // Problem: If Prefix = "/" the packages are not relocatable with RPM version 3.x .
168                     // Therefore Prefix has to be "/opt" in spec file, although packages shall not be
169                     // relocatable (except for installations with root privileges). So /opt has to be
170                     // listed left and right of equal sign: --relocate /opt=<installDir>/opt
171                     // -> /opt has to be added to the installDir
172                     File localInstallDir = new File(installDir, relocations);  // "/" -> "/opt"
173                     String localInstallDirString = localInstallDir.getPath();
174 
175                     // Fixing problem with installation directory and RPM version 3.x
176                     String fixedInstallDir = helper.fixInstallationDirectory(localInstallDirString);
177                     relocations = relocations + "=" + fixedInstallDir;
178                     // relocations: "/opt/staroffice8=" + fixedInstallDir;
179                 }
180 
181                 // Some packages have to be installed with parameter "--force", if the link "/usr/bin/soffice"
182                 // already exists. These pacakges return true with methode "useForce()".
183                 boolean useForce = false;
184                 if ( packageData.useForce() ) {
185                     File sofficeLink = new File("/usr/bin/soffice");
186                     if ( sofficeLink.exists() ) { useForce = true; }
187                 }
188 
189                 // On Debian based systems, rpms can be installed with the switch --force-debian, if a rpm
190                 // is installed.
191 
192                 String forceDebianString = "";
193                 String nodepsString = "";
194 
195                 if ( ! data.debianInvestigated() ) {
196                     helper.investigateDebian(data);
197                     data.setDebianInvestigated(true);
198                 }
199 
200                 if ( data.isDebianSystem() ) {
201                     nodepsString = "--nodeps";
202 
203                     if ( data.useForceDebian() ) {
204                         forceDebianString = "--force-debian";
205                     }
206                 }
207 
208                 String databasePath = null;
209                 String databaseString = "";
210                 boolean useLocalDatabase = false;
211 
212                 if ( data.isUserInstallation() ) {
213                     databasePath = data.getDatabasePath();
214                     if ( databasePath == null ) {
215                         databasePath = helper.getLinuxDatabasePath(data);
216                         data.setDatabasePath(databasePath);
217                     }
218                 }
219 
220                 if (( databasePath != null ) && (! databasePath.equalsIgnoreCase("null"))) {
221                     databaseString = "--dbpath";
222                     useLocalDatabase = true;
223                 }
224 
225                 // Defining a Vector that contains the full rpm command. Then the string array can be
226                 // created dynamically. Otherwise there would be too many different scenarios.
227 
228                 Vector rpmVector = new Vector();
229 
230                 rpmVector.add("rpm");
231                 rpmVector.add("--upgrade");
232                 rpmVector.add("--ignoresize");
233 
234                 if ( useForce ) {
235                     rpmVector.add("--force");
236                 }
237 
238                 if ( ! forceDebianString.equals("") ) {
239                     rpmVector.add(forceDebianString);
240                 }
241 
242                 if ( ! nodepsString.equals("") ) {
243                     rpmVector.add(nodepsString);
244                 }
245 
246                 rpmVector.add("-vh");
247 
248                 if ( relocations != null ) {
249                     rpmVector.add("--relocate");
250                     rpmVector.add(relocations);
251                 }
252 
253                 if ( useLocalDatabase ) {
254                     rpmVector.add(databaseString);
255                     rpmVector.add(databasePath);
256                 }
257 
258                 rpmVector.add(packageName);
259 
260                 // Creating String and StringArray for rpm command
261 
262                 int capacity = rpmVector.size();
263 
264                 String rpmCommand = "";
265                 String[] rpmCommandArray = new String[capacity];
266 
267                 for (int i = 0; i < rpmVector.size(); i++) {
268                     rpmCommandArray[i] = (String)rpmVector.get(i);
269                     rpmCommand = rpmCommand + " " + (String)rpmVector.get(i);
270                 }
271 
272                 rpmCommand = rpmCommand.trim();
273 
274                 // Staring rpm process
275 
276                 Vector returnVector = new Vector();
277                 Vector returnErrorVector = new Vector();
278                 // int returnValue = SystemManager.executeProcessReturnVector(rpmCommand, returnVector, returnErrorVector);
279                 int returnValue = ExecuteProcess.executeProcessReturnVector(rpmCommandArray, returnVector, returnErrorVector);
280 
281                 if ( returnValue == 0 ) {
282                     log = rpmCommand + "<br><b>Returns: " + returnValue + " Successful installation</b><br>";
283                     LogManager.addCommandsLogfileComment(log);
284                 } else {    // an error occurred during installation
285                     if ( packageData.installCanFail() ) {
286                         log = rpmCommand + "<br><b>Returns: " + returnValue + " Problem during installation. Can be ignored.</b><br>";
287                         LogManager.addCommandsLogfileComment(log);
288                     } else {
289                         log = rpmCommand + "<br><b>Returns: " + returnValue + " Error during installation</b><br>";
290                         LogManager.addCommandsLogfileComment(log);
291                         for (int i = 0; i < returnErrorVector.size(); i++) {
292                             LogManager.addCommandsLogfileComment((String)returnErrorVector.get(i));
293                         }
294                         data.setIsErrorInstallation(true);
295                     }
296                 }
297 
298                 // saving installation state at package
299                 packageData.setIsNewInstalled(true);
300             } else {
301                 log = "<b>Error: Did not find package " + packageName + "</b><br>";
302                 System.err.println(log);
303                 String message = ResourceManager.getString("String_File_Not_Found") + ": " + packageName;
304                 String title = ResourceManager.getString("String_Error");
305                 Informer.showErrorMessage(message, title);
306                 LogManager.addCommandsLogfileComment(log);
307                 data.setIsErrorInstallation(true);
308             }
309         }
310     }
311 
uninstallPackage(PackageDescription packageData)312     public void uninstallPackage(PackageDescription packageData) {
313         // get ProductDescription for logging mechanism
314         ProductDescription productData = SetupDataProvider.getProductDescription();
315         InstallData data = InstallData.getInstance();
316 
317         String log  = "";
318         // String log = "<br><b>Package: " + packageData.getName() + "</b>";
319         // LogManager.addCommandsLogfileComment(log);
320 
321         String rpmPackageName = packageData.getPackageName();
322 
323         if (( rpmPackageName.equals("")) || ( rpmPackageName == null )) {
324             log = "<b>No package name specified. Nothing to do</b>";
325             LogManager.addCommandsLogfileComment(log);
326         } else {
327             log = "<b>Package Name: " + rpmPackageName + "</b>";
328             LogManager.addCommandsLogfileComment(log);
329 
330             String packageName = packageData.getPkgRealName();
331             String databasePath = data.getDatabasePath();
332             String databaseString = "";
333             boolean useLocalDatabase = false;
334 
335             if (( databasePath != null ) && (! databasePath.equalsIgnoreCase("null"))) {
336                 databaseString = "--dbpath";
337                 useLocalDatabase = true;
338             }
339 
340             // On Debian based systems, rpms can be installed with the switch --force-debian, if a rpm
341             // is installed.
342 
343             String forceDebianString = "";
344             String nodepsString = "";
345             String noscriptsString = "";
346 
347             if ( ! data.debianInvestigated() ) {
348                 helper.investigateDebian(data);
349                 data.setDebianInvestigated(true);
350             }
351 
352             if ( data.isDebianSystem() ) {
353                 nodepsString = "--nodeps";
354 
355                 if ( data.useForceDebian() ) {
356                     forceDebianString = "--force-debian";
357                 }
358             }
359 
360             if (( data.isErrorInstallation() ) && ( data.isFirstPackage() )) {
361                 noscriptsString = "--noscripts";
362             }
363 
364             // Defining a Vector that contains the full rpm command. Then the string array can be
365             // created dynamically. Otherwise there would be too many different scenarios.
366 
367             Vector rpmVector = new Vector();
368 
369             rpmVector.add("rpm");
370 
371             if ( ! forceDebianString.equals("") ) {
372                 rpmVector.add(forceDebianString);
373             }
374 
375             if ( ! nodepsString.equals("") ) {
376                 rpmVector.add(nodepsString);
377             }
378 
379             if ( ! noscriptsString.equals("") ) {
380                 rpmVector.add(noscriptsString);
381             }
382 
383             rpmVector.add("-ev");
384 
385             if ( useLocalDatabase ) {
386                 rpmVector.add(databaseString);
387                 rpmVector.add(databasePath);
388             }
389 
390             rpmVector.add(packageName);
391 
392             // Creating String and StringArray for rpm command
393 
394             int capacity = rpmVector.size();
395 
396             String rpmCommand = "";
397             String[] rpmCommandArray = new String[capacity];
398 
399             for (int i = 0; i < rpmVector.size(); i++) {
400                 rpmCommandArray[i] = (String)rpmVector.get(i);
401                 rpmCommand = rpmCommand + " " + (String)rpmVector.get(i);
402             }
403 
404             rpmCommand = rpmCommand.trim();
405 
406             // Starting rpm process
407 
408             Vector returnVector = new Vector();
409             Vector returnErrorVector = new Vector();
410             int returnValue = ExecuteProcess.executeProcessReturnVector(rpmCommandArray, returnVector, returnErrorVector);
411 
412             if ( returnValue == 0 ) {
413                 log = rpmCommand + "<br><b>Returns: " + returnValue + " Successful uninstallation</b><br>";
414                 LogManager.addCommandsLogfileComment(log);
415             } else {    // an error occurred during installation
416                 if ( packageData.uninstallCanFail() ) {
417                     log = rpmCommand + "<br><b>Returns: " + returnValue + " Problem during uninstallation. Can be ignored.</b><br>";
418                     LogManager.addCommandsLogfileComment(log);
419                 } else {
420                     log = rpmCommand + "<br><b>Returns: " + returnValue + " Error during uninstallation</b><br>";
421                     LogManager.addCommandsLogfileComment(log);
422                     for (int i = 0; i < returnErrorVector.size(); i++) {
423                         LogManager.addCommandsLogfileComment((String)returnErrorVector.get(i));
424                     }
425                     data.setIsErrorInstallation(true);
426                 }
427             }
428         }
429     }
430 
isPackageInstalledClassic(PackageDescription packageData, InstallData installData)431     public boolean isPackageInstalledClassic(PackageDescription packageData, InstallData installData) {
432 
433         boolean isInstalled = false;
434         boolean doCheck = false;
435 
436         // only checking existing packages (and always at uninstallation)
437         if ( (packageData.pkgExists()) || (installData.isUninstallationMode()) ) {
438             doCheck = true;
439         }
440 
441         String rpmPackageName = packageData.getPackageName();
442 
443         if ( rpmPackageName.equals("") ) {
444             rpmPackageName = null;
445         }
446 
447         if (( rpmPackageName != null ) && ( doCheck )) {
448 
449             String databaseString = "";
450             String databasePath = null;
451             String packageName = packageData.getPkgRealName();
452             Vector allPackages = null;
453             boolean useLocalDatabase = false;
454 
455             if (installData.isUserInstallation()) {
456                 databasePath = installData.getDatabasePath();
457             }
458 
459             if (( databasePath != null ) && (! databasePath.equals("null"))) {
460                 databaseString = "--dbpath";
461                 useLocalDatabase = true;
462             }
463 
464             if (packageName != null) {
465 
466                 String rpmCommand;
467                 String[] rpmCommandArray;
468 
469                 if (useLocalDatabase) {
470                     rpmCommand = "rpm" + " " + databaseString + " " + databasePath + " --query " + packageName;
471                     rpmCommandArray = new String[5];
472                     rpmCommandArray[0] = "rpm";
473                     rpmCommandArray[1] = databaseString;
474                     rpmCommandArray[2] = databasePath;
475                     rpmCommandArray[3] = "--query";
476                     rpmCommandArray[4] = packageName;
477                 } else {
478                     rpmCommand = "rpm" + " --query " + packageName;
479                     rpmCommandArray = new String[3];
480                     rpmCommandArray[0] = "rpm";
481                     rpmCommandArray[1] = "--query";
482                     rpmCommandArray[2] = packageName;
483                 }
484 
485                 int returnValue = ExecuteProcess.executeProcessReturnValue(rpmCommandArray);
486 
487                 if ( returnValue == 0 ) {
488                     isInstalled = true;
489                     packageData.setWasAlreadyInstalled(true); // needed for logging
490                     String log = rpmCommand + "<br><b>Returns: " + returnValue + " Package is installed" + "</b><br>";
491                     LogManager.addCommandsLogfileComment(log);
492                 } else {
493                     String log = rpmCommand + "<br><b>Returns: " + returnValue + " Package is not installed" + "</b><br>";
494                     LogManager.addCommandsLogfileComment(log);
495                 }
496             }
497         }
498 
499         return isInstalled;
500     }
501 
queryAllDatabase(InstallData installData)502     private void queryAllDatabase(InstallData installData) {
503 
504         String databaseString = "";
505         String databasePath = null;
506         HashMap map = new HashMap();;
507         boolean useLocalDatabase = false;
508 
509         if (installData.isUserInstallation()) {
510             databasePath = installData.getDatabasePath();
511         }
512 
513         if (( databasePath != null ) && (! databasePath.equals("null"))) {
514             databaseString = "--dbpath";
515             useLocalDatabase = true;
516         }
517 
518         String rpmCommand;
519         String[] rpmCommandArray;
520 
521         if (useLocalDatabase) {
522             rpmCommand = "rpm" + " " + databaseString + " " + databasePath + " --query" + " -a";
523             rpmCommandArray = new String[5];
524             rpmCommandArray[0] = "rpm";
525             rpmCommandArray[1] = databaseString;
526             rpmCommandArray[2] = databasePath;
527             rpmCommandArray[3] = "--query";
528             rpmCommandArray[4] = "-a";
529         } else {
530             rpmCommand = "rpm" + " --query" + " -a";
531             rpmCommandArray = new String[3];
532             rpmCommandArray[0] = "rpm";
533             rpmCommandArray[1] = "--query";
534             rpmCommandArray[2] = "-a";
535         }
536 
537         Vector returnVector = new Vector();
538         Vector returnErrorVector = new Vector();
539         int returnValue = ExecuteProcess.executeProcessReturnVector(rpmCommandArray, returnVector, returnErrorVector);
540 
541         String log = rpmCommand + "<br><b>Returns: " + returnValue + "</b><br>";
542         LogManager.addCommandsLogfileComment(log);
543         String value = "1";
544 
545         if ( ! returnVector.isEmpty()) {
546             for (int i = 0; i < returnVector.size(); i++) {
547                 String onePackage = (String)returnVector.get(i);
548                 int pos1 = onePackage.lastIndexOf("-");
549                 int pos2 = onePackage.substring(0, pos1).lastIndexOf("-");
550                 String key = onePackage.substring(0, pos2);
551                 map.put(key, value);
552             }
553         }
554 
555         installData.setDatabaseQueried(true);
556         installData.setDatabaseMap(map);
557     }
558 
isPackageInstalled(PackageDescription packageData, InstallData installData)559     public boolean isPackageInstalled(PackageDescription packageData, InstallData installData) {
560 
561         boolean isInstalled = false;
562         boolean doCheck = false;
563 
564         // only checking existing packages (and always at uninstallation)
565         if ( (packageData.pkgExists()) || (installData.isUninstallationMode()) ) {
566             doCheck = true;
567         }
568 
569         String rpmPackageName = packageData.getPackageName();
570 
571         if ( rpmPackageName.equals("") ) {
572             rpmPackageName = null;
573         }
574 
575         if (( rpmPackageName != null ) && ( doCheck )) {
576             String packageName = packageData.getPkgRealName();
577 
578             if (packageName != null) {
579 
580                 HashMap map = null;
581                 if ( ! installData.databaseQueried() ) {
582                     queryAllDatabase(installData);
583                 }
584 
585                 map = installData.getDatabaseMap();
586 
587                 if ( map.containsKey(packageName)) {
588                     isInstalled = true;
589                 }
590             } else {
591                 System.err.println("Error: No packageName defined for package: " + packageData.getPackageName());
592             }
593         }
594 
595         return isInstalled;
596     }
597 
isInstallSetPackageOlder(PackageDescription packageData, InstallData installData)598     public boolean isInstallSetPackageOlder(PackageDescription packageData, InstallData installData) {
599         boolean installSetPackageIsOlder = false;
600         boolean checkIfInstalledIsOlder = false;
601         installSetPackageIsOlder = findOlderPackage(packageData, installData, checkIfInstalledIsOlder);
602         return installSetPackageIsOlder;
603     }
604 
isInstalledPackageOlder(PackageDescription packageData, InstallData installData)605     public boolean isInstalledPackageOlder(PackageDescription packageData, InstallData installData) {
606         boolean installedPackageIsOlder = false;
607         boolean checkIfInstalledIsOlder = true;
608         installedPackageIsOlder = findOlderPackage(packageData, installData, checkIfInstalledIsOlder);
609         return installedPackageIsOlder;
610     }
611 
findOlderPackage(PackageDescription packageData, InstallData installData, boolean checkIfInstalledIsOlder)612     private boolean findOlderPackage(PackageDescription packageData, InstallData installData, boolean checkIfInstalledIsOlder) {
613 
614         // The information about the new package is stored in packageData (the version and the release).
615         // This information can be stored in xpd files. If it is not stored in xpd files, it is determined
616         // during installation process by querying the rpm file. This process costs much time and should
617         // therefore be done by the process, that creates the xpd files. On the other hand this requires,
618         // that the xpd files contain the correct information.
619 
620         boolean isOlder = false;
621 
622         // get the version of the installed package
623         String rpmPackageName = packageData.getPackageName();
624         String log;
625 
626         if ( rpmPackageName.equals("")) {
627             rpmPackageName = null;
628         }
629 
630         if ( rpmPackageName != null ) {
631             String databaseString = "";
632             String databasePath = null;
633             String packageName =  packageData.getPkgRealName();
634             Vector allPackages = null;
635             boolean useLocalDatabase = false;
636 
637             if (installData.isUserInstallation()) {
638                 databasePath = installData.getDatabasePath();
639             }
640 
641             if (( databasePath != null ) && (! databasePath.equals("null"))) {
642                 databaseString = "--dbpath";
643                 useLocalDatabase = true;
644             }
645 
646             if (packageName != null) {
647                 // Collect information about the installed package by querying the database.
648                 // Instead of rpm file name, the real package name has to be used.
649 
650                 String rpmCommand;
651                 String[] rpmCommandArray;
652 
653                 if (useLocalDatabase) {
654                     rpmCommand = "rpm" + " " + databaseString + " " + databasePath + " -q --queryformat %{VERSION}\\n " + packageName;
655                     rpmCommandArray = new String[7];
656                     rpmCommandArray[0] = "rpm";
657                     rpmCommandArray[1] = databaseString;
658                     rpmCommandArray[2] = databasePath;
659                     rpmCommandArray[3] = "-q";
660                     rpmCommandArray[4] = "--queryformat";
661                     rpmCommandArray[5] = "%{VERSION}\\n";
662                     rpmCommandArray[6] = packageName;
663                 } else {
664                     rpmCommand = "rpm" + " -q --queryformat %{VERSION}\\n " + packageName;
665                     rpmCommandArray = new String[5];
666                     rpmCommandArray[0] = "rpm";
667                     rpmCommandArray[1] = "-q";
668                     rpmCommandArray[2] = "--queryformat";
669                     rpmCommandArray[3] = "%{VERSION}\\n";
670                     rpmCommandArray[4] = packageName;
671                 }
672 
673                 Vector versionVector = new Vector();
674                 Vector returnErrorVector = new Vector();
675                 int returnValue = ExecuteProcess.executeProcessReturnVector(rpmCommandArray, versionVector, returnErrorVector);
676                 String version = (String) versionVector.lastElement();
677                 log = rpmCommand + "<br><b>Returns: " + version + "</b><br>";
678                 LogManager.addCommandsLogfileComment(log);
679 
680                 if ( ! installData.installedProductMinorSet() ) {
681                     int productMinor = helper.getInstalledMinor(version);
682                 	installData.setInstalledProductMinor(productMinor);
683                     installData.setInstalledProductMinorSet(true);
684                 }
685 
686                 if (useLocalDatabase) {
687                     rpmCommand = "rpm" + " " + databaseString + " " + databasePath + " -q --queryformat %{RELEASE}\\n " + packageName;
688                     rpmCommandArray[5] = "%{RELEASE}\\n";
689                 } else {
690                     rpmCommand = "rpm" + " -q --queryformat %{RELEASE}\\n " + packageName;
691                     rpmCommandArray[3] = "%{RELEASE}\\n";
692                 }
693 
694                 Vector releaseVector = new Vector();
695                 returnValue = ExecuteProcess.executeProcessReturnVector(rpmCommandArray, releaseVector, returnErrorVector);
696                 String release = (String) releaseVector.lastElement();
697 
698                 log = rpmCommand + "<br><b>Returns: " + release + "</b><br>";
699                 LogManager.addCommandsLogfileComment(log);
700 
701                 isOlder = helper.compareVersionAndRelease(version, release, packageData, checkIfInstalledIsOlder);
702 
703                 if ( checkIfInstalledIsOlder ) {
704                     if ( isOlder ) {
705                         LogManager.addCommandsLogfileComment("<b>-> Installed package is older</b><br>");
706                     } else {
707                         LogManager.addCommandsLogfileComment("<b>-> Installed package is not older</b><br>");
708                     }
709                 } else {
710                     if ( isOlder ) {
711                         LogManager.addCommandsLogfileComment("<b>-> Package in installation set is older</b><br>");
712                     } else {
713                         LogManager.addCommandsLogfileComment("<b>-> Package in installation set is not older</b><br>");
714                     }
715                 }
716 
717             } else {
718                 System.err.println("Error: No packageName defined for package: " + rpmPackageName);
719             }
720         }
721 
722         return isOlder;
723     }
724 
725 }
726