source: other-projects/trunk/realistic-books/packages/AntInstaller/web/manual1.6.2/manual/CoreTasks/tar.html@ 19253

Last change on this file since 19253 was 19253, checked in by davidb, 15 years ago

Establishing a source code repository for Veronica's Realistic Book's software

File size: 10.7 KB
Line 
1<html>
2
3<head>
4<meta http-equiv="Content-Language" content="en-us">
5<title>Tar Task</title>
6<link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
7</head>
8
9<body>
10
11<h2><a name="tar">Tar</a></h2>
12<h3>Description</h3>
13<p>Creates a tar archive.</p>
14<p>The <i>basedir</i> attribute is the reference directory from where to tar.</p>
15<p>This task is a <a href="../dirtasks.html#directorybasedtasks">directory based task</a>
16and, as such, forms an implicit <a href="../CoreTypes/fileset.html">Fileset</a>. This
17defines which files, relative to the <i>basedir</i>, will be included in the
18archive. The tar task supports all the attributes of Fileset to refine the
19set of files to be included in the implicit fileset.</p>
20
21<p>In addition to the implicit fileset, the tar task supports nested filesets. These
22filesets are extended to allow control over the access mode, username and groupname
23to be applied to the tar entries. This is useful, for example, when preparing archives for
24Unix systems where some files need to have execute permission.</p>
25
26<p>Early versions of tar did not support path lengths greater than 100
27characters. Modern versions of tar do so, but in incompatible ways.
28The behaviour of the tar task when it encounters such paths is
29controlled by the <i>longfile</i> attribute.
30If the longfile attribute is set to <code>fail</code>, any long paths will
31cause the tar task to fail. If the longfile attribute is set to
32<code>truncate</code>, any long paths will be truncated to the 100 character
33maximum length prior to adding to the archive. If the value of the longfile
34attribute is set to <code>omit</code> then files containing long paths will be
35omitted from the archive. Either option ensures that the archive can be
36untarred by any compliant version of tar. If the loss of path or file
37information is not acceptable, and it rarely is, longfile may be set to the
38value <code>gnu</code>. The tar task will then produce a GNU tar file which
39can have arbitrary length paths. Note however, that the resulting archive will
40only be able to be untarred with GNU tar. The default for the longfile
41attribute is <code>warn</code> which behaves just like the gnu option except
42that it produces a warning for each file path encountered that does not match
43the limit.</p>
44
45<p>This task can perform compression by setting the compression attribute to "gzip"
46or "bzip2".</p>
47
48<h3>Parameters</h3>
49<table border="1" cellpadding="2" cellspacing="0">
50 <tr>
51 <td valign="top"><b>Attribute</b></td>
52 <td valign="top"><b>Description</b></td>
53 <td valign="top" align="center"><b>Required</b></td>
54 </tr>
55 <tr>
56 <td valign="top">destfile</td>
57 <td valign="top">the tar-file to create.</td>
58 <td align="center" valign="top">Yes</td>
59 </tr>
60 <tr>
61 <td valign="top">basedir</td>
62 <td valign="top">the directory from which to tar the files.</td>
63 <td align="center" valign="top">No</td>
64 </tr>
65 <tr>
66 <td valign="top">longfile</td>
67 <td valign="top">Determines how long files (&gt;100 chars) are to be
68 handled. Allowable values are &quot;truncate&quot;, &quot;fail&quot;,
69 &quot;warn&quot;, &quot;omit&quot; and &quot;gnu&quot;. Default is
70 &quot;warn&quot;.</td>
71 <td valign="top" align="center">No</td>
72 </tr>
73 <tr>
74 <td valign="top">includes</td>
75 <td valign="top">comma- or space-separated list of patterns of files that must be
76 included. All files are included when omitted.</td>
77 <td valign="top" align="center">No</td>
78 </tr>
79 <tr>
80 <td valign="top">includesfile</td>
81 <td valign="top">the name of a file. Each line of this file is
82 taken to be an include pattern</td>
83 <td valign="top" align="center">No</td>
84 </tr>
85 <tr>
86 <td valign="top">excludes</td>
87 <td valign="top">comma- or space-separated list of patterns of files that must be
88 excluded. No files (except default excludes) are excluded when omitted.</td>
89 <td valign="top" align="center">No</td>
90 </tr>
91 <tr>
92 <td valign="top">excludesfile</td>
93 <td valign="top">the name of a file. Each line of this file is
94 taken to be an exclude pattern</td>
95 <td valign="top" align="center">No</td>
96 </tr>
97 <tr>
98 <td valign="top">defaultexcludes</td>
99 <td valign="top">indicates whether default excludes should be used or not
100 (&quot;yes&quot;/&quot;no&quot;). Default excludes are used when omitted.</td>
101 <td valign="top" align="center">No</td>
102 </tr>
103 <tr>
104 <td valign="top">compression</td>
105 <td valign="top">compression method. Allowable values are
106 &quot;none&quot;, &quot;gzip&quot; and &quot;bzip2&quot;. Default is
107 &quot;none&quot;.</td>
108 <td valign="top" align="center">No</td>
109 </tr>
110</table>
111
112<h3>Nested Elements</h3>
113The tar task supports nested <a href="../CoreTypes/fileset.html">tarfileset</a> elements. These are
114extended Filesets which, in addition to the standard fileset elements, support three additional
115attributes
116
117<table border="1" cellpadding="2" cellspacing="0">
118 <tr>
119 <td valign="top"><b>Attribute</b></td>
120 <td valign="top"><b>Description</b></td>
121 <td valign="top" align="center"><b>Required</b></td>
122 </tr>
123 <tr>
124 <td valign="top">mode</td>
125 <td valign="top">A 3 digit octal string, specify the user, group
126 and other modes in the standard Unix fashion. Only applies to
127 plain files. Default is 644.</td>
128 <td align="center" valign="top">No</td>
129 </tr>
130 <tr>
131 <td valign="top">dirmode</td>
132 <td valign="top">A 3 digit octal string, specify the user, group
133 and other modes in the standard Unix fashion. Only applies to
134 directories. Default is 755. <em>since Ant 1.6</em>.</td>
135 <td align="center" valign="top">No</td>
136 </tr>
137 <tr>
138 <td valign="top">username</td>
139 <td valign="top">The username for the tar entry. This is not the same as the UID.
140 </td>
141 <td align="center" valign="top">No</td>
142 </tr>
143 <tr>
144 <td valign="top">group</td>
145 <td valign="top">The groupname for the tar entry. This is not the same as the GID.
146 </td>
147 <td align="center" valign="top">No</td>
148 </tr>
149 <tr>
150 <td valign="top">uid</td>
151 <td valign="top">The user identifier (UID) for the tar entry. This is an integer value
152 and is not the same as the username. <em>since Ant 1.6.2</em>.
153 </td>
154 <td align="center" valign="top">No</td>
155 </tr>
156 <tr>
157 <td valign="top">gid</td>
158 <td valign="top">The group identifier (GID) for the tar entry. <em>since Ant 1.6.2</em>.
159 </td>
160 <td align="center" valign="top">No</td>
161 </tr>
162 <tr>
163 <td valign="top">prefix</td>
164 <td valign="top">If the prefix attribute is set, all files in the fileset
165 are prefixed with that path in the archive.</td>
166 <td align="center" valign="top">No</td>
167 </tr>
168 <tr>
169 <td valign="top">fullpath</td>
170 <td valign="top">If the fullpath attribute is set, the file in the fileset
171 is written with that path in the archive. The prefix attribute, if specified, is
172 ignored. It is an error to have more than one file specified in
173 such a fileset.</td>
174 <td align="center" valign="top">No</td>
175 </tr>
176 <tr>
177 <td valign="top">preserveLeadingSlashes</td>
178 <td valign="top">Indicates whether leading `/'s should
179 be preserved in the file names. Default is <code>false</code>.</td>
180 <td align="center" valign="top">No</td>
181 </tr>
182</table>
183
184<h3>Examples</h3>
185<pre> &lt;tar tarfile=&quot;${dist}/manual.tar&quot; basedir=&quot;htdocs/manual&quot;/&gt;
186 &lt;gzip zipfile=&quot;${dist}/manual.tar.gz&quot; src=&quot;${dist}/manual.tar&quot;/&gt;</pre>
187<p>tars all files in the <code>htdocs/manual</code> directory into a file called <code>manual.tar</code>
188in the <code>${dist}</code> directory, then applies the gzip task to compress
189it.</p>
190<pre> &lt;tar destfile=&quot;${dist}/manual.tar&quot;
191 basedir=&quot;htdocs/manual&quot;
192 excludes=&quot;mydocs/**, **/todo.html&quot;
193 /&gt;</pre>
194<p>tars all files in the <code>htdocs/manual</code> directory into a file called <code>manual.tar</code>
195in the <code>${dist}</code> directory. Files in the directory <code>mydocs</code>,
196or files with the name <code>todo.html</code> are excluded.</p>
197
198<pre>
199&lt;tar destfile=&quot;${basedir}/docs.tar&quot;&gt;
200 &lt;tarfileset dir=&quot;${dir.src}/docs&quot;
201 fullpath=&quot;/usr/doc/ant/README&quot;
202 preserveLeadingSlashes=&quot;true&quot;&gt;
203 &lt;include name=&quot;readme.txt&quot;/&gt;
204 &lt;/tarfileset&gt;
205 &lt;tarfileset dir=&quot;${dir.src}/docs&quot;
206 prefix=&quot;/usr/doc/ant&quot;
207 preserveLeadingSlashes=&quot;true&quot;&gt;
208 &lt;include name=&quot;*.html&quot;/&gt;
209 &lt;/tarfileset&gt;
210&lt;/tar&gt;</pre>
211
212<p>
213 Writes the file <code>docs/readme.txt</code> as
214 <code>/usr/doc/ant/README</code> into the archive. All
215 <code>*.html</code> files in the <code>docs</code> directory are
216 prefixed by <code>/usr/doc/ant</code>, so for example
217 <code>docs/index.html</code> is written as
218 <code>/usr/doc/ant/index.html</code> to the archive.
219</p>
220
221
222<pre>&lt;tar longfile=&quot;gnu&quot;
223 destfile=&quot;${dist.base}/${dist.name}-src.tar&quot; &gt;
224 &lt;tarfileset dir=&quot;${dist.name}/..&quot; mode=&quot;755&quot; username=&quot;ant&quot; group=&quot;ant&quot;&gt;
225 &lt;include name=&quot;${dist.name}/bootstrap.sh&quot;/&gt;
226 &lt;include name=&quot;${dist.name}/build.sh&quot;/&gt;
227 &lt;/tarfileset&gt;
228 &lt;tarfileset dir=&quot;${dist.name}/..&quot; username=&quot;ant&quot; group=&quot;ant&quot;&gt;
229 &lt;include name=&quot;${dist.name}/**&quot;/&gt;
230 &lt;exclude name=&quot;${dist.name}/bootstrap.sh&quot;/&gt;
231 &lt;exclude name=&quot;${dist.name}/build.sh&quot;/&gt;
232 &lt;/tarfileset&gt;
233&lt;/tar&gt; </pre>
234
235<p>This example shows building a tar which uses the GNU extensions for long paths and
236where some files need to be marked as executable (mode 755)
237and the rest are use the default mode (read-write by owner). The first
238fileset selects just the executable files. The second fileset must exclude
239the executable files and include all others. </p>
240
241<p><strong>Note: </strong> The tar task does not ensure that a file is only selected
242by one fileset. If the same file is selected by more than one fileset, it will be included in the
243tar file twice, with the same path.</p>
244
245<p><strong>Note:</strong> The patterns in the include and exclude
246elements are considered to be relative to the corresponding dir
247attribute as with all other filesets. In the example above,
248<code>${dist.name}</code> is not an absolute path, but a simple name
249of a directory, so <code>${dist.name}</code> is a valid path relative
250to <code>${dist.name}/..</code>.</p>
251
252<hr>
253<p align="center">Copyright &copy; 2000-2002,2004 The Apache Software Foundation. All rights
254Reserved.</p>
255
256</body>
257</html>
258
Note: See TracBrowser for help on using the repository browser.