1

I'm attempting to create a package using Packages that installs in ~/Applications (because each user can have an instance of the app in question running but it needs a custom port per user as it daemonises and runs like an HTTP server).

I can't work out how this is done. In the Payload section I can only pick from /Applications, /Library and /Users/Shared. I've tried adding a custom folder but without knowing the username ahead of time I don't know what to put in the prompt.

I could use a shell script in the Scripts tab (part of the install requires that anyway), but I'm unclear as to where the binary for the app should be put (I could place it in one of the above paths and then move it but I don't wish to spread build artefacts around the user's system, even for clean builds), or how to refer to its initial location in the script, whether it's via the Payload tab or the Additional Resources section under Scripts.

I'm happy to use a different tool or directly edit scripts (back to the old days;-) any help or insight would be much appreciated.

  • Why does installing in ~/Applications cause a different port to be used? I am assuming the binary is identical to one that would be installed in /Applications. For a unique port, the application should request 0 for the port and be assigned one by macOS. Multiple users can then launch the /Applications copy without concern. See Miln Beyond for an example of this behaviour. – Graham Miln Aug 3 '18 at 16:37
  • @GrahamMiln It doesn't cause a different port to be used, that would depend on the launch script being passed the correct switches, but the app checks to see if it's already been run and the way they've written means it has to be in different location, hence ~/Applications. The port needs to be known in advance so that clients can connect. – Iain Aug 3 '18 at 17:17
2

pkgbuild and productbuild

Try building the package using the newer pkgbuild tool. You can pass --install-location <install-path> as part of the command.

You may also find productbuild useful to know about.

Both tools have detailed manual pages and can handle installation in script determined locations.

  • Thanks for that. That's led me to more resources that basically say not to do it! I may just use a zip/dmg with scripts. We'll see what comes of it. I appreciate the help. – Iain Aug 5 '18 at 16:15
  • Good to hear the links led to an answer – even if it was not what you hoped for! Ideally your app could use dynamically OS allocated ports and then published them via Bonjour/Zero Conf for clients to connect to. This would be "the Mac way" – at the cost of more development work for you! – Graham Miln Aug 5 '18 at 17:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .