Create ZIP archive without storing permissions

command-line-interfacecompressionpermissionstarunix

I am distributing packaged files in ZIP format. I use the following to create:

zip -r distr.zip files/

When expanded on other UNIX system files preserve their permissions as they were when I packed them. I am willing to avoid storing permission information.

My question is: Is it possible to do so? I'm using info-zip 3.0

The problem is that on my system i use umask 0002 and files are writable for groups. However when expanded on other systems, groups write permission is not desired. I could remove group write permissions, but then it wouldn't work on my system.

Best Answer

I can't spot a suitable option to control permissions when unzipping

Using tar however, there's the option --no-same-permissions which may help, the manual page says:

 --no-same-permissions
       apply the user's umask when extracting permissions from the archive

Does that do the trick for you?

Alternately, if you want to use a zip file, you might want to try creating it with a different program. For example, Apache Ant gives you full control over the permissions of files and directories it zips up - http://ant.apache.org/manual/Types/zipfileset.html has details. For example, you could do something like:

<zip destfile="dist.zip">
   <zipfileset dir="dist" filemode="664" dirmode="755" />
</zip>
Related Topic