From e57404953c27f56d5321c36476b01d236911e3ed Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Thu, 11 Apr 2024 09:12:07 -0700 Subject: [PATCH] temp commit Copies changes to /usr/share/ubuntu-drivers-common/fake-devices-wrapper to /target/usr/share/ubuntu-drivers-common/fake-devices-wrapper. Makes sure the command is called in the system environment and not the snap environment. in-progress umockdev configs misc logging statements --- examples/dry-run-configs/broadcom.yaml | 1 + examples/umockdev/broadcom.yaml | 7 ++++++ subiquity/server/controllers/drivers.py | 5 ++++ subiquity/server/ubuntu_drivers.py | 31 ++++++++++++++++++++++++- 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 examples/dry-run-configs/broadcom.yaml create mode 100644 examples/umockdev/broadcom.yaml diff --git a/examples/dry-run-configs/broadcom.yaml b/examples/dry-run-configs/broadcom.yaml new file mode 100644 index 00000000..c9121c06 --- /dev/null +++ b/examples/dry-run-configs/broadcom.yaml @@ -0,0 +1 @@ +ubuntu_drivers_run_on_host_umockdev: "examples/umockdev/broadcom.yaml" diff --git a/examples/umockdev/broadcom.yaml b/examples/umockdev/broadcom.yaml new file mode 100644 index 00000000..ea5b6170 --- /dev/null +++ b/examples/umockdev/broadcom.yaml @@ -0,0 +1,7 @@ +devices: + # This is a fake broadcom wireless chip + - modalias: 'pci:v000014E4d00004353sv00sd01bc02sc80i00' + vendor: '0x14E4' + device: '0x4353' + + diff --git a/subiquity/server/controllers/drivers.py b/subiquity/server/controllers/drivers.py index 333102ba..3051f319 100644 --- a/subiquity/server/controllers/drivers.py +++ b/subiquity/server/controllers/drivers.py @@ -91,12 +91,14 @@ class DriversController(SubiquityController): @with_context() async def _list_drivers(self, context): + log.debug("about to wait_apt") with context.child("wait_apt"): await self._wait_apt.wait() # The APT_CONFIGURED event (which unblocks _wait_apt.wait) is sent # after the user confirms the destruction changes. At this point, the # source is already mounted so the user can't go back all the way to # the source screen to enable/disable the "search drivers" checkbox. + log.debug("about to check if search_drivers") if not self.app.controllers.Source.model.search_drivers: self.drivers = [] self.list_drivers_done_event.set() @@ -104,12 +106,15 @@ class DriversController(SubiquityController): apt = self.app.controllers.Mirror.final_apt_configurer try: async with apt.overlay() as d: + log.debug("about to ensure_cmd_exists") try: # Make sure ubuntu-drivers is available. await self.ubuntu_drivers.ensure_cmd_exists(d.mountpoint) except CommandNotFoundError: + log.debug("cmd dne") self.drivers = [] else: + log.debug("cmd exists") self.drivers = await self.ubuntu_drivers.list_drivers( root_dir=d.mountpoint, context=context ) diff --git a/subiquity/server/ubuntu_drivers.py b/subiquity/server/ubuntu_drivers.py index cd72ad63..7ecc068c 100644 --- a/subiquity/server/ubuntu_drivers.py +++ b/subiquity/server/ubuntu_drivers.py @@ -177,7 +177,11 @@ class UbuntuDriversFakePCIDevicesInterface(UbuntuDriversInterface): app.base_model.drivers.fake_pci_devices = True - prefix: list[str] = ["/usr/share/ubuntu-drivers-common/fake-devices-wrapper"] + prefix: list[str] = [ + "env", + "-i", + "/usr/share/ubuntu-drivers-common/fake-devices-wrapper", + ] self.list_drivers_cmd = prefix + self.list_drivers_cmd self.list_oem_cmd = prefix + self.list_oem_cmd self.install_drivers_cmd = prefix + self.install_drivers_cmd @@ -185,6 +189,7 @@ class UbuntuDriversFakePCIDevicesInterface(UbuntuDriversInterface): async def ensure_cmd_exists(self, root_dir: str) -> None: # TODO This does not tell us if the "--recommended" option is # available. + log.debug("in fake ensure") try: await arun_command(["sh", "-c", "command -v ubuntu-drivers"], check=True) except subprocess.CalledProcessError: @@ -193,7 +198,11 @@ class UbuntuDriversFakePCIDevicesInterface(UbuntuDriversInterface): ) async def list_drivers(self, root_dir: str, context) -> List[str]: + log.debug("in fake list") result = await arun_command(self.list_drivers_cmd) + log.debug("got fake list") + log.debug(f"fake list={result.stdout}") + log.debug(f"result stderr={result.stderr}") return self._drivers_from_output(result.stdout) async def list_oem(self, root_dir: str, context) -> List[str]: @@ -201,6 +210,26 @@ class UbuntuDriversFakePCIDevicesInterface(UbuntuDriversInterface): result = await arun_command(self.list_oem_cmd) return self._oem_metapackages_from_output(result.stdout) + async def install_drivers(self, root_dir: str, context) -> None: + await arun_command( + [ + "cp", + "/usr/share/ubuntu-drivers-common/fake-devices-wrapper", + f"{root_dir}/usr/share/ubuntu-drivers-common/fake-devices-wrapper", + ] + ) + + await run_curtin_command( + self.app, + context, + "in-target", + "-t", + root_dir, + "--", + *self.install_drivers_cmd, + private_mounts=True, + ) + class UbuntuDriversHasDriversInterface(UbuntuDriversInterface): """A dry-run implementation of ubuntu-drivers that returns a hard-coded