我可以将Unix权限存储在一个zip文件(使用apache ant构建)中吗? [英] Can i store unix permissions in a zip file (built with apache ant)?

查看:85
本文介绍了我可以将Unix权限存储在一个zip文件(使用apache ant构建)中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Java应用程序构建linux安装程序,最后得到的是install.jar和setup.sh,它们是使用ant放入zip文件中的.

I'm building a linux installer for a Java application, and I end up with an install.jar and a setup.sh that I put in a zip file using ant.

这个想法是用户解压缩该zip文件,然后运行setup.sh,但是麻烦的是,他们总是始终需要先chmod setup.sh才能赋予自己执行权限.

The idea is the user unzips the zip file and then runs setup.sh but the trouble is that they always need to chmod setup.sh first to give themselves execute permissions.

我要删除此步骤,我不确定问题部分是否是

I want to remove this step and Im not sure if the problem part is:

  1. 我在Windows上构建的
  2. 我正在使用蚂蚁压缩任务构建
  3. 否则该zip不能预先获得权限,并且在没有x权限的情况下始终会解压缩.

推荐答案

您不能将Linux/Unix文件权限存储在ZIP文件中.

编辑(在注释后),这些属性可以存储在ZIP文件中. GNU的unzip显然能够读取该附加字段并恢复文件权限. 我不确定何时将其添加到ZIP格式中,因为早期版本-来自MS-DOS世界-不支持此功能.

Edit (after comments) by using the "external attributes" field inside the ZIP header these attributes can be store inside a ZIP file. GNU's unzip is apparently able to read that additional field and restore file permissions. I'm not sure when this was added to the ZIP format as the early versions - coming from a MS-DOS world - did not have support for this.

TAR格式(一种本机" Unix/Linux格式)已被设计为包含文件属性,Ant可以创建TAR文件,该文件将保留所有Linux/Unix操作系统上的属性.

The TAR format - being a "native" Unix/Linux format - has been designed to include file attributes and Ant can create TAR files that will preserve attributes across all Linux/Unix operating systems.


<tar compression="gzip" destfile="my-archive.tgz">
  <tarfileset mode="544" dir="dir_with_shell_scripts">
     <include name="*.sh"/>
  </tarfileset>
</tar>

这篇关于我可以将Unix权限存储在一个zip文件(使用apache ant构建)中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆