3

So I'm packaging a printer tool for our company consisting two .pkg files (drivers) and an .app file.

Right now I'm using the following command to build the package:

pkgbuild --root ./content --script ./scripts --identifier com.MyGreatCompany --version 0.1 --install-location /tmp/ ./PrinterTool.pkg

So when installing the package all content is placed in the /tmp/ directory. A postinstall script then completes the installation like this:

installer -verbose -pkg /private/tmp/PackageOne.pkg -target /
installer -verbose -pkg /private/tmp/PackageTwo.pkg -target /
/bin/rm -rf /Applications/Utilities/PrinterTool.app
/bin/mv -f /private/tmp/PrinterTool.app /Applications/Utilities/PrinterTool.app

This kind of works. The first install attempt goes well, but when I'm trying to re-install the same package things go wrong. The .app file is not copied to the /tmp folder and thus not moved to the Utilities folder.

So i'd like to know two things:

  1. Is there an explanation why the .app file is only copied once?
  2. Is this the best way to package multiple file types? I have the feeling that placing it in the /tmp folder is unnecessary. By default the package files are being placed in some kind of installer /tmp folder, right? Can't this be the working directory from which the postinstall script will run?
Matter
  • 429
  • 1
  • 4
  • 15

1 Answers1

4

Yeah... you don't want to do it this way :D

First, of you don't need to create the subpackages, just don't. You can have several bundles in the same pkg file. Use the --components flag to define them (or create a Components Property List). Build your entire file system inside of your rootdir. So in your case you'd have:

.../content/Applications/Utilities/PrinterTool.app
.../content/Library/...wherever.../driver-whatever.

Then your --install-location is just /.

If you really need multiple packages (or if it's just more convenient), then you want to use productbuild to combine them. You can pass multiple --package options to create a multi-package installer.

Rob Napier
  • 286,113
  • 34
  • 456
  • 610
  • Oke, I get it. It sort of works the same way as packagemaker did, just specify the entire path. About the subpackages, these aren't created by me. These are driver packages delivered with the printer. These need to be installed alongside the printertool. So the only option I have is to use productbuild then. For the packages I can pass the --package option, which option do I use for just placing files? – Matter Feb 17 '15 at 14:07
  • --component or --content, depending on what you're doing. If it starts getting complicated, you may want to create a distribution plist instead. You can use the --synthesize option to write a basic distribution plist for you (basically saving all the other options for you) – Rob Napier Feb 17 '15 at 14:59