Skip to content

Commit

Permalink
virtme-ng: handle undefined release with --root
Browse files Browse the repository at this point in the history
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 <andrea.righi@linux.dev>
  • Loading branch information
arighi committed Oct 5, 2024
1 parent 7ca90bc commit 4133a39
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions virtme_ng/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) as e:
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"
Expand Down

0 comments on commit 4133a39

Please sign in to comment.