Create an OS X package from the command line

Jun 23, '03 09:57:00AM

Contributed by: carsten

How to Programmatically Create a Mac OS X Package (from the command-line or a shell script).

Note that any lines ending with a backslash should be one line; they've been broken here for a narrower display width.

  1. Set up the files you want to package in a folder called dstroot:
    % mkdir ./dstroot
    % mkdir -p ./dstroot/usr/local/bin/ \
       dstroot/usr/local/share/man/man1/
    % install -m 755 myprog ./dstroot/usr/local/bin/
    % install -m 644 myprog.1 \
       ./dstroot/usr/local/share/man/man1/
    
  2. Create a package info file (this has nothing to do with Fink info files). Either copy one from another .pkg to use as a template, or see this pkg info file from osxutils.

  3. Make the package:
    % find dstroot -name .DS_Store -delete
    % sudo chown -R root:staff dstroot
    % package dstroot mypackage-0.1.info -d . -ignoreDSStore
    % rm -f 1
    % install -m 644 README.txt \
       mypackage-0.1.pkg/Contents/Resources/ReadMe.txt
    % install -m 644 LICENSE.txt \ 
       mypackage-0.1.pkg/Contents/Resources/License.txt
    % sudo chown -R root:staff \
       mypackage-0.1.pkg/Contents/Resource
    % tar -h mypackage-0.1.pkg -cf mypackage-0.1.pkg.tar
    % gzip -9 mypackage-0.1.pkg.tar
    
See an example Makefile from the osxutils package which builds a .pkg from the command line at SourceForge.

Comments (8)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030619213002144