简体   繁体   English

通过productbuild和pkgbuild修改文件所有权

[英]File Ownership Modification by productbuild and pkgbuild

I am trying to create an installer for a Java app on Mac OS 10.8.4. 我正在尝试在Mac OS 10.8.4上为Java应用程序创建安装程序。 The app runs fine, and I can install it without a hitch from a zip file. 该应用程序运行正常,我可以从zip文件中顺利安装它。 I can create a .pkg installer with either productbuild or pkgbuild. 我可以用productbuild或pkgbuild创建一个.pkg安装程序。 I can also install either of the installer .pkg file successfully, however the app does not run properly due to the fact that both packaging programs change the ownership of a data directory and its subordinate files and subdirectories from user to root. 我也可以成功安装任何一个安装程序.pkg文件,但由于两个打包程序都将数据目录及其下级文件和子目录的所有权从用户更改为root,因此应用程序无法正常运行。 I install this data directory in the Resources directory of the .app bundle, and the first time the program executes, it moves the data directory to /Users/user/Library/Application Support. 我将此数据目录安装在.app包的Res​​ources目录中,并且在程序第一次执行时,它将数据目录移动到/ Users / user / Library / Application Support。 I tried using the --ownership preserve and --ownership preserve-other options with pkgbuild to no avail. 我尝试使用-ownership preserve和--ownership保留 - 其他选项与pkgbuild无济于事。 The only way I have been able to install and execute properly is via the zip file, since it leaves file ownership alone. 我能够正确安装和执行的唯一方法是通过zip文件,因为它只保留文件所有权。 Here is the pkgbuild command I am using: 这是我正在使用的pkgbuild命令:

pkgbuild --ownership preserve --component ./myApp.app ./myApp-installer.pkg pkgbuild --ownership preserve --component ./myApp.app ./myApp-installer.pkg

My questions are: 我的问题是:

  1. How can I force pkgbuild to honor my --ownership preserve option? 我如何强制pkgbuild兑现我的 - 所有权保留选项?

  2. Is it possible to build a separate data-only package with user ownership and destined for the user area and merge it with the executable package via the --synthesize option of pkgbuild? 是否可以构建一个具有用户所有权并且发往用户区域的单独的仅数据包,并通过pkgbuild的--synthesize选项将其与可执行包合并? if yes, could someone show me how to build such a data-only package? 如果有,有人可以告诉我如何构建这样一个仅限数据的包吗?

I know it is quite old, I'll just answer in case someone else needs the answer. 我知道它已经很老了,我会回答以防其他人需要答案。 What I usually do, is that I have a shell script which creates the .pkg file for me. 我通常做的是,我有一个shell脚本,为我创建.pkg文件。 In that script I set all the file permissions and ownership before packaging. 在该脚本中,我在打包之前设置了所有文件权限和所有权。 Here is an example: 这是一个例子:

NAME="PKGFILENAME"

IDENTIFIER="com.pkg.APPNAME"

VERSION="1.0.0"

INSTALL_LOCATION="PATH_TO_WHERE_THE_FILES_SHOULD_BE_COPIED_ON_USERS_MACHINE"
ROOT_LOCATION="PATH_TO_WHERE_FILES_ARE_ON_YOUR_MASCHINE"

# Remove any unwanted .DS_Store files.
find "$ROOT_LOCATION" -name '*.DS_Store' -type f -delete

# put any command for changing the ownership or permissions here
chmod -R +r "$ROOT_LOCATION"

# Build package.
/usr/bin/pkgbuild \
    --root "$ROOT_LOCATION" \
    --install-location "$INSTALL_LOCATION" \
    --identifier "$IDENTIFIER" \
    --version "$VERSION" \
    "$NAME.pkg"

save this something in a file like create-my-package.sh and run this in command line. 将此内容保存在create-my-package.sh等文件中,并在命令行中运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM