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