4

How can I build a novice-usable (clickable download) installer for a Mac OS X command-line tool, and where should the binary be installed so that a novice user with no knowledge of shell paths can just open the Terminal app and type "foo" to run the freshly installed foo tool?

Can the installer also install documentation so that the user can type "man foo"?

Are there any other options that should be considered to make the use of a pure command-line (stdin, stdout) tool accessible to a novice Mac user?

hotpaw2
  • 70,107
  • 14
  • 90
  • 153
  • Are you going to make a novice to use the command line? That sounds oxymoronic ... – Yuji Oct 07 '10 at 21:05
  • @Yuji : That is exactly my need. I already have a large number of novice users for my command-line tool, but the email I've gotten indicates that many of them needed expert help to get everything installed properly. – hotpaw2 Oct 07 '10 at 23:53
  • Same problem, but in a simpler version: I have an already-built (Qt command line) executable file, and I want to put it in a component package (.pkg). No XCode involved. How do I do that? – jpsecher Sep 29 '15 at 13:56

1 Answers1

4

What's the minimum version of OS X you're targeting? 10.6 (and IIRC 10.5) include /usr/local/bin in the default PATH, but 10.4 did not. As long as you don't need to support 10.4, you should just put the executable in /usr/local/bin and the man page in /usr/local/share/man/man1 (or whatever the appropriate chapter number is).

For building the installer itself, you can use Apple's PackageMaker utility (part of Xcode). Create a prototype local folder with bin and share/man/man1 subfolders and populate them with your files. Create a package project in PackageMaker, and choose your organization name and minimum target OS. Drag the prototype folder into the project's Contents sidebar. Set the Destination to /usr/local. Switch to the Contents tab and edit the ownership and permissions the files should be installed with (the owner/group should probably all be root/admin, with rwxrwxr-x perms on the folders and executable, rw-rw-r-- on the man page). If any irrelevant files (e.g. .DS_Store) snuck in, exclude them. Look around for any other settings you want to change, then save the project and build the installer. Then test it, to make sure it does what you expect.

Gordon Davisson
  • 118,432
  • 16
  • 123
  • 151
  • And can that be automated to generate in a CI? – hithwen Aug 19 '13 at 10:02
  • 1
    @hithwen: I'm not sure; what's a "CI"? There is a command-line `packagemaker` tool, but I'm less familiar with it. – Gordon Davisson Aug 20 '13 at 05:23
  • A continuous integration system such as jenkins or buildbot. Thanks I'll have a look to packagemaker – hithwen Aug 20 '13 at 09:20
  • 1
    @hithwen: In that case it should be pretty easy to set up a packagemaker "project" in the GUI version of PackageMaker, save it as a .pmdoc, then use `packagemaker --doc /path/to/project.pmdoc` in your automated build process. See the man page [here](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/packagemaker.1.html) for more options. – Gordon Davisson Aug 20 '13 at 15:04
  • It seems PackageMaker is deprecated but thanks anyway, you put me on the right track, I'll continue here: http://stackoverflow.com/questions/11487596/making-os-x-installer-packages-like-a-pro-xcode4-developer-id-mountain-lion-re – hithwen Aug 21 '13 at 12:41