Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos MAC PackageMaker预安装/后安装脚本以获取原始*.pkg文件目录_Macos_Bash_Packagemaker - Fatal编程技术网

Macos MAC PackageMaker预安装/后安装脚本以获取原始*.pkg文件目录

Macos MAC PackageMaker预安装/后安装脚本以获取原始*.pkg文件目录,macos,bash,packagemaker,Macos,Bash,Packagemaker,安装时如何获取原始*.pkg文件目录 我创建了一个pkg文件,并将它与另一个文件(如test.txt)放在同一个文件夹中,如~/Desktop/test 在安装pkg文件时,我希望它将“test.txt”文件复制到~/Library文件夹。 因此,我将preinstall/postinstall脚本添加到pkg文件中,以复制“test.txt”文件。 我尝试使用目录 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

安装时如何获取原始*.pkg文件目录

我创建了一个pkg文件,并将它与另一个文件(如
test.txt
)放在同一个文件夹中,如~/Desktop/test

在安装pkg文件时,我希望它将“test.txt”文件复制到~/Library文件夹。 因此,我将preinstall/postinstall脚本添加到pkg文件中,以复制“test.txt”文件。 我尝试使用目录

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
但它将返回tmp目录

/private/tmp/PKInstallSandbox.G5GFI6/Scripts/com.myApp.testApp.pkg.o5k2nE
不是原始的pkg目录
(~/Desktop/test)


有人知道安装时如何获取原始目录吗?

您已经创建了一个平面软件包?您是否尝试查看传递给postinstall脚本的参数

$0 - Script path
$1 - Package path
$2 - Target location
$3 - Target volume`
参数$1应该提供您要查找的内容

复制自,但似乎仍适用于较新的扁平软件包。

这有一些关于Packagemaker的有用帖子,包括有关用法和常见问题解决方案的详细信息。

这:

pkgpath=\`dirname "$PACKAGE_PATH"\`

将在变量
$pkgpath

中为您提供程序包的路径,为什么不将plist嵌入到您的程序包中?此外,plist应由应用程序创建,而不是软件包plist文件可能会在以后更改,这将导致在plist文件更改时频繁创建新的相关软件包。顺便说一句:这可能不仅仅是要复制的plist文件。你找到解决方案了吗?