From f79d5c3ec54be8b4f976f432e3fb8363c30ddc80 Mon Sep 17 00:00:00 2001 From: Andrea Righi Date: Sat, 5 Oct 2024 16:17:19 +0200 Subject: [PATCH] virtme-ng: handle undefined release with --root When the --root option is used to automatically create a new chroot from scratch, virtme-ng attempts to populate the chroot using the latest Ubuntu cloud image. The specific Ubuntu release is determined by running lsb_release on the host system, aiming to match the host environment as closely as possible. However, if the host is not running Ubuntu, this command may either fail or return "n/a" (e.g., on Arch Linux). In such cases, treat the "n/a" result as an error and prompt the user to manually specify the target Ubuntu release for initializing the chroot. Fixes: 97dd475 ("Add hint when trying to create root filesystem outside a Debian host") Signed-off-by: Andrea Righi --- virtme_ng/run.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/virtme_ng/run.py b/virtme_ng/run.py index 4ebcb41..1670faf 100644 --- a/virtme_ng/run.py +++ b/virtme_ng/run.py @@ -548,9 +548,11 @@ def create_root(destdir, arch, release): .decode(sys.stdout.encoding) .rstrip() ) - except CalledProcessError as e: - print("Try specifying an Ubuntu release with --root-release") - raise e + if release == "n/a": + raise ValueError("unknown release") + except (CalledProcessError, ValueError): + print("Unknown release, try specifying an Ubuntu release with --root-release") + sys.exit(1) url = ( "https://cloud-images.ubuntu.com/" + f"{release}/current/{release}-server-cloudimg-{arch}-root.tar.xz"