diff --git a/Makefile b/Makefile index 0f7cae0f4..bb142dcce 100644 --- a/Makefile +++ b/Makefile @@ -192,7 +192,7 @@ $(UPDATES_IMG): prepare-test-deps test/prepare-updates-img create-updates.img: bots - -rm $(UPDATES_IMG) + -rm *updates.img make $(UPDATES_IMG) test/reference: test/common diff --git a/test/machine_install.py b/test/machine_install.py index a273eaba7..a78d2656f 100755 --- a/test/machine_install.py +++ b/test/machine_install.py @@ -20,6 +20,7 @@ import subprocess import sys import time +from tempfile import TemporaryDirectory WEBUI_TEST_DIR = os.path.dirname(__file__) ROOT_DIR = os.path.dirname(WEBUI_TEST_DIR) @@ -83,22 +84,36 @@ def _serve_payload(self): return payload_cached_name, http_payload_port - def _write_interactive_defaults_ks(self): + def _write_interactive_defaults_ks(self, updates_image, updates_image_edited): payload_cached_name, http_payload_port = self._serve_payload() content = f'liveimg --url="http://10.0.2.2:{http_payload_port}/{payload_cached_name}"' - Machine.execute(self, f'echo \'{content}\' > /usr/share/anaconda/interactive-defaults.ks') + defaults_path = "usr/share/anaconda/" + print("Adding interactive defaults to updates.img") + with TemporaryDirectory() as tmp_dir: + os.makedirs(f"{tmp_dir}/{defaults_path}") + # unpack initrd to the temporary directory + os.system(f"cd {tmp_dir} && gzip -dc {updates_image} | cpio -idu") + # add new interactive-defaults.ks (have to be available at start of the installer) + with open(f"{tmp_dir}/{defaults_path}/interactive-defaults.ks", "wt", encoding="utf-8") as f: + f.write(content) + # pack the updates.img again and replace the original one + os.system(f"cd {tmp_dir} && find . | cpio -c -o | gzip -9cv > {updates_image_edited}") def start(self): - update_img_file = os.path.join(ROOT_DIR, "updates.img") - if not os.path.exists(update_img_file): - raise FileNotFoundError("Missing updates.img file") - - self.http_updates_img_port = self._serve_updates_img() - self.payload_path = os.path.join(BOTS_DIR, "./images/fedora-rawhide-anaconda-payload") if not os.path.exists(self.payload_path): raise FileNotFoundError(f"Missing payload file {self.payload_path}; use 'make payload'.") + update_img_global_file = os.path.join(ROOT_DIR, "updates.img") + update_img_file = os.path.join(ROOT_DIR, self.label + "-updates.img") + if not os.path.exists(update_img_global_file): + raise FileNotFoundError("Missing updates.img file") + + if not self.is_live(): + # Configure the payload in interactive-defaults.ks + self._write_interactive_defaults_ks(update_img_global_file, update_img_file) + + self.http_updates_img_port = self._serve_updates_img() iso_path = f"{os.getcwd()}/bots/images/{self.image}" extra_args = "" @@ -136,7 +151,7 @@ def start(self): "--noautoconsole " f"--graphics vnc,listen={self.ssh_address} " "--extra-args " - f"'inst.sshd inst.webui.remote inst.webui inst.updates=http://10.0.2.2:{self.http_updates_img_port}/updates.img' " + f"'inst.sshd inst.webui.remote inst.webui inst.updates=http://10.0.2.2:{self.http_updates_img_port}/{self.label}-updates.img' " "--network none " f"--qemu-commandline=" "'-netdev user,id=hostnet0," @@ -153,9 +168,6 @@ def start(self): if not self.is_live(): Machine.wait_boot(self, timeout_sec=300) - # Configure the payload in interactive-defaults.ks - self._write_interactive_defaults_ks() - for _ in range(30): try: Machine.execute(self, "journalctl -t anaconda | grep 'anaconda: ui.webui: cockpit web view has been started'")