ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r804625 - in /ant/sandbox/antlibs/compress/trunk/src: main/org/apache/ant/compress/antlib.xml main/org/apache/ant/compress/taskdefs/Ar.java main/org/apache/ant/compress/taskdefs/Cpio.java tests/antunit/uncpio-test.xml
Date Sun, 16 Aug 2009 05:44:27 GMT
Author: bodewig
Date: Sun Aug 16 05:44:27 2009
New Revision: 804625

URL: http://svn.apache.org/viewvc?rev=804625&view=rev
Log:
cpio task

Added:
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Cpio.java
  (contents, props changed)
      - copied, changed from r804624, ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Tar.java
Modified:
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
    ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Ar.java
    ant/sandbox/antlibs/compress/trunk/src/tests/antunit/uncpio-test.xml

Modified: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml?rev=804625&r1=804624&r2=804625&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml (original)
+++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/antlib.xml Sun Aug
16 05:44:27 2009
@@ -37,6 +37,10 @@
     classname="org.apache.ant.compress.taskdefs.Ar"
     />
   <taskdef
+    name="cpio"
+    classname="org.apache.ant.compress.taskdefs.Cpio"
+    />
+  <taskdef
     name="tar"
     classname="org.apache.ant.compress.taskdefs.Tar"
     />

Modified: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Ar.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Ar.java?rev=804625&r1=804624&r2=804625&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Ar.java (original)
+++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Ar.java Sun
Aug 16 05:44:27 2009
@@ -24,7 +24,7 @@
 import org.apache.tools.ant.BuildException;
 
 /**
- * Creates tar archives.
+ * Creates ar archives.
  */
 public class Ar extends ArchiveBase {
     /** stolen from ArEntry */

Copied: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Cpio.java
(from r804624, ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Tar.java)
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Cpio.java?p2=ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Cpio.java&p1=ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Tar.java&r1=804624&r2=804625&rev=804625&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Tar.java
(original)
+++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Cpio.java
Sun Aug 16 05:44:27 2009
@@ -18,59 +18,50 @@
 
 package org.apache.ant.compress.taskdefs;
 
-import org.apache.ant.compress.util.TarStreamFactory;
+import org.apache.ant.compress.util.CpioStreamFactory;
 import org.apache.commons.compress.archivers.ArchiveEntry;
-import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
-import org.apache.commons.compress.archivers.tar.TarConstants;
+import org.apache.commons.compress.archivers.cpio.CpioArchiveEntry;
+import org.apache.commons.compress.archivers.cpio.CpioConstants;
 
 /**
- * Creates tar archives.
+ * Creates cpio archives.
  */
-public class Tar extends ArchiveBase {
-    public Tar() {
-        super(new TarStreamFactory(),
+public class Cpio extends ArchiveBase {
+    public Cpio() {
+        super(new CpioStreamFactory(),
               new ArchiveBase.EntryBuilder() {
                 public ArchiveEntry buildEntry(ArchiveBase.ResourceWithFlags r) {
                     boolean isDir = r.getResource().isDirectory();
-                    TarArchiveEntry ent =
-                        new TarArchiveEntry(r.getName(),
-                                            isDir ? TarConstants.LF_DIR
-                                            : TarConstants.LF_NORMAL);
-                    ent.setModTime(r.getResource().getLastModified());
-                    ent.setSize(isDir ? 0 : r.getResource().getSize());
+                    CpioArchiveEntry ent =
+                        new CpioArchiveEntry(r.getName(),
+                                             isDir
+                                             ? 0 : r.getResource().getSize());
+                    ent.setTime(r.getResource().getLastModified() / 1000);
 
+                    int mode =
+                        isDir ? CpioConstants.C_ISDIR : CpioConstants.C_ISREG;
                     if (r.getResourceFlags().hasModeBeenSet()) {
-                        ent.setMode(r.getResourceFlags().getMode());
+                        ent.setMode(mode | r.getResourceFlags().getMode());
                     } else if (!isDir
                                && r.getCollectionFlags().hasModeBeenSet()) {
-                        ent.setMode(r.getCollectionFlags().getMode());
+                        ent.setMode(mode | r.getCollectionFlags().getMode());
                     } else if (isDir
                                && r.getCollectionFlags().hasDirModeBeenSet()) {
-                        ent.setMode(r.getCollectionFlags().getDirMode());
+                        ent.setMode(mode | r.getCollectionFlags().getDirMode());
+                    } else {
+                        ent.setMode(mode);
                     }
 
                     if (r.getResourceFlags().hasUserIdBeenSet()) {
-                        ent.setUserId(r.getResourceFlags().getUserId());
+                        ent.setUID(r.getResourceFlags().getUserId());
                     } else if (r.getCollectionFlags().hasUserIdBeenSet()) {
-                        ent.setUserId(r.getCollectionFlags().getUserId());
+                        ent.setUID(r.getCollectionFlags().getUserId());
                     }
 
                     if (r.getResourceFlags().hasGroupIdBeenSet()) {
-                        ent.setGroupId(r.getResourceFlags().getGroupId());
+                        ent.setGID(r.getResourceFlags().getGroupId());
                     } else if (r.getCollectionFlags().hasGroupIdBeenSet()) {
-                        ent.setGroupId(r.getCollectionFlags().getGroupId());
-                    }
- 
-                    if (r.getResourceFlags().hasUserNameBeenSet()) {
-                        ent.setUserName(r.getResourceFlags().getUserName());
-                    } else if (r.getCollectionFlags().hasUserNameBeenSet()) {
-                        ent.setUserName(r.getCollectionFlags().getUserName());
-                    }
-
-                    if (r.getResourceFlags().hasGroupNameBeenSet()) {
-                        ent.setGroupName(r.getResourceFlags().getGroupName());
-                    } else if (r.getCollectionFlags().hasGroupNameBeenSet()) {
-                        ent.setGroupName(r.getCollectionFlags().getGroupName());
+                        ent.setGID(r.getCollectionFlags().getGroupId());
                     }
  
                     return ent;

Propchange: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Cpio.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Cpio.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: ant/sandbox/antlibs/compress/trunk/src/tests/antunit/uncpio-test.xml
URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/tests/antunit/uncpio-test.xml?rev=804625&r1=804624&r2=804625&view=diff
==============================================================================
--- ant/sandbox/antlibs/compress/trunk/src/tests/antunit/uncpio-test.xml (original)
+++ ant/sandbox/antlibs/compress/trunk/src/tests/antunit/uncpio-test.xml Sun Aug 16 05:44:27
2009
@@ -26,7 +26,19 @@
     <mkdir dir="${input}"/>
   </target>
 
-  <target name="testAgainstNativeTar" depends="setUp">
+  <target name="testAgainstAntlibCpioTask" depends="setUp">
+    <cmp:cpio destfile="${input}/test.cpio">
+      <fileset dir="."/>
+    </cmp:cpio>
+    <cmp:uncpio src="${input}/test.cpio" dest="${output}"/>
+    <au:assertFileExists file="${output}/uncpio-test.xml"/>
+    <au:assertFilesMatch
+       actual="${output}/uncpio-test.xml"
+       expected="uncpio-test.xml"
+       />
+  </target>
+
+  <target name="testAgainstNativeCpio" depends="setUp">
     <cmp:uncpio src="../resources/asf-logo.gif.cpio" dest="${output}" />
     <au:assertFileExists file="${output}/asf-logo.gif"/>
     <au:assertFilesMatch



Mime
View raw message