How do I get the original *.pkg file directory when install it?
I have created a pkg file, and put it with another file(like test.txt
) into a same folder, like ~/Desktop/test
And when install pkg file, I want it to copy the "test.txt" file to ~/Library folder. So I add preinstall/postinstall script into pkg file to copy the "test.txt" file. I try to get the directory use
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
But it will return the tmp directory
/private/tmp/PKInstallSandbox.G5GFI6/Scripts/com.myApp.testApp.pkg.o5k2nE
not the original pkg directory (~/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?
$0 - Script path
$1 - Package path
$2 - Target location
$3 - Target volume`
Parameter $1 should give you what you're looking for.
Copied from old bundle style format information, but still seems to apply to newer flat packages.