[izpack-changes] r1904 - in izpack-src/trunk/src: dtd lib/com/izforge/izpack lib/com/izforge/izpack/compiler

noreply at berlios.de noreply at berlios.de
Fri Nov 16 13:40:17 CET 2007


Author: dreil
Date: 2007-11-16 13:40:11 +0100 (Fri, 16 Nov 2007)
New Revision: 1904

Modified:
   izpack-src/trunk/src/dtd/installation.dtd
   izpack-src/trunk/src/lib/com/izforge/izpack/ExecutableFile.java
   izpack-src/trunk/src/lib/com/izforge/izpack/PackFile.java
   izpack-src/trunk/src/lib/com/izforge/izpack/ParsableFile.java
   izpack-src/trunk/src/lib/com/izforge/izpack/compiler/CompilerConfig.java
   izpack-src/trunk/src/lib/com/izforge/izpack/compiler/PackInfo.java
Log:
added condition support in installation.xml

Modified: izpack-src/trunk/src/dtd/installation.dtd
===================================================================
--- izpack-src/trunk/src/dtd/installation.dtd	2007-11-16 12:26:14 UTC (rev 1903)
+++ izpack-src/trunk/src/dtd/installation.dtd	2007-11-16 12:40:11 UTC (rev 1904)
@@ -10,7 +10,7 @@
 -->
 
 <!-- The root element -->
-<!ELEMENT installation (preinstall?, info, properties?, variables?, 
+<!ELEMENT installation (preinstall?, info, packaging?, properties?, variables?, 
                         guiprefs?, locale, resources?, panels,
                         listeners?, packs, jar*, native*, postinstall?)>
     <!ATTLIST installation version CDATA #REQUIRED>
@@ -32,6 +32,15 @@
     <!ELEMENT webdir (#PCDATA)>
     <!ELEMENT summarylogfilepath (#PCDATA)>
 
+<!ELEMENT packaging (packager, unpacker)>
+<!ELEMENT packager (options)>
+<!ATTLIST packager class CDATA #REQUIRED>
+<!ELEMET options EMPTY>
+<!ATTLIST options volumesize CDATA #IMPLIED>
+<!ATTLIST options firstvolumefreespace CDATA #IMPLIED>
+<!ELEMENT unpacker EMPTY>
+<!ATTLIST unpacker class CDATA #REQUIRED>
+
 <!-- The properties markup (property declarations) -->
 <!ELEMENT properties (property*)>
     <!ELEMENT property EMPTY>
@@ -117,11 +126,13 @@
             <!ATTLIST file targetdir CDATA #REQUIRED>
             <!ATTLIST file os (unix|windows|mac) #IMPLIED>
             <!ATTLIST file override (true|false|asktrue|askfalse|update) "update">
+            <!ATTLIST file condition CDATA #IMPLIED>
         <!ELEMENT singlefile (os*, additionaldata*)>
             <!ATTLIST singlefile src CDATA #REQUIRED>
             <!ATTLIST singlefile target CDATA #REQUIRED>
             <!ATTLIST singlefile os (unix|windows|mac) #IMPLIED>
             <!ATTLIST singlefile override (true|false|asktrue|askfalse|update) "update">
+            <!ATTLIST files condition CDATA #IMPLIED>
     <!ELEMENT fileset (include*, exclude*, os*, additionaldata*)>
           <!ATTLIST fileset dir CDATA #REQUIRED>
           <!ATTLIST fileset targetdir CDATA #REQUIRED>  
@@ -131,6 +142,7 @@
           <!ATTLIST fileset override (true|false|asktrue|askfalse|update) "update">
           <!ATTLIST fileset includes CDATA #IMPLIED>
           <!ATTLIST fileset excludes CDATA #IMPLIED>
+          <!ATTLIST fileset condition CDATA #IMPLIED>
       <!ELEMENT include EMPTY>
             <!ATTLIST include name CDATA #REQUIRED>
       <!ELEMENT exclude EMPTY>
@@ -143,6 +155,7 @@
           <!ATTLIST parsable type CDATA "plain">
           <!ATTLIST parsable encoding CDATA #IMPLIED>
           <!ATTLIST parsable os (unix|windows|mac) #IMPLIED>
+          <!ATTLIST parsable condition CDATA #IMPLIED>
       <!ELEMENT executable (args?, os*)>
           <!ATTLIST executable targetfile CDATA #IMPLIED>
           <!ATTLIST executable class CDATA #IMPLIED>
@@ -150,6 +163,7 @@
           <!ATTLIST executable stage (postinstall|never|uninstall) "never">
           <!ATTLIST executable failure (abort|warn|ask) "ask">
           <!ATTLIST executable keep (true|false) "false">
+          <!ATTLIST executable condition CDATA #IMPLIED>
           <!ELEMENT args (arg+)>
               <!ELEMENT arg EMPTY>
                   <!ATTLIST arg value CDATA #REQUIRED>

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/ExecutableFile.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/ExecutableFile.java	2007-11-16 12:26:14 UTC (rev 1903)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/ExecutableFile.java	2007-11-16 12:40:11 UTC (rev 1904)
@@ -84,6 +84,9 @@
      * compatibility.
      */
     public boolean keepFile;
+    
+    /** condition for this executable */
+    private String condition = null;
 
     /** Constructs a new uninitialized instance. */
     public ExecutableFile()
@@ -167,4 +170,26 @@
         retval.append("\n");
         return retval.toString();
     }
+
+    
+    /**
+     * @return the condition
+     */
+    public String getCondition()
+    {
+        return this.condition;
+    }
+
+    
+    /**
+     * @param condition the condition to set
+     */
+    public void setCondition(String condition)
+    {
+        this.condition = condition;
+    }
+    
+    public boolean hasCondition() {
+        return this.condition != null;
+    }
 }

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/PackFile.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/PackFile.java	2007-11-16 12:26:14 UTC (rev 1903)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/PackFile.java	2007-11-16 12:40:11 UTC (rev 1904)
@@ -102,6 +102,9 @@
     public String previousPackId = null;
 
     public long offsetInPreviousPack = -1;
+    
+    /** condition for this packfile */
+    private String condition = null;
 
     /**
      * Constructs and initializes from a source file.
@@ -256,4 +259,25 @@
         return additionals;
     }
 
+    
+    /**
+     * @return the condition
+     */
+    public String getCondition()
+    {
+        return this.condition;
+    }
+
+    
+    /**
+     * @param condition the condition to set
+     */
+    public void setCondition(String condition)
+    {
+        this.condition = condition;
+    }
+
+    public boolean hasCondition() {
+        return this.condition != null;
+    }
 }

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/ParsableFile.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/ParsableFile.java	2007-11-16 12:26:14 UTC (rev 1903)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/ParsableFile.java	2007-11-16 12:40:11 UTC (rev 1904)
@@ -46,6 +46,9 @@
 
     /** The list of OS constraints limiting file installation. */
     public List osConstraints = null;
+    
+    /** condition for this Parsable */
+    private String condition = null;
 
     /**
      * Constructs and initializes a new instance.
@@ -63,4 +66,26 @@
         this.osConstraints = osConstraints;
     }
 
+    
+    /**
+     * @return the condition
+     */
+    public String getCondition()
+    {
+        return this.condition;
+    }
+
+    
+    /**
+     * @param condition the condition to set
+     */
+    public void setCondition(String condition)
+    {
+        this.condition = condition;
+    }
+    
+    public boolean hasCondition() {
+        return this.condition != null;
+    }
+
 }

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/compiler/CompilerConfig.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/compiler/CompilerConfig.java	2007-11-16 12:26:14 UTC (rev 1903)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/compiler/CompilerConfig.java	2007-11-16 12:40:11 UTC (rev 1904)
@@ -605,10 +605,7 @@
             String parent = el.getAttribute("parent");
             
             String conditionid = el.getAttribute("condition");
-            if ((conditionid != null) && (id == null)) {
-                parseError(el,"Pack, which has no id can not have conditions.");
-                new Exception("Pack, which has no id can not have conditions.");
-            }
+            
             if(required && excludeGroup != null)
             {
                 parseError(el, "Pack, which has excludeGroup can not be required.", 
@@ -655,8 +652,10 @@
                 String type = p.getAttribute("type", "plain");
                 String encoding = p.getAttribute("encoding", null);
                 List osList = OsConstraint.getOsList(p); // TODO: unverified
-
-                pack.addParsable(new ParsableFile(target, type, encoding, osList));
+                String condition = p.getAttribute("condition");
+                ParsableFile parsable = new ParsableFile(target, type, encoding, osList);
+                parsable.setCondition(condition);
+                pack.addParsable(parsable);
             }
 
             // We get the executables list
@@ -666,7 +665,8 @@
                 XMLElement e = (XMLElement) iter.next();
                 ExecutableFile executable = new ExecutableFile();
                 String val; // temp value
-
+                String condition = e.getAttribute("condition");
+                executable.setCondition(condition);
                 executable.path = requireAttribute(e, "targetfile");
 
                 // when to execute this executable
@@ -725,16 +725,17 @@
                 int override = getOverrideValue(f);
                 Map additionals = getAdditionals(f);
                 boolean unpack = src.endsWith(".zip") && "true".equalsIgnoreCase(f.getAttribute("unpack"));
-
+                String condition = f.getAttribute("condition");
+                
                 File file = new File(src);
                 if (!file.isAbsolute()) file = new File(basedir, src);
 
                 try
                 {
                     if (unpack)
-                        addArchiveContent(baseDir, file, targetdir, osList, override, pack, additionals);
+                        addArchiveContent(baseDir, file, targetdir, osList, override, pack, additionals,condition);
                     else
-                        addRecursively(baseDir, file, targetdir, osList, override, pack, additionals);
+                        addRecursively(baseDir, file, targetdir, osList, override, pack, additionals,condition);
                 }
                 catch (Exception x)
                 {
@@ -752,13 +753,13 @@
                 List osList = OsConstraint.getOsList(f); // TODO: unverified
                 int override = getOverrideValue(f);
                 Map additionals = getAdditionals(f);
-
+                String condition = f.getAttribute("condition");
                 File file = new File(src);
                 if (!file.isAbsolute()) file = new File(basedir, src);
 
                 try
                 {
-                    pack.addFile(baseDir, file, target, osList, override, additionals);
+                    pack.addFile(baseDir, file, target, osList, override, additionals,condition);
                 }
                 catch (FileNotFoundException x)
                 {
@@ -784,6 +785,7 @@
                 List osList = OsConstraint.getOsList(f); // TODO: unverified
                 int override = getOverrideValue(f);
                 Map additionals = getAdditionals(f);
+                String condition = f.getAttribute("condition");
 
                 // get includes and excludes
                 Vector xcludesList = null;
@@ -867,9 +869,7 @@
                     try
                     {
                         String target = new File(targetdir, files[i]).getPath();
-                        pack
-                                .addFile(baseDir, new File(dir, files[i]), target, osList, override,
-                                        additionals);
+                        pack.addFile(baseDir, new File(dir, files[i]), target, osList, override,additionals,condition);
                     }
                     catch (FileNotFoundException x)
                     {
@@ -881,7 +881,7 @@
                     try
                     {
                         String target = new File(targetdir, dirs[i]).getPath();
-                        pack.addFile(baseDir, new File(dir, dirs[i]), target, osList, override, additionals);
+                        pack.addFile(baseDir, new File(dir, dirs[i]), target, osList, override, additionals,condition);
                     }
                     catch (FileNotFoundException x)
                     {
@@ -1117,8 +1117,9 @@
      * @param override Overriding behaviour.
      * @param pack Pack to be packed into
      * @param additionals Map which contains additional data
+     * @param condition 
      */
-    protected void addArchiveContent(File baseDir, File archive, String targetdir, List osList, int override, PackInfo pack, Map additionals) throws IOException {
+    protected void addArchiveContent(File baseDir, File archive, String targetdir, List osList, int override, PackInfo pack, Map additionals, String condition) throws IOException {
       
       FileInputStream fin = new FileInputStream(archive);
       ZipInputStream zin = new ZipInputStream(fin);
@@ -1135,7 +1136,7 @@
             PackagerHelper.copyStream(zin, out);
             out.close();
         
-            pack.addFile(baseDir, temp, targetdir + "/" + zentry.getName(), osList, override, additionals);
+            pack.addFile(baseDir, temp, targetdir + "/" + zentry.getName(), osList, override, additionals,condition);
         } catch (IOException e) {
             throw new IOException("Couldn't create temporary file for "+zentry.getName()+" in archive "+archive+" ("+e.getMessage()+")");
         }
@@ -1153,24 +1154,25 @@
      * @param override Overriding behaviour.
      * @param pack Pack to be packed into
      * @param additionals Map which contains additional data
+     * @param condition 
      * @exception FileNotFoundException if the file does not exist
      */
     protected void addRecursively(File baseDir, File file, String targetdir, List osList, int override,
-            PackInfo pack, Map additionals) throws IOException
+            PackInfo pack, Map additionals, String condition) throws IOException
     {
         String targetfile = targetdir + "/" + file.getName();
         if (!file.isDirectory())
-            pack.addFile(baseDir, file, targetfile, osList, override, additionals);
+            pack.addFile(baseDir, file, targetfile, osList, override, additionals,condition);
         else
         {
             File[] files = file.listFiles();
             if (files.length == 0) // The directory is empty so must be added
-                pack.addFile(baseDir, file, targetfile, osList, override, additionals);
+                pack.addFile(baseDir, file, targetfile, osList, override, additionals,condition);
             else
             {
                 // new targetdir = targetfile;
                 for (int i = 0; i < files.length; i++)
-                    addRecursively(baseDir, files[i], targetfile, osList, override, pack, additionals);
+                    addRecursively(baseDir, files[i], targetfile, osList, override, pack, additionals,condition);
             }
         }
     }

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/compiler/PackInfo.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/compiler/PackInfo.java	2007-11-16 12:26:14 UTC (rev 1903)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/compiler/PackInfo.java	2007-11-16 12:40:11 UTC (rev 1904)
@@ -184,6 +184,7 @@
      * @param targetfile path file will be installed to.
      * @param osList the target operation system(s) of this pack.
      * @param override what to do if the file already exists when installing
+     * @param condition 
      * 
      * @throws FileNotFoundException if the file specified does not exist. The file is not read
      * until the {@link Packager#createInstaller} is invoked, thus a FileNotFoundEception will occur
@@ -205,12 +206,13 @@
      * until the {@link Packager#createInstaller} is invoked, thus a FileNotFoundEception will occur
      * then, if the file is deleted in between.
      */
-    public void addFile(File baseDir, File file, String targetfile, List osList, int override, Map additionals)
+    public void addFile(File baseDir, File file, String targetfile, List osList, int override, Map additionals, String condition)
             throws FileNotFoundException
     {
         if (!file.exists()) throw new FileNotFoundException(file.toString());
 
         PackFile packFile = new PackFile(baseDir, file, targetfile, osList, override, additionals);
+        packFile.setCondition(condition);
         files.put(packFile, file);
     }
 



More information about the izpack-changes mailing list