xref: /AOO41X/main/javainstaller2/src/JavaSetup/org/openoffice/setup/InstallData.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 package org.openoffice.setup;
29 
30 import org.openoffice.setup.SetupData.PackageDescription;
31 import org.openoffice.setup.Util.Controller;
32 import org.openoffice.setup.Util.SystemManager;
33 import java.io.File;
34 import java.util.HashMap;
35 import java.util.Locale;
36 import java.util.Vector;
37 
38 public class InstallData
39 {
40     public static final String ACTION_TYPICAL   = "ActionTypical";
41     public static final String ACTION_CUSTOM    = "ActionCustom";
42 
43     private static InstallData instance = null;
44 
45     static private boolean isUserInstallation;    /* root or user installation? */
46     static private boolean isRootInstallation;    /* root or user installation? */
47     static private boolean isInstallationMode;    /* installation or uninstallation? */
48     static private boolean isUninstallationMode;  /* installation or uninstallation? */
49     static private boolean isCustomInstallation = false;  /* custom or typical? */
50     static private boolean isTypicalInstallation = true;  /* custom or typical? */
51     static private boolean isSolarisUserInstallation = false;
52     static private boolean isChangeInstallation = false;
53     static private boolean stillRunning = false;
54     static private boolean stillAnalyzing = true;
55     static private boolean databaseAnalyzed = false;  /* the database was already analyzed? */
56     static private boolean moduleSizeSet = false;  /* the database was already analyzed? */
57     static private boolean preInstallDone = false;  /* preInstall script already executed? */
58     static private boolean isAbortedInstallation = false;
59     static private boolean isErrorInstallation = false;
60     static private boolean logModuleStates = false;  /* logging the current state of modules */
61     static private boolean visibleModulesChecked = false; /* checking, if the user selected modules */
62     static private boolean languageModulesChecked = false; /* checking, if the user selected language modules */
63     static private boolean applicationModulesChecked = false; /* checking, if the user selected application modules */
64     static private boolean isMaskedCompleteUninstallation = false; /* checking if all visible modules are uninstalled */
65     static private boolean typicalSelectionStateSaved = false;
66     static private boolean customSelectionStateSaved = false;
67     static private boolean startSelectionStateSaved = false;
68     static private boolean olderVersionExists = false;
69     static private boolean sameVersionExists = false;
70     static private boolean newerVersionExists = false;
71     static private boolean majorUpgrade = false;
72     static private boolean isMultiLingual = false;
73     static private boolean dontUpdate = false;
74     static private boolean hideEula = false;
75     static private boolean databaseQueried = false;
76     static private boolean useRtl = false;
77     static private boolean installedProductMinorSet = false;
78     static private boolean isDebianSystem = false;
79     static private boolean useForceDebian = false;  /* --force-debian */
80     static private boolean debianInvestigated = false;
81     static private boolean isFirstPackage = false;
82     static private String installType;            /* custom or typical installation */
83     static private String osType;                 /* Linux, SunOS, ...              */
84     static private String installDir = null;
85     static private String defaultDir = "/opt";
86     static private String installDefaultDir = null;
87     static private String productDir = null;
88     static private String packageFormat = null;
89     static private String architecture = null;
90     static private String packagePath = null;
91     static private String packageSubdir = "packages";
92     static private String adminFileNameReloc = null;
93     static private String adminFileNameRelocNoDepends = null;
94     static private String adminFileNameNoReloc = null;
95     static private String adminFileNameNoRelocNoDepends = null;
96     static private String databasePath = null;
97     static private String getUidPath = null;
98     static private String installationPrivileges = null;
99     static private String storedInstallationPrivileges = null; /* privileges saved in file */
100     static private String localTempPath = null;
101     static private String installDirName = "installdata";
102     static private String uninstallDirName = "uninstalldata";
103     static private int availableDiscSpace = 0;
104     static private int preselectedLanguages = 0;
105     static private int productMinor = 0;
106     static private int installedProductMinor = 0;
107     static private File jarFilePath = null;
108     static private File resourceRoot;
109     static private File infoRoot;
110     static private HashMap shellEnvironment = null;   /* Solaris environment for user install */
111     static private HashMap databaseMap = null;
112     static private PackageDescription updatePackage = null;
113     static private Vector removeFiles = new Vector();  /* Files to remove, if installation is aborted */
114     static private Vector installPackages = new Vector();
115     static private Vector oldPackages = new Vector();
116     static private Vector systemLanguages = new Vector();
117 
118     public static InstallData getInstance()
119     {
120       if (instance == null) {
121         instance = new InstallData();
122       }
123       return instance;
124     }
125 
126     private InstallData()
127     {
128         installType = ACTION_TYPICAL;  // default installation type
129         isUserInstallation = SystemManager.isUserInstallation();
130         isRootInstallation = !isUserInstallation;
131         setInstallationPrivileges(isUserInstallation);
132         osType = SystemManager.getOSType();
133         resourceRoot = SystemManager.getResourceRoot();
134         setInstallationMode();
135         setSolarisUserInstall();
136         setHtmlFileExistence();
137         setBidiSupport();
138     }
139 
140     public void setInstallationType(String installationtype) {
141         installType = installationtype;
142 
143         if ( installType.equals(this.getCustomActionCommand())) {
144             isCustomInstallation = true;
145             isTypicalInstallation = false;
146         }
147 
148         if ( installType.equals(this.getTypicalActionCommand())) {
149             isCustomInstallation = false;
150             isTypicalInstallation = true;
151         }
152     }
153 
154     private void setInstallationMode() {
155         // Exists a directory "uninstalldata" below the resource root?
156         File uninstallDir = new File(resourceRoot, uninstallDirName);
157         File installDir = new File(resourceRoot, installDirName);
158 
159         if ( SystemManager.exists_directory(uninstallDir.getPath())) {
160             isInstallationMode = false;
161             isUninstallationMode = true;
162             infoRoot = uninstallDir;
163             System.err.println("Mode: uninstallation");
164         } else if ( SystemManager.exists_directory(installDir.getPath())) {
165             isInstallationMode = true;
166             isUninstallationMode = false;
167             infoRoot = installDir;
168             System.err.println("Mode: installation");
169         } else {
170             // isInstallationMode = null;
171             // isUninstallationMode = null;
172             infoRoot = null;
173             System.err.println("Error: Did not find info path");
174             System.err.println("Error: No info about installation or uninstallation");
175             System.exit(1);
176         }
177     }
178 
179     private void setSolarisUserInstall() {
180         if (( isUserInstallation ) && (osType.equalsIgnoreCase("SunOS"))) {
181             isSolarisUserInstallation = true;
182             if ( isInstallationMode ) {
183                 Controller.checkForUidFile(this);
184             }
185         }
186     }
187 
188     private void setHtmlFileExistence() {
189         // After inforoot is determined, the existence of files in subdirectory "html" can be checked
190         File htmlDirectory = getInfoRoot("html");
191         ResourceManager.checkFileExistence(htmlDirectory);
192     }
193 
194     private void setBidiSupport() {
195     	Locale locale = Locale.getDefault();
196         if (( locale.getLanguage().equals(new Locale("he", "", "").getLanguage()) )
197             || ( locale.getLanguage().equals(new Locale("ar", "", "").getLanguage()) )) {
198             useRtl = true;
199         }
200     }
201 
202     private void setInstallationPrivileges(boolean isUserInstallation) {
203         if ( isUserInstallation ) {
204             installationPrivileges = "user";
205         } else {
206             installationPrivileges = "root";
207         }
208     }
209 
210     public String getInstallationType() {
211         return installType;
212     }
213 
214     public String getCustomActionCommand() {
215         return ACTION_CUSTOM;
216     }
217 
218     public String getTypicalActionCommand() {
219         return ACTION_TYPICAL;
220     }
221 
222     public String getInstallationPrivileges() {
223         return installationPrivileges;
224     }
225 
226     public String getOSType() {
227         return osType;
228     }
229 
230     public File getResourceRoot() {
231         return resourceRoot;
232     }
233 
234     public File getResourceRoot(String subDirectory) {
235 
236         File dir = getResourceRoot();
237 
238         if (dir != null) {
239             dir = new File(dir, subDirectory);
240             if (!dir.exists()) {
241                 dir = null;
242             }
243         }
244 
245         return dir;
246     }
247 
248     public File getInfoRoot() {
249         return infoRoot;
250     }
251 
252     public File getInfoRoot(String subDirectory) {
253         File dir = new File(infoRoot, subDirectory);
254         if (!dir.exists()) {
255             dir = null;
256         }
257 
258         return dir;
259     }
260 
261     public boolean isUserInstallation() {
262         return isUserInstallation;
263     }
264 
265     public boolean isRootInstallation() {
266         return isRootInstallation;
267     }
268 
269     public boolean isInstallationMode() {
270         return isInstallationMode;
271     }
272 
273     public boolean isUninstallationMode() {
274         return isUninstallationMode;
275     }
276 
277     public boolean isSolarisUserInstallation() {
278         return isSolarisUserInstallation;
279     }
280 
281     public boolean useRtl() {
282         return useRtl;
283     }
284 
285     public String getDefaultDir() {
286         return defaultDir;
287     }
288 
289     public void setDefaultDir(String dir) {
290         defaultDir = dir;
291     }
292 
293     public String getProductDir() {
294         return productDir;
295     }
296 
297     public void setProductDir(String dir) {
298         productDir = dir;
299     }
300 
301     public int getProductMinor() {
302         return productMinor;
303     }
304 
305     public void setProductMinor(int minor) {
306         productMinor = minor;
307     }
308 
309     public int getInstalledProductMinor() {
310         return installedProductMinor;
311     }
312 
313     public void setInstalledProductMinor(int minor) {
314         installedProductMinor = minor;
315     }
316 
317     public String getInstallDirName() {
318         return installDirName;
319     }
320 
321     public String getUninstallDirName() {
322         return uninstallDirName;
323     }
324 
325     public String getInstallDir() {
326         return installDir;
327     }
328 
329     public void setInstallDir(String dir) {
330         installDir = dir;
331     }
332 
333     public String getInstallDefaultDir() {
334         return installDefaultDir;
335     }
336 
337     public void setInstallDefaultDir(String dir) {
338         installDefaultDir = dir;
339     }
340 
341     public String getDatabasePath() {
342         return databasePath;
343     }
344 
345     public void setDatabasePath(String path) {
346         databasePath = path;
347     }
348 
349     public String getPackagePath() {
350         if ( packagePath == null ) {
351             packagePath = SystemManager.getPackagePath(packageSubdir);
352         }
353         return packagePath;
354     }
355 
356     public void setPackagePath(String path) {
357         packagePath = path;
358     }
359 
360     public String getPackageSubdir() {
361         return packageSubdir;
362     }
363 
364     public void setPackageSubdir(String dir) {
365         packageSubdir = dir;
366     }
367 
368     public String getPackageFormat() {
369         return packageFormat;
370     }
371 
372     public void setPackageFormat(String format) {
373         packageFormat = format;
374     }
375 
376     public String getArchitecture() {
377         return architecture;
378     }
379 
380     public void setArchitecture(String arch) {
381         architecture = arch;
382     }
383 
384     public String getLocalTempPath() {
385         return localTempPath;
386     }
387 
388     public void setLocalTempPath(String path) {
389         localTempPath = path;
390     }
391 
392     public int getAvailableDiscSpace() {
393         return availableDiscSpace;
394     }
395 
396     public void setAvailableDiscSpace(int space) {
397         availableDiscSpace = space;
398     }
399 
400     public int getPreselectedLanguages() {
401         return preselectedLanguages;
402     }
403 
404     public void setPreselectedLanguages(int count) {
405         preselectedLanguages = count;
406     }
407 
408     public String getAdminFileNameReloc() {
409         return adminFileNameReloc;
410     }
411 
412     public void setAdminFileNameReloc(String fileName) {
413         adminFileNameReloc = fileName;
414     }
415 
416     public String getAdminFileNameRelocNoDepends() {
417         return adminFileNameRelocNoDepends;
418     }
419 
420     public void setAdminFileNameRelocNoDepends(String fileName) {
421         adminFileNameRelocNoDepends = fileName;
422     }
423 
424     public String getAdminFileNameNoReloc() {
425         return adminFileNameNoReloc;
426     }
427 
428     public void setAdminFileNameNoReloc(String fileName) {
429         adminFileNameNoReloc = fileName;
430     }
431 
432     public String getAdminFileNameNoRelocNoDepends() {
433         return adminFileNameNoRelocNoDepends;
434     }
435 
436     public void setAdminFileNameNoRelocNoDepends(String fileName) {
437         adminFileNameNoRelocNoDepends = fileName;
438     }
439 
440     public String getGetUidPath() {
441         return getUidPath;
442     }
443 
444     public void setGetUidPath(String filePath) {
445         getUidPath = filePath;
446     }
447 
448     public String getStoredInstallationPrivileges() {
449         return storedInstallationPrivileges;
450     }
451 
452     public void setStoredInstallationPrivileges(String privileges) {
453         storedInstallationPrivileges = privileges;
454     }
455 
456     public void setStillRunning(boolean running) {
457         stillRunning = running;
458     }
459 
460     public boolean stillRunning() {
461         return stillRunning;
462     }
463 
464     public void setStillAnalyzing(boolean running) {
465         stillAnalyzing = running;
466     }
467 
468     public boolean stillAnalyzing() {
469         return stillAnalyzing;
470     }
471 
472     public void setDatabaseAnalyzed(boolean analyzed) {
473         databaseAnalyzed = analyzed;
474     }
475 
476     public boolean databaseAnalyzed() {
477         return databaseAnalyzed;
478     }
479 
480     public void setModuleSizeSet(boolean set) {
481         moduleSizeSet = set;
482     }
483 
484     public boolean moduleSizeSet() {
485         return moduleSizeSet;
486     }
487 
488     public void setPreInstallDone(boolean done) {
489         preInstallDone = done;
490     }
491 
492     public boolean preInstallDone() {
493         return preInstallDone;
494     }
495 
496     public boolean isChangeInstallation() {
497         return isChangeInstallation;
498     }
499 
500     public void setIsChangeInstallation(boolean changeInstallation) {
501         isChangeInstallation = changeInstallation;
502     }
503 
504     public boolean isTypicalInstallation() {
505         return isTypicalInstallation;
506     }
507 
508     public boolean isCustomInstallation() {
509         return isCustomInstallation;
510     }
511 
512     public boolean isAbortedInstallation() {
513         return isAbortedInstallation;
514     }
515 
516     public void setIsAbortedInstallation(boolean abortedInstallation) {
517         isAbortedInstallation = abortedInstallation;
518     }
519 
520     public boolean isErrorInstallation() {
521         return isErrorInstallation;
522     }
523 
524     public void setIsErrorInstallation(boolean errorInstallation) {
525         isErrorInstallation = errorInstallation;
526     }
527 
528     public boolean isMultiLingual() {
529         return isMultiLingual;
530     }
531 
532     public void setIsMultiLingual(boolean multiLingual) {
533         isMultiLingual = multiLingual;
534     }
535 
536     public boolean logModuleStates() {
537         return logModuleStates;
538     }
539 
540     public void setLogModuleStates(boolean log) {
541         logModuleStates = log;
542     }
543 
544     public boolean visibleModulesChecked() {
545         return visibleModulesChecked;
546     }
547 
548     public void setVisibleModulesChecked(boolean checked) {
549         visibleModulesChecked = checked;
550     }
551 
552     public boolean languageModulesChecked() {
553         return languageModulesChecked;
554     }
555 
556     public void setLanguageModulesChecked(boolean checked) {
557         languageModulesChecked = checked;
558     }
559 
560     public boolean applicationModulesChecked() {
561         return applicationModulesChecked;
562     }
563 
564     public void setApplicationModulesChecked(boolean checked) {
565         applicationModulesChecked = checked;
566     }
567 
568     public boolean isMaskedCompleteUninstallation() {
569         return isMaskedCompleteUninstallation;
570     }
571 
572     public void setMaskedCompleteUninstallation(boolean masked) {
573         isMaskedCompleteUninstallation = masked;
574     }
575 
576     public boolean typicalSelectionStateSaved() {
577         return typicalSelectionStateSaved;
578     }
579 
580     public void setTypicalSelectionStateSaved(boolean saved) {
581         typicalSelectionStateSaved = saved;
582     }
583 
584     public boolean customSelectionStateSaved() {
585         return customSelectionStateSaved;
586     }
587 
588     public void setCustomSelectionStateSaved(boolean saved) {
589         customSelectionStateSaved = saved;
590     }
591 
592     public boolean startSelectionStateSaved() {
593         return startSelectionStateSaved;
594     }
595 
596     public void setStartSelectionStateSaved(boolean saved) {
597         startSelectionStateSaved = saved;
598     }
599 
600     public boolean olderVersionExists() {
601     	return olderVersionExists;
602     }
603 
604     public void setOlderVersionExists(boolean exists) {
605         olderVersionExists = exists;
606     }
607 
608     public boolean isMajorUpgrade() {
609     	return majorUpgrade;
610     }
611 
612     public void setMajorUpgrade(boolean upgrade) {
613         majorUpgrade = upgrade;
614     }
615 
616     public boolean sameVersionExists() {
617     	return sameVersionExists;
618     }
619 
620     public void setSameVersionExists(boolean exists) {
621         sameVersionExists = exists;
622     }
623 
624     public boolean newerVersionExists() {
625     	return newerVersionExists;
626     }
627 
628     public void setNewerVersionExists(boolean exists) {
629         newerVersionExists = exists;
630     }
631 
632     public boolean dontUpdate() {
633     	return dontUpdate;
634     }
635 
636     public void setDontUpdate(boolean value) {
637         dontUpdate = value;
638     }
639 
640     public boolean hideEula() {
641     	return hideEula;
642     }
643 
644     public void setHideEula(boolean value) {
645         hideEula = value;
646     }
647 
648     public boolean installedProductMinorSet() {
649     	return installedProductMinorSet;
650     }
651 
652     public void setInstalledProductMinorSet(boolean value) {
653         installedProductMinorSet = value;
654     }
655 
656     public boolean debianInvestigated() {
657     	return debianInvestigated;
658     }
659 
660     public void setDebianInvestigated(boolean value) {
661         debianInvestigated = value;
662     }
663 
664     public boolean isDebianSystem() {
665     	return isDebianSystem;
666     }
667 
668     public void setIsDebianSystem(boolean value) {
669         isDebianSystem = value;
670     }
671 
672     public boolean isFirstPackage() {
673     	return isFirstPackage;
674     }
675 
676     public void setIsFirstPackage(boolean value) {
677         isFirstPackage = value;
678     }
679 
680     public boolean useForceDebian() {
681     	return useForceDebian;
682     }
683 
684     public void setUseForceDebian(boolean value) {
685         useForceDebian = value;
686     }
687 
688     public boolean databaseQueried() {
689     	return databaseQueried;
690     }
691 
692     public void setDatabaseQueried(boolean value) {
693         databaseQueried = value;
694     }
695 
696     public PackageDescription getUpdatePackage() {
697         return updatePackage;
698     }
699 
700     public void setUpdatePackage(PackageDescription onePackage) {
701         updatePackage = onePackage;
702     }
703 
704     public HashMap getShellEnvironment() {
705         return shellEnvironment;
706     }
707 
708     public HashMap getDatabaseMap() {
709     	return databaseMap;
710     }
711 
712     public void setDatabaseMap(HashMap map) {
713         databaseMap = map;
714     }
715 
716     public Vector getRemoveFiles() {
717         return removeFiles;
718     }
719 
720     public Vector getInstallPackages() {
721         return installPackages;
722     }
723 
724     public void setInstallPackages(Vector packages) {
725         installPackages = packages;
726     }
727 
728     public Vector getOldPackages() {
729         return oldPackages;
730     }
731 
732     public void setOldPackages(Vector packages) {
733         oldPackages = packages;
734     }
735 
736     public Vector getSystemLanguages() {
737         return systemLanguages;
738     }
739 
740     public void setSystemLanguages(Vector languages) {
741         systemLanguages = languages;
742     }
743 
744     public void setShellEnvironment(HashMap environment) {
745         shellEnvironment = environment;
746     }
747 
748     public File getJarFilePath() {
749         if ( jarFilePath == null ) {
750             jarFilePath = SystemManager.getJarFilePath();
751         }
752         return jarFilePath;
753     }
754 
755 }
756