diff --git a/CHANGELOG.md b/CHANGELOG.md index ea53292c..a7538398 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,21 @@ Requires macOS 12.0 and higher. ### Added - To artificially change the `requredInstallationDate` to honor a previous macOS minor version, set `minorVersionRecalculationThreshold` under `osVersionRequirement` in amount of minor versions. - Ex: `minorVersionRecalculationThreshold` is set to 1 and SOFA feed has macOS 14.5 available - - macOS device is 14.3: Target macOS 14.4.1 requiredInstallationDate of 2024-04-15 00:00:00 +0000 - - macOS device is 14.4: Target macOS 14.4.1 requiredInstallationDate of 2024-04-15 00:00:00 +0000 - - macOS device is 14.4.1: Target macOS 14.5 requiredInstallationDate of 2024-06-03 00:00:00 +0000 + - macOS device is 14.0: Required OS: 14.5 - Target macOS 14.4.1 requiredInstallationDate of 2024-04-08 00:00:00 +0000 + - macOS device is 14.1: Required OS: 14.5 - Target macOS 14.4.1 requiredInstallationDate of 2024-04-08 00:00:00 +0000 + - macOS device is 14.2: Required OS: 14.5 - Target macOS 14.4.1 requiredInstallationDate of 2024-04-08 00:00:00 +0000 + - macOS device is 14.3: Required OS: 14.5 - Target macOS 14.4.1 requiredInstallationDate of 2024-04-08 00:00:00 +0000 + - macOS device is 14.4: Required OS: 14.5 - Target macOS 14.4.1 requiredInstallationDate of 2024-04-15 00:00:00 +0000 +\ - macOS device is 14.4.1: Required OS: 14.5 - Target macOS 14.5 requiredInstallationDate of 2024-06-03 00:00:00 +0000 + - macOS device is 14.5: Required OS: 14.5 - Fully updated + - Ex: `minorVersionRecalculationThreshold` is set to 2 and SOFA feed has macOS 14.5 available + - macOS device is 14.0: Required OS: 14.5 - Target macOS 14.4 requiredInstallationDate of 2024-03-21 00:00:00 +0000 + - macOS device is 14.1: Required OS: 14.5 - Target macOS 14.4 requiredInstallationDate of 2024-03-21 00:00:00 +0000 + - macOS device is 14.2: Required OS: 14.5 - Target macOS 14.4 requiredInstallationDate of 2024-03-21 00:00:00 +0000 + - macOS device is 14.3: Required OS: 14.5 - Target macOS 14.4 requiredInstallationDate of 2024-03-21 00:00:00 +0000 + - macOS device is 14.4: Required OS: 14.5 - Target macOS 14.4.1 requiredInstallationDate of 2024-04-15 00:00:00 +0000 +\ - macOS device is 14.4.1: Required OS: 14.5 - Target macOS 14.5 requiredInstallationDate of 2024-06-03 00:00:00 +0000 + - macOS device is 14.5: Required OS: 14.5 - Fully updated - Addresses [612](https://github.com/macadmins/nudge/issues/612) ### Changed diff --git a/Nudge/UI/Main.swift b/Nudge/UI/Main.swift index 0b15d787..1ff9483e 100644 --- a/Nudge/UI/Main.swift +++ b/Nudge/UI/Main.swift @@ -279,22 +279,26 @@ class AppDelegate: NSObject, NSApplicationDelegate { releaseDate = selectedOS!.releaseDate ?? Date() if requiredInstallationDate == Date(timeIntervalSince1970: 0) { if OSVersionRequirementVariables.minorVersionRecalculationThreshold > 0 { - let safeIndex = max(0, minorVersions.count - (OSVersionRequirementVariables.minorVersionRecalculationThreshold + 1)) // Ensure the index is within bounds - let targetVersion = minorVersions[safeIndex] - var foundVersion = false - LogManager.notice("minorVersionRecalculationThreshold is set - Targeting macOS \(targetVersion) requiredInstallationDate via SOFA", logger: sofaLog) - for osVersion in macOSSOFAAssets { - for securityRelease in osVersion.securityReleases { - if securityRelease.productVersion == targetVersion && VersionManager.versionLessThan(currentVersion: currentInstalledVersion, newVersion: targetVersion) { - requiredInstallationDate = securityRelease.releaseDate?.addingTimeInterval(slaExtension) ?? DateManager().getCurrentDate().addingTimeInterval(TimeInterval(90 * 86400)) - foundVersion = true - break + if minorVersions.isEmpty { + requiredInstallationDate = selectedOS!.releaseDate?.addingTimeInterval(slaExtension) ?? DateManager().getCurrentDate().addingTimeInterval(TimeInterval(90 * 86400)) + } else { + let safeIndex = max(0, minorVersions.count - (OSVersionRequirementVariables.minorVersionRecalculationThreshold + 1)) // Ensure the index is within bounds + let targetVersion = minorVersions[safeIndex] + var foundVersion = false + LogManager.notice("minorVersionRecalculationThreshold is set - Targeting macOS \(targetVersion) requiredInstallationDate via SOFA", logger: sofaLog) + for osVersion in macOSSOFAAssets { + for securityRelease in osVersion.securityReleases.reversed() { + if VersionManager.versionGreaterThanOrEqual(currentVersion: securityRelease.productVersion, newVersion: targetVersion) && VersionManager.versionLessThan(currentVersion: currentInstalledVersion, newVersion: targetVersion) { + requiredInstallationDate = securityRelease.releaseDate?.addingTimeInterval(slaExtension) ?? DateManager().getCurrentDate().addingTimeInterval(TimeInterval(90 * 86400)) + foundVersion = true + break + } } } - } - if !foundVersion { - LogManager.warning("Could not find requiredInstallationDate from target macOS \(targetVersion)", logger: sofaLog) - requiredInstallationDate = selectedOS!.releaseDate?.addingTimeInterval(slaExtension) ?? DateManager().getCurrentDate().addingTimeInterval(TimeInterval(90 * 86400)) + if !foundVersion { + LogManager.warning("Could not find requiredInstallationDate from target macOS \(targetVersion)", logger: sofaLog) + requiredInstallationDate = selectedOS!.releaseDate?.addingTimeInterval(slaExtension) ?? DateManager().getCurrentDate().addingTimeInterval(TimeInterval(90 * 86400)) + } } } else { requiredInstallationDate = selectedOS!.releaseDate?.addingTimeInterval(slaExtension) ?? DateManager().getCurrentDate().addingTimeInterval(TimeInterval(90 * 86400))