How to build a simple pkg with pkgbuild

Pkgbuild is a built in command line tool found in OS X

 In this simple example, we will build a simple pkg using pkgbuild that creates a folder containing bookmarks in the Applications. The purpose of this article is to demonstrate the most simple construction of a package using pkgbuild.  You can issue the following command in terminal to view the manual and additional features.

 Creating your folder structure

First create the project folder on your desktop. In this case we will call it, Bookmarks.

 

Screen Shot 2014-12-16 at 6.16.10 PM

 

Next we will create a folder inside the Bookmarks called ROOT. Within ROOT, we need to create the path to where the install will happen. If we want to install a folder of bookmarks for all users in the Applications folder, the structure would look like this.  This structure defines the path where the files will be installed. Screen Shot 2014-12-16 at 6.35.54 PM

Issuing the terminal commands

Next we need to jump into terminal and navigate to that folder using the cd (change directory command)

Once inside the Bookmarks project folder, lets make sure  ownership of this all files are set correctly. Issue following command to read check ownership and correct permissions of your ROOT folder has.

Since this, is going into the /Applications folder, we will need to change the ownership to root:wheel. You can use following command to change ownership.

If permissions need to be changed, you can use the following command. Refer to the chart below to determine which numbers the hashtag should be. Typically an application will be 755:

 

Screen Shot 2014-12-16 at 6.57.13 PM

Okay we’re ready to use the pkgbuild command

In the above example, we are issuing the ‘pkgbuild’ command at the ‘–root level’. We are identifying the pathway by selecting the ‘ROOT’ folder. The ‘–identifier’ is a package receipt that will be generated on the system. ‘–version’ is the version of the app that you designate. Lastly you can name the package, in this case ‘bookmarks.pkg’.

 The pkgbuild is now complete

After running this command, the package is generated inside the project folder. This package can now be deployed to your clients through a software management system.

 

 

 




Interested In A Free Installer?

Our custom Wifi On/Off script has been a popular post!
This script automatically turns off the wireless interface on a computer when it is connected to a wired network, and turn the wireless interface back on when it is disconnected from the wired network.
This script has two main benefits:
  1. Network connection failover
  2. Eliminates unnecessary wireless traffic, and Multi-homed computers.
We are now offering a pkg installer for this script to anyone that signs up for our mailing list.