Skip to content

Commit

Permalink
Merge pull request sparkle-project#1 from pornel/master
Browse files Browse the repository at this point in the history
Merge
  • Loading branch information
MaddTheSane committed Feb 3, 2014
2 parents bd98b33 + a4759c8 commit d4d984f
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 67 deletions.
4 changes: 2 additions & 2 deletions Configurations/ConfigCommon.xcconfig
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Common

RELAUNCH_TOOL_PRODUCT_NAME = Autoupdate
FINISH_INSTALL_TOOL_NAME = Autoupdate

CURRENT_PROJECT_VERSION = 1.6
GCC_PRECOMPILE_PREFIX_HEADER = YES
GCC_PREFIX_HEADER = $(SDKROOT)/System/Library/Frameworks/Cocoa.framework/Headers/Cocoa.h
ARCHS = i386 x86_64

SPARKLE_COMMON_CFLAGS = -DRELAUNCH_TOOL_PRODUCT_NAME=$(RELAUNCH_TOOL_PRODUCT_NAME)
GCC_PREPROCESSOR_DEFINITIONS = FINISH_INSTALL_TOOL_NAME=$(FINISH_INSTALL_TOOL_NAME)

// Enable warnings
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES
Expand Down
2 changes: 1 addition & 1 deletion Configurations/ConfigCommonDebug.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ GCC_OPTIMIZATION_LEVEL = 0
DEBUG_INFORMATION_FORMAT = dwarf
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
SPARKLE_EXTRA_DEBUG = -DDEBUG
OTHER_CFLAGS = $(SPARKLE_COMMON_CFLAGS) $(SPARKLE_EXTRA_DEBUG)
OTHER_CFLAGS = $(SPARKLE_EXTRA_DEBUG)

2 changes: 1 addition & 1 deletion Configurations/ConfigRelaunch.xcconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Relaunch Tool only

PRODUCT_NAME = $(RELAUNCH_TOOL_PRODUCT_NAME)
PRODUCT_NAME = $(FINISH_INSTALL_TOOL_NAME)
SKIP_INSTALL = YES
18 changes: 12 additions & 6 deletions SUBasicUpdateDriver.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
#import "SUCodeSigningVerifier.h"
#import "SUUpdater_Private.h"

#ifdef FINISH_INSTALL_TOOL_NAME
// FINISH_INSTALL_TOOL_NAME expands to unquoted finish_install
#define QUOTE_NS_STRING2(str) @"" #str
#define QUOTE_NS_STRING1(str) QUOTE_NS_STRING2(str)
#define FINISH_INSTALL_TOOL_NAME_STRING QUOTE_NS_STRING1(FINISH_INSTALL_TOOL_NAME)
#else
#error FINISH_INSTALL_TOOL_NAME not defined
#endif

@interface SUBasicUpdateDriver () <NSURLDownloadDelegate>; @end


Expand Down Expand Up @@ -325,14 +334,11 @@ - (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)
if ([[updater delegate] respondsToSelector:@selector(updater:willInstallUpdate:)])
[[updater delegate] updater:updater willInstallUpdate:updateItem];

// RELAUNCH_TOOL_PRODUCT_NAME expands to unquoted finish_install
#define NS_STRING_FROM_MACRO(s) NS_STRING_FROM_MACRO_QUOTE_(s)
#define NS_STRING_FROM_MACRO_QUOTE_(s) @"" #s
NSString *relaunchName = NS_STRING_FROM_MACRO(RELAUNCH_TOOL_PRODUCT_NAME);
NSString *const finishInstallToolName = FINISH_INSTALL_TOOL_NAME_STRING;

// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
NSString *relaunchPathToCopy = [SPARKLE_BUNDLE pathForResource:relaunchName ofType:@"app"];
NSString *relaunchPathToCopy = [SPARKLE_BUNDLE pathForResource:finishInstallToolName ofType:@"app"];
if (relaunchPathToCopy != nil)
{
NSString *targetPath = [[host appSupportPath] stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
Expand Down Expand Up @@ -361,7 +367,7 @@ - (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)
NSString *pathToRelaunch = [host bundlePath];
if ([[updater delegate] respondsToSelector:@selector(pathToRelaunchForUpdater:)])
pathToRelaunch = [[updater delegate] pathToRelaunchForUpdater:updater];
NSString *relaunchToolPath = [[relaunchPath stringByAppendingPathComponent: @"/Contents/MacOS"] stringByAppendingPathComponent: relaunchName];
NSString *relaunchToolPath = [[relaunchPath stringByAppendingPathComponent: @"/Contents/MacOS"] stringByAppendingPathComponent: finishInstallToolName];
[NSTask launchedTaskWithLaunchPath: relaunchToolPath arguments:[NSArray arrayWithObjects:
[host bundlePath],
pathToRelaunch,
Expand Down
11 changes: 3 additions & 8 deletions SUHost.m
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,15 @@ - (NSImage *)icon
// Use a default icon if none is defined.
if (!icon) {
BOOL isMainBundle = (bundle == [NSBundle mainBundle]);

// Starting with 10.6, iconForFileType: accepts a UTI.
NSString *fileType = nil;
if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_5)
fileType = isMainBundle ? NSFileTypeForHFSTypeCode(kGenericApplicationIcon) : @".bundle";
else
fileType = isMainBundle ? (NSString*)kUTTypeApplication : (NSString*)kUTTypeBundle;

NSString *fileType = isMainBundle ? (NSString*)kUTTypeApplication : (NSString*)kUTTypeBundle;
icon = [[NSWorkspace sharedWorkspace] iconForFileType:fileType];
}
return icon;
}

- (BOOL)isRunningOnReadOnlyVolume
{
{
struct statfs statfs_info;
statfs([[bundle bundlePath] fileSystemRepresentation], &statfs_info);
return (statfs_info.f_flags & MNT_RDONLY);
Expand Down
68 changes: 21 additions & 47 deletions SUPlainInstallerInternals.m
Original file line number Diff line number Diff line change
Expand Up @@ -472,62 +472,36 @@ + (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temp
}

err = FSPathMakeRef((UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &dstDirRef, NULL);

if (err == noErr && hadFileAtDest)
{
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5)
{
NSFileManager *manager = [[[NSFileManager alloc] init] autorelease];
BOOL success = [manager moveItemAtPath:dst toPath:tmpPath error:error];
if (!success && hadFileAtDest)
{
if (error != NULL)
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] forKey:NSLocalizedDescriptionKey]];
return NO;
}

} else {
err = FSMoveObjectSync(&dstRef, &tmpDirRef, (CFStringRef)[tmpPath lastPathComponent], &movedRef, 0);
if (err != noErr && hadFileAtDest)
{
if (error != NULL)
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] forKey:NSLocalizedDescriptionKey]];
return NO;
}
}
{
NSFileManager *manager = [[[NSFileManager alloc] init] autorelease];
BOOL success = [manager moveItemAtPath:dst toPath:tmpPath error:error];
if (!success && hadFileAtDest)
{
if (error != NULL)
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] forKey:NSLocalizedDescriptionKey]];
return NO;
}
}

err = FSPathMakeRef((UInt8 *)[src fileSystemRepresentation], &srcRef, NULL);
if (err == noErr)
{
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_5)
NSFileManager *manager = [[[NSFileManager alloc] init] autorelease];
BOOL success = [manager copyItemAtPath:src toPath:dst error:error];
if (!success)
{
NSFileManager *manager = [[[NSFileManager alloc] init] autorelease];
BOOL success = [manager copyItemAtPath:src toPath:dst error:error];
if (!success)
{
// We better move the old version back to its old location
if( hadFileAtDest )
success = [manager moveItemAtPath:tmpPath toPath:dst error:error];
if (!success && error != NULL)
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] forKey:NSLocalizedDescriptionKey]];
return NO;
// We better move the old version back to its old location
if( hadFileAtDest )
success = [manager moveItemAtPath:tmpPath toPath:dst error:error];
if (!success && error != NULL)
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] forKey:NSLocalizedDescriptionKey]];
return NO;

}
} else {
err = FSCopyObjectSync(&srcRef, &dstDirRef, (CFStringRef)[dst lastPathComponent], NULL, 0);
if (err != noErr)
{
// We better move the old version back to its old location
if( hadFileAtDest )
FSMoveObjectSync(&movedRef, &dstDirRef, (CFStringRef)[dst lastPathComponent], &movedRef, 0);
if (error != NULL)
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Couldn't copy %@ to %@.", src, dst] forKey:NSLocalizedDescriptionKey]];
return NO;
}
}
}

// If the currently-running application is trusted, the new
// version should be trusted as well. Remove it from the
// quarantine to avoid a delay at launch, and to avoid
Expand Down
10 changes: 8 additions & 2 deletions SUUpdateAlert.m
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,14 @@ - (void)displayReleaseNotes
{
// Set the default font
[releaseNotesView setPreferencesIdentifier:[SPARKLE_BUNDLE bundleIdentifier]];
[[releaseNotesView preferences] setStandardFontFamily:[[NSFont systemFontOfSize:8] familyName]];
[[releaseNotesView preferences] setDefaultFontSize:(int)[NSFont systemFontSizeForControlSize:NSSmallControlSize]];
WebPreferences *prefs = [releaseNotesView preferences];
NSString *familyName = [[NSFont systemFontOfSize:8] familyName];
if ([familyName hasPrefix:@"."]) { // 10.9 returns ".Lucida Grande UI", which isn't a valid name for the WebView
familyName = @"Lucida Grande";
}
[prefs setStandardFontFamily:familyName];
[prefs setDefaultFontSize:(int)[NSFont systemFontSizeForControlSize:NSSmallControlSize]];
[prefs setPlugInsEnabled:NO];
[releaseNotesView setFrameLoadDelegate:self];
[releaseNotesView setPolicyDelegate:self];

Expand Down
Binary file modified Sparkle.icns
Binary file not shown.

0 comments on commit d4d984f

Please sign in to comment.