[英]MAC PackageMaker preinstall/postinstall script to get original *.pkg file directory
How do I get the original *.pkg file directory when install it? 安装时如何获取原始* .pkg文件目录?
I have created a pkg file, and put it with another file(like test.txt
) into a same folder, like ~/Desktop/test 我创建了一个pkg文件,并将其与另一个文件(如
test.txt
)放在同一个文件夹中,如〜/ Desktop / test
And when install pkg file, I want it to copy the "test.txt" file to ~/Library folder. 当安装pkg文件时,我希望它将“test.txt”文件复制到〜/ Library文件夹。 So I add preinstall/postinstall script into pkg file to copy the "test.txt" file.
所以我将preinstall / postinstall脚本添加到pkg文件中以复制“test.txt”文件。 I try to get the directory use
我试着让目录使用
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
But it will return the tmp directory 但它将返回tmp目录
/private/tmp/PKInstallSandbox.G5GFI6/Scripts/com.myApp.testApp.pkg.o5k2nE
not the original pkg directory (~/Desktop/test)
不是原来的pkg目录
(~/Desktop/test)
Has anybody know how to get the original directory when install? 安装时有谁知道如何获取原始目录?
You've created a flat package? 你创造了一个扁平的包裹? Have you tried looking at the parameters passed to the postinstall script?
您是否尝试查看传递给postinstall脚本的参数?
$0 - Script path
$1 - Package path
$2 - Target location
$3 - Target volume`
Parameter $1 should give you what you're looking for. 参数$ 1应该可以为您提供所需的信息。
Copied from old bundle style format information , but still seems to apply to newer flat packages. 从旧的捆绑样式格式信息复制,但似乎仍适用于较新的扁平包。
这个Mac安装程序博客有一些关于Packagemaker的有用帖子,包括有关常见问题的用法和解决方案的详细信息。
This: 这个:
pkgpath=\`dirname "$PACKAGE_PATH"\`
will give you the path to the package in the variable $pkgpath
. 将为您提供变量
$pkgpath
包的路径。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.