Skip to content

Commit f17e763

Browse files
committed
osenum: Use mounted snapshot for current OS
This should fix the failure to find SystemVersion.plist when a macOS update is pending. Signed-off-by: Hector Martin <[email protected]>
1 parent 972183c commit f17e763

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

src/osenum.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ def collect_part(self, part):
9696
part.os = []
9797

9898
ct = part.container
99+
ct_name = ct.get("ContainerReference", None)
100+
99101
by_role = {}
100102
by_device = {}
101103

@@ -121,10 +123,23 @@ def collect_part(self, part):
121123
if len(data) != 1 or len(system) != 1:
122124
logging.info(f" Weird VG: {vg['Volumes']}")
123125
continue
126+
data = data[0]["DeviceIdentifier"]
127+
system = system[0]["DeviceIdentifier"]
128+
129+
volumes["Data"] = by_device[data]
130+
volumes["System"] = by_device[system]
124131

125-
volumes["Data"] = by_device[data[0]["DeviceIdentifier"]]
126-
volumes["System"] = by_device[system[0]["DeviceIdentifier"]]
127132
vgid = vg["APFSVolumeGroupUUID"]
133+
134+
if self.sysinfo.boot_uuid == vgid:
135+
for volume in self.dutil.disk_parts[ct_name]["APFSVolumes"]:
136+
if "MountedSnapshots" not in volume:
137+
continue
138+
snapshots = volume["MountedSnapshots"]
139+
if volume["DeviceIdentifier"] == system and len(snapshots) == 1:
140+
volumes = dict(volumes)
141+
volumes["System"]["DeviceIdentifier"] = snapshots[0]["SnapshotBSD"]
142+
128143
os = self.collect_os(part, volumes, vgid)
129144
logging.info(f" Found {os}")
130145
part.os.append(os)

0 commit comments

Comments
 (0)