Browse files

Fix 10.4 compatiblity broken by delta updates.

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...
1 parent fe1372c commit 454822823831818aef29826adebd7a43d2ac725a @vslavik vslavik committed with andymatuschak Jun 6, 2010
Showing with 22 additions and 10 deletions.
  1. +7 −4 SUBasicUpdateDriver.m
  2. +1 −0 SUBinaryDeltaCommon.h
  3. +9 −0 SUBinaryDeltaCommon.m
  4. +2 −1 SUBinaryDeltaUnarchiver.m
  5. +3 −5 Sparkle.xcodeproj/project.pbxproj
View
11 SUBasicUpdateDriver.m
@@ -13,6 +13,7 @@
#import "SUInstaller.h"
#import "SUStandardVersionComparator.h"
#import "SUUnarchiver.h"
+#import "SUBinaryDeltaCommon.h"
@implementation SUBasicUpdateDriver
@@ -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;
+ }
}
}
View
1 SUBinaryDeltaCommon.h
@@ -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);
View
9 SUBinaryDeltaCommon.m
@@ -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);
View
3 SUBinaryDeltaUnarchiver.m
@@ -6,6 +6,7 @@
// Copyright 2009 Mark Rowe. All rights reserved.
//
+#import "SUBinaryDeltaCommon.h"
#import "SUBinaryDeltaUnarchiver.h"
#import "SUBinaryDeltaApply.h"
#import "SUUnarchiver_Private.h"
@@ -16,7 +17,7 @@ @implementation SUBinaryDeltaUnarchiver
+ (BOOL)canUnarchivePath:(NSString *)path
{
- return [[path pathExtension] isEqualToString:@"delta"];
+ return binaryDeltaSupported() && [[path pathExtension] isEqualToString:@"delta"];
}
- (void)applyBinaryDelta
View
8 Sparkle.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 44;
+ objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
@@ -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 */; };
@@ -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 */,
);
@@ -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,

0 comments on commit 4548228

Please sign in to comment.