If you’ve not used pkgbuild before, it can be a bit daunting to go from the (admittedly rather confusing) GUI-based Package Maker to the command-line tool pkgbuild, but never fear, for making simple packages, it’s actually a lot easier.
To illustrate common usage cases, here is an example of a package I had to build today to use with DeployStudio and Munki.
pkgbuild --identifier au.com.automatica.usertemplate.pkg --version 1.0 --root English.lproj --install-location /System/Library/User Template/English.lproj ~/Desktop/UserTemplate.pkg
What this does is builds an installer package, and puts it on my desktop (the last line of the command). The package identifier is au.com.automatica.usertemplate.pkg which needs to be a unique string for your package and consistent between different versions of the package so OS X knows it’s an upgrade install. The version was specified as 1.0 so if I add to this and bump the version, OS X knows to upgrade an existing installation. The root is the folder that gets added to the package, or the app and the install location is where the contents of the root get dumped.
Thank you, but this doesn’t explain:
* what is au.com.automatica.usertemplate.pkg? a file? What kind of file is it? Where did you get it or how did you create it?
* what is English.lproj? I don’t have a file called English.lproj, so how is that generated or where do I get it? All I have is binaries to install into the system.
* what is the extra parameter after –install-location for? ‘Template/English.lproj’? And what is this file, what does it do, why do I need it? Again, I have binaries I’ve compiled but how does this help me make a pkg to install them with?
Hi Aaron,
Now, you’re probably not going to see this as you’ve posted the questions above with an invalid website address and email address. Never mind, this may be useful for someone else…
what is au.com.automatica.usertemplate.pkg? That is a Reverse Domain Name identifier. It serves as a unique identifier to identify my package from all the others that are out there. It uses a domain name to avoid clashes with other people’s packages and it’s reversed so it sorts nicely (so all the au.com.automatica packages appear near each other in a list of installed packages for instance)
what is English.lproj?… This is the folder that I’m packaging up.
Basically, if you’re doing this for an app that you’ve compiled, and your app has been built into a directory called Build and you would like it to be installed in /Applications the syntax would be something like:
pkgbuild –identifier au.com.automatica.thebestappintheworld.pkg –version 1.0 –root Build –install-location /Applications MyApp.pkg
This will bundle up the contents of the Build directory (containing your app) and make a package in the current directory called MyApp.pkg
Hey, big thanks for helping me come to terms with this command !
1: How can we bundle the resources files (license files/README files) in the .pkg file?
2: How to call sub-installers using pkgbuild?
Suppose I have total 4 sub packages which are build with pkgbuild. Now needs to create a main package which will call all the above 4 sub packages silently. How can we make it using pkgbuild?