CreateSampleFile.java 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /*
  2. * Copyright (C) 2015 iZc
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. package de.nplusc.izc.InstallPak;
  18. import de.nplusc.izc.tools.IOtools.FileTK;
  19. import java.io.FileNotFoundException;
  20. import java.io.IOException;
  21. import java.util.ArrayList;
  22. import java.util.LinkedHashMap;
  23. import java.util.Map;
  24. import org.yaml.snakeyaml.DumperOptions;
  25. import org.yaml.snakeyaml.Yaml;
  26. /**
  27. *
  28. * @author LH
  29. */
  30. public class CreateSampleFile
  31. {
  32. public static void main(String[] devnulled) throws FileNotFoundException, IOException
  33. {
  34. //SHARED
  35. DumperOptions yamlOptions = new DumperOptions();
  36. yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
  37. Yaml y = new Yaml(yamlOptions);
  38. /*
  39. Map<String,Object> izsetup = new LinkedHashMap<>();
  40. izsetup.put("comment:type","izsetup");
  41. ArrayList<String> rootEntries=new ArrayList<>();
  42. rootEntries.add("Group1");
  43. rootEntries.add("Runtimes");
  44. rootEntries.add("nichtWin8");
  45. izsetup.put("Segments",rootEntries);
  46. Map<String,String[]> group1 = new LinkedHashMap<>();
  47. group1.put("Condition",new String[]{"IsWin8"});
  48. group1.put("ifnode",new String[]{"Group1Win8"});
  49. group1.put("postCond",new String[]{"Group1Post"});
  50. izsetup.put("Group1",group1);
  51. Map<String,String[]> group1win8 = new LinkedHashMap<>();
  52. group1win8.put("Condition",new String[]{"Is64Bit"});
  53. group1win8.put("elsenode",new String[]{"Group1Win8_32"});
  54. izsetup.put("Group1",group1);
  55. Map<String,String[]> group1win8_32 = new LinkedHashMap<>();
  56. group1win8_32.put("Exec1",new String[]{"Installiere was 32-bit spezifisches","program","ping","google.de"});
  57. group1win8_32.put("Comment:exec",new String[]{"Beschreibung","Typ","Parameter1","...","parameterN"});
  58. izsetup.put("Group1Win8_32",group1win8_32);
  59. Map<String,String[]> group1post = new LinkedHashMap<>();
  60. group1post.put("Exec1",new String[]{"Group1Post","program","ping","amazon.de"});
  61. izsetup.put("Group1Post",group1post);
  62. Map<String,String[]> runtimes = new LinkedHashMap<>();
  63. runtimes.put("Exec1",new String[]{"Runtime1","program","ping","ccc.de"});
  64. runtimes.put("Exec2",new String[]{"Runtime2","program","ping","microsoft.de"});
  65. izsetup.put("Runtimes",runtimes);
  66. Map<String,String[]> nonwin8 = new LinkedHashMap<>();
  67. nonwin8.put("Condition",new String[]{"IsWin8"});
  68. nonwin8.put("elsenode",new String[]{"nonwin8Impl"});
  69. izsetup.put("nichtWin8",nonwin8);
  70. Map<String,String[]> nonwin8Impl = new LinkedHashMap<>();
  71. nonwin8Impl.put("Exec1",new String[]{"Nicht für wind00f 8","program","ping","example.com"});
  72. izsetup.put("nonwin8Impl",nonwin8Impl);*/
  73. Map<String,Object> izsetup = new LinkedHashMap<>();
  74. ArrayList<String> rootEntries=new ArrayList<>();
  75. rootEntries.add("GamesTls");
  76. izsetup.put("Segments",rootEntries);
  77. Map<String,String[]> addons = new LinkedHashMap<>();
  78. addons.put("Exec1",new String[]{"NOOP","program","ping","localhost"});
  79. izsetup.put("GamesTls", addons);
  80. String izbo = "000|izsetup|3.0.0|: valides YAML und trotzdem kompatibel" +"\n"+y.dump(izsetup);
  81. FileTK.writeFile(izbo, "D:\\src\\izsetup\\gamestls.izsetup");
  82. //izpackage
  83. /*
  84. Map<String,Object> izpackage = new LinkedHashMap<>();
  85. izpackage.put("comment:type","izpackage");
  86. ArrayList<String> flags = new ArrayList<>();
  87. flags.add("multidisk");
  88. izpackage.put("flags",flags);
  89. izpackage.put("comment:packagebases","Namen der IDs der echten Packages die auch in der Liste auftauchen\nDer Rest ist von diesen referenziert");
  90. ArrayList<String> packageBases=new ArrayList<>();
  91. packageBases.add("BaseSystem");
  92. packageBases.add("Addons");
  93. packageBases.add("XPTools");
  94. packageBases.add("Games");
  95. packageBases.add("Game-Tools");
  96. izpackage.put("packagebases",packageBases);
  97. Map<String,String> BaseSystem = new LinkedHashMap<>();
  98. BaseSystem.put("Name","BaseSystem");
  99. BaseSystem.put("script","#basedir#\\pack001.izsetup");
  100. BaseSystem.put("detectInstall","File://C:\\kernel.etl2");
  101. BaseSystem.put("desc","Die minimal nötigen Tools und Komponenten fürs System");
  102. BaseSystem.put("defaultEnabled","true");
  103. izpackage.put("BaseSystem",BaseSystem);
  104. Map<String,String> Addons = new LinkedHashMap<>();
  105. Addons.put("Name","AddOns");
  106. Addons.put("dependsOn","BaseSystem");
  107. Addons.put("script","#basedir#\\addons.izsetup");
  108. Addons.put("detectInstall","File://%userprofile%\\appdata\\programname\\datei1.dat");
  109. Addons.put("desc","Addons und sosntiges was nicht zwingend notwendig ist");
  110. Addons.put("defaultEnabled","true");
  111. izpackage.put("Addons",Addons);
  112. Map<String,String> XPAddons = new LinkedHashMap<>();
  113. XPAddons.put("Condition","IsWin7");
  114. XPAddons.put("Comment:Condition","Bei Erfüllt das Package aus If enablen, sonst das aus Else verwenden");
  115. XPAddons.put("ifnode","XPAddonsIf");
  116. izpackage.put("XPTools", XPAddons);
  117. Map<String,String> XPAddonsIf = new LinkedHashMap<>();
  118. XPAddonsIf.put("Name","XPAddOns");
  119. XPAddonsIf.put("dependsOn","BaseSystem");
  120. XPAddonsIf.put("script","#basedir#\\xprevocer.izsetup");
  121. XPAddonsIf.put("detectInstall","File://C:\\ornder2\\datei2.bin");
  122. XPAddonsIf.put("desc","Sach das bei XP defult war aber dort fehlt");
  123. XPAddonsIf.put("defaultEnabled","true");
  124. izpackage.put("XPAddonsIf", XPAddonsIf);
  125. Map<String,String> Games = new LinkedHashMap<>();
  126. Games.put("Name","Games");
  127. Games.put("comment:waitDisk","Prüft ob spezifizierte datei vorhanden ist und fordert zum einlegen der disk auf falls nicht\n spezifisierte datei sollte nur auf der entsprechenden disk sein");
  128. Games.put("waitDisk", "#basedir#\\games.izsetup");
  129. Games.put("comment:waitMessage","WaitMessage ist optional, defaulted wenn nur waitDisk");
  130. Games.put("waitMessage","Bitte Games-Disk einlegen");
  131. Games.put("dependsOn","BaseSystem");
  132. Games.put("script","#basedir#\\games.izsetup");
  133. Games.put("detectInstall","File://C:\\Program Files\\ImgBurn\\ImgBurn.exexexe");
  134. Games.put("desc","Die Games die nicht fehlen dürfen");
  135. Games.put("defaultEnabled","true");
  136. izpackage.put("Games",Games);
  137. Map<String,String> Gamest = new LinkedHashMap<>();
  138. Gamest.put("Name","game-Tools");
  139. Gamest.put("waitDisk", "#basedir#\\gamestls.izsetup");
  140. Gamest.put("comment:dependsOn","Dependency geht zu games und zu den dependencys von games");
  141. Gamest.put("dependsOn","Games");
  142. Gamest.put("script","#basedir#\\gamestls.izsetup");
  143. Gamest.put("detectInstall","File://C:\\Program Files\\ImgBurn\\ImgBurn.exexexe");
  144. Gamest.put("desc","Tools für die games aus dem Package");
  145. Gamest.put("defaultEnabled","true");
  146. izpackage.put("Game-Tools", Gamest);
  147. //Yaml y = new Yaml();
  148. String izbo = "000|izsetup|3.0.0|: valides YAML und trotzdem kompatibel" +"\n"+y.dump(izpackage);
  149. FileTK.writeFile(izbo, "D:\\src\\izsetup\\sample.izpackage");
  150. */
  151. //bundle.izmeta
  152. /*
  153. Map<String,String> izbundle = new LinkedHashMap<>();
  154. izbundle.put("comment:type","izbundle");
  155. izbundle.put("meta:isZipped","true");
  156. izbundle.put("comment:meta:isZipped","bei false sind die dateien als normale dateien neben dieser bundle gelagert -> kein entzippern\n" +
  157. "CMM|in tempdir nötig. Muss bei multidisk-bundles deaktiviert sein. bei diskbundles wird Deaktivierung empfohlen\n" +
  158. "CMM|da es die Festplatte nicht so vollstopft");
  159. izbundle.put("bundlename","Sample");
  160. izbundle.put("packagedata","sample.iZpackage");
  161. izbundle.put("description","Beispieldaten und testdaten");
  162. izbundle.put("extractSize","123556");
  163. String izbo = "000|izsetup|3.0.0|: valides YAML und trotzdem kompatibel" +"\n"+y.dump(izbundle);
  164. FileTK.writeFile(izbo, "D:\\src\\izsetup\\bundle.izmeta");
  165. */
  166. //temp code
  167. //FileTK.writeFile(y.dump(y.load(new FileInputStream("D:\\src\\izsetup\\sample.izpackage"))), "D:\\src\\izsetup\\valid");
  168. /*System.out.println(FileTK.fileAsString("D:\\src\\izsetup\\valid"));
  169. */
  170. }
  171. }