Changeset 804
- Timestamp:
- Apr 12, 2013, 5:57:57 PM (12 years ago)
- Location:
- java/installer2
- Files:
-
- 5 added
- 8 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
java/installer2/locales/net/oni2/aeinstaller/localization/Global_de.properties
r730 r804 3 3 4 4 invalidPath.title=Falscher Ordner 5 invalidPath.text=Dieses Programm muss im Unterordner Edition/AEInstaller innerhalb einer regulären Oni-Installation liegen.\nDer volle Pfad zu der .jar-Datei sollte so aussehen:\nOniFolder/Edition/AEInstaller/AEInstaller2.jar5 invalidPath.text=Dieses Programm muss im Unterordner AE/AEInstaller/bin innerhalb einer regulären Oni-Installation liegen.\nDer volle Pfad zu der .jar-Datei sollte so aussehen:\nOniFolder/AE/AEInstaller/bin/AEInstaller2.jar 6 6 7 7 dotNetMissing.title=.NET ist nicht installiert -
java/installer2/src/net/oni2/aeinstaller/AEInstaller.properties
r786 r804 1 1 appname=AE Installer 2 2 appversion=.0 12 appversion=.02 -
java/installer2/src/net/oni2/aeinstaller/backend/oni/management/Installer.java
r755 r804 25 25 import net.oni2.aeinstaller.backend.oni.PersistDat; 26 26 import net.oni2.aeinstaller.backend.oni.XMLTools; 27 import net.oni2.aeinstaller.backend.oni.management.tools.ToolInstallationList; 27 28 import net.oni2.aeinstaller.backend.packages.EBSLInstallType; 28 29 import net.oni2.aeinstaller.backend.packages.Package; … … 100 101 log.println("AEI2 version: " 101 102 + SwingJavaBuilder.getConfig().getResource("appversion")); 103 104 ToolInstallationList til = ToolInstallationList.getInstance(); 102 105 log.println("Installed tools:"); 103 106 for (Package t : PackageManager.getInstance().getInstalledTools()) { 104 log.println(String.format(" - %s (%s)", t.getName(), t.getVersion())); 107 log.println(String.format(" - %s (%s)", t.getName(), t.getVersion()) 108 + (til.isModified(t.getPackageNumber()) ? " (! LOCALLY MODIFIED !)" 109 : "")); 105 110 } 106 111 log.println("Installing mods:"); … … 236 241 log.println(); 237 242 Date end = new Date(); 238 log.println("In itialization ended at " + sdf.format(end));243 log.println("Installation ended at " + sdf.format(end)); 239 244 log.println("Process took " 240 245 + ((end.getTime() - start.getTime()) / 1000) + " seconds"); -
java/installer2/src/net/oni2/aeinstaller/backend/oni/management/tools/ToolsManager.java
r784 r804 1 package net.oni2.aeinstaller.backend.oni.management ;1 package net.oni2.aeinstaller.backend.oni.management.tools; 2 2 3 3 import java.io.File; 4 import java.io.FileInputStream;5 import java.io.FileNotFoundException;6 import java.io.FileOutputStream;7 4 import java.io.IOException; 5 import java.util.Arrays; 6 import java.util.HashSet; 8 7 import java.util.TreeSet; 9 8 10 9 import net.oni2.aeinstaller.backend.CaseInsensitiveFile; 10 import net.oni2.aeinstaller.backend.FileChecksum; 11 11 import net.oni2.aeinstaller.backend.Paths; 12 12 import net.oni2.aeinstaller.backend.packages.Package; 13 import net.oni2.platformtools.PlatformInformation; 14 import net.oni2.platformtools.PlatformInformation.Platform; 13 import net.oni2.aeinstaller.backend.packages.PackageManager; 15 14 16 15 import org.apache.commons.io.FileUtils; 17 18 import com.thoughtworks.xstream.XStream;19 import com.thoughtworks.xstream.io.xml.StaxDriver;20 16 21 17 /** … … 23 19 */ 24 20 public class ToolsManager { 21 25 22 /** 26 * @return Currentlyinstalled tools23 * Verify integrity of installed tools 27 24 */ 28 @SuppressWarnings("unchecked") 29 public static TreeSet<Integer> getInstalledTools() { 30 File installCfg = new File(Paths.getInstallerPath(), 31 "installed_tools.xml"); 32 TreeSet<Integer> res = new TreeSet<Integer>(); 33 try { 34 if (installCfg.exists()) { 35 FileInputStream fis = new FileInputStream(installCfg); 36 XStream xs = new XStream(new StaxDriver()); 37 Object obj = xs.fromXML(fis); 38 if (obj instanceof TreeSet<?>) 39 res = (TreeSet<Integer>) obj; 40 fis.close(); 41 } 42 } catch (FileNotFoundException e) { 43 e.printStackTrace(); 44 } catch (IOException e) { 45 e.printStackTrace(); 46 } 47 return res; 48 } 49 50 private static void writeInstalledTools(TreeSet<Integer> tools) { 51 File installCfg = new File(Paths.getInstallerPath(), 52 "installed_tools.xml"); 53 try { 54 FileOutputStream fos = new FileOutputStream(installCfg); 55 XStream xs = new XStream(new StaxDriver()); 56 xs.toXML(tools, fos); 57 fos.close(); 58 } catch (FileNotFoundException e) { 59 e.printStackTrace(); 60 } catch (IOException e) { 61 e.printStackTrace(); 25 public static void verifyToolsIntegrity() { 26 final ToolInstallationList til = ToolInstallationList.getInstance(); 27 for (final Package m : PackageManager.getInstance().getInstalledTools()) { 28 ToolFileIterator.iteratePlatformToolFiles(m, 29 new ToolFileIteratorEntry() { 30 @Override 31 public void toolFile(File source, File target) { 32 byte[] chkSrc = FileChecksum 33 .calculateFileMD5(source); 34 if (!target.exists()) { 35 til.markModified(m.getPackageNumber(), true); 36 } else { 37 byte[] chkTrg = FileChecksum 38 .calculateFileMD5(target); 39 if (!Arrays.equals(chkSrc, chkTrg)) 40 til.markModified(m.getPackageNumber(), true); 41 } 42 } 43 }); 62 44 } 63 45 } … … 70 52 */ 71 53 public static void installTools(TreeSet<Package> tools, boolean uninstall) { 72 T reeSet<Integer> installed = getInstalledTools();54 ToolInstallationList til = ToolInstallationList.getInstance(); 73 55 for (Package m : tools) { 74 if (!uninstall || installed.contains(m.getPackageNumber())) { 75 File plain = CaseInsensitiveFile.getCaseInsensitiveFile( 76 m.getLocalPath(), "plain"); 77 if (plain.exists()) { 78 if (m.hasSeparatePlatformDirs()) { 79 File plainCommon = CaseInsensitiveFile 80 .getCaseInsensitiveFile(plain, "common"); 81 File plainMac = CaseInsensitiveFile 82 .getCaseInsensitiveFile(plain, "mac_only"); 83 File plainWin = CaseInsensitiveFile 84 .getCaseInsensitiveFile(plain, "win_only"); 85 if (plainCommon.exists()) 86 copyRemoveToolsFiles(plainCommon, 87 Paths.getEditionBasePath(), uninstall); 88 if (PlatformInformation.getPlatform() == Platform.MACOS 89 && plainMac.exists()) 90 copyRemoveToolsFiles(plainMac, 91 Paths.getEditionBasePath(), uninstall); 92 else if (plainWin.exists()) 93 copyRemoveToolsFiles(plainWin, 94 Paths.getEditionBasePath(), uninstall); 95 } else { 96 copyRemoveToolsFiles(plain, Paths.getEditionBasePath(), 97 uninstall); 98 } 56 if (!uninstall) { // Install: 57 final HashSet<String> files = new HashSet<String>(); 58 ToolFileIterator.iteratePlatformToolFiles(m, 59 new ToolFileIteratorEntry() { 60 @Override 61 public void toolFile(File source, File target) { 62 copyToolsFiles(source, target, files); 63 } 64 }); 65 til.addTool(m.getPackageNumber(), files); 66 } else { // Uninstall: 67 if (til.isInstalled(m.getPackageNumber())) { 68 removeTool(til.getFiles(m.getPackageNumber())); 69 til.removeTool(m.getPackageNumber()); 99 70 } 100 71 } 101 if (uninstall)102 installed.remove(m.getPackageNumber());103 else104 installed.add(m.getPackageNumber());105 72 } 106 writeInstalledTools(installed);73 til.saveList(); 107 74 } 108 75 109 private static void copyRemoveToolsFiles(File srcFolder, File targetFolder, 110 boolean remove) { 111 for (File f : srcFolder.listFiles()) { 112 try { 113 if (f.isDirectory()) 114 copyRemoveToolsFiles(f, 115 CaseInsensitiveFile.getCaseInsensitiveFile( 116 targetFolder, f.getName()), remove); 117 else { 118 File targetFile = CaseInsensitiveFile 119 .getCaseInsensitiveFile(targetFolder, f.getName()); 120 if (remove) { 121 if (targetFile.exists()) 122 targetFile.delete(); 123 } else { 124 if (!targetFile.getName().equals(f.getName())) 125 targetFile.delete(); 126 FileUtils.copyFileToDirectory(f, targetFolder); 127 if (f.canExecute()) 128 CaseInsensitiveFile.getCaseInsensitiveFile( 129 targetFolder, f.getName()).setExecutable( 130 true); 131 } 132 } 133 } catch (IOException e) { 134 e.printStackTrace(); 76 private static void copyToolsFiles(File src, File target, 77 HashSet<String> files) { 78 try { 79 File targetFile = CaseInsensitiveFile.getCaseInsensitiveFile( 80 target.getParentFile(), target.getName()); 81 82 // Case mismatch? 83 if (!targetFile.getName().equals(src.getName())) 84 targetFile.delete(); 85 86 files.add(target.getPath().replace( 87 Paths.getEditionBasePath().getPath(), "")); 88 89 FileUtils.copyFile(src, target); 90 if (src.canExecute()) 91 target.setExecutable(true); 92 } catch (IOException e) { 93 e.printStackTrace(); 94 } 95 } 96 97 private static void removeTool(HashSet<String> files) { 98 for (String p : files) { 99 File targetFile = new File(Paths.getEditionBasePath().getPath() + p); 100 if (targetFile.getPath().contains( 101 Paths.getEditionBasePath().getPath())) { 102 File targetFolder = targetFile.getParentFile(); 103 104 if (targetFile.exists()) 105 targetFile.delete(); 106 if (targetFolder.list().length == 0) 107 targetFolder.delete(); 135 108 } 136 109 } 137 if (remove)138 if (targetFolder.list().length == 0)139 targetFolder.delete();140 110 } 141 142 111 } -
java/installer2/src/net/oni2/aeinstaller/backend/packages/Package.java
r749 r804 14 14 import net.oni2.aeinstaller.backend.CaseInsensitiveFile; 15 15 import net.oni2.aeinstaller.backend.Paths; 16 import net.oni2.aeinstaller.backend.oni.management. ToolsManager;16 import net.oni2.aeinstaller.backend.oni.management.tools.ToolInstallationList; 17 17 import net.oni2.moddepot.DepotConfig; 18 18 import net.oni2.moddepot.ECompatiblePlatform; … … 230 230 public boolean isInstalled() { 231 231 if (tool) 232 return Tool sManager.getInstalledTools().contains(packageNumber);232 return ToolInstallationList.getInstance().isInstalled(packageNumber); 233 233 else 234 234 return PackageManager.getInstance().isModInstalled(this); -
java/installer2/src/net/oni2/aeinstaller/backend/packages/PackageManager.java
r749 r804 14 14 15 15 import net.oni2.aeinstaller.backend.Paths; 16 import net.oni2.aeinstaller.backend.oni.management.Installer; 17 import net.oni2.aeinstaller.backend.oni.management.tools.ToolInstallationList; 16 18 import net.oni2.moddepot.DepotManager; 17 19 import net.oni2.moddepot.model.NodeMod; 18 20 import net.oni2.moddepot.model.TaxonomyTerm; 19 import net.oni2.aeinstaller.backend.oni.management.Installer;20 import net.oni2.aeinstaller.backend.oni.management.ToolsManager;21 21 22 22 import com.thoughtworks.xstream.XStream; … … 266 266 public TreeSet<Package> getInstalledTools() { 267 267 TreeSet<Package> res = new TreeSet<Package>(); 268 for (int n : Tool sManager.getInstalledTools()) {268 for (int n : ToolInstallationList.getInstance().getItems().keySet()) { 269 269 res.add(getPackageByNumber(n)); 270 270 } … … 301 301 for (int depNum : m.getDependencies()) { 302 302 Package other = getPackageByNumber(depNum); 303 if (!mods.contains(other)) { 304 if (!res.containsKey(m)) 305 res.put(m, new HashSet<Package>()); 306 res.get(m).add(other); 303 if (other != null) { 304 if (!mods.contains(other)) { 305 if (!res.containsKey(m)) 306 res.put(m, new HashSet<Package>()); 307 res.get(m).add(other); 308 } 307 309 } 308 310 } … … 326 328 for (int confNum : m.getIncompabitilities()) { 327 329 Package other = getPackageByNumber(confNum); 328 if (mods.contains(other)) { 329 if (!res.containsKey(m)) 330 res.put(m, new HashSet<Package>()); 331 res.get(m).add(other); 330 if (other != null) { 331 if (mods.contains(other)) { 332 if (!res.containsKey(m)) 333 res.put(m, new HashSet<Package>()); 334 res.get(m).add(other); 335 } 332 336 } 333 337 } -
java/installer2/src/net/oni2/aeinstaller/gui/MainWin.java
r773 r804 50 50 import net.oni2.aeinstaller.backend.oni.management.InstallProgressListener; 51 51 import net.oni2.aeinstaller.backend.oni.management.Installer; 52 import net.oni2.aeinstaller.backend.oni.management.ToolsManager; 52 import net.oni2.aeinstaller.backend.oni.management.tools.ToolInstallationList; 53 import net.oni2.aeinstaller.backend.oni.management.tools.ToolsManager; 53 54 import net.oni2.aeinstaller.backend.packages.Package; 54 55 import net.oni2.aeinstaller.backend.packages.PackageManager; … … 358 359 dl.setVisible(true); 359 360 if (dl.isFinished()) { 360 T reeSet<Integer> installed = ToolsManager361 .getInsta lledTools();361 ToolInstallationList til = ToolInstallationList 362 .getInstance(); 362 363 TreeSet<Package> tools = new TreeSet<Package>(); 363 364 for (Package m : execUpdates) 364 if (m.isTool() 365 && installed.contains(m.getPackageNumber())) 365 if (m.isTool() && til.isInstalled(m.getPackageNumber())) 366 366 tools.add(m); 367 367 if (tools.size() > 0) { 368 ToolsManager.installTools(tools, true); 368 369 ToolsManager.installTools(tools, false); 369 370 } … … 548 549 private void checkCorePackages() { 549 550 if (!SettingsManager.getInstance().isOfflineMode()) { 551 TreeSet<Package> tools = new TreeSet<Package>(); 550 552 for (Package m : PackageManager.getInstance().getCoreTools()) { 551 553 if (m.isNewerAvailable()) { 552 554 execCoreUpdates.add(m); 555 tools.add(m); 553 556 } 554 557 } … … 566 569 } 567 570 } 568 ToolsManager.installTools(PackageManager.getInstance() 569 .getCoreTools(), false); 570 } 571 572 ToolsManager.installTools(tools, true); 573 ToolsManager.installTools(tools, false); 574 } 575 ToolsManager.verifyToolsIntegrity(); 576 if (ToolInstallationList.getInstance().getModifiedTools().size() > 0) 577 System.out.println("Locally modified tools: " 578 + ToolInstallationList.getInstance().getModifiedTools() 579 .toString()); 571 580 } 572 581 -
java/installer2/src/net/oni2/aeinstaller/gui/toolmanager/ToolManager.java
r773 r804 18 18 19 19 import net.oni2.SettingsManager; 20 import net.oni2.aeinstaller.backend.oni.management. ToolsManager;20 import net.oni2.aeinstaller.backend.oni.management.tools.ToolsManager; 21 21 import net.oni2.aeinstaller.backend.packages.Package; 22 22 import net.oni2.aeinstaller.gui.downloadwindow.Downloader; -
java/installer2/src/net/oni2/aeinstaller/localization/Global.properties
r730 r804 3 3 4 4 invalidPath.title=Wrong directory 5 invalidPath.text=This program has to be placed in the subfolder Edition/AEInstaller inside a vanilla Oni folder.\nThe full path of the .jar-file has to be:\nOniFolder/Edition/AEInstaller/AEInstaller2.jar5 invalidPath.text=This program has to be placed in the subfolder AE/AEInstaller/bin inside a vanilla Oni folder.\nThe full path of the .jar-file has to be:\nOniFolder/AE/AEInstaller/bin/AEInstaller2.jar 6 6 7 7 dotNetMissing.title=.NET is not installed
Note:
See TracChangeset
for help on using the changeset viewer.