From f7a461a85f65b9a0de2cef735d695fadd456f63f Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Thu, 26 Dec 2024 22:21:10 -0500 Subject: [PATCH 1/3] macos: disable auto-updates for local (source) builds The auto-update prompt isn't useful for local (source) builds so disable both update checks and automatic downloads. There are multiple ways we could check if we've been built for source, but the easiest and least intrusive approach is to check the value of the 'GhosttyCommit' Info.plist key. Because it is only set as part of the release build process, an empty key implies that we've been build from source. --- macos/Sources/App/macOS/AppDelegate.swift | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index 7b0ff6fc2..8d56b91d5 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -485,10 +485,16 @@ class AppDelegate: NSObject, } // Sync our auto-update settings - updaterController.updater.automaticallyChecksForUpdates = - config.autoUpdate == .check || config.autoUpdate == .download - updaterController.updater.automaticallyDownloadsUpdates = - config.autoUpdate == .download + // Local (source) builds always disable the updater + if let commit = Bundle.main.infoDictionary?["GhosttyCommit"] as? String, !commit.isEmpty { + updaterController.updater.automaticallyChecksForUpdates = + config.autoUpdate == .check || config.autoUpdate == .download + updaterController.updater.automaticallyDownloadsUpdates = + config.autoUpdate == .download + } else { + updaterController.updater.automaticallyChecksForUpdates = false + updaterController.updater.automaticallyDownloadsUpdates = false + } // Config could change keybindings, so update everything that depends on that syncMenuShortcuts(config) From 2c3847c9af1597723e3d9fb5882b0bf11ee12853 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Fri, 27 Dec 2024 08:16:18 -0500 Subject: [PATCH 2/3] macos: disable Sparkle checks in Debug and Release This approach uses Xcode's Info.plist preprocessing to conditionally set `SUEnableAutomaticChecks=false` for the Debug and Release build schemes. It is unset for the ReleaseLocal scheme. When this Info.plist key is explicitly set to false (as it is for these build schemes), we disable auto-updates at runtime. Otherwise, we apply the behavior defined by our "auto-update" configuration. --- macos/Ghostty-Info.plist | 4 ++++ macos/Ghostty.xcodeproj/project.pbxproj | 5 +++++ macos/Sources/App/macOS/AppDelegate.swift | 7 ++++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/macos/Ghostty-Info.plist b/macos/Ghostty-Info.plist index 83194e136..b794b79f6 100644 --- a/macos/Ghostty-Info.plist +++ b/macos/Ghostty-Info.plist @@ -94,6 +94,10 @@ +#if SPARKLE_CHECKS_DISABLED + SUEnableAutomaticChecks + +#endif SUPublicEDKey wsNcGf5hirwtdXMVnYoxRIX/SqZQLMOsYlD3q3imeok= diff --git a/macos/Ghostty.xcodeproj/project.pbxproj b/macos/Ghostty.xcodeproj/project.pbxproj index 68322756b..3dd37c0ff 100644 --- a/macos/Ghostty.xcodeproj/project.pbxproj +++ b/macos/Ghostty.xcodeproj/project.pbxproj @@ -730,6 +730,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_PREPROCESS = YES; MACOSX_DEPLOYMENT_TARGET = 13.1; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; @@ -843,6 +844,8 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_PREPROCESS = YES; + INFOPLIST_PREPROCESSOR_DEFINITIONS = "SPARKLE_CHECKS_DISABLED=1"; MACOSX_DEPLOYMENT_TARGET = 13.1; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -899,6 +902,8 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + INFOPLIST_PREPROCESS = YES; + INFOPLIST_PREPROCESSOR_DEFINITIONS = "SPARKLE_CHECKS_DISABLED=1"; MACOSX_DEPLOYMENT_TARGET = 13.1; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index 8d56b91d5..7ebf52d3d 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -484,9 +484,10 @@ class AppDelegate: NSObject, default: UserDefaults.standard.removeObject(forKey: "NSQuitAlwaysKeepsWindows") } - // Sync our auto-update settings - // Local (source) builds always disable the updater - if let commit = Bundle.main.infoDictionary?["GhosttyCommit"] as? String, !commit.isEmpty { + // Sync our auto-update settings. If SUEnableAutomaticChecks (in our Info.plist) is + // explicitly false (NO), auto-updates are disabled. Otherwise, we use the behavior + // defined by our "auto-update" configuration. + if Bundle.main.infoDictionary?["SUEnableAutomaticChecks"] as? Bool != false { updaterController.updater.automaticallyChecksForUpdates = config.autoUpdate == .check || config.autoUpdate == .download updaterController.updater.automaticallyDownloadsUpdates = From 6508fec945258f526e0adf0dcc174d954e23fb8d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 29 Dec 2024 09:22:54 -0800 Subject: [PATCH 3/3] Revert "macos: disable auto-updates for local (source) builds (#3273)" This reverts commit b39850fd8b463f78c6fb450cd7a59e43bdf4b622, reversing changes made to 64ea3a1a29677ca5f094f8058c40c549bb741bc5. --- macos/Ghostty-Info.plist | 4 ---- macos/Ghostty.xcodeproj/project.pbxproj | 5 ----- macos/Sources/App/macOS/AppDelegate.swift | 17 +++++------------ 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/macos/Ghostty-Info.plist b/macos/Ghostty-Info.plist index 17caf19d7..914c6ed6b 100644 --- a/macos/Ghostty-Info.plist +++ b/macos/Ghostty-Info.plist @@ -96,10 +96,6 @@ -#if SPARKLE_CHECKS_DISABLED - SUEnableAutomaticChecks - -#endif SUPublicEDKey wsNcGf5hirwtdXMVnYoxRIX/SqZQLMOsYlD3q3imeok= diff --git a/macos/Ghostty.xcodeproj/project.pbxproj b/macos/Ghostty.xcodeproj/project.pbxproj index 3dd37c0ff..68322756b 100644 --- a/macos/Ghostty.xcodeproj/project.pbxproj +++ b/macos/Ghostty.xcodeproj/project.pbxproj @@ -730,7 +730,6 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - INFOPLIST_PREPROCESS = YES; MACOSX_DEPLOYMENT_TARGET = 13.1; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; @@ -844,8 +843,6 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - INFOPLIST_PREPROCESS = YES; - INFOPLIST_PREPROCESSOR_DEFINITIONS = "SPARKLE_CHECKS_DISABLED=1"; MACOSX_DEPLOYMENT_TARGET = 13.1; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -902,8 +899,6 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - INFOPLIST_PREPROCESS = YES; - INFOPLIST_PREPROCESSOR_DEFINITIONS = "SPARKLE_CHECKS_DISABLED=1"; MACOSX_DEPLOYMENT_TARGET = 13.1; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index 7ebf52d3d..7b0ff6fc2 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -484,18 +484,11 @@ class AppDelegate: NSObject, default: UserDefaults.standard.removeObject(forKey: "NSQuitAlwaysKeepsWindows") } - // Sync our auto-update settings. If SUEnableAutomaticChecks (in our Info.plist) is - // explicitly false (NO), auto-updates are disabled. Otherwise, we use the behavior - // defined by our "auto-update" configuration. - if Bundle.main.infoDictionary?["SUEnableAutomaticChecks"] as? Bool != false { - updaterController.updater.automaticallyChecksForUpdates = - config.autoUpdate == .check || config.autoUpdate == .download - updaterController.updater.automaticallyDownloadsUpdates = - config.autoUpdate == .download - } else { - updaterController.updater.automaticallyChecksForUpdates = false - updaterController.updater.automaticallyDownloadsUpdates = false - } + // Sync our auto-update settings + updaterController.updater.automaticallyChecksForUpdates = + config.autoUpdate == .check || config.autoUpdate == .download + updaterController.updater.automaticallyDownloadsUpdates = + config.autoUpdate == .download // Config could change keybindings, so update everything that depends on that syncMenuShortcuts(config)