Skip to content

Commit

Permalink
Fix 10.4 compatiblity broken by delta updates.
Browse files Browse the repository at this point in the history
Delta updates code uses libxar, which is only available in 10.5+, and
Sparkle framework fails to load on 10.4 because of it. Instead of having
hard dependency on libxar, Sparkle now links with it weakly and checks
for its availability at runtime.  This required bumping Xcode project
compatibility to 3.2 to get weak linking support.

With this change, delta updates are still not supported on 10.4, but
Sparkle runs there again and just ignores the deltas. This should be
good enough given 10.4's age and shrinking user base.
  • Loading branch information
vslavik authored and andymatuschak committed Jun 6, 2010
1 parent fe1372c commit 4548228
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
11 changes: 7 additions & 4 deletions SUBasicUpdateDriver.m
Expand Up @@ -13,6 +13,7 @@
#import "SUInstaller.h"
#import "SUStandardVersionComparator.h"
#import "SUUnarchiver.h"
#import "SUBinaryDeltaCommon.h"

@implementation SUBasicUpdateDriver

Expand Down Expand Up @@ -92,10 +93,12 @@ - (void)appcastDidFinishLoading:(SUAppcast *)ac
item = [updateEnumerator nextObject];
} while (item && ![self hostSupportsItem:item]);

SUAppcastItem *deltaUpdateItem = [[item deltaUpdates] objectForKey:[host version]];
if (deltaUpdateItem && [self hostSupportsItem:deltaUpdateItem]) {
nonDeltaUpdateItem = [item retain];
item = deltaUpdateItem;
if (binaryDeltaSupported()) {
SUAppcastItem *deltaUpdateItem = [[item deltaUpdates] objectForKey:[host version]];
if (deltaUpdateItem && [self hostSupportsItem:deltaUpdateItem]) {
nonDeltaUpdateItem = [item retain];
item = deltaUpdateItem;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions SUBinaryDeltaCommon.h
Expand Up @@ -14,6 +14,7 @@
@class NSString;
@class NSData;

extern int binaryDeltaSupported(void);
extern int compareFiles(const FTSENT **a, const FTSENT **b);
extern NSData *hashOfFile(FTSENT *ent);
extern NSString *hashOfTree(NSString *path);
Expand Down
9 changes: 9 additions & 0 deletions SUBinaryDeltaCommon.m
Expand Up @@ -16,6 +16,15 @@
#include <sys/param.h>
#include <sys/stat.h>

extern int xar_close(void*) __attribute__((weak_import));

int binaryDeltaSupported(void)
{
// OS X 10.4 didn't include libxar, so we link against it weakly.
// This checks whether libxar is available at runtime.
return xar_close != 0;
}

int compareFiles(const FTSENT **a, const FTSENT **b)
{
return strcoll((*a)->fts_name, (*b)->fts_name);
Expand Down
3 changes: 2 additions & 1 deletion SUBinaryDeltaUnarchiver.m
Expand Up @@ -6,6 +6,7 @@
// Copyright 2009 Mark Rowe. All rights reserved.
//

#import "SUBinaryDeltaCommon.h"
#import "SUBinaryDeltaUnarchiver.h"
#import "SUBinaryDeltaApply.h"
#import "SUUnarchiver_Private.h"
Expand All @@ -16,7 +17,7 @@ @implementation SUBinaryDeltaUnarchiver

+ (BOOL)canUnarchivePath:(NSString *)path
{
return [[path pathExtension] isEqualToString:@"delta"];
return binaryDeltaSupported() && [[path pathExtension] isEqualToString:@"delta"];
}

- (void)applyBinaryDelta
Expand Down
8 changes: 3 additions & 5 deletions Sparkle.xcodeproj/project.pbxproj
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 44;
objectVersion = 46;
objects = {

/* Begin PBXBuildFile section */
Expand All @@ -18,10 +18,9 @@
5D06E9050FD68D7D005AE3F6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
5D06E9390FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D06E9370FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.h */; };
5D06E93A0FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E9380FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.m */; };
5D1AF58A0FD7678C0065DB48 /* libxar.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5890FD7678C0065DB48 /* libxar.1.dylib */; };
5D1AF58A0FD7678C0065DB48 /* libxar.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5890FD7678C0065DB48 /* libxar.1.dylib */; settings = {ATTRIBUTES = (Weak, ); }; };
5D1AF58B0FD7678C0065DB48 /* libxar.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5890FD7678C0065DB48 /* libxar.1.dylib */; };
5D1AF5900FD767AD0065DB48 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF58F0FD767AD0065DB48 /* libxml2.dylib */; };
5D1AF5940FD767B90065DB48 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF58F0FD767AD0065DB48 /* libxml2.dylib */; };
5D1AF59A0FD767E50065DB48 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5990FD767E50065DB48 /* libz.dylib */; };
5D1AF59C0FD768010065DB48 /* libcrypto.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF59B0FD768010065DB48 /* libcrypto.dylib */; };
5D1AF82B0FD768180065DB48 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5990FD767E50065DB48 /* libz.dylib */; };
Expand Down Expand Up @@ -408,7 +407,6 @@
FAEFA2F80D94AA7900472538 /* AppKit.framework in Frameworks */,
5D06E8FD0FD68D6B005AE3F6 /* libbz2.dylib in Frameworks */,
5D1AF58A0FD7678C0065DB48 /* libxar.1.dylib in Frameworks */,
5D1AF5940FD767B90065DB48 /* libxml2.dylib in Frameworks */,
5D1AF82B0FD768180065DB48 /* libz.dylib in Frameworks */,
5D1AF82C0FD7681A0065DB48 /* libcrypto.dylib in Frameworks */,
);
Expand Down Expand Up @@ -836,7 +834,7 @@
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "Sparkle" */;
compatibilityVersion = "Xcode 3.0";
compatibilityVersion = "Xcode 3.2";
hasScannedForEncodings = 1;
knownRegions = (
English,
Expand Down

0 comments on commit 4548228

Please sign in to comment.