diff --git a/.travis.yml b/.travis.yml index 90a7a5da..084559ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,2 +1,6 @@ language: objective-c +before_install: + - brew update + - brew install macmade/tap/xcode-coveralls script: make ci +after_success: xcode-coveralls --exclude /Applications --exclude Tests --exclude Vendor build/Build/Intermediates/Sparkle.build/Coverage/Sparkle.build/Objects-normal/x86_64 diff --git a/Configurations/ConfigCommonCoverage.xcconfig b/Configurations/ConfigCommonCoverage.xcconfig new file mode 100644 index 00000000..afa2360c --- /dev/null +++ b/Configurations/ConfigCommonCoverage.xcconfig @@ -0,0 +1,4 @@ +#include "ConfigCommonDebug.xcconfig" + +GCC_GENERATE_TEST_COVERAGE_FILES = YES +GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = YES diff --git a/Configurations/ConfigTestApp.xcconfig b/Configurations/ConfigTestApp.xcconfig index a0f18581..f34249fc 100644 --- a/Configurations/ConfigTestApp.xcconfig +++ b/Configurations/ConfigTestApp.xcconfig @@ -3,6 +3,5 @@ INFOPLIST_FILE = TestApplication/TestApplication-Info.plist WRAPPER_EXTENSION = app ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon -CLANG_ENABLE_OBJC_ARC = NO LD_RUNPATH_SEARCH_PATHS = @executable_path/../Frameworks PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.SparkleTestApp diff --git a/Configurations/ConfigUnitTestCoverage.xcconfig b/Configurations/ConfigUnitTestCoverage.xcconfig new file mode 100644 index 00000000..67f13139 --- /dev/null +++ b/Configurations/ConfigUnitTestCoverage.xcconfig @@ -0,0 +1,2 @@ +GCC_GENERATE_TEST_COVERAGE_FILES = NO +GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO diff --git a/Makefile b/Makefile index f23423c2..0908eb99 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ test: ci: for i in {7..11} ; do \ if xcrun --sdk "macosx10.$$i" --show-sdk-path 2> /dev/null ; then \ - xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Debug test || exit 1 ; \ + ( rm -rf build && xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Coverage -derivedDataPath build test ) || exit 1 ; \ fi ; \ done diff --git a/README.markdown b/README.markdown index 929dd1e9..824729f7 100644 --- a/README.markdown +++ b/README.markdown @@ -1,4 +1,4 @@ -# Sparkle [![Build Status](https://travis-ci.org/sparkle-project/Sparkle.svg?branch=master)](https://travis-ci.org/sparkle-project/Sparkle) +# Sparkle [![Build Status](https://travis-ci.org/sparkle-project/Sparkle.svg?branch=master)](https://travis-ci.org/sparkle-project/Sparkle) [![Coverage Status](https://coveralls.io/repos/sparkle-project/Sparkle/badge.svg?branch=master&service=github)](https://coveralls.io/github/sparkle-project/Sparkle?branch=master) An easy-to-use software update framework for Cocoa developers. diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 8f116790..6a9c2cae 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -245,6 +245,12 @@ 7223E7631AD1AEFF008E3161 /* sais.c in Sources */ = {isa = PBXBuildFile; fileRef = 7223E7611AD1AEFF008E3161 /* sais.c */; }; 7268AC631AD634C200C3E0C1 /* SUBinaryDeltaCreate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */; }; 72D4DAA11AD7632900B211E2 /* SUBinaryDeltaCreate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */; }; + 72E45CF31B640CDD005C701A /* SUTestApplicationDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 72E45CF21B640CDD005C701A /* SUTestApplicationDelegate.m */; }; + 72E45CF71B640DAE005C701A /* SUUpdateSettingsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 72E45CF51B640DAE005C701A /* SUUpdateSettingsWindowController.m */; }; + 72E45CF81B640DAE005C701A /* SUUpdateSettingsWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 72E45CF61B640DAE005C701A /* SUUpdateSettingsWindowController.xib */; }; + 72E45CFC1B641961005C701A /* sparkletestcast.xml in Resources */ = {isa = PBXBuildFile; fileRef = 72E45CFB1B641961005C701A /* sparkletestcast.xml */; }; + 72E45CFE1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem in Resources */ = {isa = PBXBuildFile; fileRef = 72E45CFD1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem */; }; + 72E45DDD1B65C3BD005C701A /* sign_update in Resources */ = {isa = PBXBuildFile; fileRef = 72E45DDC1B65C3BD005C701A /* sign_update */; }; 767B61AC1972D488004E0C3C /* SUGuidedPackageInstaller.h in Headers */ = {isa = PBXBuildFile; fileRef = 767B61AA1972D488004E0C3C /* SUGuidedPackageInstaller.h */; }; 767B61AD1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */; }; 767B61AE1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */; }; @@ -472,6 +478,8 @@ 33545B7C1B46774D0059250D /* SUXPCInstaller.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SUXPCInstaller.m; sourceTree = ""; }; 33545B811B4679080059250D /* com.devmate.UpdateInstaller.xpc */ = {isa = PBXFileReference; explicitFileType = "wrapper.xpc-service"; includeInIndex = 0; path = com.devmate.UpdateInstaller.xpc; sourceTree = BUILT_PRODUCTS_DIR; }; 33545B9B1B469BE60059250D /* Sparkle Test App.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = "Sparkle Test App.entitlements"; sourceTree = ""; }; + 149B78631B7D3A0C00D7D62C /* ConfigCommonCoverage.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigCommonCoverage.xcconfig; sourceTree = ""; }; + 149B78641B7D3A4800D7D62C /* ConfigUnitTestCoverage.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUnitTestCoverage.xcconfig; sourceTree = ""; }; 3772FEA813DE0B6B00F79537 /* SUVersionDisplayProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUVersionDisplayProtocol.h; sourceTree = ""; }; 4607BEA21948443800EF8DA4 /* nb */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/Sparkle.strings; sourceTree = ""; }; 4607BEA31948443800EF8DA4 /* nb */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = nb; path = nb.lproj/SUAutomaticUpdateAlert.xib; sourceTree = ""; }; @@ -683,6 +691,14 @@ 7223E7621AD1AEFF008E3161 /* sais.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sais.h; sourceTree = ""; }; 7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBinaryDeltaCreate.m; sourceTree = ""; }; 7268AC641AD634E400C3E0C1 /* SUBinaryDeltaCreate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBinaryDeltaCreate.h; sourceTree = ""; }; + 72E45CF11B640CDD005C701A /* SUTestApplicationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUTestApplicationDelegate.h; sourceTree = ""; }; + 72E45CF21B640CDD005C701A /* SUTestApplicationDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUTestApplicationDelegate.m; sourceTree = ""; }; + 72E45CF41B640DAE005C701A /* SUUpdateSettingsWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUpdateSettingsWindowController.h; sourceTree = ""; }; + 72E45CF51B640DAE005C701A /* SUUpdateSettingsWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUpdateSettingsWindowController.m; sourceTree = ""; }; + 72E45CF61B640DAE005C701A /* SUUpdateSettingsWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SUUpdateSettingsWindowController.xib; sourceTree = ""; }; + 72E45CFB1B641961005C701A /* sparkletestcast.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = sparkletestcast.xml; sourceTree = ""; }; + 72E45CFD1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test_app_only_dsa_priv_dont_ever_do_this_for_real.pem; sourceTree = ""; }; + 72E45DDC1B65C3BD005C701A /* sign_update */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = sign_update; path = bin/sign_update; sourceTree = SOURCE_ROOT; }; 767B61AA1972D488004E0C3C /* SUGuidedPackageInstaller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUGuidedPackageInstaller.h; sourceTree = ""; }; 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUGuidedPackageInstaller.m; sourceTree = ""; }; 8DC2EF5A0486A6940098B216 /* Sparkle-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Sparkle-Info.plist"; sourceTree = ""; }; @@ -1107,9 +1123,17 @@ 61B5F91D09C4CF7F00B25A18 /* Test Application */ = { isa = PBXGroup; children = ( + 72E45DDC1B65C3BD005C701A /* sign_update */, 61B5F92A09C4CFD800B25A18 /* InfoPlist.strings */, 61B5F92409C4CFC900B25A18 /* main.m */, + 72E45CF11B640CDD005C701A /* SUTestApplicationDelegate.h */, + 72E45CF21B640CDD005C701A /* SUTestApplicationDelegate.m */, + 72E45CF41B640DAE005C701A /* SUUpdateSettingsWindowController.h */, + 72E45CF51B640DAE005C701A /* SUUpdateSettingsWindowController.m */, + 72E45CF61B640DAE005C701A /* SUUpdateSettingsWindowController.xib */, 61B5F92C09C4CFD800B25A18 /* MainMenu.xib */, + 72E45CFB1B641961005C701A /* sparkletestcast.xml */, + 72E45CFD1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem */, 14732BBF1960F0AC00593899 /* test_app_only_dsa_pub.pem */, 61B5F90409C4CEE200B25A18 /* TestApplication-Info.plist */, ); @@ -1171,6 +1195,7 @@ 5D06E8F20FD68D21005AE3F6 /* ConfigBinaryDeltaDebug.xcconfig */, 5D06E8F30FD68D21005AE3F6 /* ConfigBinaryDeltaRelease.xcconfig */, FA1941D00D94A70100DD942E /* ConfigCommon.xcconfig */, + 149B78631B7D3A0C00D7D62C /* ConfigCommonCoverage.xcconfig */, FA1941CF0D94A70100DD942E /* ConfigCommonDebug.xcconfig */, FA1941CC0D94A70100DD942E /* ConfigCommonRelease.xcconfig */, FA1941D10D94A70100DD942E /* ConfigFramework.xcconfig */, @@ -1183,6 +1208,7 @@ FA1941CB0D94A70100DD942E /* ConfigTestAppDebug.xcconfig */, FA1941D20D94A70100DD942E /* ConfigTestAppRelease.xcconfig */, FA3AAF3B1050B273004B3130 /* ConfigUnitTest.xcconfig */, + 149B78641B7D3A4800D7D62C /* ConfigUnitTestCoverage.xcconfig */, FA3AAF3A1050B273004B3130 /* ConfigUnitTestDebug.xcconfig */, FA3AAF391050B273004B3130 /* ConfigUnitTestRelease.xcconfig */, 14732BC91960F70A00593899 /* make-release-package.sh */, @@ -1611,7 +1637,11 @@ 1420DF50196247F900203BB0 /* Images.xcassets in Resources */, 61B5F92E09C4CFD800B25A18 /* InfoPlist.strings in Resources */, 61B5F92F09C4CFD800B25A18 /* MainMenu.xib in Resources */, + 72E45CFC1B641961005C701A /* sparkletestcast.xml in Resources */, 14732BC01960F2C200593899 /* test_app_only_dsa_pub.pem in Resources */, + 72E45CF81B640DAE005C701A /* SUUpdateSettingsWindowController.xib in Resources */, + 72E45DDD1B65C3BD005C701A /* sign_update in Resources */, + 72E45CFE1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1837,6 +1867,8 @@ buildActionMask = 2147483647; files = ( 61B5F93009C4CFDC00B25A18 /* main.m in Sources */, + 72E45CF31B640CDD005C701A /* SUTestApplicationDelegate.m in Sources */, + 72E45CF71B640DAE005C701A /* SUUpdateSettingsWindowController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2169,6 +2201,66 @@ }; name = Release; }; + 149B785A1B7D398100D7D62C /* Coverage */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 149B78631B7D3A0C00D7D62C /* ConfigCommonCoverage.xcconfig */; + buildSettings = { + }; + name = Coverage; + }; + 149B785B1B7D398100D7D62C /* Coverage */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = FA1941CA0D94A70100DD942E /* ConfigFrameworkDebug.xcconfig */; + buildSettings = { + }; + name = Coverage; + }; + 149B785C1B7D398100D7D62C /* Coverage */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = FA1941CB0D94A70100DD942E /* ConfigTestAppDebug.xcconfig */; + buildSettings = { + }; + name = Coverage; + }; + 149B785D1B7D398100D7D62C /* Coverage */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 149B78641B7D3A4800D7D62C /* ConfigUnitTestCoverage.xcconfig */; + buildSettings = { + }; + name = Coverage; + }; + 149B785E1B7D398100D7D62C /* Coverage */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 5D06E8F20FD68D21005AE3F6 /* ConfigBinaryDeltaDebug.xcconfig */; + buildSettings = { + }; + name = Coverage; + }; + 149B785F1B7D398100D7D62C /* Coverage */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = FA1941D30D94A70100DD942E /* ConfigRelaunchDebug.xcconfig */; + buildSettings = { + }; + name = Coverage; + }; + 149B78601B7D398100D7D62C /* Coverage */ = { + isa = XCBuildConfiguration; + buildSettings = { + }; + name = Coverage; + }; + 149B78611B7D398100D7D62C /* Coverage */ = { + isa = XCBuildConfiguration; + buildSettings = { + }; + name = Coverage; + }; + 149B78621B7D398100D7D62C /* Coverage */ = { + isa = XCBuildConfiguration; + buildSettings = { + }; + name = Coverage; + }; 1DEB91AE08733DA50010E9CD /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = FA1941CA0D94A70100DD942E /* ConfigFrameworkDebug.xcconfig */; @@ -2334,6 +2426,7 @@ isa = XCConfigurationList; buildConfigurations = ( 1420DF4B1962329200203BB0 /* Debug */, + 149B78611B7D398100D7D62C /* Coverage */, 1420DF4C1962329200203BB0 /* Release */, ); defaultConfigurationIsVisible = 0; @@ -2343,6 +2436,7 @@ isa = XCConfigurationList; buildConfigurations = ( 14732BC71960F69300593899 /* Debug */, + 149B78601B7D398100D7D62C /* Coverage */, 14732BC81960F69300593899 /* Release */, ); defaultConfigurationIsVisible = 0; @@ -2352,6 +2446,7 @@ isa = XCConfigurationList; buildConfigurations = ( 14950061195FB89500BC5B5B /* Debug */, + 149B78621B7D398100D7D62C /* Coverage */, 14950062195FB89500BC5B5B /* Release */, ); defaultConfigurationIsVisible = 0; @@ -2361,6 +2456,7 @@ isa = XCConfigurationList; buildConfigurations = ( 1DEB91AE08733DA50010E9CD /* Debug */, + 149B785B1B7D398100D7D62C /* Coverage */, 1DEB91AF08733DA50010E9CD /* Release */, ); defaultConfigurationIsVisible = 0; @@ -2370,6 +2466,7 @@ isa = XCConfigurationList; buildConfigurations = ( 1DEB91B208733DA50010E9CD /* Debug */, + 149B785A1B7D398100D7D62C /* Coverage */, 1DEB91B308733DA50010E9CD /* Release */, ); defaultConfigurationIsVisible = 0; @@ -2406,6 +2503,7 @@ isa = XCConfigurationList; buildConfigurations = ( 55C14BBB136EEF1500649790 /* Debug */, + 149B785F1B7D398100D7D62C /* Coverage */, 55C14BBC136EEF1500649790 /* Release */, ); defaultConfigurationIsVisible = 0; @@ -2415,6 +2513,7 @@ isa = XCConfigurationList; buildConfigurations = ( 5D06E8D20FD68C7D005AE3F6 /* Debug */, + 149B785E1B7D398100D7D62C /* Coverage */, 5D06E8D30FD68C7D005AE3F6 /* Release */, ); defaultConfigurationIsVisible = 0; @@ -2424,6 +2523,7 @@ isa = XCConfigurationList; buildConfigurations = ( 612279DB0DB5470300AB99EA /* Debug */, + 149B785D1B7D398100D7D62C /* Coverage */, 612279DC0DB5470300AB99EA /* Release */, ); defaultConfigurationIsVisible = 0; @@ -2433,6 +2533,7 @@ isa = XCConfigurationList; buildConfigurations = ( 61B5F90609C4CEE300B25A18 /* Debug */, + 149B785C1B7D398100D7D62C /* Coverage */, 61B5F90709C4CEE300B25A18 /* Release */, ); defaultConfigurationIsVisible = 0; diff --git a/Sparkle/Autoupdate/Autoupdate.m b/Sparkle/Autoupdate/Autoupdate.m index 1a2bdbd6..b63f8135 100644 --- a/Sparkle/Autoupdate/Autoupdate.m +++ b/Sparkle/Autoupdate/Autoupdate.m @@ -8,11 +8,6 @@ #include -/*! - * If the Installation takes longer than this time the Application Icon is shown in the Dock so that the user has some feedback. - */ -static const NSTimeInterval SUInstallationTimeLimit = 5; - /*! * Time this app uses to recheck if the parent has already died. */ @@ -20,157 +15,148 @@ static const NSTimeInterval SUParentQuitCheckInterval = .25; @interface TerminationListener : NSObject -@property (copy) NSString *hostpath; -@property (copy) NSString *executablepath; -@property (assign) pid_t parentprocessid; -@property (copy) NSString *folderpath; +- (instancetype)initWithProcessId:(pid_t)pid; -@property (copy) NSString *selfPath; -@property (copy) NSString *installationPath; -@property (strong) NSTimer *watchdogTimer; -@property (strong) NSTimer *longInstallationTimer; -@property (strong) SUHost *host; -@property (assign) BOOL shouldRelaunch; -@property (assign) BOOL shouldShowUI; -@property (strong) SUStatusController *statusController; +@end -- (void)parentHasQuit; +@interface TerminationListener () -- (void)relaunch; -- (void)install; - -- (void)showAppIconInDock:(NSTimer *)aTimer; -- (void)watchdog:(NSTimer *)aTimer; +@property (nonatomic, assign) pid_t processIdentifier; +@property (nonatomic, strong) NSTimer *watchdogTimer; @end @implementation TerminationListener -@synthesize hostpath; -@synthesize executablepath; -@synthesize parentprocessid; -@synthesize folderpath; +@synthesize processIdentifier = _processIdentifier; +@synthesize watchdogTimer = _watchdogTimer; -@synthesize selfPath; -@synthesize installationPath; -@synthesize watchdogTimer; -@synthesize longInstallationTimer; -@synthesize host; -@synthesize shouldRelaunch; -@synthesize shouldShowUI; -@synthesize statusController; - -- (instancetype)initWithHostPath:(NSString *)inhostpath executablePath:(NSString *)execpath parentProcessId:(pid_t)ppid folderPath:(NSString *)infolderpath shouldRelaunch:(BOOL)relaunch shouldShowUI:(BOOL)showUI selfPath:(NSString *)inSelfPath +- (instancetype)initWithProcessId:(pid_t)pid { if (!(self = [super init])) { return nil; } - self.hostpath = inhostpath; - self.executablepath = execpath; - self.parentprocessid = ppid; - self.folderpath = infolderpath; - self.selfPath = inSelfPath; - self.shouldRelaunch = relaunch; - self.shouldShowUI = showUI; - - BOOL alreadyTerminated = (getppid() == 1); // ppid is launchd (1) => parent terminated already - - if (alreadyTerminated) - [self parentHasQuit]; - else - self.watchdogTimer = [NSTimer scheduledTimerWithTimeInterval:SUParentQuitCheckInterval target:self selector:@selector(watchdog:) userInfo:nil repeats:YES]; + self.processIdentifier = pid; return self; } - -- (void)dealloc -{ - [self.longInstallationTimer invalidate]; - [self.statusController close]; -} - - -- (void)parentHasQuit +- (void)cleanupWithCompletion:(void (^)(void))completionBlock { [self.watchdogTimer invalidate]; - self.longInstallationTimer = [NSTimer scheduledTimerWithTimeInterval:SUInstallationTimeLimit - target: self selector: @selector(showAppIconInDock:) - userInfo:nil repeats:NO]; + completionBlock(); + completionBlock = nil; +} - if (self.folderpath) - [self install]; +- (void)startListeningWithCompletion:(void (^)(void))completionBlock +{ + BOOL alreadyTerminated = (getppid() == 1); // ppid is launchd (1) => parent terminated already + if (alreadyTerminated) + [self cleanupWithCompletion:completionBlock]; else - [self relaunch]; + self.watchdogTimer = [NSTimer scheduledTimerWithTimeInterval:SUParentQuitCheckInterval target:self selector:@selector(watchdog:) userInfo:completionBlock repeats:YES]; } -- (void)watchdog:(NSTimer *)__unused aTimer +- (void)watchdog:(NSTimer *)timer { - if (![NSRunningApplication runningApplicationWithProcessIdentifier:self.parentprocessid]) { - [self parentHasQuit]; + if (![NSRunningApplication runningApplicationWithProcessIdentifier:self.processIdentifier]) { + [self cleanupWithCompletion:timer.userInfo]; } } -- (void)showAppIconInDock:(NSTimer *)__unused aTimer +@end + +/*! + * If the Installation takes longer than this time the Application Icon is shown in the Dock so that the user has some feedback. + */ +static const NSTimeInterval SUInstallationTimeLimit = 5; + +@interface AppInstaller : NSObject + +/* + * hostPath - path to host (original) application + * relaunchPath - path to what the host wants to relaunch (default is same as hostPath) + * parentProcessId - process identifier of the host before launching us + * updateFolderPath - path to update folder (i.e, temporary directory containing the new update) + * shouldRelaunch - indicates if the new installed app should re-launched + * shouldShowUI - indicates if we should show the status window when installing the update + */ +- (instancetype)initWithHostPath:(NSString *)hostPath relaunchPath:(NSString *)relaunchPath parentProcessId:(pid_t)parentProcessId updateFolderPath:(NSString *)updateFolderPath shouldRelaunch:(BOOL)shouldRelaunch shouldShowUI:(BOOL)shouldShowUI; + +@end + +@interface AppInstaller () + +@property (nonatomic, strong) TerminationListener *terminationListener; +@property (nonatomic, strong) SUStatusController *statusController; + +@property (nonatomic, copy) NSString *updateFolderPath; +@property (nonatomic, copy) NSString *hostPath; +@property (nonatomic, copy) NSString *relaunchPath; +@property (nonatomic, assign) BOOL shouldRelaunch; +@property (nonatomic, assign) BOOL shouldShowUI; + +@end + +@implementation AppInstaller + +@synthesize terminationListener = _terminationListener; +@synthesize statusController = _statusController; +@synthesize updateFolderPath = _updateFolderPath; +@synthesize hostPath = _hostPath; +@synthesize relaunchPath = _relaunchPath; +@synthesize shouldRelaunch = _shouldRelaunch; +@synthesize shouldShowUI = _shouldShowUI; + +- (instancetype)initWithHostPath:(NSString *)hostPath relaunchPath:(NSString *)relaunchPath parentProcessId:(pid_t)parentProcessId updateFolderPath:(NSString *)updateFolderPath shouldRelaunch:(BOOL)shouldRelaunch shouldShowUI:(BOOL)shouldShowUI { - ProcessSerialNumber psn = { 0, kCurrentProcess }; - TransformProcessType(&psn, kProcessTransformToForegroundApplication); + if (!(self = [super init])) { + return nil; + } + + self.hostPath = hostPath; + self.relaunchPath = relaunchPath; + self.terminationListener = [[TerminationListener alloc] initWithProcessId:parentProcessId]; + self.updateFolderPath = updateFolderPath; + self.shouldRelaunch = shouldRelaunch; + self.shouldShowUI = shouldShowUI; + + return self; } - -- (void)relaunch __attribute__((noreturn)) +- (void)applicationDidFinishLaunching:(NSNotification __unused *)notification { - if (self.shouldRelaunch) - { - NSString *appPath = nil; - if (!self.folderpath || ![self.executablepath isEqualToString:self.hostpath]) - appPath = self.executablepath; - else - appPath = self.installationPath; + [self.terminationListener startListeningWithCompletion:^{ + self.terminationListener = nil; - NSError *error = nil; - [[NSWorkspace sharedWorkspace] launchApplicationAtURL:[NSURL fileURLWithPath:appPath] - options:NSWorkspaceLaunchNewInstance - configuration:nil error:&error]; - if (error.code != noErr) - { - SULog(@"%ld - %@", error.code, error.localizedDescription); - } - } - - if (self.folderpath) - { - NSError *theError = nil; - if (![SUPlainInstaller _removeFileAtPath:[SUInstaller updateFolder] error:&theError]) - SULog(@"Couldn't remove update folder: %@.", theError); - } - [[NSFileManager defaultManager] removeItemAtPath:self.selfPath error:NULL]; - - exit(EXIT_SUCCESS); + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUInstallationTimeLimit * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + // Show app icon in the dock + ProcessSerialNumber psn = { 0, kCurrentProcess }; + TransformProcessType(&psn, kProcessTransformToForegroundApplication); + }); + + [self install]; + }]; } - - (void)install { - NSBundle *theBundle = [NSBundle bundleWithPath:self.hostpath]; - self.host = [[SUHost alloc] initWithBundle:theBundle]; - self.installationPath = [[self.host installationPath] copy]; - + NSBundle *theBundle = [NSBundle bundleWithPath:self.hostPath]; + SUHost *host = [[SUHost alloc] initWithBundle:theBundle]; + NSString *installationPath = [[host installationPath] copy]; + if (self.shouldShowUI) { - SUStatusController *statusCtl = [[SUStatusController alloc] initWithHost:self.host]; // We quit anyway after we've installed, so leak this for now. - [statusCtl setButtonTitle:SULocalizedString(@"Cancel Update", @"") target:nil action:Nil isDefault:NO]; - [statusCtl beginActionWithTitle:SULocalizedString(@"Installing update...", @"") - maxProgressValue: 0 statusText: @""]; - [statusCtl showWindow:self]; - - [self.statusController close]; // If there's an existing status controller, close it before we release our strong reference to it. - self.statusController = statusCtl; // Keep a strong reference to the status controller, or else it might get prematurely deallocated. + self.statusController = [[SUStatusController alloc] initWithHost:host]; + [self.statusController setButtonTitle:SULocalizedString(@"Cancel Update", @"") target:nil action:Nil isDefault:NO]; + [self.statusController beginActionWithTitle:SULocalizedString(@"Installing update...", @"") + maxProgressValue: 0 statusText: @""]; + [self.statusController showWindow:self]; } - - [SUInstaller installFromUpdateFolder:self.folderpath - overHost:self.host - installationPath:self.installationPath + + [SUInstaller installFromUpdateFolder:self.updateFolderPath + overHost:host + installationPath:installationPath versionComparator:[SUStandardVersionComparator defaultComparator] completionHandler:^(NSError *error) { if (error) { @@ -182,11 +168,42 @@ static const NSTimeInterval SUParentQuitCheckInterval = .25; } exit(EXIT_FAILURE); } else { - [self relaunch]; + NSString *pathToRelaunch = nil; + // If the installation path differs from the host path, we give higher precedence for it than + // if the desired relaunch path differs from the host path + if (![installationPath.pathComponents isEqualToArray:self.hostPath.pathComponents] || [self.relaunchPath.pathComponents isEqualToArray:self.hostPath.pathComponents]) { + pathToRelaunch = installationPath; + } else { + pathToRelaunch = self.relaunchPath; + } + [self cleanupAndTerminateWithPathToRelaunch:pathToRelaunch]; } }]; } +- (void)cleanupAndTerminateWithPathToRelaunch:(NSString *)relaunchPath __attribute__((noreturn)) +{ + if (self.shouldRelaunch) { + NSError *error = nil; + [[NSWorkspace sharedWorkspace] launchApplicationAtURL:[NSURL fileURLWithPath:relaunchPath] + options:NSWorkspaceLaunchNewInstance + configuration:nil + error:&error]; + if (error.code != noErr) + { + SULog(@"%ld - %@", error.code, error.localizedDescription); + } + } + + NSError *theError = nil; + if (![SUPlainInstaller _removeFileAtPath:self.updateFolderPath error:&theError]) + SULog(@"Couldn't remove update folder: %@.", theError); + + [[NSFileManager defaultManager] removeItemAtPath:[[NSBundle mainBundle] bundlePath] error:NULL]; + + exit(EXIT_SUCCESS); +} + @end int main(int __unused argc, const char __unused *argv[]) @@ -197,28 +214,30 @@ int main(int __unused argc, const char __unused *argv[]) if (args.count < 5 || args.count > 7) { return EXIT_FAILURE; } + + NSApplication *application = [NSApplication sharedApplication]; BOOL shouldShowUI = (args.count > 6) ? [args[6] boolValue] : YES; if (shouldShowUI) { - [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; + [application activateIgnoringOtherApps:YES]; } - - [NSApplication sharedApplication]; + + AppInstaller *appInstaller = [[AppInstaller alloc] initWithHostPath:args[1] + relaunchPath:args[2] + parentProcessId:[args[3] intValue] + updateFolderPath:args[4] + shouldRelaunch:(args.count > 5) ? [args[5] boolValue] : YES + shouldShowUI:shouldShowUI]; NSConnection *connection = [[NSConnection alloc] init]; - TerminationListener *termListen = [[TerminationListener alloc] initWithHostPath:args[1] - executablePath:args[2] - parentProcessId:[args[3] intValue] - folderPath:args[4] - shouldRelaunch:(args.count > 5) ? [args[5] boolValue] : YES - shouldShowUI:shouldShowUI - selfPath:[[NSBundle mainBundle] bundlePath]]; - [connection setRootObject:termListen]; - if (![connection registerName:[NSString stringWithFormat:@"Sparkle-%@", termListen.host.bundle.bundleIdentifier]]) + [connection setRootObject:appInstaller]; + if (![connection registerName:[NSString stringWithFormat:@"Sparkle-%@", [NSBundle bundleWithPath:appInstaller.hostPath].bundleIdentifier]]) { NSLog(@"%@ server: could not register server. Is one already running?\n", args.firstObject); } - [[NSApplication sharedApplication] run]; + [application setDelegate:appInstaller]; + [application run]; + // Ensure connection is not deallocated by ARC before caling -[NSApplication run] [connection class]; } diff --git a/Sparkle/SUHost.m b/Sparkle/SUHost.m index 0bc94909..5bb73ac9 100644 --- a/Sparkle/SUHost.m +++ b/Sparkle/SUHost.m @@ -89,7 +89,8 @@ if (SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) { // We'll install to "#{CFBundleName}.app", but only if that path doesn't already exist. If we're "Foo 4.2.app," and there's a "Foo.app" in this directory, we don't want to overwrite it! But if there's no "Foo.app," we'll take that name. NSString *normalizedAppPath = [[[self.bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[self.bundle bundlePath] pathExtension]]]; - if (![[NSFileManager defaultManager] fileExistsAtPath:[[[self.bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[self.bundle bundlePath] pathExtension]]]]) { + + if (![[NSFileManager defaultManager] fileExistsAtPath:normalizedAppPath]) { return normalizedAppPath; } } @@ -157,7 +158,7 @@ { struct statfs statfs_info; statfs([[self.bundle bundlePath] fileSystemRepresentation], &statfs_info); - return (statfs_info.f_flags & MNT_RDONLY); + return (statfs_info.f_flags & MNT_RDONLY) != 0; } - (BOOL)isBackgroundApplication diff --git a/Sparkle/SUInstaller.h b/Sparkle/SUInstaller.h index 153f3d42..4afe1cbe 100644 --- a/Sparkle/SUInstaller.h +++ b/Sparkle/SUInstaller.h @@ -18,7 +18,6 @@ + (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(BOOL *)isGuidedPtr; + (void)installFromUpdateFolder:(NSString *)updateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath versionComparator:(id)comparator completionHandler:(void (^)(NSError *))completionHandler; + (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result error:(NSError *)error completionHandler:(void (^)(NSError *))completionHandler; -+ (NSString *)updateFolder; @end diff --git a/Sparkle/SUInstaller.m b/Sparkle/SUInstaller.m index 33647133..400f9597 100644 --- a/Sparkle/SUInstaller.m +++ b/Sparkle/SUInstaller.m @@ -16,13 +16,6 @@ @implementation SUInstaller -static NSString *sUpdateFolder = nil; - -+ (NSString *)updateFolder -{ - return sUpdateFolder; -} - + (BOOL)isAliasFolderAtPath:(NSString *)path { NSNumber *aliasFlag = nil; @@ -48,8 +41,6 @@ static NSString *sUpdateFolder = nil; NSDirectoryEnumerator *dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:inUpdateFolder]; NSString *bundleFileNameNoExtension = [bundleFileName stringByDeletingPathExtension]; - sUpdateFolder = inUpdateFolder; - while ((currentFile = [dirEnum nextObject])) { NSString *currentPath = [inUpdateFolder stringByAppendingPathComponent:currentFile]; NSString *currentFilename = [currentFile lastPathComponent]; diff --git a/Sparkle/pl.lproj/Sparkle.strings b/Sparkle/pl.lproj/Sparkle.strings index 953bf45f..25cdfc63 100644 --- a/Sparkle/pl.lproj/Sparkle.strings +++ b/Sparkle/pl.lproj/Sparkle.strings @@ -1,12 +1,12 @@ /* "%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?"; */ -"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ został pobrany i jest gotowy do użycia! Czy chciałbyś teraz zainstalować i ponownie uruchomić %1$@?"; +"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ został pobrany i jest gotowy do użycia! Czy chcesz teraz zainstalować i ponownie uruchomić %1$@?"; /* "%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again." = "%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again."; */ -"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again." = "%1$@ nie może zostać zaktualizowany gdy jest uruchomiony z woluminu tylko do odczytu w stylu obraz dysku lub napęd optyczny. Przenieś %1$@ do teczki Programy, uruchom z nowej lokalizacji i spróbuj ponownie."; +"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again." = "%1$@ nie może zostać zaktualizowany gdy jest uruchomiony z woluminu tylko do odczytu jak obraz dysku lub napęd optyczny. Przenieś %1$@ do folderu Programy, uruchom z nowej lokacji i spróbuj ponownie."; -"%@ %@ is currently the newest version available." = "%1$@ %2$@ jest najbardziej aktualną dostępną wersją."; +"%@ %@ is currently the newest version available." = "%1$@ %2$@ jest najnowszą dostępną wersją."; -"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ jest już dostępny (aktualnie posiadasz %3$@). Chciałbyś go teraz pobrać?"; +"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ jest już dostępny (aktualnie posiadasz %3$@). Czy chcesz go teraz pobrać?"; "%@ downloaded" = "Pobrano %@"; @@ -24,7 +24,7 @@ "An error occurred while installing the update. Please try again later." = "Błąd podczas instalowania uaktualnienia. Spróbuj ponownie później"; -"An error occurred while parsing the update feed." = "Błąd podczas analizowania danych o uaktualnieniu."; +"An error occurred while parsing the update feed." = "Błąd podczas wczytywania danych o uaktualnieniu."; "An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@." = "Błąd podczas ponownego uruchomienia %1$@, ale nowa wersja będzie dostępna przy ponownym ręcznym uruchomieniu %1$@."; @@ -38,10 +38,10 @@ "Checking for updates..." = "Sprawdzam uaktualnienia…"; /* Take care not to overflow the status window. */ -"Downloading update..." = "Pobieram uaktualnienia…"; +"Downloading update..." = "Pobieram uaktualnienie…"; /* Take care not to overflow the status window. */ -"Extracting update..." = "Rozpakowuję uaktualnienia…"; +"Extracting update..." = "Rozpakowuję uaktualnienie…"; /* the unit for gigabytes */ "GB" = "GB"; @@ -61,7 +61,7 @@ "Ready to Install" = "Gotowy do instalacji"; -"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu." = "Czy %1$@ powinien automatycznie sprawdzać uaktualnienia? Zawsze możesz to samemu sprawdzić z menu %1$@."; +"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu." = "Czy %1$@ ma automatycznie sprawdzać uaktualnienia? Zawsze możesz ręcznie sprawdzać z menu %1$@."; "Update Error!" = "Błąd uaktualniania!"; @@ -70,4 +70,3 @@ "You already have the newest version of %@." = "Posiadasz najnowszą wersję %@."; "You're up-to-date!" = "Jesteś na bieżąco!"; - diff --git a/TestApplication/After Update/Sparkle Updated Test App.xcodeproj/project.pbxproj b/TestApplication/After Update/Sparkle Updated Test App.xcodeproj/project.pbxproj deleted file mode 100644 index 963e475f..00000000 --- a/TestApplication/After Update/Sparkle Updated Test App.xcodeproj/project.pbxproj +++ /dev/null @@ -1,283 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 5A195FB01983E85D000BE570 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A195FAF1983E85D000BE570 /* main.m */; }; - 5A195FB31983E85D000BE570 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 5A195FB21983E85D000BE570 /* AppDelegate.m */; }; - 5A195FB51983E85D000BE570 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5A195FB41983E85D000BE570 /* Images.xcassets */; }; - 5A195FB81983E85D000BE570 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5A195FB61983E85D000BE570 /* MainMenu.xib */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 5A195FAA1983E85D000BE570 /* Sparkle Updated Test App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Sparkle Updated Test App.app"; sourceTree = BUILT_PRODUCTS_DIR; }; - 5A195FAE1983E85D000BE570 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 5A195FAF1983E85D000BE570 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - 5A195FB11983E85D000BE570 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; - 5A195FB21983E85D000BE570 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; - 5A195FB41983E85D000BE570 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; - 5A195FB71983E85D000BE570 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 5A195FA71983E85D000BE570 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 5A195FA11983E85D000BE570 = { - isa = PBXGroup; - children = ( - 5A195FAC1983E85D000BE570 /* Sparkle Updated Test App */, - 5A195FAB1983E85D000BE570 /* Products */, - ); - sourceTree = ""; - }; - 5A195FAB1983E85D000BE570 /* Products */ = { - isa = PBXGroup; - children = ( - 5A195FAA1983E85D000BE570 /* Sparkle Updated Test App.app */, - ); - name = Products; - sourceTree = ""; - }; - 5A195FAC1983E85D000BE570 /* Sparkle Updated Test App */ = { - isa = PBXGroup; - children = ( - 5A195FB11983E85D000BE570 /* AppDelegate.h */, - 5A195FB21983E85D000BE570 /* AppDelegate.m */, - 5A195FB61983E85D000BE570 /* MainMenu.xib */, - 5A195FAD1983E85D000BE570 /* Supporting Files */, - ); - path = "Sparkle Updated Test App"; - sourceTree = ""; - }; - 5A195FAD1983E85D000BE570 /* Supporting Files */ = { - isa = PBXGroup; - children = ( - 5A195FB41983E85D000BE570 /* Images.xcassets */, - 5A195FAE1983E85D000BE570 /* Info.plist */, - 5A195FAF1983E85D000BE570 /* main.m */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 5A195FA91983E85D000BE570 /* Sparkle Updated Test App */ = { - isa = PBXNativeTarget; - buildConfigurationList = 5A195FC71983E85D000BE570 /* Build configuration list for PBXNativeTarget "Sparkle Updated Test App" */; - buildPhases = ( - 5A195FA61983E85D000BE570 /* Sources */, - 5A195FA71983E85D000BE570 /* Frameworks */, - 5A195FA81983E85D000BE570 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = "Sparkle Updated Test App"; - productName = "Sparkle Updated Test App"; - productReference = 5A195FAA1983E85D000BE570 /* Sparkle Updated Test App.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 5A195FA21983E85D000BE570 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0600; - ORGANIZATIONNAME = "Sparkle-project"; - TargetAttributes = { - 5A195FA91983E85D000BE570 = { - CreatedOnToolsVersion = 6.0; - }; - }; - }; - buildConfigurationList = 5A195FA51983E85D000BE570 /* Build configuration list for PBXProject "Sparkle Updated Test App" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 5A195FA11983E85D000BE570; - productRefGroup = 5A195FAB1983E85D000BE570 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 5A195FA91983E85D000BE570 /* Sparkle Updated Test App */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 5A195FA81983E85D000BE570 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 5A195FB51983E85D000BE570 /* Images.xcassets in Resources */, - 5A195FB81983E85D000BE570 /* MainMenu.xib in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 5A195FA61983E85D000BE570 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 5A195FB31983E85D000BE570 /* AppDelegate.m in Sources */, - 5A195FB01983E85D000BE570 /* main.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXVariantGroup section */ - 5A195FB61983E85D000BE570 /* MainMenu.xib */ = { - isa = PBXVariantGroup; - children = ( - 5A195FB71983E85D000BE570 /* Base */, - ); - name = MainMenu.xib; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 5A195FC51983E85D000BE570 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.7; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = macosx; - }; - name = Debug; - }; - 5A195FC61983E85D000BE570 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - CODE_SIGN_IDENTITY = "-"; - COPY_PHASE_STRIP = YES; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.7; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = macosx; - }; - name = Release; - }; - 5A195FC81983E85D000BE570 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = Sparkle; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = "Sparkle Updated Test App/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Debug; - }; - 5A195FC91983E85D000BE570 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = Sparkle; - COMBINE_HIDPI_IMAGES = YES; - INFOPLIST_FILE = "Sparkle Updated Test App/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 5A195FA51983E85D000BE570 /* Build configuration list for PBXProject "Sparkle Updated Test App" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 5A195FC51983E85D000BE570 /* Debug */, - 5A195FC61983E85D000BE570 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 5A195FC71983E85D000BE570 /* Build configuration list for PBXNativeTarget "Sparkle Updated Test App" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 5A195FC81983E85D000BE570 /* Debug */, - 5A195FC91983E85D000BE570 /* Release */, - ); - defaultConfigurationIsVisible = 0; - }; -/* End XCConfigurationList section */ - }; - rootObject = 5A195FA21983E85D000BE570 /* Project object */; -} diff --git a/TestApplication/After Update/Sparkle Updated Test App/AppDelegate.h b/TestApplication/After Update/Sparkle Updated Test App/AppDelegate.h deleted file mode 100644 index ac12a211..00000000 --- a/TestApplication/After Update/Sparkle Updated Test App/AppDelegate.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// AppDelegate.h -// Sparkle Updated Test App -// -// Created by Kornel on 26/07/2014. -// Copyright (c) 2014 Sparkle-project. All rights reserved. -// - -#import - -@interface AppDelegate : NSObject - - -@end - diff --git a/TestApplication/After Update/Sparkle Updated Test App/AppDelegate.m b/TestApplication/After Update/Sparkle Updated Test App/AppDelegate.m deleted file mode 100644 index 54538ff5..00000000 --- a/TestApplication/After Update/Sparkle Updated Test App/AppDelegate.m +++ /dev/null @@ -1,27 +0,0 @@ -// -// AppDelegate.m -// Sparkle Updated Test App -// -// Created by Kornel on 26/07/2014. -// Copyright (c) 2014 Sparkle-project. All rights reserved. -// - -#import "AppDelegate.h" - -@interface AppDelegate () -@end - -@implementation AppDelegate - -- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - NSRunAlertPanel(@"Update succeeded!", @"This is the updated version of Sparkle Test App.\n\nDelete and rebuild the app to test updates again.", @"OK", nil, nil); - - NSURL *bundleURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]; - if (bundleURL) { - [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs: @[bundleURL]]; - } - - [NSApp terminate:self]; -} - -@end diff --git a/TestApplication/After Update/Sparkle Updated Test App/Base.lproj/MainMenu.xib b/TestApplication/After Update/Sparkle Updated Test App/Base.lproj/MainMenu.xib deleted file mode 100644 index 86e35280..00000000 --- a/TestApplication/After Update/Sparkle Updated Test App/Base.lproj/MainMenu.xib +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/Contents.json b/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/Contents.json deleted file mode 100644 index 2e9df94b..00000000 --- a/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/Contents.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "images" : [ - { - "size" : "16x16", - "idiom" : "mac", - "filename" : "icon_16x16.png", - "scale" : "1x" - }, - { - "size" : "16x16", - "idiom" : "mac", - "filename" : "icon_16x16@2x.png", - "scale" : "2x" - }, - { - "size" : "32x32", - "idiom" : "mac", - "filename" : "icon_32x32.png", - "scale" : "1x" - }, - { - "size" : "32x32", - "idiom" : "mac", - "filename" : "icon_32x32@2x.png", - "scale" : "2x" - }, - { - "size" : "128x128", - "idiom" : "mac", - "filename" : "icon_128x128.png", - "scale" : "1x" - }, - { - "size" : "128x128", - "idiom" : "mac", - "filename" : "icon_128x128@2x.png", - "scale" : "2x" - }, - { - "idiom" : "mac", - "size" : "256x256", - "scale" : "1x" - }, - { - "idiom" : "mac", - "size" : "256x256", - "scale" : "2x" - }, - { - "idiom" : "mac", - "size" : "512x512", - "scale" : "1x" - }, - { - "idiom" : "mac", - "size" : "512x512", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_128x128.png b/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_128x128.png deleted file mode 100644 index 4d798520..00000000 Binary files a/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_128x128.png and /dev/null differ diff --git a/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_128x128@2x.png b/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_128x128@2x.png deleted file mode 100644 index 2bf2b0b8..00000000 Binary files a/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_128x128@2x.png and /dev/null differ diff --git a/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_16x16.png b/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_16x16.png deleted file mode 100644 index 23eada4e..00000000 Binary files a/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_16x16.png and /dev/null differ diff --git a/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_16x16@2x.png b/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_16x16@2x.png deleted file mode 100644 index 7ab394c6..00000000 Binary files a/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_16x16@2x.png and /dev/null differ diff --git a/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_32x32.png b/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_32x32.png deleted file mode 100644 index fa1e0dac..00000000 Binary files a/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_32x32.png and /dev/null differ diff --git a/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_32x32@2x.png b/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_32x32@2x.png deleted file mode 100644 index f44f9779..00000000 Binary files a/TestApplication/After Update/Sparkle Updated Test App/Images.xcassets/Sparkle.appiconset/icon_32x32@2x.png and /dev/null differ diff --git a/TestApplication/After Update/Sparkle Updated Test App/Info.plist b/TestApplication/After Update/Sparkle Updated Test App/Info.plist deleted file mode 100644 index 6b1edff0..00000000 --- a/TestApplication/After Update/Sparkle Updated Test App/Info.plist +++ /dev/null @@ -1,36 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - ${EXECUTABLE_NAME} - CFBundleIconFile - - CFBundleIdentifier - org.sparkle-project.${PRODUCT_NAME:rfc1034identifier} - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - ${PRODUCT_NAME} - CFBundlePackageType - APPL - CFBundleShortVersionString - 2.0 - CFBundleSignature - ???? - CFBundleVersion - 2 - LSApplicationCategoryType - public.app-category.developer-tools - LSMinimumSystemVersion - ${MACOSX_DEPLOYMENT_TARGET} - NSHumanReadableCopyright - Copyright © 2014 Sparkle-project. All rights reserved. - NSMainNibFile - MainMenu - NSPrincipalClass - NSApplication - - diff --git a/TestApplication/After Update/Sparkle Updated Test App/main.m b/TestApplication/After Update/Sparkle Updated Test App/main.m deleted file mode 100644 index 6aafcfc3..00000000 --- a/TestApplication/After Update/Sparkle Updated Test App/main.m +++ /dev/null @@ -1,6 +0,0 @@ - -#import - -int main(int argc, const char * argv[]) { - return NSApplicationMain(argc, argv); -} diff --git a/TestApplication/After Update/Sparkle Updated Test App/test_app_only_dsa_pub.pem b/TestApplication/After Update/Sparkle Updated Test App/test_app_only_dsa_pub.pem deleted file mode 100644 index dacd55e9..00000000 --- a/TestApplication/After Update/Sparkle Updated Test App/test_app_only_dsa_pub.pem +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN PUBLIC KEY----- -MIIDOzCCAi0GByqGSM44BAEwggIgAoIBAQD2WbLx8Bd1b1vp8FdDpSzkHZ0tlX5x -Hrzm0WWE9IokOmJw/UWk1GQYRJnA8UlufFTJV4dZVL3It4xwqqWWFyN36LWgQUpf -ss9eTn7M7vjk7BVYch7QMs4jGEnSYkebuYfVhUZlg5VViQ+37Rj+ENtBUrkPJxIY -CGAOIJn45uX5oNIPbElFkadU6m7zd1gn8KhRgIepa2k3iBbkFuCbxTPT/aqLI+MW -8kR4jXITTgBkDew6DXLVL9SsJup4LeAEizTGyyTBY5bfMJaO8NaB8+uPrkC3SZV+ -r/LIaBcmU3vVfmw43FGzBlJtGflPaL8Ek9lRK1aSzk3Gr7tPdaado9tPAhUAmn4E -HKjL3lXfHzBmDSrrp5G5+IkCggEAFvGRfoL0u3zN4O+8imTxfiSYcFUjBUly4gIl -NXM4AgFmy8WE+diZRh6/3eg+CO0B1io+thmU2sTFAbV7sHVuGaBpPyFtcvrCHGGp -EcqWwmxuhUc1CzeoBvGw4u8mfCBvcUPjFfhllJJFdIgaTrYXFxqgsb6ZKWKsYz9J -jjJkOlRFIlRfowd1RlqodZYYvdvfWnPd32HpI9i/ofhPdlF5W2f51diH/jVJaRCo -TKECwcYG+qkPC5gkIIgzC6/DPRT8pzCLJ0NoWj3TQwL1LffMSmT9hTGAD1iyJjn5 -S9ZLLkz/K+QoGS+Rv4gboMAxa0Cla7R8NwtXqMD0kpeZwDAAgQOCAQYAAoIBAQDw -tDiRJy5DsFNRIaKe6NlyW1gyjYIhbeOCDt5fYMdX7tOR64ng28ACU5ESu6jRANMp -NYjE9oTBx28C0TXXRLDiblHe6IsisKsJJgkNkNc2DwUdPcGoPTRK/MS0k0CQsPQq -cU0Uh/vYXNQ3rsJMAJ0xJ+yYllm3MVQkbZrWlJTe/nU6M8ahiR6WBelrKhzHrhuy -MZ8n+oXvBc/Jo8Z63O/5e94BS0PiGb1Eo84ds6ramno7XJpTXE/nxphBSsaXCwdy -T97rvDzfDG0v0eo9fdX9aL7jPVODDt0bk+MSRdDpcMlgJzhIpNUtafrTUHIkPyKb -/BX9wwwXLfWGTz5TRovi ------END PUBLIC KEY----- diff --git a/TestApplication/English.lproj/InfoPlist.strings b/TestApplication/English.lproj/InfoPlist.strings index e6e21d40..e62659a8 100644 --- a/TestApplication/English.lproj/InfoPlist.strings +++ b/TestApplication/English.lproj/InfoPlist.strings @@ -1,4 +1,3 @@ /* Localized versions of Info.plist keys */ NSHumanReadableCopyright = "© Andy Matuschak, 2006"; -CFBundleShortVersionString = "1.5"; \ No newline at end of file diff --git a/TestApplication/English.lproj/MainMenu.xib b/TestApplication/English.lproj/MainMenu.xib index 5bf06c63..ccd4e02a 100644 --- a/TestApplication/English.lproj/MainMenu.xib +++ b/TestApplication/English.lproj/MainMenu.xib @@ -1,140 +1,44 @@ - + - + - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - + - + - + - - - - - + @@ -153,7 +57,7 @@ - + @@ -338,7 +242,7 @@ - + @@ -348,7 +252,6 @@ - - + diff --git a/TestApplication/SUTestApplicationDelegate.h b/TestApplication/SUTestApplicationDelegate.h new file mode 100644 index 00000000..cbe0710c --- /dev/null +++ b/TestApplication/SUTestApplicationDelegate.h @@ -0,0 +1,13 @@ +// +// SUTestApplicationDelegate.h +// Sparkle +// +// Created by Mayur Pawashe on 7/25/15. +// Copyright (c) 2015 Sparkle Project. All rights reserved. +// + +#import + +@interface SUTestApplicationDelegate : NSObject + +@end diff --git a/TestApplication/SUTestApplicationDelegate.m b/TestApplication/SUTestApplicationDelegate.m new file mode 100644 index 00000000..8b0f1d55 --- /dev/null +++ b/TestApplication/SUTestApplicationDelegate.m @@ -0,0 +1,190 @@ +// +// SUTestApplicationDelegate.m +// Sparkle +// +// Created by Mayur Pawashe on 7/25/15. +// Copyright (c) 2015 Sparkle Project. All rights reserved. +// + +#import "SUTestApplicationDelegate.h" +#import "SUUpdateSettingsWindowController.h" + +@interface SUTestApplicationDelegate () + +@property (nonatomic) SUUpdateSettingsWindowController *updateSettingsWindowController; +@property (nonatomic) NSTask *serverTask; + +@end + +@implementation SUTestApplicationDelegate + +@synthesize updateSettingsWindowController = _updateSettingsWindowController; +@synthesize serverTask = _serverTask; + +static NSString * const UPDATED_VERSION = @"2.0"; + +- (void)applicationDidFinishLaunching:(NSNotification * __unused)notification +{ + NSBundle *mainBundle = [NSBundle mainBundle]; + + // Check if we are already up to date + if ([[mainBundle objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey] isEqualToString:UPDATED_VERSION]) { + NSAlert *alreadyUpdatedAlert = [[NSAlert alloc] init]; + alreadyUpdatedAlert.messageText = @"Update succeeded!"; + alreadyUpdatedAlert.informativeText = @"This is the updated version of Sparkle Test App.\n\nDelete and rebuild the app to test updates again."; + [alreadyUpdatedAlert runModal]; + + [[NSApplication sharedApplication] terminate:nil]; + } + + NSFileManager *fileManager = [NSFileManager defaultManager]; + + // Locate user's cache directory + NSError *cacheError = nil; + NSURL *cacheDirectoryURL = [fileManager URLForDirectory:NSCachesDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:&cacheError]; + + if (cacheDirectoryURL == nil) { + NSLog(@"Failed to locate cache directory with error: %@", cacheError); + assert(NO); + } + + NSString *bundleIdentifier = mainBundle.bundleIdentifier; + assert(bundleIdentifier != nil); + + // Create a directory that'll be used for our web server listing + NSURL *serverDirectoryURL = [cacheDirectoryURL URLByAppendingPathComponent:bundleIdentifier]; + if ([fileManager fileExistsAtPath:serverDirectoryURL.path]) { + NSError *removeServerDirectoryError = nil; + + if (![fileManager removeItemAtURL:serverDirectoryURL error:&removeServerDirectoryError]) { + assert(NO); + } + } + + NSError *createDirectoryError = nil; + if (![fileManager createDirectoryAtURL:serverDirectoryURL withIntermediateDirectories:YES attributes:nil error:&createDirectoryError]) { + NSLog(@"Failed creating directory at %@ with error %@", serverDirectoryURL.path, createDirectoryError); + assert(NO); + } + + NSURL *bundleURL = mainBundle.bundleURL; + assert(bundleURL != nil); + + // Copy main bundle into server directory + NSURL *destinationBundleURL = [serverDirectoryURL URLByAppendingPathComponent:bundleURL.lastPathComponent]; + NSError *copyBundleError = nil; + if (![fileManager copyItemAtURL:bundleURL toURL:destinationBundleURL error:©BundleError]) { + NSLog(@"Failed to copy main bundle into server directory with error %@", copyBundleError); + assert(NO); + } + + // Update bundle's version keys to latest version + NSURL *infoURL = [[destinationBundleURL URLByAppendingPathComponent:@"Contents"] URLByAppendingPathComponent:@"Info.plist"]; + + BOOL infoFileExists = [fileManager fileExistsAtPath:infoURL.path]; + assert(infoFileExists); + + NSMutableDictionary *infoDictionary = [[NSMutableDictionary alloc] initWithContentsOfURL:infoURL]; + infoDictionary[(NSString *)kCFBundleVersionKey] = UPDATED_VERSION; + infoDictionary[@"CFBundleShortVersionString"] = UPDATED_VERSION; + + BOOL wroteInfoFile = [infoDictionary writeToURL:infoURL atomically:NO]; + assert(wroteInfoFile); + + // Change current working directory so web server knows where to list files + BOOL changedCurrentWorkingDirectory = [fileManager changeCurrentDirectoryPath:serverDirectoryURL.path]; + assert(changedCurrentWorkingDirectory); + + // Create the archive for our update + NSString *zipName = @"Sparkle_Test_App.zip"; + NSTask *dittoTask = [[NSTask alloc] init]; + dittoTask.launchPath = @"/usr/bin/ditto"; + dittoTask.arguments = @[@"-c", @"-k", @"--sequesterRsrc", @"--keepParent", destinationBundleURL.lastPathComponent, zipName]; + [dittoTask launch]; + [dittoTask waitUntilExit]; + + assert(dittoTask.terminationStatus == 0); + + [[NSFileManager defaultManager] removeItemAtURL:destinationBundleURL error:NULL]; + + // Don't ever do this at home, kids (seriously) + // (that is, including the private key inside of your application) + NSString *privateKeyPath = [mainBundle pathForResource:@"test_app_only_dsa_priv_dont_ever_do_this_for_real" ofType:@"pem"]; + assert(privateKeyPath != nil); + + // Sign our update + NSTask *signUpdateTask = [[NSTask alloc] init]; + NSString *signUpdatePath = [mainBundle pathForResource:@"sign_update" ofType:@""]; + assert(signUpdatePath != nil); + signUpdateTask.launchPath = signUpdatePath; + + NSURL *archiveURL = [serverDirectoryURL URLByAppendingPathComponent:zipName]; + signUpdateTask.arguments = @[archiveURL, privateKeyPath]; + + NSPipe *outputPipe = [NSPipe pipe]; + signUpdateTask.standardOutput = outputPipe; + + [signUpdateTask launch]; + [signUpdateTask waitUntilExit]; + + assert(signUpdateTask.terminationStatus == 0); + + NSData *signatureData = [outputPipe.fileHandleForReading readDataToEndOfFile]; + NSString *signature = [[[NSString alloc] initWithData:signatureData encoding:NSUTF8StringEncoding] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + + assert(signature != nil); + + // Obtain the file attributes to get the file size of our update later + NSError *fileAttributesError = nil; + NSDictionary *archiveFileAttributes = [fileManager attributesOfItemAtPath:archiveURL.path error:&fileAttributesError]; + if (archiveFileAttributes == nil) { + NSLog(@"Failed to retrieve file attributes from archive with error %@", fileAttributesError); + assert(NO); + } + + NSString * const appcastName = @"sparkletestcast"; + NSString * const appcastExtension = @"xml"; + + // Copy our appcast over to the server directory + NSURL *appcastDestinationURL = [[serverDirectoryURL URLByAppendingPathComponent:appcastName] URLByAppendingPathExtension:appcastExtension]; + NSError *copyAppcastError = nil; + if (![fileManager copyItemAtURL:[mainBundle URLForResource:appcastName withExtension:appcastExtension] toURL:appcastDestinationURL error:©AppcastError]) { + NSLog(@"Failed to copy appcast into cache directory with error %@", copyAppcastError); + assert(NO); + } + + // Update the appcast with the file size and signature of the update archive + // We could be using some sort of XML parser instead of doing string substitutions, but for now, this is easier + NSError *appcastError = nil; + NSMutableString *appcastContents = [[NSMutableString alloc] initWithContentsOfURL:appcastDestinationURL encoding:NSUTF8StringEncoding error:&appcastError]; + if (appcastContents == nil) { + NSLog(@"Failed to load appcast contents with error %@", appcastError); + assert(NO); + } + + NSUInteger numberOfLengthReplacements = [appcastContents replaceOccurrencesOfString:@"$INSERT_ARCHIVE_LENGTH" withString:[NSString stringWithFormat:@"%llu", archiveFileAttributes.fileSize] options:NSLiteralSearch range:NSMakeRange(0, appcastContents.length)]; + assert(numberOfLengthReplacements == 1); + + NSUInteger numberOfSignatureReplacements = [appcastContents replaceOccurrencesOfString:@"$INSERT_DSA_SIGNATURE" withString:signature options:NSLiteralSearch range:NSMakeRange(0, appcastContents.length)]; + assert(numberOfSignatureReplacements == 1); + + NSError *writeAppcastError = nil; + if (![appcastContents writeToURL:appcastDestinationURL atomically:NO encoding:NSUTF8StringEncoding error:&writeAppcastError]) { + NSLog(@"Failed to write updated appcast with error %@", writeAppcastError); + assert(NO); + } + + // Finally start the server + self.serverTask = [NSTask launchedTaskWithLaunchPath:@"/usr/bin/python" arguments:@[@"-m", @"SimpleHTTPServer", @"1337"]]; + + // Show the Settings window + self.updateSettingsWindowController = [[SUUpdateSettingsWindowController alloc] init]; + [self.updateSettingsWindowController showWindow:nil]; +} + +- (void)applicationWillTerminate:(NSNotification * __unused)notification +{ + [self.serverTask terminate]; +} + +@end diff --git a/TestApplication/SUUpdateSettingsWindowController.h b/TestApplication/SUUpdateSettingsWindowController.h new file mode 100644 index 00000000..f209eadc --- /dev/null +++ b/TestApplication/SUUpdateSettingsWindowController.h @@ -0,0 +1,13 @@ +// +// SUUpdateSettingsWindowController.h +// Sparkle +// +// Created by Mayur Pawashe on 7/25/15. +// Copyright (c) 2015 Sparkle Project. All rights reserved. +// + +#import + +@interface SUUpdateSettingsWindowController : NSWindowController + +@end diff --git a/TestApplication/SUUpdateSettingsWindowController.m b/TestApplication/SUUpdateSettingsWindowController.m new file mode 100644 index 00000000..3d651044 --- /dev/null +++ b/TestApplication/SUUpdateSettingsWindowController.m @@ -0,0 +1,32 @@ +// +// SUUpdateSettingsWindowController.m +// Sparkle +// +// Created by Mayur Pawashe on 7/25/15. +// Copyright (c) 2015 Sparkle Project. All rights reserved. +// + +#import "SUUpdateSettingsWindowController.h" +#import + +@interface SUUpdateSettingsWindowController () + +@property (nonatomic) IBOutlet SUUpdater *updater; + +@end + +@implementation SUUpdateSettingsWindowController + +@synthesize updater = _updater; + +- (NSString *)windowNibName +{ + return NSStringFromClass([self class]); +} + +- (IBAction)checkForUpdates:(id __unused)sender +{ + [self.updater checkForUpdates:nil]; +} + +@end diff --git a/TestApplication/SUUpdateSettingsWindowController.xib b/TestApplication/SUUpdateSettingsWindowController.xib new file mode 100644 index 00000000..99d04aef --- /dev/null +++ b/TestApplication/SUUpdateSettingsWindowController.xib @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TestApplication/TestApplication-Info.plist b/TestApplication/TestApplication-Info.plist index 7f99a9f0..45b0254b 100644 --- a/TestApplication/TestApplication-Info.plist +++ b/TestApplication/TestApplication-Info.plist @@ -18,6 +18,8 @@ ???? CFBundleVersion 1.5 + CFBundleShortVersionString + 1.5 NSMainNibFile MainMenu NSPrincipalClass @@ -25,21 +27,13 @@ SUEnableSystemProfiling SUFeedURL - http://sparkle-project.org/files/sparkletestcast.xml + http://0.0.0.0:1337/sparkletestcast.xml SUPublicDSAKeyFile test_app_only_dsa_pub.pem NSAppTransportSecurity - NSExceptionDomains - - sparkle-project.org - - NSIncludesSubdomains - - NSTemporaryExceptionAllowsInsecureHTTPLoads - - - + NSAllowsArbitraryLoads + diff --git a/TestApplication/sparkletestcast.xml b/TestApplication/sparkletestcast.xml new file mode 100644 index 00000000..670d606c --- /dev/null +++ b/TestApplication/sparkletestcast.xml @@ -0,0 +1,23 @@ + + + + Sparkle Test App Changelog + Most recent changes with links to updates. + en + + Version 2.0 + + +
  • Lorem ipsum dolor sit amet, consectetur adipiscing elit.
  • +
  • Suspendisse sed felis ac ante ultrices rhoncus. Etiam quis elit vel nibh placerat facilisis in id leo.
  • +
  • Vestibulum nec tortor odio, nec malesuada libero. Cras vel convallis nunc.
  • +
  • Suspendisse tristique massa eget velit consequat tincidunt. Praesent sodales hendrerit pretium.
  • + + ]]> +
    + Sat, 26 Jul 2014 15:20:11 +0000 + +
    +
    +
    diff --git a/TestApplication/test_app_only_dsa_priv_dont_ever_do_this_for_real.pem b/TestApplication/test_app_only_dsa_priv_dont_ever_do_this_for_real.pem new file mode 100644 index 00000000..42efc795 --- /dev/null +++ b/TestApplication/test_app_only_dsa_priv_dont_ever_do_this_for_real.pem @@ -0,0 +1,36 @@ +-----BEGIN D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SRRGICFBi3 +z3tWjm2F6noctsjrVH5d0jRZ +-----END DSA PRIVATE KEY----- diff --git a/TestApplication/test_app_only_dsa_pub.pem b/TestApplication/test_app_only_dsa_pub.pem index dacd55e9..8e54f1b3 100644 --- a/TestApplication/test_app_only_dsa_pub.pem +++ b/TestApplication/test_app_only_dsa_pub.pem @@ -1,20 +1,36 @@ -----BEGIN PUBLIC KEY----- -MIIDOzCCAi0GByqGSM44BAEwggIgAoIBAQD2WbLx8Bd1b1vp8FdDpSzkHZ0tlX5x -Hrzm0WWE9IokOmJw/UWk1GQYRJnA8UlufFTJV4dZVL3It4xwqqWWFyN36LWgQUpf -ss9eTn7M7vjk7BVYch7QMs4jGEnSYkebuYfVhUZlg5VViQ+37Rj+ENtBUrkPJxIY -CGAOIJn45uX5oNIPbElFkadU6m7zd1gn8KhRgIepa2k3iBbkFuCbxTPT/aqLI+MW -8kR4jXITTgBkDew6DXLVL9SsJup4LeAEizTGyyTBY5bfMJaO8NaB8+uPrkC3SZV+ -r/LIaBcmU3vVfmw43FGzBlJtGflPaL8Ek9lRK1aSzk3Gr7tPdaado9tPAhUAmn4E -HKjL3lXfHzBmDSrrp5G5+IkCggEAFvGRfoL0u3zN4O+8imTxfiSYcFUjBUly4gIl -NXM4AgFmy8WE+diZRh6/3eg+CO0B1io+thmU2sTFAbV7sHVuGaBpPyFtcvrCHGGp -EcqWwmxuhUc1CzeoBvGw4u8mfCBvcUPjFfhllJJFdIgaTrYXFxqgsb6ZKWKsYz9J -jjJkOlRFIlRfowd1RlqodZYYvdvfWnPd32HpI9i/ofhPdlF5W2f51diH/jVJaRCo -TKECwcYG+qkPC5gkIIgzC6/DPRT8pzCLJ0NoWj3TQwL1LffMSmT9hTGAD1iyJjn5 -S9ZLLkz/K+QoGS+Rv4gboMAxa0Cla7R8NwtXqMD0kpeZwDAAgQOCAQYAAoIBAQDw -tDiRJy5DsFNRIaKe6NlyW1gyjYIhbeOCDt5fYMdX7tOR64ng28ACU5ESu6jRANMp -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