install: losetup: check if the back-file attribute for a loop device is null (MR 2456)

Seems to be ChromeOS specific:

> this happens every time on my machine. I am on ChromeOS 129.0.6668.112
> using a Debian bookworm chroot through Crouton. I am not sure why
> this is happening nor which layer is responsible for this. I deleted
> the chroot and created another one but the problem persists.

Commit msg tweaked by Oliver.
This commit is contained in:
Vikram Alagh 2024-10-26 02:09:31 +05:30 committed by Oliver Smith
parent e8e146c68a
commit 8ac2e48a21
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -72,7 +72,7 @@ def device_by_back_file(back_file: Path) -> Path:
# Find the back_file # Find the back_file
losetup = json.loads(losetup_output) losetup = json.loads(losetup_output)
for loopdevice in losetup["loopdevices"]: for loopdevice in losetup["loopdevices"]:
if Path(loopdevice["back-file"]) == back_file: if loopdevice["back-file"] is not None and Path(loopdevice["back-file"]) == back_file:
return Path(loopdevice["name"]) return Path(loopdevice["name"])
raise RuntimeError(f"Failed to find loop device for {back_file}") raise RuntimeError(f"Failed to find loop device for {back_file}")