From bf3e82b166b0a0b4108b24d7e6052ef595950e29 Mon Sep 17 00:00:00 2001 From: Jiri Konecny Date: Wed, 28 Feb 2024 21:56:58 +0100 Subject: [PATCH 1/2] reanaconda: Early quit if deps not installed Tell user early that the execution of reanaconda is not possible because dependencies are not installed. --- reanaconda/reanaconda.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/reanaconda/reanaconda.py b/reanaconda/reanaconda.py index 044ab36..7a3bd5f 100755 --- a/reanaconda/reanaconda.py +++ b/reanaconda/reanaconda.py @@ -63,6 +63,18 @@ CMDLINE_KICKSTART = 'inst.ks=http://10.0.2.22/kickstart' +def check_dependencies(): + ok = True + if not shutil.which("qemu-system-x86_64"): + print("'qemu-system-x86_64' needs to be installed!", file=sys.stderr) + ok = False + if not shutil.which("qemu-img"): + print("'qemu-img' needs to be installed!", file=sys.stderr) + ok = False + + return ok + + class DaemonHTTPServer(http.server.HTTPServer, socketserver.ThreadingMixIn): daemon_threads = True @@ -250,6 +262,9 @@ def cleanup(): if __name__ == '__main__': + # early quit if dependencies are not installed in the system + check_dependencies() + if len(sys.argv) < 2 or '--help' in sys.argv: print(__doc__) sys.exit(1) From ac681eb9e9c0c7ca1212fa088c68bad7c220eb3e Mon Sep 17 00:00:00 2001 From: Jiri Konecny Date: Wed, 28 Feb 2024 21:59:24 +0100 Subject: [PATCH 2/2] reanaconda: Fix URL path to download boot files vmlinuz and initrd was in the past stored in `isolinux` directory but now it is stored in `image/pxeboot`. Keep the backward compatibility by trying the old path if download fails. --- reanaconda/reanaconda.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/reanaconda/reanaconda.py b/reanaconda/reanaconda.py index 7a3bd5f..865d5fc 100755 --- a/reanaconda/reanaconda.py +++ b/reanaconda/reanaconda.py @@ -52,6 +52,8 @@ import docopt +from urllib.error import HTTPError + QEMU_SENSIBLE_ARGUMENTS = [ '-enable-kvm', '-machine', 'q35', '-cpu', 'host', '-smp', '2', '-m', '2G', '-object', 'rng-random,id=rng0,filename=/dev/urandom', @@ -212,8 +214,7 @@ def prime(qemu_args, append, fetch_from=None): 'reanaconda/disk.img', '20G']) if fetch_from: - _download(f'{fetch_from}/isolinux/vmlinuz', 'reanaconda/vmlinuz') - _download(f'{fetch_from}/isolinux/initrd.img', 'reanaconda/initrd.img') + _fetch_boot_files(fetch_from) qemu_args += ['-kernel', 'reanaconda/vmlinuz', '-initrd', 'reanaconda/initrd.img'] append += f' inst.stage2={fetch_from}' @@ -241,6 +242,16 @@ def cb(): saving_done.wait() print('exiting') +def _fetch_boot_files(url): + try: + _download(f'{url}/images/pxeboot/vmlinuz', 'reanaconda/vmlinuz') + _download(f'{url}/images/pxeboot/initrd.img', 'reanaconda/initrd.img') + except HTTPError as ex: + print(f"Can't download {url}: {ex}") + print(f"Trying older isolinux/ path instead") + _download(f'{url}/isolinux/vmlinuz', 'reanaconda/vmlinuz') + _download(f'{url}/isolinux/initrd.img', 'reanaconda/initrd.img') + def updates(updates_img, kickstart=None): if not os.path.isdir('reanaconda'):