Copying a file to installation directory at runtime
My requirement is as followed- When my user runs the installer (.pkg) in his machine, he will keep a config file in the same location with .pkg. My installer is expected to copy the file to the installation directory while installing. In case of Wix (for windows installer) we can define a component with compressed=false, which makes it not to include the file within the installer itself, rather looking for it on the runtime. You can find some context in this question. Is there any way to achieve this with Packages?
. With "old" version of macOS, it could be possible to easily retrieve the location of the distribution/package and so you could use a post-installation script to copy your config file.
. Because of new security measures in macOS 10.12 (IIIRC) and later, retrieving your .pkg location is not as easy. If for instance, your .pkg is inside a disk image. The "path" to your .pkg as visible from the post- or pre-installation scripts will not be the expected one but a temporary location. It's still possible to retrieve the .pkg location but it's not 100% guaranteed but this involves writing some code (where basically you list all the mounted disk image and you try to figure out on which one your .pkg instance is).
. There's also an option in Apple Installer package format to reference a folder to be the "uncompressed" payload. This is not supported by Packages (it's on my to-do list) and this requires, IIRC, OS X 10.7 or later. I haven't checked whether this would still work with the new security measures described above.
. A probable additional limitation is that this kind of external reference may prevent the distribution/package from being signed correctly.
. If you only needs to provide that kind of solution for a few number of customers, a solution could be:
- set your distribution to import built flat package(s) of your solution instead of building them from the original resources
- add a package that includes the config file (either in the payload or the additional resources) and if needed use post-installation script to move the file to the correct location.
Oh, can you help me with the packaging problem? Thank you. https://github.com/packagesdev/packages/issues/49