Skip to content

pkgbuild: Build simple pkg file with pkgbuild

Build pkg with pkgbuild without limitations like in “Packages”.

Background: I am a script guy, I make automation workflows to my customers in the PostProduction branch. So I come around the problem that I want to implement these scripts in an easy way. Actually this should be as easy as the customer gets an pkg installer and start using the script without waiting for my expertise to install the script in the correct location on the client machine or server.

I have been using the nice Application called “Packages”, but it has its limitations to where you are allowed to install stuff. It has a really nice and intuitive interface and can make these bundled pkg installers.
But I just wanted a simple and flat pkg installer.

Surprise OSX comes with such a tool embedded.

Here is a personal note on how to get a nice simple pkg file for ddrescue: https://www.gnu.org/software/ddrescue/
This require you to compile ddrescue yourself. But any other type of app or script can be used by adjusting the info below.

Disclaimer: Please use this info as-is, I am not to be held responsible for any damage to your system. It works for me, but you can expect different outcome in your environment. Feel free to contact me if you have any comments to this info.

Create all the pre-requisist for the pkgbuild

  1. Create a folder for you pkg project. In this case “ddrescue”
  2. Create your folder structure inside “ddrescue” starting with a folder called ROOT.
  3. Put all the files you need to install inside the folderstructure. You should end up with something like:
    Folderstructure for pkgbuild
  4. In the terminal go into the project folder “ddrescue”
    $ cd ~/Desktop/ddrescue
    
  5. Check the ownership and permission of the folderstructure, depends what you are installing and where you are installing it.
    $ la -lah
    
  6. In this due to I am installing in /usr/local/bin I want to be root as user and wheel as group.
    $ chown -R root:wheel ROOT/
    $ chmod -R 755 ROOT/
    
  7. The project are now ready to make a install pkg from, by issuing the following pkgbuild command.
    $ pkgbuild --root ROOT --identifier com.kulmosen.ddrescue --version 1.21 ddrescue.pkg

Congratulation you should now a have a nice pkg file inside you project folder called “ddrescue.pkg”

End result with pkgbuild

Published inAppleScripting

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *