Better, Faster, Freer

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: i386 ]
Version: HEAD ]

001 /*************************************************************************
002  *
003  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004  * 
005  * Copyright 2008 by Sun Microsystems, Inc.
006  *
007  * OpenOffice.org - a multi-platform office productivity suite
008  *
009  * $RCSfile: InstallData.java,v $
010  * $Revision: 1.9 $
011  *
012  * This file is part of OpenOffice.org.
013  *
014  * OpenOffice.org is free software: you can redistribute it and/or modify
015  * it under the terms of the GNU Lesser General Public License version 3
016  * only, as published by the Free Software Foundation.
017  *
018  * OpenOffice.org is distributed in the hope that it will be useful,
019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
021  * GNU Lesser General Public License version 3 for more details
022  * (a copy is included in the LICENSE file that accompanied this code).
023  *
024  * You should have received a copy of the GNU Lesser General Public License
025  * version 3 along with OpenOffice.org.  If not, see
026  * <http://www.openoffice.org/license.html>
027  * for a copy of the LGPLv3 License.
028  *
029  ************************************************************************/
030 
031 package org.openoffice.setup;
032 
033 import org.openoffice.setup.SetupData.PackageDescription;
034 import org.openoffice.setup.Util.Controller;
035 import org.openoffice.setup.Util.SystemManager;
036 import java.io.File;
037 import java.util.HashMap;
038 import java.util.Vector;
039 
040 public class InstallData
041 {
042     public static final String ACTION_TYPICAL   = "ActionTypical";
043     public static final String ACTION_CUSTOM    = "ActionCustom";
044 
045     private static InstallData instance = null;
046 
047     static private boolean isUserInstallation;    /* root or user installation? */
048     static private boolean isRootInstallation;    /* root or user installation? */
049     static private boolean isInstallationMode;    /* installation or uninstallation? */
050     static private boolean isUninstallationMode;  /* installation or uninstallation? */
051     static private boolean isCustomInstallation = false;  /* custom or typical? */
052     static private boolean isTypicalInstallation = true;  /* custom or typical? */
053     static private boolean isSolarisUserInstallation = false;
054     static private boolean isChangeInstallation = false;
055     static private boolean stillRunning = false;
056     static private boolean stillAnalyzing = true;
057     static private boolean databaseAnalyzed = false;  /* the database was already analyzed? */
058     static private boolean moduleSizeSet = false;  /* the database was already analyzed? */
059     static private boolean preInstallDone = false;  /* preInstall script already executed? */
060     static private boolean isAbortedInstallation = false;
061     static private boolean isErrorInstallation = false;
062     static private boolean logModuleStates = false;  /* logging the current state of modules */
063     static private boolean visibleModulesChecked = false; /* checking, if the user selected modules */
064     static private boolean languageModulesChecked = false; /* checking, if the user selected language modules */
065     static private boolean applicationModulesChecked = false; /* checking, if the user selected application modules */
066     static private boolean isMaskedCompleteUninstallation = false; /* checking if all visible modules are uninstalled */
067     static private boolean typicalSelectionStateSaved = false;
068     static private boolean customSelectionStateSaved = false;
069     static private boolean startSelectionStateSaved = false;
070     static private boolean olderVersionExists = false;
071     static private boolean sameVersionExists = false;
072     static private boolean newerVersionExists = false;
073     static private boolean isMultiLingual = false;
074     static private boolean dontUpdate = false;
075     static private boolean hideEula = false;
076     static private boolean databaseQueried = false;
077     static private String installType;            /* custom or typical installation */
078     static private String osType;                 /* Linux, SunOS, ...              */
079     static private String installDir = null;
080     static private String defaultDir = "/opt";
081     static private String installDefaultDir = null;
082     static private String productDir = null;
083     static private String packageFormat = null;
084     static private String architecture = null;
085     static private String packagePath = null;
086     static private String packageSubdir = "packages";
087     static private String adminFileNameReloc = null;
088     static private String adminFileNameNoReloc = null;
089     static private String databasePath = null;
090     static private String getUidPath = null;
091     static private String installationPrivileges = null;
092     static private String storedInstallationPrivileges = null; /* privileges saved in file */
093     static private String localTempPath = null;
094     static private String installDirName = "installdata";
095     static private String uninstallDirName = "uninstalldata";
096     static private int availableDiscSpace = 0;
097     static private int preselectedLanguages = 0;
098     static private File jarFilePath = null;
099     static private File resourceRoot;
100     static private File infoRoot;
101     static private HashMap shellEnvironment = null;   /* Solaris environment for user install */
102     static private HashMap databaseMap = null;
103     static private PackageDescription updatePackage = null;
104     static private Vector removeFiles = new Vector();  /* Files to remove, if installation is aborted */
105     static private Vector installPackages = new Vector();
106     static private Vector systemLanguages = new Vector();
107     
108     public static InstallData getInstance()
109     {
110       if (instance == null) {
111         instance = new InstallData();
112       }
113       return instance;
114     }
115 
116     private InstallData()
117     {
118         installType = ACTION_TYPICAL;  // default installation type
119         isUserInstallation = SystemManager.isUserInstallation();
120         isRootInstallation = !isUserInstallation;
121         setInstallationPrivileges(isUserInstallation);
122         osType = SystemManager.getOSType();
123         resourceRoot = SystemManager.getResourceRoot();
124         setInstallationMode();
125         setSolarisUserInstall();
126         setHtmlFileExistence();
127     }
128 
129     public void setInstallationType(String installationtype) {
130         installType = installationtype;
131 
132         if ( installType.equals(this.getCustomActionCommand())) {
133             isCustomInstallation = true;
134             isTypicalInstallation = false;
135         }
136 
137         if ( installType.equals(this.getTypicalActionCommand())) {
138             isCustomInstallation = false;
139             isTypicalInstallation = true;
140         }
141     }
142 
143     private void setInstallationMode() {        
144         // Exists a directory "uninstalldata" below the resource root?
145         File uninstallDir = new File(resourceRoot, uninstallDirName);
146         File installDir = new File(resourceRoot, installDirName);
147         
148         if ( SystemManager.exists_directory(uninstallDir.getPath())) {
149             isInstallationMode = false;
150             isUninstallationMode = true;
151             infoRoot = uninstallDir;
152             System.err.println("Mode: uninstallation");            
153         } else if ( SystemManager.exists_directory(installDir.getPath())) {
154             isInstallationMode = true;
155             isUninstallationMode = false;
156             infoRoot = installDir;         
157             System.err.println("Mode: installation");
158         } else {
159             // isInstallationMode = null;
160             // isUninstallationMode = null;
161             infoRoot = null;
162             System.err.println("Error: Did not find info path");
163             System.err.println("Error: No info about installation or uninstallation");
164             System.exit(1);
165         }
166     }
167     
168     private void setSolarisUserInstall() {
169         if (( isUserInstallation ) && (osType.equalsIgnoreCase("SunOS"))) {
170             isSolarisUserInstallation = true;
171             if ( isInstallationMode ) {
172                 Controller.checkForUidFile(this);
173             }
174         }
175     }
176 
177     private void setHtmlFileExistence() {
178         // After inforoot is determined, the existence of files in subdirectory "html" can be checked
179         File htmlDirectory = getInfoRoot("html");
180         ResourceManager.checkFileExistence(htmlDirectory);
181     }
182     
183     private void setInstallationPrivileges(boolean isUserInstallation) {
184         if ( isUserInstallation ) {
185             installationPrivileges = "user";
186         } else {            
187             installationPrivileges = "root";
188         }
189     }
190 
191     public String getInstallationType() {
192         return installType;
193     }
194 
195     public String getCustomActionCommand() {
196         return ACTION_CUSTOM;
197     }
198 
199     public String getTypicalActionCommand() {
200         return ACTION_TYPICAL;
201     }
202 
203     public String getInstallationPrivileges() {
204         return installationPrivileges;
205     }
206 
207     public String getOSType() {
208         return osType;
209     }
210 
211     public File getResourceRoot() {
212         return resourceRoot;
213     }
214 
215     public File getResourceRoot(String subDirectory) {
216         
217         File dir = getResourceRoot();
218         
219         if (dir != null) {
220             dir = new File(dir, subDirectory);
221             if (!dir.exists()) {
222                 dir = null;
223             }
224         }
225 
226         return dir;
227     }
228 
229     public File getInfoRoot() {
230         return infoRoot;
231     }
232 
233     public File getInfoRoot(String subDirectory) {
234         File dir = new File(infoRoot, subDirectory);
235         if (!dir.exists()) {
236             dir = null;
237         }
238 
239         return dir;
240     }
241 
242     public boolean isUserInstallation() {
243         return isUserInstallation;
244     }
245 
246     public boolean isRootInstallation() {
247         return isRootInstallation;
248     }
249 
250     public boolean isInstallationMode() {
251         return isInstallationMode;
252     }
253 
254     public boolean isUninstallationMode() {
255         return isUninstallationMode;
256     }
257 
258     public boolean isSolarisUserInstallation() {
259         return isSolarisUserInstallation;
260     }
261 
262     public String getDefaultDir() {
263         return defaultDir;
264     }
265 
266     public void setDefaultDir(String dir) {
267         defaultDir = dir;
268     }
269 
270     public String getProductDir() {
271         return productDir;
272     }
273 
274     public void setProductDir(String dir) {
275         productDir = dir;
276     }
277 
278     public String getInstallDirName() {
279         return installDirName;
280     }
281 
282     public String getUninstallDirName() {
283         return uninstallDirName;
284     }
285     
286     public String getInstallDir() {
287         return installDir;
288     }
289 
290     public void setInstallDir(String dir) {
291         installDir = dir;
292     }
293 
294     public String getInstallDefaultDir() {
295         return installDefaultDir;
296     }
297 
298     public void setInstallDefaultDir(String dir) {
299         installDefaultDir = dir;
300     }
301 
302     public String getDatabasePath() {
303         return databasePath;
304     }
305 
306     public void setDatabasePath(String path) {
307         databasePath = path;
308     }
309 
310     public String getPackagePath() {
311         if ( packagePath == null ) {
312             packagePath = SystemManager.getPackagePath(packageSubdir);
313         }
314         return packagePath;
315     }
316 
317     public void setPackagePath(String path) {
318         packagePath = path;
319     }
320 
321     public String getPackageSubdir() {
322         return packageSubdir;
323     }
324 
325     public void setPackageSubdir(String dir) {
326         packageSubdir = dir;
327     }
328 
329     public String getPackageFormat() {
330         return packageFormat;
331     }
332 
333     public void setPackageFormat(String format) {
334         packageFormat = format;
335     }
336 
337     public String getArchitecture() {
338         return architecture;
339     }
340 
341     public void setArchitecture(String arch) {
342         architecture = arch;
343     }
344 
345     public String getLocalTempPath() {
346         return localTempPath;
347     }
348     
349     public void setLocalTempPath(String path) {
350         localTempPath = path;
351     }
352 
353     public int getAvailableDiscSpace() {
354         return availableDiscSpace;
355     }
356     
357     public void setAvailableDiscSpace(int space) {
358         availableDiscSpace = space;
359     }
360 
361     public int getPreselectedLanguages() {
362         return preselectedLanguages;
363     }
364     
365     public void setPreselectedLanguages(int count) {
366         preselectedLanguages = count;
367     }
368 
369     public String getAdminFileNameReloc() {
370         return adminFileNameReloc;
371     }
372 
373     public void setAdminFileNameReloc(String fileName) {
374         adminFileNameReloc = fileName;
375     }
376 
377     public String getAdminFileNameNoReloc() {
378         return adminFileNameNoReloc;
379     }
380 
381     public void setAdminFileNameNoReloc(String fileName) {
382         adminFileNameNoReloc = fileName;
383     }
384     
385     public String getGetUidPath() {
386         return getUidPath;
387     }
388 
389     public void setGetUidPath(String filePath) {
390         getUidPath = filePath;
391     }
392 
393     public String getStoredInstallationPrivileges() {
394         return storedInstallationPrivileges;
395     }
396 
397     public void setStoredInstallationPrivileges(String privileges) {
398         storedInstallationPrivileges = privileges;
399     }
400 
401     public void setStillRunning(boolean running) {
402         stillRunning = running;
403     }
404     
405     public boolean stillRunning() {
406         return stillRunning;
407     }
408 
409     public void setStillAnalyzing(boolean running) {
410         stillAnalyzing = running;
411     }
412     
413     public boolean stillAnalyzing() {
414         return stillAnalyzing;
415     }
416 
417     public void setDatabaseAnalyzed(boolean analyzed) {
418         databaseAnalyzed = analyzed;
419     }
420     
421     public boolean databaseAnalyzed() {
422         return databaseAnalyzed;
423     }
424 
425     public void setModuleSizeSet(boolean set) {
426         moduleSizeSet = set;
427     }
428     
429     public boolean moduleSizeSet() {
430         return moduleSizeSet;
431     }
432 
433     public void setPreInstallDone(boolean done) {
434         preInstallDone = done;
435     }
436     
437     public boolean preInstallDone() {
438         return preInstallDone;
439     }
440 
441     public boolean isChangeInstallation() {
442         return isChangeInstallation;
443     }
444     
445     public void setIsChangeInstallation(boolean changeInstallation) {
446         isChangeInstallation = changeInstallation;
447     }
448 
449     public boolean isTypicalInstallation() {
450         return isTypicalInstallation;
451     }
452 
453     public boolean isCustomInstallation() {
454         return isCustomInstallation;
455     }
456 
457     public boolean isAbortedInstallation() {
458         return isAbortedInstallation;
459     }
460     
461     public void setIsAbortedInstallation(boolean abortedInstallation) {
462         isAbortedInstallation = abortedInstallation;
463     }
464 
465     public boolean isErrorInstallation() {
466         return isErrorInstallation;
467     }
468     
469     public void setIsErrorInstallation(boolean errorInstallation) {
470         isErrorInstallation = errorInstallation;
471     }
472 
473     public boolean isMultiLingual() {
474         return isMultiLingual;
475     }
476     
477     public void setIsMultiLingual(boolean multiLingual) {
478         isMultiLingual = multiLingual;
479     }
480 
481     public boolean logModuleStates() {
482         return logModuleStates;
483     }
484     
485     public void setLogModuleStates(boolean log) {
486         logModuleStates = log;
487     }
488     
489     public boolean visibleModulesChecked() {
490         return visibleModulesChecked;
491     }
492 
493     public void setVisibleModulesChecked(boolean checked) {
494         visibleModulesChecked = checked;
495     }
496 
497     public boolean languageModulesChecked() {
498         return languageModulesChecked;
499     }
500 
501     public void setLanguageModulesChecked(boolean checked) {
502         languageModulesChecked = checked;
503     }
504 
505     public boolean applicationModulesChecked() {
506         return applicationModulesChecked;
507     }
508 
509     public void setApplicationModulesChecked(boolean checked) {
510         applicationModulesChecked = checked;
511     }
512 
513     public boolean isMaskedCompleteUninstallation() {
514         return isMaskedCompleteUninstallation;
515     }
516     
517     public void setMaskedCompleteUninstallation(boolean masked) {
518         isMaskedCompleteUninstallation = masked;
519     }
520 
521     public boolean typicalSelectionStateSaved() {
522         return typicalSelectionStateSaved;
523     }
524     
525     public void setTypicalSelectionStateSaved(boolean saved) {
526         typicalSelectionStateSaved = saved;
527     }
528 
529     public boolean customSelectionStateSaved() {
530         return customSelectionStateSaved;
531     }
532     
533     public void setCustomSelectionStateSaved(boolean saved) {
534         customSelectionStateSaved = saved;
535     }
536 
537     public boolean startSelectionStateSaved() {
538         return startSelectionStateSaved;
539     }
540