简体   繁体   English

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

[英]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.

相关问题 如何为Mac OS的PackageMaker编写预安装脚本 - How to write preinstall script for packagemaker for Mac os Mac OSx PKG预安装脚本问题 - Mac OSx PKG preinstall script issue 在Mac上提供有关安装后脚本的帮助 - assistance with postinstall script on Mac 如何复制dmg中.pkg文件旁边的配置。 无法从PackageMaker“预检”脚本访问它 - How do I copy a config placed along side a .pkg file in dmg. Can't access it from PackageMaker “preflight” script 如何在通过packagemaker shell命令构建的安装程序中包含预安装脚本? - How do you include a preinstall script in an installer built via the packagemaker shell command? 尝试通过 pkgbuild 构建 macOS 应用程序,但在预安装或安装后它是 root,如何更改为普通用户并获取 sudo - try to build macOS app by pkgbuild, but in preinstall or postinstall it is root, how to change to nomal user and get sudo 使用后安装脚本Mac OSX的安装失败 - Installation failed with postinstall script Mac OSX mac osX packageMaker:如何将目标设置为用户主目录? - mac osX packageMaker: how to set the destination to the user home directory? Mac PackageMaker:仅当文件不存在时才执行操作 - Mac PackageMaker : Do actions only if a file doesn't exist 在Mac OS上使用Packagemaker - using packagemaker on mac os
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM