mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Initial work on copying the relauncher to NSTemporaryDirectory()
This commit is contained in:
1 parent
072a73b375
commit
3852809c7b
6 files changed
+42
-8
No files matched your search
@@ -49,7 +49,7 @@
|
||||
- (void)installUpdate
|
||||
{
|
||||
showErrors = YES;
|
||||
[SUInstaller installFromUpdateFolder:[downloadPath stringByDeletingLastPathComponent] overHostBundle:hostBundle delegate:self synchronously:postponingInstallation];
|
||||
[SUInstaller installFromUpdateFolder:[downloadPath stringByDeletingLastPathComponent] overHostBundle:hostBundle delegate:self synchronously:postponingInstallation relauncherPath:&relaunchPath];
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(NSNotification *)note
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
NSURLDownload *download;
|
||||
NSString *downloadPath;
|
||||
SUUnarchiver *unarchiver;
|
||||
NSString *relaunchPath;
|
||||
}
|
||||
|
||||
- (void)checkForUpdatesAtURL:(NSURL *)appcastURL hostBundle:(NSBundle *)hb;
|
||||
|
||||
+21
-3
@@ -160,7 +160,9 @@
|
||||
|
||||
- (void)installUpdate
|
||||
{
|
||||
[SUInstaller installFromUpdateFolder:[downloadPath stringByDeletingLastPathComponent] overHostBundle:hostBundle delegate:self synchronously:NO];
|
||||
//This will copy the relauncher into NSTemporaryDirectory() just before it overwrites the bundle
|
||||
//See https://bugs.launchpad.net/sparkle/+bug/230123
|
||||
[SUInstaller installFromUpdateFolder:[downloadPath stringByDeletingLastPathComponent] overHostBundle:hostBundle delegate:self synchronously:NO relauncherPath:&relaunchPath];
|
||||
}
|
||||
|
||||
- (void)installerFinishedForHostBundle:(NSBundle *)hb
|
||||
@@ -173,10 +175,26 @@
|
||||
- (void)relaunchHostApp
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
|
||||
NSString *relaunchPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"relaunch" ofType:nil];
|
||||
|
||||
@try
|
||||
{
|
||||
[NSTask launchedTaskWithLaunchPath:relaunchPath arguments:[NSArray arrayWithObjects:[hostBundle bundlePath], [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], nil]];
|
||||
//if we failed to copy the relauncher into NSTemporaryDirectory(), use the one in the new bundle and hope for the best.
|
||||
|
||||
NSString *realRelauncherPath = relaunchPath;
|
||||
if(!relaunchPath || ![[NSFileManager defaultManager] fileExistsAtPath:relaunchPath])
|
||||
realRelauncherPath = [[NSBundle bundleForClass:[self class]] pathForAuxiliaryExecutable:@"relaunch"];
|
||||
|
||||
[NSTask launchedTaskWithLaunchPath:realRelauncherPath arguments:[NSArray arrayWithObjects:[hostBundle bundlePath], [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], nil]];
|
||||
|
||||
//if there's a possibility that a copy of relauncher is in NSTemporaryDirectory(), we need to be sure to clean it up
|
||||
if(relaunchPath)
|
||||
{
|
||||
[[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation
|
||||
source:[relaunchPath stringByDeletingLastPathComponent]
|
||||
destination:@""
|
||||
files:[NSArray arrayWithObject:[relaunchPath lastPathComponent]]
|
||||
tag:NULL];
|
||||
}
|
||||
}
|
||||
@catch (NSException *e)
|
||||
{
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@interface SUInstaller : NSObject { }
|
||||
+ (void)installFromUpdateFolder:(NSString *)updateFolder overHostBundle:(NSBundle *)hostBundle delegate:delegate synchronously:(BOOL)synchronously;
|
||||
+ (void)installFromUpdateFolder:(NSString *)updateFolder overHostBundle:(NSBundle *)hostBundle delegate:delegate synchronously:(BOOL)synchronously relauncherPath:(NSString **)relaunchPath;
|
||||
+ (void)_finishInstallationWithResult:(BOOL)result hostBundle:(NSBundle *)hostBundle error:(NSError *)error delegate:delegate;
|
||||
@end
|
||||
|
||||
|
||||
+6
-1
@@ -16,7 +16,7 @@ NSString *SUInstallerDelegateKey = @"SUInstallerDelegate";
|
||||
|
||||
@implementation SUInstaller
|
||||
|
||||
+ (void)installFromUpdateFolder:(NSString *)updateFolder overHostBundle:(NSBundle *)hostBundle delegate:delegate synchronously:(BOOL)synchronously;
|
||||
+ (void)installFromUpdateFolder:(NSString *)updateFolder overHostBundle:(NSBundle *)hostBundle delegate:delegate synchronously:(BOOL)synchronously relauncherPath:(NSString **)relaunchPath;
|
||||
{
|
||||
// Search subdirectories for the application
|
||||
NSString *currentFile, *newAppDownloadPath = nil, *bundleFileName = [[hostBundle bundlePath] lastPathComponent], *alternateBundleFileName = [[hostBundle name] stringByAppendingPathExtension:[[hostBundle bundlePath] pathExtension]];
|
||||
@@ -56,6 +56,11 @@ NSString *SUInstallerDelegateKey = @"SUInstallerDelegate";
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *relaunchPathToCopy = [[NSBundle bundleForClass:[self class]] pathForAuxiliaryExecutable:@"relaunch"];
|
||||
NSString *targetPath = [NSTemporaryDirectory() stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
|
||||
if([[NSFileManager defaultManager] copyPath:relaunchPathToCopy toPath:targetPath handler:nil])
|
||||
*relaunchPath = targetPath;
|
||||
|
||||
[(isPackage ? [SUPackageInstaller class] : [SUPlainInstaller class]) performInstallationWithPath:newAppDownloadPath hostBundle:hostBundle delegate:delegate synchronously:synchronously];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
61F83F740DBFE141006FDD30 /* SUBasicUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */; };
|
||||
DAAEFC9B0DA5722F0051E0D0 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
|
||||
DAAEFD4E0DA572330051E0D0 /* relaunch.m in Sources */ = {isa = PBXBuildFile; fileRef = 613242130CD06CEF00106AA4 /* relaunch.m */; };
|
||||
DAAEFD510DA572550051E0D0 /* relaunch in Resources */ = {isa = PBXBuildFile; fileRef = DAAEFC960DA571DF0051E0D0 /* relaunch */; };
|
||||
DAAEFD510DA572550051E0D0 /* relaunch in CopyFiles */ = {isa = PBXBuildFile; fileRef = DAAEFC960DA571DF0051E0D0 /* relaunch */; };
|
||||
FAEFA2F70D94AA7500472538 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
|
||||
FAEFA2F80D94AA7900472538 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
|
||||
FAEFA3040D94AB3400472538 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
|
||||
@@ -144,6 +144,16 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
63F107920DDABE9E0073D493 /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = relaunch;
|
||||
dstSubfolderSpec = 6;
|
||||
files = (
|
||||
DAAEFD510DA572550051E0D0 /* relaunch in CopyFiles */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@@ -634,6 +644,7 @@
|
||||
8DC2EF520486A6940098B216 /* Resources */,
|
||||
8DC2EF540486A6940098B216 /* Sources */,
|
||||
8DC2EF560486A6940098B216 /* Frameworks */,
|
||||
63F107920DDABE9E0073D493 /* CopyFiles */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -738,7 +749,6 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
DAAEFD510DA572550051E0D0 /* relaunch in Resources */,
|
||||
610D5A750A1670A4004AAD9C /* SUStatus.nib in Resources */,
|
||||
61AAE8280A321A7F00D8810D /* Sparkle.strings in Resources */,
|
||||
61AAE8290A321A8000D8810D /* SUAutomaticUpdateAlert.nib in Resources */,
|
||||
|
||||
Reference in new issue
Block a user