Apple

How to use Terminal to create packages for software deployment

Jesus Vigo reviews the steps necessary to create package-based installers to simplify the software deployment process for OS X.

Use Terminal to create packages for software deployment

A management suite, such as Apple Remote Desktop, simplifies the deployment of software applications to all managed OS X devices. But what happens when you use an alternative management suite that only supports PKG file types?

In keeping with the sysadmin theme, I'd like to touch on the topic of creating your own installer packages to deploy apps, settings, or even scripts—complete with paths to the destination and security permissions.

The magical functionality necessary to create most packages is built right in to Terminal with the pkgbuild command, so there are no additional software licenses or costs.

Let's jump right into the process below and create a deployable pkg file.

  1. For the purposes of this tutorial, I've chosen Google Chrome to model the creation process, but feel free to substitute for an app of your choice. Start by mounting the application's DMG file. Take note of both the name of the mounted volume and the app itself (Figure A).
    Figure A
    Figure A
  2. Launch Terminal and type in the following command, replacing the paths as necessary (Figure B).
    sudo pkgbuild —install-location /Applications —component /Volumes/Google\ Chrome/Google\ Chrome.app ./Desktop/Google\ Chrome.pkg
    Figure B
    Figure B
  3. After authenticating, your package will commence building (Figure C).
    Figure C
    Figure C
  4. The process will take several minutes, depending on the file size (Figure D).
    Figure D
    Figure D
  5. Upon completion, the pkg will save to your desktop, ready for deployment (Figure E).
    Figure E
    Figure E

That's it! The process really is that easy for most applications. The only caveat here is that not all apps are created equal, so how a dev compiles his or her app could affect the success of the pkg build.

This is where testing is your friend. Honestly, you really don't want to deploy an untested application across your network or roll it into your AutoDMG image.

What's your experience with creating your own installer packages? Let us know in the discussion thread below.

Also see

About Jesus Vigo

Jesus Vigo is a Network Administrator by day and owner of Mac|Jesus, LLC, specializing in Mac and Windows integration and providing solutions to small- and medium-size businesses. He brings 19 years of experience and multiple certifications from seve...

Editor's Picks

Free Newsletters, In your Inbox