Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Tell the old version of a system extension from the new one

Țugui Dragoș5b8ed9e01806
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 947f93b6..a1357597 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -194407,6 +194407,112 @@
}
}
},
+ "Version %@ replaced this one, which macOS is removing. Some removals finish only when the Mac restarts." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Toto rozšíření nahradila verze %@ a systém macOS ho odstraňuje. Některá odstranění se dokončí až po restartu Macu."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Version %@ hat diese Version ersetzt, die macOS gerade entfernt. Manches wird erst vollständig entfernt, wenn der Mac neu startet."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "La versión %@ ha reemplazado a esta, que macOS está eliminando. Algunas eliminaciones solo terminan cuando el Mac se reinicia."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "La version %@ a remplacé celle-ci, que macOS est en train de supprimer. Certaines suppressions ne s’achèvent qu’au redémarrage du Mac."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "La versione %@ ha sostituito questa, che macOS sta rimuovendo. Alcune rimozioni si completano solo al riavvio del Mac."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "このバージョンはバージョン%@に置き換えられ、macOSが削除しています。Macを再起動しないと完了しない削除もあります。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%@ 버전이 이 버전을 대체했으며, macOS가 이 버전을 제거하고 있습니다. 일부 제거 작업은 Mac을 재시동해야만 완료됩니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Versie %@ heeft deze versie vervangen, en macOS is die aan het verwijderen. Sommige verwijderingen worden pas voltooid als de Mac opnieuw opstart."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Tę wersję zastąpiła wersja %@, a macOS ją usuwa. Czasem usuwanie kończy się dopiero po ponownym uruchomieniu Maca."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "A versão %@ substituiu esta, que o macOS está removendo. Algumas remoções só terminam quando o Mac reinicia."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Versiunea %@ a înlocuit‑o pe aceasta, pe care macOS o elimină în acest moment. Unele eliminări se încheie doar când Mac‑ul repornește."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Версия %@ заменила это расширение, и macOS его удаляет. Некоторые удаления завершаются только после перезагрузки Mac."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Version %@ har ersatt den här versionen, som macOS håller på att ta bort. Vissa borttagningar slutförs först när datorn startas om."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Bunun yerini %@ sürümü aldı ve macOS bunu kaldırıyor. Bazı kaldırma işlemleri ancak Mac yeniden başladığında tamamlanır."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Цю версію замінила версія %@, і macOS зараз її вилучає. Деякі вилучення завершуються лише після перезапуску Mac."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "此版本已被版本%@取代,macOS正在移除它。有些移除要等Mac重新启动后才能完成。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "版本%@已取代此版本,macOS正在移除此版本。有些移除作業要等到Mac重新開機後才會完成。"
+ }
+ }
+ }
+ },
"Version %@ skipped" : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/Extensions/AppExtensions.swift b/Packages/PeelCore/Sources/PeelCore/Extensions/AppExtensions.swift
index 43ef2148..de4805ef 100644
--- a/Packages/PeelCore/Sources/PeelCore/Extensions/AppExtensions.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Extensions/AppExtensions.swift
@@ -27,7 +27,8 @@ public struct AppExtension: Sendable, Hashable, Identifiable {
reportedState: String?,
installedFor: String? = nil,
goneApp: String? = nil,
- category: String? = nil
+ category: String? = nil,
+ version: String? = nil
) {
self.id = id ?? identifier
self.identifier = identifier
@@ -42,6 +43,7 @@ public struct AppExtension: Sendable, Hashable, Identifiable {
self.installedFor = installedFor
self.goneApp = goneApp
self.category = category
+ self.version = version
}
public enum Kind: String, Sendable, Hashable, CaseIterable {
@@ -96,6 +98,10 @@ public struct AppExtension: Sendable, Hashable, Identifiable {
public let goneApp: String?
/// The category `systemextensionsctl` lists a system extension under; nil for an app extension.
public let category: String?
+ /// The version `systemextensionsctl` lists, `<short>/<build>`; nil for an app extension.
+ public let version: String?
+ /// For a version macOS is removing while it keeps another version of it, that version, as shown.
+ public internal(set) var replacedBy: String?
/// Tells rows apart in a list. The identifier alone can't: while an app updates a system extension, macOS
/// lists the old and the new version under the same identifier.
public let id: String
@@ -147,6 +153,14 @@ extension AppExtension {
}
}
+ /// The version as macOS shows one with its build, `2.0 (200)`.
+ public var shownVersion: String? {
+ version.map { listed in
+ let parts = listed.split(separator: "/", maxSplits: 1)
+ return parts.count == 2 ? "\(parts[0]) (\(parts[1]))" : listed
+ }
+ }
+
/// The name of the app it came with, also once that app is gone.
public var appName: String? {
owner ?? goneApp.map { URL(filePath: $0).deletingPathExtension().lastPathComponent }
@@ -405,7 +419,7 @@ public enum AppExtensions {
}
guard count(in: lines, /^(\d+) extension\(s\)$/) == rows.count else { return nil }
let records = records()
- return rows.map { row, category in
+ return notingReplacements(rows.map { row, category in
let record = record(for: row.identifier, version: row.version, among: records)
let installedFor = record.flatMap(installedFor)
return AppExtension(
@@ -422,8 +436,21 @@ public enum AppExtensions {
reportedState: row.state,
installedFor: installedFor,
goneApp: goneApp(installedFor: installedFor),
- category: category
+ category: category,
+ version: row.version
)
+ })
+ }
+
+ /// Each system extension macOS is removing while it keeps another version of it, with the version that stays.
+ static func notingReplacements(_ found: [AppExtension]) -> [AppExtension] {
+ found.map { item in
+ guard item.election == .beingRemoved else { return item }
+ var noted = item
+ noted.replacedBy = found.first {
+ $0.identifier == item.identifier && $0.election != .beingRemoved && $0.version != item.version
+ }?.shownVersion
+ return noted
}
}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swift
index a9a6e312..2d00ab60 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/AppExtensionsTests.swift
@@ -405,6 +405,26 @@ struct AppExtensionsTests {
#expect(categories["org.example.camera"] == "com.apple.system_extension.cmio")
}
+ @Test func saysWhichVersionReplacesASystemExtensionBeingRemoved() async throws {
+ let listing = """
+ 3 extension(s)
+ --- com.apple.system_extension.network_extension (Go to 'System Settings > General > Login Items & Extensions > Network Extensions' to modify these system extension(s))
+ enabled\tactive\tteamID\tbundleID (version)\tname\t[state]
+ \t\tABCDE12345\torg.example.filter (2.20/2626)\tExample Filter\t[terminated waiting to uninstall on reboot]
+ *\t*\tABCDE12345\torg.example.filter (2.20.2/2629)\tExample Filter\t[activated enabled]
+ \t\tABCDE12345\torg.example.proxy (1.0)\tExample Proxy\t[terminated waiting to uninstall on reboot]
+ """
+
+ let found = try #require(await AppExtensions.systemExtensions { _, _ in listing })
+
+ let old = try #require(found.first { $0.version == "2.20/2626" })
+ let new = try #require(found.first { $0.version == "2.20.2/2629" })
+ let alone = try #require(found.first { $0.identifier == "org.example.proxy" })
+ #expect(old.replacedBy == "2.20.2 (2629)")
+ #expect(new.replacedBy == nil && new.shownVersion == "2.20.2 (2629)")
+ #expect(alone.replacedBy == nil && alone.shownVersion == "1.0")
+ }
+
@Test func systemSettingsDeletesOnlyANetworkExtensionAndOnlyOnMacOS27() {
func item(_ category: String?, kind: AppExtension.Kind = .systemExtension) -> AppExtension {
AppExtension(
diff --git a/Peel/Views/Extensions/ExtensionDetailView.swift b/Peel/Views/Extensions/ExtensionDetailView.swift
index c8d13a1b..81e5bd02 100644
--- a/Peel/Views/Extensions/ExtensionDetailView.swift
+++ b/Peel/Views/Extensions/ExtensionDetailView.swift
@@ -50,6 +50,12 @@ struct ExtensionDetailView: View {
}
}
}
+ if let version = item.shownVersion {
+ LabeledContent("Version") {
+ Text(verbatim: version)
+ .textSelection(.enabled)
+ }
+ }
if let team = item.teamIdentifier {
LabeledContent("Signed by") {
Text(verbatim: team)
@@ -177,6 +183,11 @@ struct ExtensionDetailView: View {
private var systemExtensionExplanation: LocalizedStringResource {
// With its app gone, the advice for an installed app leads nowhere: Orphaned Files' words say what does.
if item.goneApp != nil, let reason = item.leftAlone { return reason.explanation }
+ // A version macOS is removing goes on its own, whatever happens to the app.
+ if item.election == .beingRemoved {
+ guard let newer = item.replacedBy else { return item.election.explanation }
+ return "Version \(newer) replaced this one, which macOS is removing. Some removals finish only when the Mac restarts."
+ }
if #available(macOS 27, *) {
return item.systemSettingsDeletesIt
? "macOS keeps its own copy of this, apart from the app. Moving the app to the Trash in Finder asks macOS to remove it, and so does choosing Delete Extension from the More button beside it in System Settings > General > Login Items & Extensions > Network Extensions. So Peel leaves that app to Finder."
diff --git a/Peel/Views/Extensions/ExtensionList.swift b/Peel/Views/Extensions/ExtensionList.swift
index 7eede193..aec9ce98 100644
--- a/Peel/Views/Extensions/ExtensionList.swift
+++ b/Peel/Views/Extensions/ExtensionList.swift
@@ -28,8 +28,11 @@ struct ExtensionList: View {
.padding(.vertical, 6)
.listRowSeparator(.hidden)
}
+ let versioned = Set(Dictionary(grouping: extensions.extensions ?? [], by: \.identifier).filter {
+ $0.value.count > 1
+ }.keys)
ForEach(filtered) { item in
- ExtensionRow(item: item)
+ ExtensionRow(item: item, showsVersion: versioned.contains(item.identifier))
}
}
.accessibilityLabel(Text(Tool.extensions.title))
@@ -98,13 +101,18 @@ struct ExtensionList: View {
private struct ExtensionRow: View {
let item: AppExtension
+ /// True when another row has the same identifier, as the old and the new version during an update.
+ let showsVersion: Bool
var body: some View {
ToolRow(systemImage: item.kind.systemImage) {
Text(verbatim: item.name)
.lineLimit(1)
} details: {
- if item.goneApp != nil, let name = item.appName {
+ if showsVersion, let version = item.shownVersion {
+ Text("Version \(version)")
+ .lineLimit(1)
+ } else if item.goneApp != nil, let name = item.appName {
Text("\(name), no longer installed")
.lineLimit(1)
} else if let owner = item.owner {