Sparkle does a couple of things inside
- It checks for a new version on the server or not.
- If available, download it and update the existing application and restart the same application.
I'm more interested in the second part, so that's how she does it.
NSString *installerPath = [[NSWorkspace sharedWorkspace] absolutePathForAppBundleWithIdentifier:@"com.apple.installer"]; installerPath = [installerPath stringByAppendingString:@"/Contents/MacOS/Installer"]; if (![[NSFileManager defaultManager] fileExistsAtPath:installerPath]) { error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingInstallerToolError userInfo:[NSDictionary dictionaryWithObject:@"Couldn't find Apple installer tool!" forKey:NSLocalizedDescriptionKey]]; result = NO; } NSTask *installer = [NSTask launchedTaskWithLaunchPath:installerPath arguments:[NSArray arrayWithObjects:path, nil]]; [installer waitUntilExit];
Now you can see that it finds Installer.app and passes pkg as a command line argument.
The installer application will take care of updating the application.
There is another way to do this without using the terminal command line /usr/sbin/installer - For more information, see the wiki - Installer (Mac OS X)
If you do not want to run the installer GUI, you can use the command above and provide the file path and pkg file information for installation.
Here are some examples.
installer -pkg InstallMe.pkg -target CurrentUserHomeDirectory installer -pkg InstallMe.pkg -target '/Volumes/Macintosh HD2' -lang ja installer -volinfo -pkg InstallMe.pkg installer -pkginfo -pkg InstallMe.pkg installer -query RestartAction -pkg InstallMe.pkg installer -pkg InstallMe.pkg -target / -showChoices
Omkar
source share