PageRenderTime 47ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-2-pre14/installer/NonInteractiveInstall.java

#
Java | 91 lines | 60 code | 14 blank | 17 comment | 10 complexity | 03c64134e919969eafa1413fe84d22b7 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  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. package installer;
  14. import java.util.Vector;
  15. /*
  16. * Performs non-interactive installation.
  17. */
  18. public class NonInteractiveInstall
  19. {
  20. public NonInteractiveInstall(String[] args)
  21. {
  22. String installDir = args[1];
  23. installer = new Install();
  24. OperatingSystem os = OperatingSystem.getOperatingSystem();
  25. OperatingSystem.OSTask[] osTasks = os.getOSTasks(installer);
  26. for(int i = 2; i < args.length; i++)
  27. {
  28. String arg = args[i];
  29. int index = arg.indexOf('=');
  30. if(index == -1)
  31. {
  32. System.err.println("Invalid parameter: " + arg);
  33. continue;
  34. }
  35. String taskName = arg.substring(0,index);
  36. String taskDir = arg.substring(index + 1);
  37. for(int j = 0; j < osTasks.length; j++)
  38. {
  39. OperatingSystem.OSTask osTask = osTasks[j];
  40. if(osTask.getName().equals(taskName))
  41. {
  42. if(taskDir.equals("off"))
  43. osTask.setEnabled(false);
  44. else
  45. {
  46. osTask.setEnabled(true);
  47. osTask.setDirectory(taskDir);
  48. }
  49. break;
  50. }
  51. }
  52. }
  53. int compCount = installer.getIntegerProperty("comp.count");
  54. Vector components = new Vector(compCount);
  55. for(int i = 0; i < compCount; i++)
  56. {
  57. String fileset = installer.getProperty("comp." + i + ".fileset");
  58. String osDep = installer.getProperty("comp." + i + ".os");
  59. if(osDep != null)
  60. {
  61. if(!os.getClass().getName().endsWith(osDep))
  62. {
  63. continue;
  64. }
  65. }
  66. components.addElement(fileset);
  67. }
  68. //
  69. ConsoleProgress progress = new ConsoleProgress();
  70. InstallThread thread = new InstallThread(
  71. installer,progress,installDir,osTasks,
  72. 0 /* XXX */,components);
  73. thread.start();
  74. }
  75. // private members
  76. private Install installer;
  77. }