Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug Mac OS X pkg?

Tags:

macos

I built a Mac OS X bundle Frequon Invaders.app, and it runs fine. The executable was created with Go. Then I packaged it like this:

$ pkgbuild --component 'Frequon Invaders.app' --install-location /Applications FrequonInvaders.pkg
pkgbuild: Adding component at /Users/Dad/Documents/projects/Frequon-Invaders-2.2/installer-macos/Frequon Invaders.app
pkgbuild: Wrote package to FrequonInvaders.pkg

When I open FrequonInvaders.pkg in Finder, I get a "install Frequon Invaders" window that lets me go through the motions of installing it, and the Summary part says "Installation was successful". But when I look in /Applications, it's not there. Indeed none of the files in the bundle were installed.

[Updated] After looking around, I found that the package appears to have been installed right on top of the original place that Frequon Invaders.app was originally built. It seems that the --install-location /Applications was completely ignored!

Question:

  • How do I use pkgbuild to build a package that is really installed where install-location said to install it?
like image 467
Arch D. Robison Avatar asked Oct 19 '22 21:10

Arch D. Robison


1 Answers

How to debug Mac OS X pkg?

Debugging .pkg files is tricky because there's no easy way to get verbose output.

sudo installer -pkg my_package.pkg  -target / -verbose

This may help understand the step that's failing but it really doesn't help narrow the problem down...

Next, you can use a utility like The Unarchiver to extract the .pkg file. Your scripts will need to be extracted twice by this utility.

Note: If you prefer the command line:

xar -xf my_package.pkg # extract pkg
tar -xf Scripts        # extract scripts

From there, you can attempt to troubleshoot what's going wrong with the scripts.

But in my case, the only way I was able to debug the scripts were to run the package over and over echoing debug statements to a file.

For example:

# preinstall
echo "here!" >> /Users/Tom/Desktop/debug.txt
like image 137
tresf Avatar answered Oct 21 '22 23:10

tresf