PageRenderTime 94ms CodeModel.GetById 86ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/installer/NonInteractiveInstall.java

#
Java | 91 lines | 60 code | 14 blank | 17 comment | 10 complexity | 03c64134e919969eafa1413fe84d22b7 MD5 | raw file
 1/*
 2 * NonInteractiveInstall.java
 3 *
 4 * Originally written by Slava Pestov for the jEdit installer project. This work
 5 * has been placed into the public domain. You may use this work in any way and
 6 * for any purpose you wish.
 7 *
 8 * THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND, NOT EVEN THE
 9 * IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR OF THIS SOFTWARE, ASSUMES
10 * _NO_ RESPONSIBILITY FOR ANY CONSEQUENCE RESULTING FROM THE USE, MODIFICATION,
11 * OR REDISTRIBUTION OF THIS SOFTWARE.
12 */
13
14package installer;
15
16import java.util.Vector;
17
18/*
19 * Performs non-interactive installation.
20 */
21public class NonInteractiveInstall
22{
23	public NonInteractiveInstall(String[] args)
24	{
25		String installDir = args[1];
26
27		installer = new Install();
28
29		OperatingSystem os = OperatingSystem.getOperatingSystem();
30		OperatingSystem.OSTask[] osTasks = os.getOSTasks(installer);
31
32		for(int i = 2; i < args.length; i++)
33		{
34			String arg = args[i];
35			int index = arg.indexOf('=');
36			if(index == -1)
37			{
38				System.err.println("Invalid parameter: " + arg);
39				continue;
40			}
41
42			String taskName = arg.substring(0,index);
43			String taskDir = arg.substring(index + 1);
44			for(int j = 0; j < osTasks.length; j++)
45			{
46				OperatingSystem.OSTask osTask = osTasks[j];
47				if(osTask.getName().equals(taskName))
48				{
49					if(taskDir.equals("off"))
50						osTask.setEnabled(false);
51					else
52					{
53						osTask.setEnabled(true);
54						osTask.setDirectory(taskDir);
55					}
56					break;
57				}
58			}
59		}
60
61		int compCount = installer.getIntegerProperty("comp.count");
62		Vector components = new Vector(compCount);
63
64		for(int i = 0; i < compCount; i++)
65		{
66			String fileset = installer.getProperty("comp." + i + ".fileset");
67
68			String osDep = installer.getProperty("comp." + i + ".os");
69			if(osDep != null)
70			{
71				if(!os.getClass().getName().endsWith(osDep))
72				{
73					continue;
74				}
75			}
76
77			components.addElement(fileset);
78		}
79
80		//
81
82		ConsoleProgress progress = new ConsoleProgress();
83		InstallThread thread = new InstallThread(
84			installer,progress,installDir,osTasks,
85			0 /* XXX */,components);
86		thread.start();
87	}
88
89	// private members
90	private Install installer;
91}