From 3ca80cb6c477804f095e4003c08a1281bab59bb6 Mon Sep 17 00:00:00 2001 From: Kaloyan Enimanev Date: Thu, 8 Sep 2011 12:59:22 +0200 Subject: [PATCH 08/10] bugfix: it was not possible to omit the creation of uninstaller with --- .../izforge/izpack/compiler/CompilerConfig.java | 80 +++++++++++++++++--- .../izpack/installer/data/UninstallDataWriter.java | 30 ++++++-- 2 files changed, 92 insertions(+), 18 deletions(-) diff --git a/izpack-compiler/src/main/java/com/izforge/izpack/compiler/CompilerConfig.java b/izpack-compiler/src/main/java/com/izforge/izpack/compiler/CompilerConfig.java index 6723f70..0d9011b 100644 --- a/izpack-compiler/src/main/java/com/izforge/izpack/compiler/CompilerConfig.java +++ b/izpack-compiler/src/main/java/com/izforge/izpack/compiler/CompilerConfig.java @@ -26,14 +26,58 @@ package com.izforge.izpack.compiler; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.StringTokenizer; +import java.util.TreeMap; +import java.util.Vector; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +import java.util.zip.ZipInputStream; + +import org.apache.commons.lang.StringUtils; + import com.izforge.izpack.api.adaptator.IXMLElement; import com.izforge.izpack.api.adaptator.IXMLParser; import com.izforge.izpack.api.adaptator.IXMLWriter; import com.izforge.izpack.api.adaptator.impl.XMLParser; import com.izforge.izpack.api.adaptator.impl.XMLWriter; import com.izforge.izpack.api.container.BindeableContainer; -import com.izforge.izpack.api.data.*; +import com.izforge.izpack.api.data.AutomatedInstallData; +import com.izforge.izpack.api.data.Blockable; +import com.izforge.izpack.api.data.DynamicInstallerRequirementValidator; +import com.izforge.izpack.api.data.DynamicVariable; +import com.izforge.izpack.api.data.GUIPrefs; +import com.izforge.izpack.api.data.Info; import com.izforge.izpack.api.data.Info.TempDir; +import com.izforge.izpack.api.data.InstallerRequirement; +import com.izforge.izpack.api.data.LookAndFeels; +import com.izforge.izpack.api.data.OverrideType; +import com.izforge.izpack.api.data.Panel; +import com.izforge.izpack.api.data.PanelActionConfiguration; import com.izforge.izpack.api.data.binding.IzpackProjectInstaller; import com.izforge.izpack.api.data.binding.Listener; import com.izforge.izpack.api.data.binding.OsModel; @@ -59,22 +103,30 @@ import com.izforge.izpack.compiler.resource.ResourceFinder; import com.izforge.izpack.core.data.DynamicInstallerRequirementValidatorImpl; import com.izforge.izpack.core.data.DynamicVariableImpl; import com.izforge.izpack.core.regex.RegularExpressionFilterImpl; -import com.izforge.izpack.core.variable.*; -import com.izforge.izpack.data.*; +import com.izforge.izpack.core.variable.ConfigFileValue; +import com.izforge.izpack.core.variable.EnvironmentValue; +import com.izforge.izpack.core.variable.ExecValue; +import com.izforge.izpack.core.variable.JarEntryConfigValue; +import com.izforge.izpack.core.variable.PlainConfigFileValue; +import com.izforge.izpack.core.variable.PlainValue; +import com.izforge.izpack.core.variable.RegistryValue; +import com.izforge.izpack.core.variable.ZipEntryConfigFileValue; +import com.izforge.izpack.data.CustomData; +import com.izforge.izpack.data.ExecutableFile; +import com.izforge.izpack.data.PackInfo; +import com.izforge.izpack.data.PanelAction; +import com.izforge.izpack.data.ParsableFile; +import com.izforge.izpack.data.UpdateCheck; import com.izforge.izpack.merge.MergeManager; import com.izforge.izpack.merge.resolve.ClassPathCrawler; import com.izforge.izpack.merge.resolve.PathResolver; -import com.izforge.izpack.util.*; +import com.izforge.izpack.util.ClassUtils; +import com.izforge.izpack.util.Debug; +import com.izforge.izpack.util.FileUtil; +import com.izforge.izpack.util.IoHelper; +import com.izforge.izpack.util.OsConstraintHelper; import com.izforge.izpack.util.file.DirectoryScanner; import com.izforge.izpack.util.file.FileUtils; -import org.apache.commons.lang.StringUtils; - -import java.io.*; -import java.net.URL; -import java.util.*; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -import java.util.zip.ZipInputStream; /** * A parser for the installer xml configuration. This parses a document conforming to the @@ -1783,6 +1835,7 @@ public class CompilerConfig extends Thread IXMLElement uninstallInfo = root.getFirstChildNamed("uninstaller"); if (xmlCompilerHelper.validateYesNoAttribute(uninstallInfo, "write", YES)) { + info.setWriteUninstaller(YES); //REFACTOR Change the way uninstaller is created mergeManager.addResourceToMerge("com/izforge/izpack/uninstaller/"); mergeManager.addResourceToMerge("uninstaller-META-INF/"); @@ -1813,6 +1866,9 @@ public class CompilerConfig extends Thread info.setUninstallerCondition(uninstallerCondition); } } + } else + { + info.setWriteUninstaller(NO); } // Add the path for the summary log file if specified diff --git a/izpack-installer/src/main/java/com/izforge/izpack/installer/data/UninstallDataWriter.java b/izpack-installer/src/main/java/com/izforge/izpack/installer/data/UninstallDataWriter.java index 8a3a25f..5ef91b2 100644 --- a/izpack-installer/src/main/java/com/izforge/izpack/installer/data/UninstallDataWriter.java +++ b/izpack-installer/src/main/java/com/izforge/izpack/installer/data/UninstallDataWriter.java @@ -1,5 +1,25 @@ package com.izforge.izpack.installer.data; +import java.io.BufferedOutputStream; +import java.io.BufferedWriter; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectOutputStream; +import java.io.OutputStreamWriter; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.jar.JarEntry; +import java.util.jar.JarException; +import java.util.jar.JarOutputStream; + import com.izforge.izpack.api.data.AutomatedInstallData; import com.izforge.izpack.api.exception.IzPackException; import com.izforge.izpack.api.merge.Mergeable; @@ -12,12 +32,6 @@ import com.izforge.izpack.util.Debug; import com.izforge.izpack.util.IoHelper; import com.izforge.izpack.util.PrivilegedRunner; -import java.io.*; -import java.util.*; -import java.util.jar.JarEntry; -import java.util.jar.JarException; -import java.util.jar.JarOutputStream; - public class UninstallDataWriter { private static final String UNINSTALLER_CONDITION = "UNINSTALLER_CONDITION"; @@ -94,6 +108,10 @@ public class UninstallDataWriter public boolean isUninstallShouldBeWriten() { + if (!installdata.getInfo().isWriteUninstaller()) + { + return false; + } String uninstallerCondition = installdata.getInfo().getUninstallerCondition(); if (uninstallerCondition == null) { -- 1.7.4.1