mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-28 05:14:34 +00:00
* origin/master: (39 commits) %s is deliberate in this format string Unused Make generate_appcast available as a shared scheme Shush Xcode Link straight to docs from the readme ignore .html files when scanning for archives Missing strings translation. Updated swift Warn against abusing installUpdatesIfAvailable when generating the appcast, if an .html file exists of the same name as the archive, then it will be linked in as the releaseNotesLink Revert "Fix pt_BR translations" Revert "Fix pt_BR translations (#1039)" Fix Japanse localization Add more info to auth tool run failure Fix pt_BR translations (#1039) Fix pt_BR translations Disable the keyboard shortcut for the install button for scheduled updates to avoid accidental installs. added `sparkle:shortVersionString` to the enclosure, #1032 Changelog percent encode the filename used in the delta url ...
79 lines
2.2 KiB
Objective-C
79 lines
2.2 KiB
Objective-C
//
|
|
// SUGuidedPackageInstaller.m
|
|
// Sparkle
|
|
//
|
|
// Created by Graham Miln on 14/05/2010.
|
|
// Copyright 2010 Dragon Systems Software Limited. All rights reserved.
|
|
//
|
|
|
|
#import <sys/stat.h>
|
|
#import "SUGuidedPackageInstaller.h"
|
|
#import "SUErrors.h"
|
|
|
|
|
|
#include "AppKitPrevention.h"
|
|
|
|
@interface SUGuidedPackageInstaller ()
|
|
|
|
@property (nonatomic, readonly, copy) NSString *packagePath;
|
|
@property (nonatomic, readonly, copy) NSString *installationPath;
|
|
|
|
@end
|
|
|
|
@implementation SUGuidedPackageInstaller
|
|
|
|
@synthesize packagePath = _packagePath;
|
|
@synthesize installationPath = _installationPath;
|
|
|
|
- (instancetype)initWithPackagePath:(NSString *)packagePath installationPath:(NSString *)installationPath
|
|
{
|
|
self = [super init];
|
|
if (self != nil) {
|
|
_packagePath = [packagePath copy];
|
|
_installationPath = [installationPath copy];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (BOOL)performInitialInstallation:(NSError * __autoreleasing *)__unused error
|
|
{
|
|
return YES;
|
|
}
|
|
|
|
- (BOOL)performFinalInstallationProgressBlock:(nullable void(^)(double))__unused cb error:(NSError * __autoreleasing *)error
|
|
{
|
|
// This command *must* be run as root
|
|
NSString *installerPath = @"/usr/sbin/installer";
|
|
|
|
NSTask *task = [[NSTask alloc] init];
|
|
task.launchPath = installerPath;
|
|
task.arguments = @[@"-pkg", self.packagePath, @"-target", @"/"];
|
|
task.standardError = [NSPipe pipe];
|
|
task.standardOutput = [NSPipe pipe];
|
|
|
|
BOOL success = YES;
|
|
@try {
|
|
[task launch];
|
|
[task waitUntilExit];
|
|
if (task.terminationStatus != EXIT_SUCCESS) {
|
|
success = NO;
|
|
if (error != NULL) {
|
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Guided package installer returned non-zero exit status (%d)", task.terminationStatus] }];
|
|
}
|
|
}
|
|
} @catch (NSException *) {
|
|
success = NO;
|
|
if (error != NULL) {
|
|
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Guided package installer task threw an exception"] }];
|
|
}
|
|
}
|
|
return success;
|
|
}
|
|
|
|
- (BOOL)canInstallSilently
|
|
{
|
|
return YES;
|
|
}
|
|
|
|
@end
|