Add ability to skip install in finish_installation tool.

This commit is contained in:
Dmytro Tretiakov committed 2014-07-30 16:26:11 +03:00
1 parent 8a4578fe4d
commit 3956a27bd0
2 files changed
+13 -13

No files matched your search

+5 -7
View File
@@ -376,12 +376,10 @@ NSArray *SUGetAllDevMateURLHosts(void)
if ([[updater delegate] respondsToSelector:@selector(updater:willInstallUpdate:)])
[[updater delegate] updater:updater willInstallUpdate:updateItem];
BOOL isAlreadyInstalled = NO;
if ([[updater delegate] respondsToSelector:@selector(updater:overrideInstallUpdate:downloadPath:)])
{
if ([[updater delegate] updater:updater overrideInstallUpdate:updateItem downloadPath:tempDir])
{
return;
}
isAlreadyInstalled = [[updater delegate] updater:updater overrideInstallUpdate:updateItem downloadPath:tempDir]
}
// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
@@ -405,10 +403,10 @@ NSArray *SUGetAllDevMateURLHosts(void)
{
copiedRelaunchTool = [SUPlainInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath temporaryName:nil error:&error];
}
[self finishRelaunchAfterSuccessfulCopying:copiedRelaunchTool fromPath:relaunchPathToCopy toPath:targetPath relaunch:relaunch];
[self finishRelaunchAfterSuccessfulCopying:copiedRelaunchTool fromPath:relaunchPathToCopy toPath:targetPath isInstalled:isAlreadyInstalled relaunch:relaunch];
}
- (void)finishRelaunchAfterSuccessfulCopying:(BOOL)copiedRelaunchTool fromPath:(NSString *)relaunchPathToCopy toPath:(NSString *)targetPath relaunch:(BOOL)relaunch
- (void)finishRelaunchAfterSuccessfulCopying:(BOOL)copiedRelaunchTool fromPath:(NSString *)relaunchPathToCopy toPath:(NSString *)targetPath isInstalled:(BOOL)isInstalled relaunch:(BOOL)relaunch
{
NSError *error = nil;
@@ -433,7 +431,7 @@ NSArray *SUGetAllDevMateURLHosts(void)
if ([[updater delegate] respondsToSelector:@selector(pathToRelaunchForUpdater:)])
pathToRelaunch = [[updater delegate] pathToRelaunchForUpdater:updater];
NSString *relaunchToolPath = [relaunchPath stringByAppendingPathComponent: @"/Contents/MacOS/finish_installation"];
NSArray *arguments = [NSArray arrayWithObjects:[host bundlePath], pathToRelaunch, [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], tempDir, relaunch ? @"1" : @"0", nil];
NSArray *arguments = [NSArray arrayWithObjects:[host bundlePath], pathToRelaunch, [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], tempDir, relaunch ? @"1" : @"0", isInstalled ? @"1" : @"0" nil];
if (SUShouldUseXPCInstaller())
{
[SUXPCInstaller launchTaskWithLaunchPath:relaunchToolPath arguments:arguments completionHandler:^{
+8 -6
View File
@@ -24,6 +24,7 @@
NSTimer *longInstallationTimer;
SUHost *host;
BOOL shouldRelaunch;
BOOL alreadyInstalled;
}
- (void) parentHasQuit;
@@ -39,17 +40,17 @@
@implementation TerminationListener
- (id) initWithHostPath:(const char *)inhostpath executablePath:(const char *)execpath parentProcessId:(pid_t)ppid folderPath: (const char*)infolderpath shouldRelaunch:(BOOL)relaunch
selfPath: (NSString*)inSelfPath
selfPath: (NSString*)inSelfPath alreadyInstalled:(BOOL)inalreadyInstalled
{
if( !(self = [super init]) )
return nil;
hostpath = inhostpath;
executablepath = execpath;
parentprocessid = ppid;
folderpath = infolderpath;
selfPath = [inSelfPath retain];
shouldRelaunch = relaunch;
alreadyInstalled = inalreadyInstalled;
BOOL alreadyTerminated = (getppid() == 1); // ppid is launchd (1) => parent terminated already
@@ -90,7 +91,7 @@
target: self selector: @selector(showAppIconInDock:)
userInfo:nil repeats:NO] retain];
if( folderpath )
if( folderpath && !alreadyInstalled )
[self install];
else
[self relaunch];
@@ -177,7 +178,7 @@
int main (int argc, const char * argv[])
{
if( argc < 5 || argc > 6 )
if( argc < 5 || argc > 7 )
return EXIT_FAILURE;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@@ -198,14 +199,15 @@ int main (int argc, const char * argv[])
#else
NSString* selfPath = [[NSBundle mainBundle] bundlePath];
#endif
[NSApplication sharedApplication];
[[[TerminationListener alloc] initWithHostPath: (argc > 1) ? argv[1] : NULL
executablePath: (argc > 2) ? argv[2] : NULL
parentProcessId: (argc > 3) ? atoi(argv[3]) : 0
folderPath: (argc > 4) ? argv[4] : NULL
shouldRelaunch: (argc > 5) ? atoi(argv[5]) : 1
selfPath: selfPath] autorelease];
selfPath: selfPath
alreadyInstalled: (argc > 6) ? atoi(argv[6]) : 0] autorelease];
[[NSApplication sharedApplication] run];
[pool drain];