4

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.

4

1 回答 1

1

我会推荐Packages

它是可编写脚本的,因此它可以成为您构建过程的一部分并为您生成一个不错的 mpkg。

我们使用它来自动下载第三方库,然后调用 make 进行编译,以及安装已编译的文件。

请注意,虽然这会生成一个 mpkg,但大多数分发都是使用磁盘映像完成的,因此我们还使用 hdiutil 创建一个稀疏映像,将 mpkg 复制到其中,将其转换为压缩的只读 dmg,然后分发它。

此过程的一个示例是:

1) 创建稀疏 RW DMG 文件。

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

2)附加到图像。记下输出中的磁盘和安装的卷名(例如 /dev/disk2s1 和 /Volumes/MyInstaller)

hdiutil attach MyInstaller.dmg.sparseimage

3)在mpkg安装程序中复制

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

4) 从图像中去除技术。

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

5)从可写稀疏图像创建压缩的只读图像。

hdiutil convert "MyInstaller.dmg.sparseimage" -format UDZO -o "MyInstaller.dmg" -ov -imagekey zlib-level=9
于 2014-04-11T22:15:26.730 回答