Changeset 702 for AE/installer2/src/net/oni2/aeinstaller
- Timestamp:
- Mar 19, 2013, 11:00:06 AM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller
- Files:
-
- 2 added
- 7 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/backend/DotNet.java
r672 r702 8 8 import net.oni2.aeinstaller.backend.Settings.Architecture; 9 9 import net.oni2.aeinstaller.backend.Settings.Platform; 10 import net.oni2.aeinstaller.backend.appexecution.AppExecution; 11 import net.oni2.aeinstaller.backend.appexecution.AppExecutionResult; 10 12 11 13 /** … … 48 50 cmd.add("which"); 49 51 cmd.add("mono"); 50 Vector<String>res = null;52 AppExecutionResult res = null; 51 53 try { 52 54 res = AppExecution.executeAndWait(cmd); … … 55 57 } 56 58 if (res != null) { 57 if (res. get(0).startsWith("/")58 && res. get(0).endsWith("mono")) {59 if (res.output.get(0).startsWith("/") 60 && res.output.get(0).endsWith("mono")) { 59 61 return true; 60 62 } -
AE/installer2/src/net/oni2/aeinstaller/backend/Settings.java
r649 r702 10 10 import java.util.Vector; 11 11 12 import net.oni2.aeinstaller.backend.appexecution.AppExecution; 13 import net.oni2.aeinstaller.backend.appexecution.AppExecutionResult; 14 12 15 import com.thoughtworks.xstream.XStream; 13 16 import com.thoughtworks.xstream.io.xml.StaxDriver; … … 79 82 cmd.add("which"); 80 83 cmd.add("wine"); 81 Vector<String>res = null;84 AppExecutionResult res = null; 82 85 try { 83 86 res = AppExecution.executeAndWait(cmd); … … 86 89 } 87 90 if (res != null) { 88 if (res. get(0).startsWith("/") && res.get(0).endsWith("wine")) {89 return res. get(0);91 if (res.output.get(0).startsWith("/") && res.output.get(0).endsWith("wine")) { 92 return res.output.get(0); 90 93 } 91 94 } … … 133 136 cmd.add("getconf"); 134 137 cmd.add("LONG_BIT"); 135 Vector<String>res = null;138 AppExecutionResult res = null; 136 139 try { 137 140 res = AppExecution.executeAndWait(cmd); … … 140 143 } 141 144 if (res != null) { 142 if (res. get(0).equals("64"))145 if (res.output.get(0).equals("64")) 143 146 return Architecture.AMD64; 144 147 } -
AE/installer2/src/net/oni2/aeinstaller/backend/ToolLauncher.java
r672 r702 5 5 6 6 import net.oni2.aeinstaller.backend.Settings.Platform; 7 import net.oni2.aeinstaller.backend.appexecution.AppExecution; 7 8 import net.oni2.aeinstaller.backend.packages.Package; 8 9 -
AE/installer2/src/net/oni2/aeinstaller/backend/appexecution/AppExecution.java
r697 r702 1 package net.oni2.aeinstaller.backend ;1 package net.oni2.aeinstaller.backend.appexecution; 2 2 3 3 import java.io.BufferedReader; … … 13 13 */ 14 14 public class AppExecution { 15 16 15 /** 17 16 * Execute a short running application and wait for termination … … 19 18 * @param cmdLine 20 19 * List of command and arguments 21 * @return List of output lines20 * @return Error code and list of output lines 22 21 * @throws IOException 23 22 * Exc 24 23 */ 25 public static Vector<String> executeAndWait(List<String> cmdLine)24 public static AppExecutionResult executeAndWait(Vector<String> cmdLine) 26 25 throws IOException { 27 26 ProcessBuilder pb = new ProcessBuilder(cmdLine); … … 39 38 lines.add(line); 40 39 } 41 return lines; 40 try { 41 proc.waitFor(); 42 } catch (InterruptedException e) { 43 // TODO Auto-generated catch block 44 e.printStackTrace(); 45 } 46 return new AppExecutionResult(proc.exitValue(), cmdLine, lines); 42 47 } 43 48 -
AE/installer2/src/net/oni2/aeinstaller/backend/oni/Installer.java
r700 r702 26 26 import net.oni2.aeinstaller.backend.Settings; 27 27 import net.oni2.aeinstaller.backend.Settings.Platform; 28 import net.oni2.aeinstaller.backend.appexecution.AppExecutionResult; 28 29 import net.oni2.aeinstaller.backend.packages.EBSLInstallType; 29 30 import net.oni2.aeinstaller.backend.packages.Package; … … 164 165 else { 165 166 File targetFile = CaseInsensitiveFile 166 .getCaseInsensitiveFile(targetFolder, 167 f.getName()); 167 .getCaseInsensitiveFile(targetFolder, f.getName()); 168 168 if (remove) { 169 169 if (targetFile.exists()) … … 464 464 List<File> patchFolders, InstallProgressListener listener, 465 465 PrintWriter log) { 466 log.println(); 467 log.println("Applying XML patches"); 468 listener.installProgressUpdate(0, 1, "Applying XML patches"); 469 466 470 // TODO: REMOVE 467 471 long startMS = new Date().getTime(); 468 // TODO: Implement this 472 469 473 String tmpFolderName = "installrun_temp-" 470 474 + new SimpleDateFormat("yyyy_MM_dd-HH_mm_ss") 471 475 .format(new Date()); 472 476 File tmpFolder = new File(Paths.getTempPath(), tmpFolderName); 477 tmpFolder.mkdir(); 473 478 474 479 HashMap<String, Vector<File>> patches = new HashMap<String, Vector<File>>(); … … 488 493 File levelFolder = new File(tmpFolder, level); 489 494 levelFolder.mkdir(); 490 491 // Get files to be patched from vanilla.dat / packages 495 496 log.println("\t\tPatches for " + level); 497 498 Vector<String> exportPatterns = new Vector<String>(); 499 // Get files to be patched from vanilla.dat 492 500 for (File patch : patches.get(level)) { 493 501 String patternWildcard = patch.getName(); … … 495 503 patternWildcard.indexOf(".oni-patch")); 496 504 patternWildcard = patternWildcard.replace('-', '*'); 505 exportPatterns.add(patternWildcard); 506 } 507 for (File srcFolder : oniLevelFolders.get(level)) { 508 if (srcFolder.isFile()) { 509 if (srcFolder.getPath().toLowerCase().contains("vanilla")) { 510 // Extract from .dat 511 AppExecutionResult res = OniSplit.export(levelFolder, 512 srcFolder, exportPatterns); 513 logAppOutput(res, log); 514 } 515 } 516 } 517 518 // Get files to be patched from packages 519 for (File patch : patches.get(level)) { 520 String patternWildcard = patch.getName(); 521 patternWildcard = patternWildcard.substring(0, 522 patternWildcard.indexOf(".oni-patch")); 523 patternWildcard = patternWildcard.replace('-', '*'); 524 patternWildcard = patternWildcard + ".oni"; 525 Vector<String> patterns = new Vector<String>(); 526 patterns.add(patternWildcard); 497 527 final Pattern patternRegex = Pattern.compile( 498 528 patternWildcard.replaceAll("\\*", ".\\*"), … … 501 531 for (File srcFolder : oniLevelFolders.get(level)) { 502 532 if (srcFolder.isFile()) { 503 // Extract from .dat 504 OniSplit.export(levelFolder, srcFolder, patternWildcard); 533 if (!srcFolder.getPath().toLowerCase() 534 .contains("vanilla")) { 535 // Extract from .dat 536 AppExecutionResult res = OniSplit.export( 537 levelFolder, srcFolder, patterns); 538 logAppOutput(res, log); 539 } 505 540 } else { 506 541 // Copy from folder with overwrite … … 522 557 Vector<File> files = new Vector<File>(); 523 558 files.add(new File(levelFolder, "*.oni")); 524 OniSplit.convertOniToXML(levelFolderXML, files); 559 AppExecutionResult res = OniSplit.convertOniToXML(levelFolderXML, 560 files); 561 logAppOutput(res, log); 525 562 526 563 // Apply patches in levelFolderXML … … 529 566 patternWildcard = patternWildcard.substring(0, 530 567 patternWildcard.indexOf(".oni-patch")); 568 patternWildcard = patternWildcard + ".xml"; 531 569 patternWildcard = patternWildcard.replace('-', '*'); 532 final Pattern patternRegex = Pattern.compile( 533 patternWildcard.replaceAll("\\*", ".\\*"), 534 Pattern.CASE_INSENSITIVE); 535 536 for (File toPatch : FileUtils.listFiles(levelFolderXML, 537 new RegexFileFilter(patternRegex), null)) { 538 // Apply patch "patch" to "toPatch" 539 XMLTools.patch(patch, toPatch); 540 } 570 571 res = XMLTools.patch(patch, new File(levelFolderXML, 572 patternWildcard)); 573 logAppOutput(res, log); 541 574 } 542 575 … … 544 577 files.clear(); 545 578 files.add(new File(levelFolderXML, "*.xml")); 546 OniSplit.convertXMLtoOni(levelFolder, files); 579 res = OniSplit.convertXMLtoOni(levelFolder, files); 580 logAppOutput(res, log); 547 581 548 582 // Remove XML folder as import will only require .oni's 549 try {550 FileUtils.deleteDirectory(levelFolderXML);551 } catch (IOException e) {552 e.printStackTrace();553 }583 // try { 584 // FileUtils.deleteDirectory(levelFolderXML); 585 // } catch (IOException e) { 586 // e.printStackTrace(); 587 // } 554 588 555 589 oniLevelFolders.get(level).add(levelFolder); 590 591 log.println(); 556 592 } 557 593 … … 571 607 totalSteps++; 572 608 609 log.println(); 573 610 log.println("Importing levels"); 574 611 for (String l : oniLevelFolders.keySet()) { … … 576 613 listener.installProgressUpdate(stepsDone, totalSteps, 577 614 "Installing level " + l); 578 for (File f : oniLevelFolders.get(l)) { 579 log.println("\t\t\t" + f.getPath()); 580 } 581 582 Vector<String> res = OniSplit.packLevel(oniLevelFolders.get(l), 615 616 AppExecutionResult res = OniSplit.packLevel(oniLevelFolders.get(l), 583 617 new File(Paths.getEditionGDF(), sanitizeLevelName(l) 584 618 + ".dat")); 585 if (res != null && res.size() > 0) { 586 for (String s : res) 587 log.println("\t\t" + s); 588 } 619 logAppOutput(res, log); 589 620 590 621 log.println(); … … 604 635 } 605 636 } 637 } else { 638 log.println("NOT copying intro"); 606 639 } 607 640 if (Settings.getInstance().get("copyoutro", true)) { … … 615 648 } 616 649 } 650 } else { 651 log.println("NOT copying outro"); 617 652 } 618 653 } … … 704 739 705 740 // Export Vanilla-Level-Dat -> Temp/Level 706 Vector<String> res = OniSplit.export(tempLevelFolder, f); 707 if (res != null && res.size() > 0) { 708 for (String s : res) 709 log.println("\t\t\t" + s); 710 } 741 AppExecutionResult res = OniSplit.export(tempLevelFolder, f); 742 logAppOutput(res, log); 711 743 712 744 log.println("\t\tMoving files"); … … 729 761 folders.add(f); 730 762 731 Vector<String> res = OniSplit.importLevel(folders, new File( 732 Paths.getVanillaOnisPath(), levelName + ".dat")); 733 if (res != null && res.size() > 0) { 734 for (String s : res) 735 log.println("\t\t" + s); 736 } 763 AppExecutionResult res = OniSplit 764 .importLevel(folders, 765 new File(Paths.getVanillaOnisPath(), levelName 766 + ".dat")); 767 logAppOutput(res, log); 737 768 738 769 log.println(); … … 888 919 && Paths.getVanillaGDF().isDirectory(); 889 920 } 921 922 private static void logAppOutput(AppExecutionResult result, PrintWriter log) { 923 if (result != null) { 924 log.println("\t\t\tCalled:"); 925 for (String s : result.cmdLine) 926 log.println("\t\t\t\t" + s); 927 log.println("\t\t\tReturned: " + result.errorCode); 928 for (String s : result.output) 929 log.println("\t\t\t\t" + s); 930 log.println(); 931 } 932 } 890 933 } -
AE/installer2/src/net/oni2/aeinstaller/backend/oni/OniSplit.java
r699 r702 5 5 import java.util.Vector; 6 6 7 import net.oni2.aeinstaller.backend.AppExecution;8 7 import net.oni2.aeinstaller.backend.CaseInsensitiveFile; 9 8 import net.oni2.aeinstaller.backend.DotNet; … … 11 10 import net.oni2.aeinstaller.backend.Settings; 12 11 import net.oni2.aeinstaller.backend.Settings.Platform; 12 import net.oni2.aeinstaller.backend.appexecution.AppExecution; 13 import net.oni2.aeinstaller.backend.appexecution.AppExecutionResult; 13 14 14 15 /** … … 33 34 * @return OniSplit output 34 35 */ 35 public static Vector<String>export(File targetFolder, File input) {36 public static AppExecutionResult export(File targetFolder, File input) { 36 37 return export(targetFolder, input, null); 37 38 } … … 44 45 * @param input 45 46 * Dat file 46 * @param pattern 47 * Filename pattern for files to export48 * @return OniSplit output 49 */ 50 public static Vector<String>export(File targetFolder, File input,51 String pattern) {47 * @param patterns 48 * Filename patterns for files to export 49 * @return OniSplit output 50 */ 51 public static AppExecutionResult export(File targetFolder, File input, 52 Vector<String> patterns) { 52 53 if (!targetFolder.exists()) 53 54 targetFolder.mkdir(); 54 55 55 56 Vector<String> cmdLine = getProgramInvocation(); 56 if (pattern == null)57 if (patterns == null) 57 58 cmdLine.add("-export"); 58 else 59 cmdLine.add("-export:" + pattern); 59 else { 60 for (String p : patterns) 61 cmdLine.add("-export:" + p); 62 } 60 63 cmdLine.add(targetFolder.getPath()); 61 64 cmdLine.add(input.getPath()); 62 Vector<String>res = null;65 AppExecutionResult res = null; 63 66 try { 64 67 res = AppExecution.executeAndWait(cmdLine); … … 78 81 * @return OniSplit output 79 82 */ 80 public static Vector<String>importLevel(Vector<File> sourceFolders,83 public static AppExecutionResult importLevel(Vector<File> sourceFolders, 81 84 File targetFile) { 82 85 Vector<String> cmdLine = getProgramInvocation(); … … 85 88 cmdLine.add(f.getPath()); 86 89 cmdLine.add(targetFile.getPath()); 87 Vector<String>res = null;90 AppExecutionResult res = null; 88 91 try { 89 92 res = AppExecution.executeAndWait(cmdLine); … … 105 108 * @return OniSplit output 106 109 */ 107 public static Vector<String>packLevel(Vector<File> sourceFoldersFiles,110 public static AppExecutionResult packLevel(Vector<File> sourceFoldersFiles, 108 111 File targetFile) { 109 112 Vector<String> cmdLine = getProgramInvocation(); … … 114 117 for (File f : sourceFoldersFiles) 115 118 cmdLine.add(f.getPath()); 116 Vector<String>res = null;119 AppExecutionResult res = null; 117 120 try { 118 121 res = AppExecution.executeAndWait(cmdLine); … … 135 138 * @return OniSplit output 136 139 */ 137 public static Vector<String>move(File targetFolder, String input,140 public static AppExecutionResult move(File targetFolder, String input, 138 141 String moveParameter) { 139 142 if (!targetFolder.exists()) … … 145 148 cmdLine.add(targetFolder.getPath()); 146 149 cmdLine.add(input); 147 Vector<String>res = null;150 AppExecutionResult res = null; 148 151 try { 149 152 res = AppExecution.executeAndWait(cmdLine); … … 163 166 * @return OniSplit output 164 167 */ 165 public static Vector<String>convertOniToXML(File targetFolder,168 public static AppExecutionResult convertOniToXML(File targetFolder, 166 169 Vector<File> inputFiles) { 167 170 if (!targetFolder.exists()) … … 174 177 cmdLine.add(f.getPath()); 175 178 } 176 Vector<String>res = null;179 AppExecutionResult res = null; 177 180 try { 178 181 res = AppExecution.executeAndWait(cmdLine); … … 192 195 * @return OniSplit output 193 196 */ 194 public static Vector<String>convertXMLtoOni(File targetFolder,197 public static AppExecutionResult convertXMLtoOni(File targetFolder, 195 198 Vector<File> inputFiles) { 196 199 if (!targetFolder.exists()) … … 203 206 cmdLine.add(f.getPath()); 204 207 } 205 Vector<String>res = null;208 AppExecutionResult res = null; 206 209 try { 207 210 res = AppExecution.executeAndWait(cmdLine); … … 239 242 240 243 private static File getProgramFile() { 241 File toolsPath = CaseInsensitiveFile.getCaseInsensitiveFile(Paths.getEditionBasePath(), "Tools"); 242 return CaseInsensitiveFile.getCaseInsensitiveFile(toolsPath, "Onisplit.exe"); 244 File toolsPath = CaseInsensitiveFile.getCaseInsensitiveFile( 245 Paths.getEditionBasePath(), "Tools"); 246 return CaseInsensitiveFile.getCaseInsensitiveFile(toolsPath, 247 "Onisplit.exe"); 243 248 } 244 249 } -
AE/installer2/src/net/oni2/aeinstaller/backend/oni/XMLTools.java
r699 r702 5 5 import java.util.Vector; 6 6 7 import net.oni2.aeinstaller.backend.AppExecution;8 7 import net.oni2.aeinstaller.backend.CaseInsensitiveFile; 9 8 import net.oni2.aeinstaller.backend.DotNet; 10 9 import net.oni2.aeinstaller.backend.Paths; 10 import net.oni2.aeinstaller.backend.appexecution.AppExecution; 11 import net.oni2.aeinstaller.backend.appexecution.AppExecutionResult; 11 12 12 13 /** … … 25 26 * @return XMLTools output 26 27 */ 27 public static Vector<String>patch(File patch, File source) {28 public static AppExecutionResult patch(File patch, File source) { 28 29 Vector<String> cmdLine = getProgramInvocation(); 29 30 // xmlTools.exe patchfile -filename:PATCH -forceinfiles:TOPATCH … … 31 32 cmdLine.add("-filename:" + patch.getPath()); 32 33 cmdLine.add("-forceinfiles:" + source.getPath()); 33 Vector<String>res = null;34 AppExecutionResult res = null; 34 35 try { 35 36 res = AppExecution.executeAndWait(cmdLine); -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.java
r701 r702 40 40 41 41 import net.oni2.aeinstaller.AEInstaller2; 42 import net.oni2.aeinstaller.backend.AppExecution;43 42 import net.oni2.aeinstaller.backend.ImageResizer; 44 43 import net.oni2.aeinstaller.backend.Paths; … … 47 46 import net.oni2.aeinstaller.backend.Settings.Platform; 48 47 import net.oni2.aeinstaller.backend.SizeFormatter; 48 import net.oni2.aeinstaller.backend.appexecution.AppExecution; 49 49 import net.oni2.aeinstaller.backend.depot.DepotManager; 50 50 import net.oni2.aeinstaller.backend.oni.InstallProgressListener;
Note:
See TracChangeset
for help on using the changeset viewer.