diff --git a/CHANGELOG b/CHANGELOG index d8896f4a..97b5f3be 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,21 @@ +# 1.11.0 + +* Big improvements to code signing and DSA verification + - Sparkle now checks not only whether an update is correctly signed, but also whether the updated version will be able to verify future updates. Updates now must either use DSA keys correctly, or not try to use them at all. Same goes for Apple Code Signing. + - Rely on code signing and the DSA key in the new app instead of appcast. If the new app has a public DSA key, then the appcast item must have a DSA signature for the app, even if the app is code signed. (Zorg) +* More verbose error message when DSA keys don't match (Kornel Lesiński) +* Added delegate methods for pre-download and immediately post-failed-download (Isaac Greenspan) +* Fix Lucida Grande is always used for release notes (LIU Dongyuan / 柳东原) +* Only remove quarantine with setResourceValue: when it's present. Fixes "Unable to quarantine: 93" messages from showing up in the console. (Zorg) +* Fixed const and nullability warnings (Jake Petroules, Kornel Lesiński) +* Replaced deprecated NSRunAlertPanel/alertWithMessageText (Kevin Wojniak) +* Imported the Foundation umbrella header in all the public headers (C.W. Betts) +* pt-BR localization update (Victor Figueiredo) +* Reject unsupported code-signing xattrs in binary delta (Zorg) +* Fixed crash while applying delta update (antonc27) +* Added logging of appcast/download URL on error (Kornel Lesiński) +* More robust reading of Autoupdate.app path from Sparkle bundle + # 1.10.0 * Massive improvements to the BinaryDelta tool (Zorg) diff --git a/Configurations/ConfigCommon.xcconfig b/Configurations/ConfigCommon.xcconfig index 21b6ad27..b8e6a447 100644 --- a/Configurations/ConfigCommon.xcconfig +++ b/Configurations/ConfigCommon.xcconfig @@ -15,7 +15,7 @@ SPARKLE_AUTOMATED_DOWNGRADES = 0 SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0 SPARKLE_VERSION_MAJOR = 1 -SPARKLE_VERSION_MINOR = 10 +SPARKLE_VERSION_MINOR = 11 SPARKLE_VERSION_PATCH = 0 SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH) @@ -31,8 +31,10 @@ MACOSX_DEPLOYMENT_TARGET = 10.7 PRODUCT_NAME = ${TARGET_NAME} PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier} -GCC_PREPROCESSOR_DEFINITIONS = SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" +GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_AUTOMATED_DOWNGRADES=$(SPARKLE_AUTOMATED_DOWNGRADES) SPARKLE_APPEND_VERSION_NUMBER=$(SPARKLE_APPEND_VERSION_NUMBER) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" + CLANG_ENABLE_OBJC_ARC = YES +GCC_ENABLE_PASCAL_STRINGS = NO // Enable warnings CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES @@ -77,6 +79,10 @@ GCC_WARN_UNUSED_LABEL = YES GCC_WARN_UNUSED_PARAMETER = YES GCC_WARN_UNUSED_VARIABLE = YES +// Fixes a strange issue where the compiler thinks references to some enums are ambiguous +CLANG_ENABLE_MODULES[sdk=macosx10.7] = NO +CLANG_ENABLE_MODULES[sdk=macosx10.8] = NO + // These should be removed once the conversion to ARC is complete WARNING_CFLAGS_EXTRA = -Wno-custom-atomic-properties -Wno-implicit-atomic-properties diff --git a/Configurations/ConfigCommonDebug.xcconfig b/Configurations/ConfigCommonDebug.xcconfig index 53972350..824b79b3 100644 --- a/Configurations/ConfigCommonDebug.xcconfig +++ b/Configurations/ConfigCommonDebug.xcconfig @@ -6,7 +6,6 @@ GCC_OPTIMIZATION_LEVEL = 0 DEBUG_INFORMATION_FORMAT = dwarf ENABLE_TESTABILITY = YES GCC_GENERATE_DEBUGGING_SYMBOLS = YES -SPARKLE_EXTRA_DEBUG = -DDEBUG -OTHER_CFLAGS = $(SPARKLE_EXTRA_DEBUG) +GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON) DEBUG=1 ONLY_ACTIVE_ARCH = YES COPY_PHASE_STRIP = NO diff --git a/Configurations/ConfigCommonRelease.xcconfig b/Configurations/ConfigCommonRelease.xcconfig index acffc466..0888aaff 100644 --- a/Configurations/ConfigCommonRelease.xcconfig +++ b/Configurations/ConfigCommonRelease.xcconfig @@ -5,6 +5,7 @@ GCC_OPTIMIZATION_LEVEL = s DEBUG_INFORMATION_FORMAT = dwarf-with-dsym GCC_GENERATE_DEBUGGING_SYMBOLS = YES +GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS_COMMON) DEAD_CODE_STRIPPING = YES GCC_TREAT_WARNINGS_AS_ERRORS = NO GCC_WARN_UNINITIALIZED_AUTOS = YES diff --git a/Makefile b/Makefile index 6912bdda..f23423c2 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,10 @@ 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 ; \ + xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Debug test || exit 1 ; \ fi ; \ done + +check-localizations: + ./Sparkle/CheckLocalizations.swift -root . -htmlPath "$(TMPDIR)/LocalizationsReport.htm" + open "$(TMPDIR)/LocalizationsReport.htm" diff --git a/README.markdown b/README.markdown index 62e7dc20..929dd1e9 100644 --- a/README.markdown +++ b/README.markdown @@ -6,13 +6,14 @@ An easy-to-use software update framework for Cocoa developers. ## Changes since 1.5b -* Up-to-date with 10.10 SDK and Xcode 6. Supports OS X 10.7+. +* Up-to-date with 10.11 SDK and Xcode 7. Supports OS X 10.7+. * Cleaned up and modernized code, using ARC and Autolayout. * Merged bugfixes, security fixes and some features from multiple Sparkle forks. * Truly automatic background updates (no UI at all) when user agreed to "Automatically download and install updates in the future." * Ability to mark updates as critical. * Progress and status notifications for the host app. * Name of finish_installation.app can be configured to match your app's name. +* Upgraded and more reliable binary delta and code signing verification. ## Features diff --git a/Resources/SUModelTranslation.plist b/Resources/SUModelTranslation.plist index 74db0ff0..35eb74c0 100644 --- a/Resources/SUModelTranslation.plist +++ b/Resources/SUModelTranslation.plist @@ -16,6 +16,8 @@ iMac (Core 2 Duo, 17 inch, Combo Drive) iMac6,1 iMac (Core 2 Duo, 24 inch, SuperDrive) + iMac7,1 + iMac Intel Core 2 Duo (aluminum enclosure) iMac8,1 iMac (Core 2 Duo, 20 or 24 inch, Early 2008 ) iMac9,1 @@ -25,7 +27,7 @@ iMac11,1 iMac (Core i5 or i7, 27 inch Late 2009) iMac11,2 - iMac (Core i3 or i5, 27 inch Mid 2010) + 21.5" iMac (mid 2010) iMac11,3 iMac (Core i5 or i7, 27 inch Mid 2010) iMac12,1 @@ -42,6 +44,10 @@ iMac (Core i5 or i7, 27 inch Late 2013) iMac14,3 iMac (Core i5 or i7, 21.5 inch Late 2013) + iMac14,4 + iMac (Core i5, 21.5 inch Mid 2014) + iMac15,1 + iMac (Retina 5K Core i5 or i7, 27 inch 2014 or 2015) MacBook1,1 MacBook (Core Duo) MacBook2,1 @@ -56,6 +62,8 @@ MacBook (Core 2 Duo, Late 2009, Unibody) MacBook7,1 MacBook (Core 2 Duo, Mid 2010, White) + MacBook8,1 + MacBook (Core M, 12 inch, Early 2015) MacBookAir1,1 MacBook Air (Core 2 Duo, 13 inch, Early 2008) MacBookAir2,1 @@ -76,6 +84,10 @@ MacBook Air (Core i5 or i7, 11 inch, Mid 2013 or Early 2014) MacBookAir6,2 MacBook Air (Core i5 or i7, 13 inch, Mid 2013 or Early 2014) + MacBookAir7,1 + MacBook Air (Core i5 or i7, 11 inch, Early 2015) + MacBookAir7,2 + MacBook Air (Core i5 or i7, 13 inch, Early 2015) MacBookPro1,1 MacBook Pro Core Duo (15-inch) MacBookPro1,2 @@ -90,8 +102,70 @@ MacBook Pro Core 2 Duo (17-inch HD, Core 2 Duo) MacBookPro4,1 MacBook Pro (Core 2 Duo Feb 2008) + MacBookPro5,1 + MacBook Pro Intel Core 2 Duo (aluminum unibody) + MacBookPro5,2 + MacBook Pro Intel Core 2 Duo (aluminum unibody) + MacBookPro5,3 + MacBook Pro Intel Core 2 Duo (aluminum unibody) + MacBookPro5,4 + MacBook Pro Intel Core 2 Duo (aluminum unibody) + MacBookPro5,5 + MacBook Pro Intel Core 2 Duo (aluminum unibody) + MacBookPro6,1 + MacBook Pro Intel Core i5, Intel Core i7 (mid 2010) + MacBookPro6,2 + MacBook Pro Intel Core i5, Intel Core i7 (mid 2010) + MacBookPro7,1 + MacBook Pro Intel Core 2 Duo (mid 2010) + MacBookPro8,1 + MacBook Pro Intel Core i5, Intel Core i7, 13" (early 2011) + MacBookPro8,2 + MacBook Pro Intel Core i7, 15" (early 2011) + MacBookPro8,3 + MacBook Pro Intel Core i7, 17" (early 2011) + MacBookPro9,1 + MacBook Pro (15-inch, Mid 2012) + MacBookPro9,2 + MacBook Pro (13-inch, Mid 2012) + MacBookPro10,1 + MacBook Pro (Retina, Mid 2012) + MacBookPro10,2 + MacBook Pro (Retina, 13-inch, Late 2012) + MacBookPro11,1 + MacBook Pro (Retina, 13-inch, Late 2013) + MacBookPro11,2 + MacBook Pro (Retina, 15-inch, Late 2013) + MacBookPro11,3 + MacBook Pro (Retina, 15-inch, Late 2013) + MacbookPro11,4 + MacBook Pro (Retina, 15-inch, Mid 2015) + MacbookPro11,5 + MacBook Pro (Retina, 15-inch, Mid 2015) + MacbookPro12,1  + MacBook Pro (Retina, 13-inch, Early 2015) Macmini1,1 Mac Mini (Core Solo/Duo) + Macmini2,1 + Mac mini Intel Core + Macmini3,1 + Mac mini Intel Core + Macmini4,1 + Mac mini Intel Core (Mid 2010) + Macmini5,1 + Mac mini (Core i5, Mid 2011) + Macmini5,2 + Mac mini (Core i5 or Core i7, Mid 2011) + Macmini5,3 + Mac mini (Core i7, Server, Mid 2011) + Macmini6,1 + Mac mini (Core i5, Late 2012) + Macmini6,2 + Mac mini (Core i7, Normal or Server, Late 2012) + Macmini7,1 + Mac mini (Core i5 or Core i7, Late 2014) + MacPro1,1,Quad + Mac Pro MacPro1,1 Mac Pro (four-core) MacPro2,1 @@ -101,7 +175,9 @@ MacPro4,1 Mac Pro (March 2009) MacPro5,1 - Mac Pro (August 2010) + Mac Pro (2010 or 2012) + MacPro6,1 + Mac Pro (Late 2013) PowerBook1,1 PowerBook G3 PowerBook2,1 @@ -164,14 +240,6 @@ Power Macintosh G3 (Blue & White) PowerMac1,2 Power Macintosh G4 (PCI Graphics) - PowerMac10,1 - Mac Mini G4 - PowerMac10,2 - Mac Mini (Late 2005) - PowerMac11,2 - Power Macintosh G5 (Late 2005) - PowerMac12,1 - iMac G5 (iSight) PowerMac2,1 iMac G3 (Slot-loading CD-ROM) PowerMac2,2 @@ -198,6 +266,8 @@ iMac G4 (17-inch Flat Panel) PowerMac5,1 Power Macintosh G4 Cube + PowerMac5,2 + Power Mac G4 Cube PowerMac6,1 iMac G4 (USB 2.0) PowerMac6,3 @@ -214,6 +284,14 @@ iMac G5 (Ambient Light Sensor) PowerMac9,1 Power Macintosh G5 (Late 2005) + PowerMac10,1 + Mac Mini G4 + PowerMac10,2 + Mac Mini (Late 2005) + PowerMac11,2 + Power Macintosh G5 (Late 2005) + PowerMac12,1 + iMac G5 (iSight) RackMac1,1 Xserve G4 RackMac1,2 @@ -224,5 +302,7 @@ Xserve (Intel Xeon) Xserve2,1 Xserve (January 2008 quad-core) + Xserve3,1 + Xserve (early 2009) diff --git a/Resources/Sparkle-Icon.psd b/Resources/Sparkle-Icon.psd new file mode 100644 index 00000000..7097a190 Binary files /dev/null and b/Resources/Sparkle-Icon.psd differ diff --git a/Sparkle.podspec b/Sparkle.podspec index 9c309f5a..e4aaf773 100644 --- a/Sparkle.podspec +++ b/Sparkle.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "Sparkle" - s.version = "1.10.0" + s.version = "1.11.0" s.summary = "A software update framework for OS X" s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers." s.homepage = "http://sparkle-project.org" diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index a488a3ff..8f116790 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -28,7 +28,7 @@ 1420DF50196247F900203BB0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1420DF4F196247F900203BB0 /* Images.xcassets */; }; 1420DF51196247F900203BB0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1420DF4F196247F900203BB0 /* Images.xcassets */; }; 142E0E0019A6954400E4312B /* Sparkle.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 142E0E0219A6A14700E4312B /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 142E0E0219A6A14700E4312B /* Sparkle.framework in Copy Files */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 142E0E0419A6A26F00E4312B /* Autoupdate.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = 55C14BB7136EEF1500649790 /* Autoupdate.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 142E0E0919A83AAC00E4312B /* SUBinaryDeltaTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 142E0E0819A83AAC00E4312B /* SUBinaryDeltaTest.m */; }; 14652F7C19A9725300959E44 /* SUBinaryDeltaCommon.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8E20FD68CC7005AE3F6 /* SUBinaryDeltaCommon.m */; }; @@ -376,14 +376,15 @@ /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ - 142E0E0119A6A13300E4312B /* CopyFiles */ = { + 142E0E0119A6A13300E4312B /* Copy Files */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = ""; dstSubfolderSpec = 10; files = ( - 142E0E0219A6A14700E4312B /* Sparkle.framework in CopyFiles */, + 142E0E0219A6A14700E4312B /* Sparkle.framework in Copy Files */, ); + name = "Copy Files"; runOnlyForDeploymentPostprocessing = 0; }; 142E0E0319A6A24100E4312B /* CopyFiles */ = { @@ -444,10 +445,14 @@ 14732BBC1960EFB500593899 /* README.markdown */ = {isa = PBXFileReference; lastKnownFileType = text; path = README.markdown; sourceTree = SOURCE_ROOT; }; 14732BBF1960F0AC00593899 /* test_app_only_dsa_pub.pem */ = {isa = PBXFileReference; lastKnownFileType = text; path = test_app_only_dsa_pub.pem; sourceTree = ""; }; 14732BC11960F3B200593899 /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = SOURCE_ROOT; usesTabs = 1; }; - 14732BC31960F3FF00593899 /* generate_keys.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = generate_keys.sh; sourceTree = ""; }; - 14732BC41960F3FF00593899 /* sign_update.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = sign_update.sh; sourceTree = ""; }; + 14732BC31960F3FF00593899 /* generate_keys */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = generate_keys; sourceTree = ""; }; + 14732BC41960F3FF00593899 /* sign_update */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = sign_update; sourceTree = ""; }; 14732BC91960F70A00593899 /* make-release-package.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "make-release-package.sh"; sourceTree = ""; }; 14732BD219610A1800593899 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; + 147D6D9E1B66DC3C006607AB /* CheckLocalizations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = CheckLocalizations.swift; path = Sparkle/CheckLocalizations.swift; sourceTree = SOURCE_ROOT; }; + 147D6DA71B66EC1C006607AB /* ca */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ca; path = ca.lproj/Sparkle.strings; sourceTree = ""; }; + 147D6DA91B66EC22006607AB /* fi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fi; path = fi.lproj/Sparkle.strings; sourceTree = ""; }; + 147D6DAA1B66EC25006607AB /* he */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = he; path = he.lproj/Sparkle.strings; sourceTree = ""; }; 14950074195FDF5900BC5B5B /* SUUpdaterTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUpdaterTest.m; sourceTree = ""; usesTabs = 0; }; 14958C6B19AEBC530061B14F /* signed-test-file.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "signed-test-file.txt"; sourceTree = ""; }; 14958C6C19AEBC610061B14F /* test-pubkey.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "test-pubkey.pem"; sourceTree = ""; }; @@ -901,6 +906,7 @@ isa = PBXGroup; children = ( 14732BC21960F3FF00593899 /* bin */, + 147D6D9E1B66DC3C006607AB /* CheckLocalizations.swift */, 14732BBA1960EF7100593899 /* CHANGELOG */, 61C268090E2DB5D000175E6C /* LICENSE */, 14732BC11960F3B200593899 /* Makefile */, @@ -915,8 +921,8 @@ 14732BC21960F3FF00593899 /* bin */ = { isa = PBXGroup; children = ( - 14732BC31960F3FF00593899 /* generate_keys.sh */, - 14732BC41960F3FF00593899 /* sign_update.sh */, + 14732BC31960F3FF00593899 /* generate_keys */, + 14732BC41960F3FF00593899 /* sign_update */, ); path = bin; sourceTree = SOURCE_ROOT; @@ -1398,8 +1404,7 @@ 612279D50DB5470200AB99EA /* Sources */, 612279D60DB5470200AB99EA /* Frameworks */, 14958C6D19AEBC890061B14F /* Resources */, - 142E0E0119A6A13300E4312B /* CopyFiles */, - 612279D70DB5470200AB99EA /* ShellScript */, + 142E0E0119A6A13300E4312B /* Copy Files */, ); buildRules = ( ); @@ -1655,20 +1660,6 @@ shellPath = /bin/sh; shellScript = "IFS=$(echo -en \"\\n\\b\")\nRESOURCES_PATHS=(\n \"${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}\"\n \"${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/${SPARKLE_RELAUNCH_TOOL_NAME}.app/Contents/Resources\"\n \"${BUILT_PRODUCTS_DIR}/com.devmate.UpdateInstaller.xpc/Contents/Resources\")\n\nfor RESOURCES_PATH in \"${RESOURCES_PATHS[@]}\"\ndo\n echo \"Correcting... ${RESOURCES_PATH}\"\n if [ -e \"${RESOURCES_PATH}/pt_BR.lproj\" ]; then\n rm -Rf \"${RESOURCES_PATH}/pt-BR.lproj\"\n mv -f \"${RESOURCES_PATH}/pt_BR.lproj\" \"${RESOURCES_PATH}/pt-BR.lproj\"\n fi\n\n if [ -e \"${RESOURCES_PATH}/zh_CN.lproj\" ]; then\n rm -Rf \"${RESOURCES_PATH}/zh-Hans.lproj\"\n mv -f \"${RESOURCES_PATH}/zh_CN.lproj\" \"${RESOURCES_PATH}/zh-Hans.lproj\"\n fi\n\n if [ -e \"${RESOURCES_PATH}/zh_TW.lproj\" ]; then\n rm -Rf \"${RESOURCES_PATH}/zh-Hant-TW.lproj\"\n mv -f \"${RESOURCES_PATH}/zh_TW.lproj\" \"${RESOURCES_PATH}/zh-Hant-TW.lproj\"\n fi\ndone\n\n"; }; - 612279D70DB5470200AB99EA /* ShellScript */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; - showEnvVarsInLog = 0; - }; 6131B1910DDCDE32005215F0 /* Run Script: Set Git Version Info */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 12; @@ -2116,6 +2107,9 @@ 0263187214FEBB31005EBF43 /* uk */, 61131A090F846D0A00E97AF6 /* zh_CN */, 61131A0A0F846D1100E97AF6 /* zh_TW */, + 147D6DA71B66EC1C006607AB /* ca */, + 147D6DA91B66EC22006607AB /* fi */, + 147D6DAA1B66EC25006607AB /* he */, ); name = Sparkle.strings; sourceTree = ""; diff --git a/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme b/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme index 5ea1b73a..7a051ea2 100644 --- a/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme +++ b/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme @@ -23,10 +23,10 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -52,11 +52,11 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -52,11 +52,11 @@ Bool in + return s1 < s2 + } + missing.sort(sorter) + unlocalized.sort(sorter) + unused.sort(sorter) + + let addRow = { (prefix: String, cssClass: String, key: String) -> Void in + body.addChild(NSXMLElement(name: "span", attributes: ["class": cssClass], stringValue: " ".join([prefix, key]) + "\n")) + } + + for key in missing { + addRow("Missing", "missing", key) + } + for key in unlocalized { + addRow("Unlocalized", "unlocalized", key) + } + for key in unused { + addRow("Unused", "unused", key) + } +} + +var err: NSError? +if !html.XMLData.writeToFile(htmlPath!, atomically: true) { + die("Can't write report: \(err)") +} diff --git a/Sparkle/Installation XPC Service/SUInstallServiceConstants.h b/Sparkle/Installation XPC Service/SUInstallServiceConstants.h index 3b5a1491..105274ef 100644 --- a/Sparkle/Installation XPC Service/SUInstallServiceConstants.h +++ b/Sparkle/Installation XPC Service/SUInstallServiceConstants.h @@ -22,7 +22,7 @@ static const char * SUInstallServiceTaskTypeKey = "task_type"; // int64_t // SUInstallServiceTaskCopyPath & SUInstallServiceTaskAuthCopyPath keys static const char * SUInstallServiceSourcePathKey = "source_path"; // c-string static const char * SUInstallServiceDestinationPathKey = "destination_path"; // c-string -static const char * SUInstallServiceTempNameKey = "tmp_name"; // c-string +static const char * SUInstallServiceAppendVersionKey = "append_version"; // bool // SUInstallServiceTaskLaunchTask keys static const char * SUInstallServiceLaunchTaksPathKey = "launch_task_path"; diff --git a/Sparkle/Installation XPC Service/SUXPCInstaller.h b/Sparkle/Installation XPC Service/SUXPCInstaller.h index 2b64a666..c2a920b4 100644 --- a/Sparkle/Installation XPC Service/SUXPCInstaller.h +++ b/Sparkle/Installation XPC Service/SUXPCInstaller.h @@ -11,9 +11,9 @@ @interface SUXPCInstaller : NSObject -+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)tmp error:(NSError **)outError; ++ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst appendVersion:(BOOL)appendVersion error:(NSError *__autoreleasing *)outError; -+ (BOOL)copyPathContent:(NSString *)src toDirectory:(NSString *)dstDir error:(NSError **)outError; // dstDir will be created if absent ++ (BOOL)copyPathContent:(NSString *)src toDirectory:(NSString *)dstDir error:(NSError *__autoreleasing *)outError; // dstDir will be created if absent + (void)launchTaskWithLaunchPath:(NSString *)path arguments:(NSArray *)arguments; diff --git a/Sparkle/Installation XPC Service/SUXPCInstaller.m b/Sparkle/Installation XPC Service/SUXPCInstaller.m index cbde9ffb..a7542b59 100644 --- a/Sparkle/Installation XPC Service/SUXPCInstaller.m +++ b/Sparkle/Installation XPC Service/SUXPCInstaller.m @@ -54,7 +54,7 @@ BOOL SUShouldUseXPCInstaller(void) return (serviceConnection); } -+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)tmp error:(NSError * __autoreleasing*)outError ++ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst appendVersion:(BOOL)appendVersion error:(NSError *__autoreleasing *)outError { xpc_connection_t connection = [self getSandboxXPCService]; @@ -65,8 +65,7 @@ BOOL SUShouldUseXPCInstaller(void) xpc_dictionary_set_string(message, SUInstallServiceSourcePathKey, [src fileSystemRepresentation]); if (dst) xpc_dictionary_set_string(message, SUInstallServiceDestinationPathKey, [dst fileSystemRepresentation]); - if (tmp) - xpc_dictionary_set_string(message, SUInstallServiceTempNameKey, [tmp UTF8String]); + xpc_dictionary_set_bool(message, SUInstallServiceAppendVersionKey, appendVersion ? true : false); __block BOOL xpcDidReply = NO; __block NSError *error = nil; diff --git a/Sparkle/Installation XPC Service/install_service.m b/Sparkle/Installation XPC Service/install_service.m index a10cf74f..a459cb88 100644 --- a/Sparkle/Installation XPC Service/install_service.m +++ b/Sparkle/Installation XPC Service/install_service.m @@ -126,14 +126,13 @@ static xpc_object_t SUISCopyPathWithAuthentication(xpc_object_t message) const char *src = xpc_dictionary_get_string(message, SUInstallServiceSourcePathKey); const char *dst = xpc_dictionary_get_string(message, SUInstallServiceDestinationPathKey); - const char *tmp = xpc_dictionary_get_string(message, SUInstallServiceTempNameKey); + bool appendVersion = xpc_dictionary_get_bool(message, SUInstallServiceAppendVersionKey); NSFileManager *manager = [NSFileManager defaultManager]; NSString *relaunchPathToCopy = src ? [manager stringWithFileSystemRepresentation:src length:strlen(src)] : nil; NSString *targetPath = dst ? [manager stringWithFileSystemRepresentation:dst length:strlen(dst)] : nil; - NSString *temporaryName = tmp ? [NSString stringWithUTF8String:tmp] : nil; NSError *error = nil; - BOOL result = [SUPlainInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath temporaryName:temporaryName error:&error]; + BOOL result = [SUPlainInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath appendVersion:appendVersion error:&error]; // send response to indicate ok xpc_object_t reply = xpc_dictionary_create_reply(message); diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 818a3e0a..44d5594c 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -442,11 +442,12 @@ CF_EXPORT CFDictionaryRef DMCopyHTTPRequestHeaders(CFBundleRef appBundle, CFData [updaterDelegate updater:self.updater willInstallUpdate:self.updateItem]; } - NSBundle *sparkleBundle = [NSBundle bundleWithIdentifier:SUBundleIdentifier]; + NSBundle *sparkleBundle = self.updater.sparkleBundle; // 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 *const relaunchPathToCopy = [sparkleBundle pathForResource:[[sparkleBundle infoDictionary] objectForKey:SURelaunchToolNameKey] ofType:@"app"]; + NSString *const relaunchToolName = @"" SPARKLE_RELAUNCH_TOOL_NAME; + NSString *const relaunchPathToCopy = [sparkleBundle pathForResource:relaunchToolName ofType:@"app"]; if (relaunchPathToCopy != nil) { NSString *targetPath = [self.host.appCachePath stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]]; // Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems. @@ -456,11 +457,11 @@ CF_EXPORT CFDictionaryRef DMCopyHTTPRequestHeaders(CFBundleRef appBundle, CFData BOOL copySuccess = NO; if (SUShouldUseXPCInstaller()) { - copySuccess = [SUXPCInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath temporaryName:nil error:&error]; + copySuccess = [SUXPCInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath appendVersion:SPARKLE_APPEND_VERSION_NUMBER error:&error]; } else { - copySuccess = [SUPlainInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath temporaryName:nil error:&error]; + copySuccess = [SUPlainInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath appendVersion:SPARKLE_APPEND_VERSION_NUMBER error:&error]; } if (copySuccess) { self.relaunchPath = targetPath; diff --git a/Sparkle/SUCodeSigningVerifier.m b/Sparkle/SUCodeSigningVerifier.m index df55265f..badbbd9a 100644 --- a/Sparkle/SUCodeSigningVerifier.m +++ b/Sparkle/SUCodeSigningVerifier.m @@ -52,7 +52,7 @@ // Note that kSecCSCheckNestedCode may not work with pre-Mavericks code signing. // See https://github.com/sparkle-project/Sparkle/issues/376#issuecomment-48824267 and https://developer.apple.com/library/mac/technotes/tn2206 - SecCSFlags flags = kSecCSDefaultFlags | kSecCSCheckAllArchitectures; + SecCSFlags flags = (SecCSFlags) (kSecCSDefaultFlags | kSecCSCheckAllArchitectures); result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, requirement, &cfError); if (cfError) { @@ -108,7 +108,7 @@ finally: // Note that kSecCSCheckNestedCode may not work with pre-Mavericks code signing. // See https://github.com/sparkle-project/Sparkle/issues/376#issuecomment-48824267 and https://developer.apple.com/library/mac/technotes/tn2206 - SecCSFlags flags = kSecCSDefaultFlags | kSecCSCheckAllArchitectures; + SecCSFlags flags = (SecCSFlags) (kSecCSDefaultFlags | kSecCSCheckAllArchitectures); result = SecStaticCodeCheckValidityWithErrors(staticCode, flags, NULL, &cfError); if (cfError) { @@ -136,7 +136,7 @@ static id valueOrNSNull(id value) { + (void)logSigningInfoForCode:(SecStaticCodeRef)code label:(NSString*)label { CFDictionaryRef signingInfo = nil; - const SecCSFlags flags = kSecCSSigningInformation | kSecCSRequirementInformation | kSecCSDynamicInformation | kSecCSContentInformation; + const SecCSFlags flags = (SecCSFlags) (kSecCSSigningInformation | kSecCSRequirementInformation | kSecCSDynamicInformation | kSecCSContentInformation); if (SecCodeCopySigningInformation(code, flags, &signingInfo) == noErr) { NSDictionary *signingDict = CFBridgingRelease(signingInfo); NSMutableDictionary *relevantInfo = [NSMutableDictionary dictionary]; diff --git a/Sparkle/SUConstants.h b/Sparkle/SUConstants.h index 43058006..125c4738 100644 --- a/Sparkle/SUConstants.h +++ b/Sparkle/SUConstants.h @@ -66,11 +66,10 @@ extern NSString *const SUPromptUserOnFirstLaunchKey; extern NSString *const SUKeepDownloadOnFailedInstallKey; extern NSString *const SUDefaultsDomainKey; extern NSString *const SUFixedHTMLDisplaySizeKey __attribute__((deprecated("This key is obsolete and has no effect."))); - -extern NSString *const SUAppendVersionNumberKey; -extern NSString *const SUEnableAutomatedDowngradesKey; -extern NSString *const SUNormalizeInstalledApplicationNameKey; -extern NSString *const SURelaunchToolNameKey; +extern NSString *const SUAppendVersionNumberKey __attribute__((deprecated("This key is obsolete. See SPARKLE_APPEND_VERSION_NUMBER."))); +extern NSString *const SUEnableAutomatedDowngradesKey __attribute__((deprecated("This key is obsolete. See SPARKLE_AUTOMATED_DOWNGRADES."))); +extern NSString *const SUNormalizeInstalledApplicationNameKey __attribute__((deprecated("This key is obsolete. SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME."))); +extern NSString *const SURelaunchToolNameKey __attribute__((deprecated("This key is obsolete. SPARKLE_RELAUNCH_TOOL_NAME."))); // ----------------------------------------------------------------------------- // Appcast keys:: diff --git a/Sparkle/SUDSAVerifier.m b/Sparkle/SUDSAVerifier.m index 4789327e..fa5f9934 100644 --- a/Sparkle/SUDSAVerifier.m +++ b/Sparkle/SUDSAVerifier.m @@ -55,7 +55,7 @@ SecExternalItemType itemType = kSecItemTypePublicKey; CFArrayRef items = NULL; - OSStatus status = SecItemImport((__bridge CFDataRef)data, NULL, &format, &itemType, 0, NULL, NULL, &items); + OSStatus status = SecItemImport((__bridge CFDataRef)data, NULL, &format, &itemType, (SecItemImportExportFlags)0, NULL, NULL, &items); if (status != errSecSuccess || !items) { if (items) { CFRelease(items); @@ -65,7 +65,13 @@ } if (format == kSecFormatOpenSSL && itemType == kSecItemTypePublicKey && CFArrayGetCount(items) == 1) { + // Seems silly, but we can't quiet the warning about dropping CFTypeRef's const qualifier through + // any manner of casting I've tried, including interim explicit cast to void*. The -Wcast-qual + // warning is on by default with -Weverything and apparently became more noisy as of Xcode 7. +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcast-qual" _secKey = (SecKeyRef)CFRetain(CFArrayGetValueAtIndex(items, 0)); +#pragma clang diagnostic pop } CFRelease(items); diff --git a/Sparkle/SUHost.h b/Sparkle/SUHost.h index 92925e7d..3bf0a8e5 100644 --- a/Sparkle/SUHost.h +++ b/Sparkle/SUHost.h @@ -11,10 +11,19 @@ #import "SUAppcastItem.h" #import "SUVersionComparisonProtocol.h" +#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101000 +typedef struct { + NSInteger majorVersion; + NSInteger minorVersion; + NSInteger patchVersion; +} NSOperatingSystemVersion; +#endif + @interface SUHost : NSObject @property (strong, readonly) NSBundle *bundle; ++ (NSOperatingSystemVersion)operatingSystemVersion; + (NSString *)systemVersionString; - (instancetype)initWithBundle:(NSBundle *)aBundle; diff --git a/Sparkle/SUHost.m b/Sparkle/SUHost.m index b9d622e8..0bc94909 100644 --- a/Sparkle/SUHost.m +++ b/Sparkle/SUHost.m @@ -13,11 +13,6 @@ #import "SULog.h" #if __MAC_OS_X_VERSION_MAX_ALLOWED < 101000 -typedef struct { - NSInteger majorVersion; - NSInteger minorVersion; - NSInteger patchVersion; -} NSOperatingSystemVersion; @interface NSProcessInfo () - (NSOperatingSystemVersion)operatingSystemVersion; @end @@ -91,7 +86,7 @@ typedef struct { - (NSString *)installationPath { - if ([[[NSBundle bundleWithIdentifier:SUBundleIdentifier] infoDictionary][SUNormalizeInstalledApplicationNameKey] boolValue]) { + 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]]]]) { @@ -276,7 +271,7 @@ typedef struct { return [self objectForUserDefaultsKey:key] ? [self boolForUserDefaultsKey:key] : [self boolForInfoDictionaryKey:key]; } -+ (NSString *)systemVersionString ++ (NSOperatingSystemVersion)operatingSystemVersion { #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1090 // Present in 10.9 despite NS_AVAILABLE's claims #pragma clang diagnostic push @@ -285,11 +280,21 @@ typedef struct { if (![NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)]) #pragma clang diagnostic pop { + NSOperatingSystemVersion version = { 0, 0, 0 }; NSURL *coreServices = [[NSFileManager defaultManager] URLForDirectory:NSCoreServiceDirectory inDomain:NSSystemDomainMask appropriateForURL:nil create:NO error:nil]; - return [NSDictionary dictionaryWithContentsOfURL:[coreServices URLByAppendingPathComponent:@"SystemVersion.plist"]][@"ProductVersion"]; + NSArray *components = [[NSDictionary dictionaryWithContentsOfURL:[coreServices URLByAppendingPathComponent:@"SystemVersion.plist"]][@"ProductVersion"] componentsSeparatedByString:@"."]; + version.majorVersion = components.count > 0 ? [components[0] integerValue] : 0; + version.minorVersion = components.count > 1 ? [components[1] integerValue] : 0; + version.patchVersion = components.count > 2 ? [components[2] integerValue] : 0; + return version; } #endif - NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion]; + return [[NSProcessInfo processInfo] operatingSystemVersion]; +} + ++ (NSString *)systemVersionString +{ + NSOperatingSystemVersion version = self.operatingSystemVersion; return [NSString stringWithFormat:@"%ld.%ld.%ld", (long)version.majorVersion, (long)version.minorVersion, (long)version.patchVersion]; } diff --git a/Sparkle/SUInstaller.m b/Sparkle/SUInstaller.m index 658e4e0d..33647133 100644 --- a/Sparkle/SUInstaller.m +++ b/Sparkle/SUInstaller.m @@ -25,21 +25,11 @@ static NSString *sUpdateFolder = nil; + (BOOL)isAliasFolderAtPath:(NSString *)path { - FSRef fileRef; - OSStatus err = noErr; - Boolean aliasFileFlag = false, folderFlag = false; - NSURL *fileURL = [NSURL fileURLWithPath:path]; - - if (FALSE == CFURLGetFSRef((CFURLRef)fileURL, &fileRef)) - err = coreFoundationUnknownErr; - - if (noErr == err) - err = FSIsAliasFile(&fileRef, &aliasFileFlag, &folderFlag); - - if (noErr == err) - return !!(aliasFileFlag && folderFlag); - else - return NO; + NSNumber *aliasFlag = nil; + [[NSURL fileURLWithPath:path] getResourceValue:&aliasFlag forKey:NSURLIsAliasFileKey error:nil]; + NSNumber *directoryFlag = nil; + [[NSURL fileURLWithPath:path] getResourceValue:&directoryFlag forKey:NSURLIsDirectoryKey error:nil]; + return aliasFlag.boolValue && directoryFlag.boolValue; } + (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(BOOL *)isGuidedPtr diff --git a/Sparkle/SUPlainInstaller.m b/Sparkle/SUPlainInstaller.m index cea72914..975e1184 100644 --- a/Sparkle/SUPlainInstaller.m +++ b/Sparkle/SUPlainInstaller.m @@ -18,8 +18,10 @@ { SUParameterAssert(host); + BOOL allowDowngrades = SPARKLE_AUTOMATED_DOWNGRADES; + // Prevent malicious downgrades - if (![[[NSBundle bundleWithIdentifier:SUBundleIdentifier] infoDictionary][SUEnableAutomatedDowngradesKey] boolValue]) { + if (!allowDowngrades) { if ([comparator compareVersion:[host version] toVersion:[[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]] == NSOrderedDescending) { NSString *errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Possible attack in progress! Attempting to \"upgrade\" from %@ to %@. Aborting update.", [host version], [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]]; NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDowngradeError userInfo:@{ NSLocalizedDescriptionKey: errorMessage }]; @@ -31,10 +33,9 @@ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSError *error = nil; NSString *oldPath = [host bundlePath]; - NSString *tempName = [self temporaryNameForPath:[host installationPath]]; - BOOL result = [self copyPathWithAuthentication:path overPath:installationPath temporaryName:tempName error:&error]; - + BOOL result = [self copyPathWithAuthentication:path overPath:installationPath appendVersion:SPARKLE_APPEND_VERSION_NUMBER error:&error]; + if (result) { if ([SUCodeSigningVerifier applicationAtPathIsCodeSigned:installationPath]) { result = [SUCodeSigningVerifier codeSignatureIsValidAtPath:installationPath error:&error]; @@ -45,7 +46,7 @@ BOOL haveOld = [[NSFileManager defaultManager] fileExistsAtPath:oldPath]; BOOL differentFromNew = ![oldPath isEqualToString:installationPath]; if (haveOld && differentFromNew) { - [self _movePathToTrash:oldPath]; // On success, trash old copy if there's still one due to renaming. + [self _movePathToTrash:oldPath appendVersion:SPARKLE_APPEND_VERSION_NUMBER]; // On success, trash old copy if there's still one due to renaming. } } diff --git a/Sparkle/SUPlainInstallerInternals.h b/Sparkle/SUPlainInstallerInternals.h index f05cae91..25b2b6f7 100644 --- a/Sparkle/SUPlainInstallerInternals.h +++ b/Sparkle/SUPlainInstallerInternals.h @@ -14,9 +14,8 @@ #import "SUPlainInstaller.h" @interface SUPlainInstaller (Internals) -+ (NSString *)temporaryNameForPath:(NSString *)path; -+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)tmp error:(NSError **)error; -+ (void)_movePathToTrash:(NSString *)path; ++ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst appendVersion:(BOOL)a error:(NSError **)error; ++ (void)_movePathToTrash:(NSString *)path appendVersion:(BOOL)a; + (BOOL)_removeFileAtPath:(NSString *)path error:(NSError **)error; + (BOOL)_removeFileAtPathWithForcedAuthentication:(NSString *)src error:(NSError **)error; @end diff --git a/Sparkle/SUPlainInstallerInternals.m b/Sparkle/SUPlainInstallerInternals.m index 75ae5a5c..7fd97e27 100644 --- a/Sparkle/SUPlainInstallerInternals.m +++ b/Sparkle/SUPlainInstallerInternals.m @@ -85,29 +85,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza @implementation SUPlainInstaller (Internals) -+ (NSString *)temporaryNameForPath:(NSString *)path -{ - // Let's try to read the version number so the filename will be more meaningful. - NSString *postFix; - NSString *version; - if ((version = [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]) && ![version isEqualToString:@""]) - { - NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet]; - [validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]]; - postFix = [version stringByTrimmingCharactersInSet:[validCharacters invertedSet]]; - } - else - postFix = @"old"; - NSString *prefix = [[path stringByDeletingPathExtension] stringByAppendingFormat:@" (%@)", postFix]; - NSString *tempDir = [prefix stringByAppendingPathExtension:[path pathExtension]]; - // Now let's make sure we get a unique path. - unsigned int cnt = 2; - while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 999) - tempDir = [NSString stringWithFormat:@"%@ %u.%@", prefix, cnt++, [path pathExtension]]; - return [tempDir lastPathComponent]; -} - -+ (NSString *)_temporaryCopyNameForPath:(NSString *)path didFindTrash:(BOOL *)outDidFindTrash ++ (NSString *)_temporaryCopyNameForPath:(NSString *)path appendVersion:(BOOL)appendVersion didFindTrash:(BOOL *)outDidFindTrash { // *** MUST BE SAFE TO CALL ON NON-MAIN THREAD! NSString *tempDir = nil; @@ -140,7 +118,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza // Let's try to read the version number so the filename will be more meaningful NSString *prefix; - if ([[[NSBundle bundleWithIdentifier:SUBundleIdentifier] infoDictionary][SUAppendVersionNumberKey] boolValue]) { + if (appendVersion) { NSString *postFix = nil; NSString *version = nil; if ((version = [[NSBundle bundleWithPath: path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]) && ![version isEqualToString:@""]) @@ -443,14 +421,14 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return success; } -+ (void)_movePathToTrash:(NSString *)path ++ (void)_movePathToTrash:(NSString *)path appendVersion:(BOOL)appendVersion { //SULog(@"Moving %@ to the trash.", path); NSInteger tag = 0; if (![[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[path stringByDeletingLastPathComponent] destination:@"" files:@[[path lastPathComponent]] tag:&tag]) { BOOL didFindTrash = NO; - NSString *trashPath = [self _temporaryCopyNameForPath:path didFindTrash:&didFindTrash]; + NSString *trashPath = [self _temporaryCopyNameForPath:path appendVersion:appendVersion didFindTrash:&didFindTrash]; if( didFindTrash ) { NSError *err = nil; @@ -464,12 +442,12 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } } -+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)__unused tmp error:(NSError *__autoreleasing *)error ++ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst appendVersion:(BOOL)appendVersion error:(NSError *__autoreleasing *)error { FSRef srcRef, dstRef, dstDirRef, tmpDirRef; OSStatus err; BOOL hadFileAtDest = NO, didFindTrash = NO; - NSString *tmpPath = [self _temporaryCopyNameForPath:dst didFindTrash:&didFindTrash]; + NSString *tmpPath = [self _temporaryCopyNameForPath:dst appendVersion:appendVersion didFindTrash:&didFindTrash]; // Make FSRef for destination: err = FSPathMakeRefWithOptions((const UInt8 *)[dst fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &dstRef, NULL); diff --git a/Sparkle/SUUIBasedUpdateDriver.m b/Sparkle/SUUIBasedUpdateDriver.m index 3c59aa40..60df8193 100644 --- a/Sparkle/SUUIBasedUpdateDriver.m +++ b/Sparkle/SUUIBasedUpdateDriver.m @@ -14,6 +14,21 @@ #import "SUStatusController.h" #import "SUConstants.h" +#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1080 +@interface NSByteCountFormatter : NSFormatter { +@private + unsigned int _allowedUnits; + char _countStyle; + BOOL _allowsNonnumericFormatting, _includesUnit, _includesCount, _includesActualByteCount, + _adaptive, _zeroPadsFractionDigits; + int _formattingContext; + int _reserved[5]; +} ++ (NSString *)stringFromByteCount:(long long)byteCount + countStyle:(NSByteCountFormatterCountStyle)countStyle; +@end +#endif + @interface SUUIBasedUpdateDriver () @property (strong) SUStatusController *statusController; @@ -121,30 +136,39 @@ [self.statusController setMaxProgressValue:[response expectedContentLength]]; } -- (NSString *)humanReadableSizeFromDouble:(double)value +- (NSString *)localizedStringFromByteCount:(long long)value { - if (value < 1000) { - return [NSString stringWithFormat:@"%.0lf %@", value, SULocalizedString(@"B", @"the unit for bytes")]; + if (SUHost.operatingSystemVersion.minorVersion < 8) { + if (value < 1000) { + return [NSString stringWithFormat:@"%.0lf %@", value / 1.0, + SULocalizedString(@"B", @"the unit for bytes")]; + } + + if (value < 1000 * 1000) { + return [NSString stringWithFormat:@"%.0lf %@", value / 1000.0, + SULocalizedString(@"KB", @"the unit for kilobytes")]; + } + + if (value < 1000 * 1000 * 1000) { + return [NSString stringWithFormat:@"%.1lf %@", value / 1000.0 / 1000.0, + SULocalizedString(@"MB", @"the unit for megabytes")]; + } + + return [NSString stringWithFormat:@"%.2lf %@", value / 1000.0 / 1000.0 / 1000.0, + SULocalizedString(@"GB", @"the unit for gigabytes")]; } - if (value < 1000 * 1000) { - return [NSString stringWithFormat:@"%.0lf %@", value / 1000.0, SULocalizedString(@"KB", @"the unit for kilobytes")]; - } - - if (value < 1000 * 1000 * 1000) { - return [NSString stringWithFormat:@"%.1lf %@", value / 1000.0 / 1000.0, SULocalizedString(@"MB", @"the unit for megabytes")]; - } - - return [NSString stringWithFormat:@"%.2lf %@", value / 1000.0 / 1000.0 / 1000.0, SULocalizedString(@"GB", @"the unit for gigabytes")]; + return [NSByteCountFormatter stringFromByteCount:value + countStyle:NSByteCountFormatterCountStyleFile]; } - (void)download:(NSURLDownload *)__unused download didReceiveDataOfLength:(NSUInteger)length { [self.statusController setProgressValue:[self.statusController progressValue] + (double)length]; if ([self.statusController maxProgressValue] > 0.0) - [self.statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ of %@", nil), [self humanReadableSizeFromDouble:[self.statusController progressValue]], [self humanReadableSizeFromDouble:[self.statusController maxProgressValue]]]]; + [self.statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ of %@", nil), [self localizedStringFromByteCount:(long long)self.statusController.progressValue], [self localizedStringFromByteCount:(long long)self.statusController.maxProgressValue]]]; else - [self.statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ downloaded", nil), [self humanReadableSizeFromDouble:[self.statusController progressValue]]]]; + [self.statusController setStatusText:[NSString stringWithFormat:SULocalizedString(@"%@ downloaded", nil), [self localizedStringFromByteCount:(long long)self.statusController.progressValue]]]; } - (IBAction)cancelDownload:(id)__unused sender diff --git a/Sparkle/SUUpdateAlert.h b/Sparkle/SUUpdateAlert.h index 61725f53..aa1c0f49 100644 --- a/Sparkle/SUUpdateAlert.h +++ b/Sparkle/SUUpdateAlert.h @@ -21,7 +21,7 @@ typedef NS_ENUM(NSInteger, SUUpdateAlertChoice) { SUOpenInfoURLChoice }; -@class WebView, SUAppcastItem, SUHost; +@class SUAppcastItem, SUHost; @interface SUUpdateAlert : SUWindowController @property (weak) id versionDisplayer; diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index dc76d38f..b7bd66fa 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -17,7 +17,16 @@ #import "SUConstants.h" -@interface SUUpdateAlert () +// WebKit protocols are not explicitly declared until 10.11 SDK, so +// declare dummy protocols to keep the build working on earlier SDKs. +#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101100 +@protocol WebFrameLoadDelegate +@end +@protocol WebPolicyDelegate +@end +#endif + +@interface SUUpdateAlert () @property (strong) SUAppcastItem *updateItem; @property (strong) SUHost *host; @@ -29,6 +38,7 @@ @property (weak) IBOutlet WebView *releaseNotesView; @property (weak) IBOutlet NSView *releaseNotesContainerView; @property (weak) IBOutlet NSTextField *descriptionField; +@property (weak) IBOutlet NSButton *automaticallyInstallUpdatesButton; @property (weak) IBOutlet NSButton *installButton; @property (weak) IBOutlet NSButton *skipButton; @property (weak) IBOutlet NSButton *laterButton; @@ -49,6 +59,7 @@ @synthesize releaseNotesView; @synthesize releaseNotesContainerView; @synthesize descriptionField; +@synthesize automaticallyInstallUpdatesButton; @synthesize installButton; @synthesize skipButton; @synthesize laterButton; @@ -194,11 +205,13 @@ if (showReleaseNotes) { [self displayReleaseNotes]; } else { + NSLayoutConstraint *automaticallyInstallUpdatesButtonToDescriptionFieldConstraint = [NSLayoutConstraint constraintWithItem:self.automaticallyInstallUpdatesButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.descriptionField attribute:NSLayoutAttributeBottom multiplier:1.0 constant:8.0]; + + [self.window.contentView addConstraint:automaticallyInstallUpdatesButtonToDescriptionFieldConstraint]; + [self.releaseNotesContainerView removeFromSuperview]; } - [self.window.contentView setNeedsLayout:YES]; // Prod autolayout to place everything - [self.window center]; } diff --git a/Sparkle/SUUpdater.h b/Sparkle/SUUpdater.h index 12fb983f..f7dddeeb 100644 --- a/Sparkle/SUUpdater.h +++ b/Sparkle/SUUpdater.h @@ -33,6 +33,7 @@ SU_EXPORT @interface SUUpdater : NSObject - (instancetype)initForBundle:(NSBundle *)bundle; @property (readonly, strong) NSBundle *hostBundle; +@property (strong, readonly) NSBundle *sparkleBundle; @property BOOL automaticallyChecksForUpdates; diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index a02db473..215c5261 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -30,6 +30,8 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification @interface SUUpdater () @property (strong) NSTimer *checkTimer; +@property (strong) NSBundle *sparkleBundle; + - (instancetype)initForBundle:(NSBundle *)bundle; - (void)startUpdateCycle; - (void)checkForUpdatesWithDriver:(SUUpdateDriver *)updateDriver; @@ -55,6 +57,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification @synthesize httpHeaders; @synthesize driver; @synthesize host; +@synthesize sparkleBundle; static NSMutableDictionary *sharedUpdaters = nil; static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObservationContext"; @@ -81,6 +84,12 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults self = [super init]; if (bundle == nil) bundle = [NSBundle mainBundle]; + self.sparkleBundle = [NSBundle bundleForClass:[self class]]; + if (!self.sparkleBundle) { + SULog(@"Error: SUUpdater can't find Sparkle.framework it belongs to"); + return nil; + } + // Register as observer straight away to avoid exceptions on -dealloc when -unregisterAsObserver is called: if (self) { [self registerAsObserver]; @@ -490,7 +499,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults return customUserAgentString; } - NSString *version = [[NSBundle bundleWithIdentifier:SUBundleIdentifier] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]; + NSString *version = [self.sparkleBundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]; NSString *userAgent = [NSString stringWithFormat:@"%@/%@ Sparkle/%@", [self.host name], [self.host displayVersion], version ? version : @"?"]; NSData *cleanedAgent = [userAgent dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; return [[NSString alloc] initWithData:cleanedAgent encoding:NSASCIIStringEncoding]; diff --git a/Sparkle/Sparkle-Info.plist b/Sparkle/Sparkle-Info.plist index 9efef523..0caff79f 100644 --- a/Sparkle/Sparkle-Info.plist +++ b/Sparkle/Sparkle-Info.plist @@ -24,13 +24,5 @@ ${CURRENT_PROJECT_VERSION} NSPrincipalClass - SUAppendVersionNumber - ${SPARKLE_APPEND_VERSION_NUMBER} - SUEnableAutomatedDowngrades - ${SPARKLE_AUTOMATED_DOWNGRADES} - SUNormalizeInstalledApplicationName - ${SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME} - SURelaunchToolName - ${SPARKLE_RELAUNCH_TOOL_NAME} diff --git a/Sparkle/ca.lproj/Sparkle.strings b/Sparkle/ca.lproj/Sparkle.strings index d0ab278c..2c3eec74 100644 --- a/Sparkle/ca.lproj/Sparkle.strings +++ b/Sparkle/ca.lproj/Sparkle.strings @@ -42,13 +42,13 @@ "Ready to Install" = "A punt per instal·lar"; +"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu." = "Voleu que %1$@ comprovi si hi ha noves actualitzacions al iniciar? Si no, podeu inciar la comprovació manualment des del menú %1$@."; + "Update Error!" = "Error d'actualització!"; "Updating %@" = "Actualitzant %@"; -"Would you like %@ to check for updates on startup? If not, you can initiate the check manually from the %@ menu." = "Voleu que %@ comprovi si hi ha noves actualitzacions al iniciar? Si no, podeu inciar la comprovació manualment des del menú @."; - "Yes" = "Sí"; -"You're up to date!" = "Ja esteu al dia!"; +"You're up-to-date!" = "Ja esteu al dia!"; diff --git a/Sparkle/cs.lproj/Sparkle.strings b/Sparkle/cs.lproj/Sparkle.strings index 843f0b2f..2ca1b168 100644 --- a/Sparkle/cs.lproj/Sparkle.strings +++ b/Sparkle/cs.lproj/Sparkle.strings @@ -67,5 +67,5 @@ "You already have the newest version of %@." = "Máte nainstalovanou nejnovější verzi aplikace @."; -"You're up to date!" = "Vaše verze je aktuální!"; +"You're up-to-date!" = "Vaše verze je aktuální!"; diff --git a/Sparkle/cy.lproj/Sparkle.strings b/Sparkle/cy.lproj/Sparkle.strings deleted file mode 100644 index a9b47b25..00000000 --- a/Sparkle/cy.lproj/Sparkle.strings +++ /dev/null @@ -1,52 +0,0 @@ -"%@ of %@" = "%1$@ of %2$@"; - -"%@ %@ has been installed and will be ready to use next time %@ starts! Would you like to relaunch now?" = "%1$@ %2$@ has been installed and will be ready to use next time %3$@ starts! Would you like to relaunch now?"; - -"%@ %@ is currently the newest version available." = "%1$@ %2$@ is currently the newest version available."; - -"%@ %@ is now available (you have %@). Would you like to download it now?" = "%1$@ %2$@ is now available (you have %3$@). Would you like to download it now?"; - -"%@ does not have permission to write to the application's directory! Are you running off a disk image? If not, ask your system administrator for help." = "%@ does not have permission to write to the application's directory! Are you running off a disk image? If not, ask your system administrator for help."; - -"A new version of %@ has been installed!" = "A new version of %@ has been installed!"; - -"A new version of %@ is available!" = "A new version of %@ is available!"; - -"An error occurred during installation. Please try again later." = "An error occurred during installation. Please try again later."; - -"An error occurred in retrieving update information. Please try again later." = "An error occurred in retrieving update information. Please try again later."; - -"An error occurred while extracting the archive. Please try again later." = "An error occurred while extracting the archive. Please try again later."; - -"An error occurred while trying to download the file. Please try again later." = "An error occurred while trying to download the file. Please try again later."; - -"An update is already in progress!" = "An update is already in progress!"; - -"Cancel" = "Cancel"; - -"Check for updates on startup?" = "Check for updates on startup?"; - -"Downloading update..." = "Downloading update…"; - -"Extracting update..." = "Extracting update…"; - -"Install and Relaunch" = "Install and Relaunch"; - -"Installing update..." = "Installing update…"; - -"No" = "No"; - -"OK" = "OK"; - -"Ready to Install" = "Ready to Install"; - -"Update Error!" = "Update Error!"; - -"Updating %@" = "Updating %@"; - -"Would you like %@ to check for updates on startup? If not, you can initiate the check manually from the application menu." = "Would you like %@ to check for updates on startup? If not, you can initiate the check manually from the application menu."; - -"Yes" = "Yes"; - -"You're up to date!" = "You're up to date!"; - diff --git a/Sparkle/en.lproj/SUUpdateAlert.xib b/Sparkle/en.lproj/SUUpdateAlert.xib index c1178be9..1451769a 100644 --- a/Sparkle/en.lproj/SUUpdateAlert.xib +++ b/Sparkle/en.lproj/SUUpdateAlert.xib @@ -1,16 +1,17 @@ - + - + - - + + + @@ -21,12 +22,12 @@ - + - - + + @@ -75,16 +76,16 @@ - + - + - + - + @@ -117,7 +118,7 @@ - + @@ -161,7 +162,7 @@ Gw