Fix not awaited ubuntu-drivers command existence check

The ensure_cmd_exists() coroutine from ubuntu_drivers was never awaited.
Therefore, the check would always silently succeed. Taking a look in
server-output would show the warning though:

RuntimeWarning: coroutine
'UbuntuDriversHasDriversInterface.ensure_cmd_exists' was never awaited
  self.ubuntu_drivers.ensure_cmd_exists(d.mountpoint)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Also, the implementation of ensure_cmd_exists() when
SUBIQUITY_DEBUG=run-drivers is set was failing because we use a shell
builtin as an executable. This was not noticed since ensure_cmd_exists()
was not executed and arun_command() does not check for errors by
default.

Signed-off-by: Olivier Gayot <olivier.gayot@canonical.com>
This commit is contained in:
Olivier Gayot 2022-03-07 15:20:43 +01:00
parent c769ae1845
commit 45e919eb51
2 changed files with 4 additions and 2 deletions

View File

@ -78,7 +78,7 @@ class DriversController(SubiquityController):
async with apt.overlay() as d: async with apt.overlay() as d:
try: try:
# Make sure ubuntu-drivers is available. # Make sure ubuntu-drivers is available.
self.ubuntu_drivers.ensure_cmd_exists(d.mountpoint) await self.ubuntu_drivers.ensure_cmd_exists(d.mountpoint)
except CommandNotFoundError: except CommandNotFoundError:
self.drivers = [] self.drivers = []
else: else:

View File

@ -137,7 +137,9 @@ class UbuntuDriversRunDriversInterface(UbuntuDriversInterface):
# TODO This does not tell us if the "--recommended" option is # TODO This does not tell us if the "--recommended" option is
# available. # available.
try: try:
await arun_command(["command", "-v", "ubuntu-drivers"]) await arun_command(
["sh", "-c", "command -v ubuntu-driver"],
check=True)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
raise CommandNotFoundError( raise CommandNotFoundError(
"Command ubuntu-drivers is not available in this system") "Command ubuntu-drivers is not available in this system")