0

I am trying to install a software. I tried running a script which calls

installer -pkg /path/to/software.pkg -target /

when i try calling the script via objective-c code like

NSTask *task;
task = [[NSTask alloc] init];
[task setLaunchPath:@"/path/to/script"];
[task launch]

The installation fails , when i try to execute the same using the system() command like

NSString* run_Command = @"/path/to/script"
system([run_Command UTF8String])

The application gets installed , upon checking the install.log to see why the first one failed, i found this line

./postinstall: LSOpenURLsWithRole() failed with error -10810 for the file /Applications/Software.app

PackageKit: Install Failed: Error Domain=PKInstallErrorDomain Code=112 "An error occurred while running scripts from the package “software.pkg”

Am i using NSTask in a wrong way or will changing any setting or environment variable make the NSTask work?

When i looked into LSOpenURLsWithRole() failed with error -10810 , i could only find that it was a matter of permission error and a -chmod will resolve the issue.

Community
  • 1
  • 1
R.Srinath
  • 11
  • 1
  • 5
  • Start by looking at the `postinstall` script. It probably is not calling `LSOpenURLsWithRole` directly, but it may be calling `open`; that's the place to start. Typically I would comment out different parts of `postinstall` until you determine which specific command is causing the error. You can also use `echo` statements to trace your way through the script. This can be all kinds of things, including some tools that dislike stdin being wired in an unexpected way (which can happen w/ `NSTask`). – Rob Napier Oct 26 '17 at 14:58
  • The software i am trying to install is not mine – R.Srinath Oct 27 '17 at 06:01
  • That doesn't change anything. You can still look at the postinstall script. It's just a file inside the package. There are lots of ways to open packages depending on how it's packaged. If it's a directory, just look at the files inside the directory ("Show Package Contents" in finder). If it's a single file, see https://stackoverflow.com/questions/11298855/how-to-unpack-and-pack-pkg-file for manually unpacking them. I particularly like the tool Pacifist to make this easier. https://www.charlessoft.com – Rob Napier Oct 27 '17 at 15:28
  • Thanks for the help , using this i will try debugging myself. – R.Srinath Oct 30 '17 at 11:01

0 Answers0