From 8ca71ed3a0e4a8614b19ee16645bbbe490ea0eab Mon Sep 17 00:00:00 2001 From: Andreas Kemnade Date: Tue, 28 Dec 2021 22:16:40 +0100 Subject: [PATCH] install: do not choke on blockdevices without fs (MR 2153) when blkid returns 2 while searching for existing pmos installations, do not abort. That might happen if there is a block device without a filesystem. Error given: (1653851) [21:39:19] (native) % blkid -s LABEL -o value /dev/sdcardp1 (1653851) [21:39:19] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (1653851) [21:39:19] NOTE: The failed command's output is above the ^^^ line in the log file: /home/andi/.local/var/pmbootstrap/log.txt (1653851) [21:39:19] ERROR: Command failed: (native) % blkid -s LABEL -o value /dev/sdcardp1 (1653851) [21:39:19] See also: (1653851) [21:39:19] Traceback (most recent call last): File "/home/andi/.local/lib/python3.9/site-packages/pmb/__init__.py", line 49, in main getattr(frontend, args.action)(args) File "/home/andi/.local/lib/python3.9/site-packages/pmb/helpers/frontend.py", line 314, in install pmb.install.install(args) File "/home/andi/.local/lib/python3.9/site-packages/pmb/install/_install.py", line 944, in install install_system_image(args, 0, f"rootfs_{args.device}", step, steps, File "/home/andi/.local/lib/python3.9/site-packages/pmb/install/_install.py", line 586, in install_system_image pmb.install.blockdevice.create(args, size_boot, size_root, File "/home/andi/.local/lib/python3.9/site-packages/pmb/install/blockdevice.py", line 138, in create mount_sdcard(args, sdcard) File "/home/andi/.local/lib/python3.9/site-packages/pmb/install/blockdevice.py", line 51, in mount_sdcard if previous_install(args, path): File "/home/andi/.local/lib/python3.9/site-packages/pmb/install/blockdevice.py", line 27, in previous_install label = pmb.chroot.root(args, ["blkid", "-s", "LABEL", "-o", "value", File "/home/andi/.local/lib/python3.9/site-packages/pmb/chroot/root.py", line 76, in root return pmb.helpers.run_core.core(args, msg, cmd_sudo, None, output, File "/home/andi/.local/lib/python3.9/site-packages/pmb/helpers/run_core.py", line 343, in core check_return_code(args, code, log_message) File "/home/andi/.local/lib/python3.9/site-packages/pmb/helpers/run_core.py", line 219, in check_return_code raise RuntimeError("Command failed: " + log_message) RuntimeError: Command failed: (native) % blkid -s LABEL -o value /dev/sdcardp1 --- pmb/install/blockdevice.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pmb/install/blockdevice.py b/pmb/install/blockdevice.py index 0611bab3..dbef80b9 100644 --- a/pmb/install/blockdevice.py +++ b/pmb/install/blockdevice.py @@ -24,8 +24,15 @@ def previous_install(args, path): pmb.helpers.mount.bind_file(args, blockdevice_outside, args.work + '/chroot_native' + blockdevice_inside) - label = pmb.chroot.root(args, ["blkid", "-s", "LABEL", "-o", "value", - blockdevice_inside], output_return=True) + try: + label = pmb.chroot.root(args, ["blkid", "-s", "LABEL", + "-o", "value", + blockdevice_inside], + output_return=True) + except RuntimeError: + logging.info("WARNING: Could not get block device label," + " assume no previous installation on that partition") + pmb.helpers.run.root(args, ["umount", args.work + "/chroot_native" + blockdevice_inside]) return "pmOS_boot" in label