Return-Path: X-Original-To: apmail-ant-notifications-archive@minotaur.apache.org Delivered-To: apmail-ant-notifications-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EF6F89131 for ; Sat, 16 Jun 2012 10:31:26 +0000 (UTC) Received: (qmail 82854 invoked by uid 500); 16 Jun 2012 10:31:26 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 82711 invoked by uid 500); 16 Jun 2012 10:31:24 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 82680 invoked by uid 99); 16 Jun 2012 10:31:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 16 Jun 2012 10:31:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 16 Jun 2012 10:31:21 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 266E92388962 for ; Sat, 16 Jun 2012 10:31:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1350904 - in /ant/core/trunk: WHATSNEW manual/Tasks/tar.html src/main/org/apache/tools/ant/taskdefs/Tar.java src/tests/antunit/taskdefs/tar-test.xml src/tests/junit/org/apache/tools/tar/TarRoundTripTest.java Date: Sat, 16 Jun 2012 10:31:00 -0000 To: notifications@ant.apache.org From: bodewig@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120616103101.266E92388962@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bodewig Date: Sat Jun 16 10:31:00 2012 New Revision: 1350904 URL: http://svn.apache.org/viewvc?rev=1350904&view=rev Log: Add a longfile='posix' option to tar task Modified: ant/core/trunk/WHATSNEW ant/core/trunk/manual/Tasks/tar.html ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Tar.java ant/core/trunk/src/tests/antunit/taskdefs/tar-test.xml ant/core/trunk/src/tests/junit/org/apache/tools/tar/TarRoundTripTest.java Modified: ant/core/trunk/WHATSNEW URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1350904&r1=1350903&r2=1350904&view=diff ============================================================================== --- ant/core/trunk/WHATSNEW (original) +++ ant/core/trunk/WHATSNEW Sat Jun 16 10:31:00 2012 @@ -58,6 +58,14 @@ Other changes: * will now properly expand files created by pbzip2 and similar tools that create files with multiple bzip2 streams. + * now supports a new "posix" option for longfile-mode which + will make it create PAX extension headers for long file names. PAX + extension headers are supported by all modern implementations of + tar including GNU tar. + This option should now be used in preference to "warn" or "gnu" as + it is more portable. For backwards compatibility reasons "warn" + will still create "gnu" extensions rather than "posix" extensions. + Changes from Ant 1.8.3 TO Ant 1.8.4 =================================== Modified: ant/core/trunk/manual/Tasks/tar.html URL: http://svn.apache.org/viewvc/ant/core/trunk/manual/Tasks/tar.html?rev=1350904&r1=1350903&r2=1350904&view=diff ============================================================================== --- ant/core/trunk/manual/Tasks/tar.html (original) +++ ant/core/trunk/manual/Tasks/tar.html Sat Jun 16 10:31:00 2012 @@ -43,23 +43,43 @@ to be applied to the tar entries. This i for directories.

Early versions of tar did not support path lengths greater than 100 -characters. Modern versions of tar do so, but in incompatible ways. -The behaviour of the tar task when it encounters such paths is -controlled by the longfile attribute. + characters. Over time several incompatible extensions have been + developed until a new POSIX standard was created that added so + called PAX extension headers (as the pax utility first introduced + them) that among another things addressed file names longer than 100 + characters. All modern implementations of tar support PAX extension + headers.

+ +

Ant's tar support predates the standard with PAX extension headers, + it supports different dialects that can be enabled using the + longfile attribute. If the longfile attribute is set to fail, any long paths will cause the tar task to fail. If the longfile attribute is set to truncate, any long paths will be truncated to the 100 character maximum length prior to adding to the archive. If the value of the longfile attribute is set to omit then files containing long paths will be omitted from the archive. Either option ensures that the archive can be -untarred by any compliant version of tar. If the loss of path or file +untarred by any compliant version of tar.

+ +

If the loss of path or file information is not acceptable, and it rarely is, longfile may be set to the -value gnu. The tar task will then produce a GNU tar file which +value gnu or posix. With posix + Ant will add PAX extension headers, with gnu it adds + GNU tar specific extensions that newer versions of GNU tar call + "oldgnu". GNU tar still creates these extensions by default but + supports PAX extension headers as well. Either choice will produce + a tar file which can have arbitrary length paths. Note however, that the resulting archive will -only be able to be untarred with GNU tar. The default for the longfile +only be able to be untarred with tar tools that support the chosen format. + +

The default for the longfile attribute is warn which behaves just like the gnu option except that it produces a warning for each file path encountered that does not match -the limit.

+the limit. It uses gnu rather than posix for backwards compatibility + reasons.

+ +

To achivieve best interoperability you should use + either fail or posix for the longfile attribute.

This task can perform compression by setting the compression attribute to "gzip" or "bzip2".

@@ -85,7 +105,7 @@ or "bzip2".

longfile Determines how long files (>100 chars) are to be handled. Allowable values are "truncate", "fail", - "warn", "omit" and "gnu". Default is + "warn", "omit", "gnu" and "posix". Default is "warn". No Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Tar.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Tar.java?rev=1350904&r1=1350903&r2=1350904&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Tar.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Tar.java Sat Jun 16 10:31:00 2012 @@ -198,7 +198,8 @@ public class Tar extends MatchingTask { *
  • truncate - paths are truncated to the maximum length *
  • fail - paths greater than the maximum cause a build exception *
  • warn - paths greater than the maximum cause a warning and GNU is used - *
  • gnu - GNU extensions are used for any paths greater than the maximum. + *
  • gnu - extensions used by older versions of GNU tar are used for any paths greater than the maximum. + *
  • posix - use POSIX PAX extension headers for any paths greater than the maximum. Supported by all modern tar implementations. *
  • omit - paths greater than the maximum are omitted from the archive * * @param mode the mode to handle long file names. @@ -299,6 +300,8 @@ public class Tar extends MatchingTask { } else if (longFileMode.isFailMode() || longFileMode.isOmitMode()) { tOut.setLongFileMode(TarOutputStream.LONGFILE_ERROR); + } else if (longFileMode.isPosixMode()) { + tOut.setLongFileMode(TarOutputStream.LONGFILE_POSIX); } else { // warn or GNU tOut.setLongFileMode(TarOutputStream.LONGFILE_GNU); @@ -844,9 +847,12 @@ public class Tar extends MatchingTask { FAIL = "fail", TRUNCATE = "truncate", GNU = "gnu", + POSIX = "posix", OMIT = "omit"; - private final String[] validModes = {WARN, FAIL, TRUNCATE, GNU, OMIT}; + private final String[] validModes = { + WARN, FAIL, TRUNCATE, GNU, POSIX, OMIT + }; /** Constructor, defaults to "warn" */ public TarLongFileMode() { @@ -895,6 +901,13 @@ public class Tar extends MatchingTask { public boolean isOmitMode() { return OMIT.equalsIgnoreCase(getValue()); } + + /** + * @return true if value is "posix". + */ + public boolean isPosixMode() { + return POSIX.equalsIgnoreCase(getValue()); + } } /** Modified: ant/core/trunk/src/tests/antunit/taskdefs/tar-test.xml URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/tar-test.xml?rev=1350904&r1=1350903&r2=1350904&view=diff ============================================================================== --- ant/core/trunk/src/tests/antunit/taskdefs/tar-test.xml (original) +++ ant/core/trunk/src/tests/antunit/taskdefs/tar-test.xml Sat Jun 16 10:31:00 2012 @@ -90,4 +90,29 @@ + + + + + + + + + + + + + + + + + + + + + + + Modified: ant/core/trunk/src/tests/junit/org/apache/tools/tar/TarRoundTripTest.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/tar/TarRoundTripTest.java?rev=1350904&r1=1350903&r2=1350904&view=diff ============================================================================== --- ant/core/trunk/src/tests/junit/org/apache/tools/tar/TarRoundTripTest.java (original) +++ ant/core/trunk/src/tests/junit/org/apache/tools/tar/TarRoundTripTest.java Sat Jun 16 10:31:00 2012 @@ -35,7 +35,18 @@ public class TarRoundTripTest extends Te /** * test round-tripping long (GNU) entries */ - public void testLongRoundTripping() throws IOException { + public void testLongRoundTrippingGNU() throws IOException { + testLongRoundTripping(TarOutputStream.LONGFILE_GNU); + } + + /** + * test round-tripping long (POSIX) entries + */ + public void testLongRoundTrippingPOSIX() throws IOException { + testLongRoundTripping(TarOutputStream.LONGFILE_POSIX); + } + + private void testLongRoundTripping(int mode) throws IOException { TarEntry original = new TarEntry(LONG_NAME); assertTrue("over 100 chars", LONG_NAME.length() > 100); assertEquals("original name", LONG_NAME, original.getName()); @@ -43,7 +54,7 @@ public class TarRoundTripTest extends Te ByteArrayOutputStream buff = new ByteArrayOutputStream(); TarOutputStream tos = new TarOutputStream(buff); - tos.setLongFileMode(TarOutputStream.LONGFILE_GNU); + tos.setLongFileMode(mode); tos.putNextEntry(original); tos.closeEntry(); tos.close();