Question

I have a program (created by a colleague, ported from Linux but successfully compiles on Mac) that I need to deploy to lots of Mac workstations. Currently we do so by pushing out pkg files (not ones we created).

My general question (that others may find the answers to useful) is how do I go about packaging a command line program/script into a pkg file that installs the program? The usual method to package an .app file seems documented well enough, but there is scant details about taking an arbitrary program and wrapping it in a pkg installer.

The man pages for pkgbuild (etc) make a lot of assumptions - that you've already built an app with xcode, that you're intending to use an .app and can generate plists, etc. All we want to do is let the mac server install a non-app program, and it wants to use pkgs.

It would be best if the solution were scriptable so that every time we update the program we can easily create a new pkg file. If a decent resource already explaining this process can be linked that of course would also work great. The question here: Making OS X Installer Packages like a Pro - Xcode Developer ID ready pkg doesn't match the need to simply install a basic cli program.

Was it helpful?

Solution

I would recommend Packages.

It's scriptable so it can become part of your build process and generates a nice mpkg for you.

We are using it to automate the download of third-party libraries, and then the invocation of make to compile, as well as the installation of compiled files.

As a note, although this will generate a mpkg, most distributions are done with disk images, so we also use hdiutil to create a sparse image, copy the mpkg into it, convert it to a compressed read-only dmg and then distribute that.

An example of this procedure would be:

1) Create Sparse RW DMG file.

hdiutil create -size 100M -type SPARSE -volname "MyInstaller" -fs HFS+ MyInstaller.dmg.sparseimage

2) Attach to image. Note disk and mounted volume name from output (ex. /dev/disk2s1 and /Volumes/MyInstaller)

hdiutil attach MyInstaller.dmg.sparseimage

3) Copy in mpkg installer

cp -R Packages/build/My_Packages.mpkg /Volumes/MyInstaller/

4) Detech from image.

hdiutil detach -force {mounted disk} (ex. hdiutil detach -force /dev/disk2s1)

5) Create compressed read only image from writable sparse image.

hdiutil convert "MyInstaller.dmg.sparseimage" -format UDZO -o "MyInstaller.dmg" -ov -imagekey zlib-level=9
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top