ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shawn Castrianni <Shawn.Castria...@halliburton.com>
Subject RE: zip/tar and file permissions
Date Wed, 04 Mar 2009 06:46:56 GMT
I just discovered that the untar task does not restore the file permissions.  So even if I
could set the correct file permissions inside the tarfileset, untar would ignore them.  There
seems to be some glaring holes in ANT when it comes to stuff like this.  With these new Java
1.6 methods, there shouldn't be any excuse not to use them in future ANT versions, right?

For example, the ANT docs state:

"This is caused by the lack of any means to query or set file permissions in the current Java
runtimes. If you need a permission-preserving copy function, use <exec executable="cp"
... > instead."

This is no longer true with java 1.6.  Sure it can't give you full granularity with user,
group, and other, but it is pretty close so might as well use it.

---
Shawn Castrianni


-----Original Message-----
From: David Weintraub [mailto:qazwart@gmail.com] 
Sent: Tuesday, March 03, 2009 2:04 PM
To: Ant Users List
Subject: Re: zip/tar and file permissions

I don't believe that tar task in Ant can be asked to simply leave file
permissions alone. We have shell scripts that have the execute
permission set, but <tar> keeps resetting them.

You can define multiple tarfilesets, and have each one with a
different permission. Each tarfileset can even be the same directory,
but simply include or exclude particular files based upon suffix or
directory. Here's what we do:

    <tar destfile="${archive.dir}/${tar.name}"
        longfile="gnu"
        compression="gzip">
        <tarfileset dir="${work.dir}/deploy"
            username="${tar.user}"
            group="${tar.group}">
            <include name="**"/>
            <exclude name="bin/**"/>
        </tarfileset>
        <tarfileset dir="${work.dir}/deploy"
            mode="755"
            username="${tar.user}"
            group="${tar.group}">
            <include name="bin/**"/>
        </tarfileset>
    </tar>

The first one excludes the bin directory while the second one includes
the bin directory and sets the execute permission. That's about the
best you can do.  Zipfiles do not contain any file permission
information, so the <zip> task won't work for you either.

Have you looked at the <bzip2> or <gzip> tasks? These are Unix based
commands, and maybe they'll store the file permissions without
changing them.

On Tue, Mar 3, 2009 at 2:14 PM, Shawn Castrianni
<Shawn.Castrianni@halliburton.com> wrote:
> I am trying to zip or tar up some files in a platform independent way but retain file
permissions if on unix.  I thought I found the answer when I saw that both zipfileset and
tarfileset support the filemode attribute.  However, I quickly discovered that this allows
the file permissions to be set to some hardcoded value for all files.  I want whatever the
file permissions are on the filesystem to be retained in the zip or tar so I can't hardcode
them all to one value.  Each file may be different.  It would seem that a better default
for filemode would be "retain" and not "644".  Is it possible to do what I want without resorting
to the exec task and just executing tar directly and then hoping that any windows machine
has MKS toolkit installed so that tar exists?
>
> ---
> Shawn Castrianni
>
> ----------------------------------------------------------------------
> This e-mail, including any attached files, may contain confidential and privileged information
for the sole use of the intended recipient.  Any review, use, distribution, or disclosure
by others is strictly prohibited.  If you are not the intended recipient (or authorized to
receive information for the intended recipient), please contact the sender by reply e-mail
and delete all copies of this message.
>



-- 
--
David Weintraub
qazwart@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message