[izpack-changes] r1910 - in izpack-src/trunk/src/lib/com/izforge/izpack: compiler panels

noreply at berlios.de noreply at berlios.de
Tue Nov 20 15:32:38 CET 2007


Author: dreil
Date: 2007-11-20 15:32:36 +0100 (Tue, 20 Nov 2007)
New Revision: 1910

Modified:
   izpack-src/trunk/src/lib/com/izforge/izpack/compiler/CompilerConfig.java
   izpack-src/trunk/src/lib/com/izforge/izpack/compiler/Packager.java
   izpack-src/trunk/src/lib/com/izforge/izpack/panels/PacksModel.java
Log:
bugfix: packaging broken with empty pack.id
added selfcontained refpacks

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-20 08:02:51 UTC (rev 1909)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/compiler/CompilerConfig.java	2007-11-20 14:32:36 UTC (rev 1910)
@@ -52,6 +52,7 @@
 import java.util.Vector;
 import java.util.jar.JarInputStream;
 import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
 import java.util.zip.ZipInputStream;
 
 import org.apache.tools.ant.DirectoryScanner;
@@ -939,21 +940,52 @@
 
             // get the name of reference xml file
         	String refFileName = requireAttribute(el, "file");
+        	String selfcontained = el.getAttribute("selfcontained");
+        	boolean isselfcontained = Boolean.valueOf(selfcontained).booleanValue();
         	
-        	// Load the reference XML file
         	
-        	// Initialises the parser
-            IXMLReader refXMLReader = null;
-            
-            File refXMLFile = new File(refFileName);
+        	File refXMLFile = new File(refFileName);
             if (!refXMLFile.isAbsolute()) refXMLFile = new File(basedir, refFileName);
             if (!refXMLFile.canRead()) {
                 throw new CompilerException("Invalid file: " + refXMLFile);
             }
             
+            InputStream specin = null;
+            
+        	if (isselfcontained){
+        	    if (!refXMLFile.getAbsolutePath().endsWith(".zip")) {
+        	        throw new CompilerException("Invalid file: " + refXMLFile + ". Selfcontained files can only be of type zip.");
+        	    }
+        	    ZipFile zip;
+                try
+                {
+                    zip = new ZipFile(refXMLFile,ZipFile.OPEN_READ);
+                    ZipEntry specentry = zip.getEntry("META-INF/izpack.xml");
+                    specin = zip.getInputStream(specentry);
+                }
+                catch (IOException e)
+                {
+                    throw new CompilerException("Error reading META-INF/izpack.xml in " + refXMLFile);
+                }        	    
+        	}
+        	else {
+        	    try
+                {
+                    specin = new FileInputStream(refXMLFile.getAbsolutePath());
+                }
+                catch (FileNotFoundException e)
+                {
+                    throw new CompilerException("FileNotFoundException exception while reading refXMLFile");
+                }
+        	}
+        	
+        	// Initialises the parser
+            IXMLReader refXMLReader = null;
+            
+            // Load the reference XML file                        
             try
             {
-            	refXMLReader = new StdXMLReader(new FileInputStream(refXMLFile.getAbsolutePath()));
+            	refXMLReader = new StdXMLReader(specin);
             }
             catch (CompilerException c)
             {
@@ -974,6 +1006,7 @@
             try
             {
                 refXMLData = (XMLElement) refXMLParser.parse();
+                
             }
             catch (XMLException x)
             {
@@ -995,6 +1028,15 @@
             // call addResources to add the referenced XML resources to this installation
             addResources(refXMLData);
             
+            try
+            {
+                specin.close();
+            }
+            catch (IOException e)
+            {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
             // Recursively call myself to add all packs and refpacks from the reference XML
             addPacksSingle(refXMLData);
         }

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/compiler/Packager.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/compiler/Packager.java	2007-11-20 08:02:51 UTC (rev 1909)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/compiler/Packager.java	2007-11-20 14:32:36 UTC (rev 1910)
@@ -237,6 +237,9 @@
             PackInfo packInfo = (PackInfo) packIter.next();
             Pack pack = packInfo.getPack();
             pack.nbytes = 0;
+            if ((pack.id == null) || (pack.id.length() == 0)) {
+                pack.id=pack.name;
+            }
 
             // create a pack specific jar if required
             com.izforge.izpack.util.JarOutputStream packStream = primaryJarStream;
@@ -251,8 +254,7 @@
             sendMsg("Writing Pack " + packNumber + ": " + pack.name, PackagerListener.MSG_VERBOSE);
 
             // Retrieve the correct output stream
-            org.apache.tools.zip.ZipEntry entry = 
-                new org.apache.tools.zip.ZipEntry("packs/pack-" + pack.id);
+            org.apache.tools.zip.ZipEntry entry = new org.apache.tools.zip.ZipEntry("packs/pack-" + pack.id);
             if( ! compressor.useStandardCompression())
             {
                 entry.setMethod(ZipEntry.STORED);

Modified: izpack-src/trunk/src/lib/com/izforge/izpack/panels/PacksModel.java
===================================================================
--- izpack-src/trunk/src/lib/com/izforge/izpack/panels/PacksModel.java	2007-11-20 08:02:51 UTC (rev 1909)
+++ izpack-src/trunk/src/lib/com/izforge/izpack/panels/PacksModel.java	2007-11-20 14:32:36 UTC (rev 1910)
@@ -110,8 +110,15 @@
                     }
                 }
                 this.removeAlreadyInstalledPacks(idata.selectedPacks);
+                Debug.trace("Found " + packsinstalled.size() + " installed packs");
+                
                 Properties variables = (Properties) oin.readObject();
-                Debug.trace("Found " + packsinstalled.size() + " installed packs");                
+                
+                Iterator iter = variables.keySet().iterator();
+                while (iter.hasNext()) {
+                    Object key = iter.next();
+                    idata.setVariable((String) key, (String) variables.get(key));
+                }                                
                 fin.close();                
             }
             catch (FileNotFoundException e)



More information about the izpack-changes mailing list