通过 productbuild 和 pkgbuild 修改文件所有权 [英] File Ownership Modification by productbuild and pkgbuild

查看:40
本文介绍了通过 productbuild 和 pkgbuild 修改文件所有权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为 Mac OS 10.8.4 上的 Java 应用程序创建安装程序.该应用程序运行良好,我可以毫不费力地从 zip 文件安装它.我可以使用 productbuild 或 pkgbuild 创建一个 .pkg 安装程序.我也可以成功安装任何一个安装程序 .pkg 文件,但是由于两个打包程序都将数据目录及其从属文件和子目录的所有权从用户更改为 root,因此该应用程序无法正常运行.我将此数据目录安装在 .app 包的 Resources 目录中,程序第一次执行时,它会将数据目录移动到/Users/user/Library/Application Support.我尝试将 --ownership preserve 和 --ownership preserve-other 选项与 pkgbuild 一起使用,但无济于事.我能够正确安装和执行的唯一方法是通过 zip 文件,因为它不涉及文件所有权.这是我正在使用的 pkgbuild 命令:

I am trying to create an installer for a Java app on Mac OS 10.8.4. The app runs fine, and I can install it without a hitch from a zip file. I can create a .pkg installer with either productbuild or pkgbuild. 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. 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. I tried using the --ownership preserve and --ownership preserve-other options with pkgbuild to no avail. The only way I have been able to install and execute properly is via the zip file, since it leaves file ownership alone. Here is the pkgbuild command I am using:

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

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

我的问题是:

  1. 如何强制 pkgbuild 遵守我的 --ownership 保留选项?

  1. How can I force pkgbuild to honor my --ownership preserve option?

是否可以通过pkgbuild 的--synthesize 选项构建一个单独的具有用户所有权并以用户区域为目的地的仅数据包,并将其与可执行包合并?如果是的话,有人可以告诉我如何构建这样一个仅限数据的包吗?

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? if yes, could someone show me how to build such a data-only package?

推荐答案

我知道它已经很老了,我只会回答以防其他人需要答案.我通常做的是,我有一个为我创建 .pkg 文件的 shell 脚本.在该脚本中,我在打包之前设置了所有文件权限和所有权.下面是一个例子:

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. 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"

将此内容保存在像 create-my-package.sh 这样的文件中,然后在命令行中运行它.

save this something in a file like create-my-package.sh and run this in command line.

这篇关于通过 productbuild 和 pkgbuild 修改文件所有权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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