bashmacospkgbuild

macos pkg: How to log bash errors


I have a macos app with a pkg installer. The pkg has a postinstall.sh and a preinstall.sh.

On most machines it works fine but for certain customers I get reports that the script has failed.

I've asked the users to send me the installer logs but those don't contain the actual bash error only something like this:

Sep 14 15:04:16 Filestars-Mac-Mini installd[2540]: PackageKit: Install Failed: Error Domain=PKInstallErrorDomain Code=112 "An error occurred while running scripts from the package “Filestar.21.0.12.0.osx-x64.pkg”." UserInfo={NSFilePath=./preinstall, NSURL=file:///Users/filestar/repos/Filestar/Filestar.Installer/macOs/Output/Filestar.21.0.12.0.osx-x64.pkg#Filestar.pkg, PKInstallPackageIdentifier=com.Filestar.pkg.Filestar, NSLocalizedDescription=An error occurred while running scripts from the package “Filestar.21.0.12.0.osx-x64.pkg”.} { NSFilePath = "./preinstall"; NSLocalizedDescription = "An error occurred while running scripts from the package \U201cFilestar.21.0.12.0.osx-x64.pkg\U201d."; NSURL = "file:///Users/filestar/repos/Filestar/Filestar.Installer/macOs/Output/Filestar.21.0.12.0.osx-x64.pkg#Filestar.pkg"; PKInstallPackageIdentifier = "com.Filestar.pkg.Filestar"; }

How can I get the actual error?


Solution

  • During your preinstall.sh and postinstall.sh scripts, append to a log file. For example, you can rm -rf /var/tmp/Filestar.log during preinstall.sh then append anything you deem interesting there. Doing the same for postinstall.sh. Then if the user reports an issue have them send you the log file.