diff --git a/examples/autoinstall-invalid.yaml b/examples/autoinstall-invalid.yaml index 5e3beea6..7e1fec7f 100644 --- a/examples/autoinstall-invalid.yaml +++ b/examples/autoinstall-invalid.yaml @@ -1,7 +1,7 @@ version: 1 early-commands: - echo a - - sleep 1 + - ["sleep", "1"] - echo a late-commands: - echo a diff --git a/subiquity/controllers/cmdlist.py b/subiquity/controllers/cmdlist.py index 1f560b49..48b9631d 100644 --- a/subiquity/controllers/cmdlist.py +++ b/subiquity/controllers/cmdlist.py @@ -13,7 +13,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -import asyncio +from subiquitycore.utils import arun_command from subiquity.controller import NoUIController @@ -23,9 +23,13 @@ class CmdListController(NoUIController): autoinstall_default = [] autoinstall_schema = { 'type': 'array', - 'items': {'type': 'string'}, + 'items': { + 'type': ['string', 'array'], + 'items': {'type': 'string'}, + }, } cmds = () + cmd_check = True def load_autoinstall_data(self, data): self.cmds = data @@ -33,8 +37,12 @@ class CmdListController(NoUIController): async def run(self): for i, cmd in enumerate(self.cmds): with self.context.child("command_{}".format(i), cmd): - proc = await asyncio.create_subprocess_shell(cmd) - await proc.communicate() + if isinstance(cmd, str): + cmd = ['sh', '-c', cmd] + await arun_command( + cmd, + stdin=None, stdout=None, stderr=None, + check=self.cmd_check) class EarlyController(CmdListController): diff --git a/subiquity/controllers/error.py b/subiquity/controllers/error.py index ab20df88..b4e3a8aa 100644 --- a/subiquity/controllers/error.py +++ b/subiquity/controllers/error.py @@ -326,6 +326,7 @@ class ErrorReport(metaclass=urwid.MetaSignals): class ErrorController(CmdListController): autoinstall_key = 'error-commands' + cmd_check = False def __init__(self, app): super().__init__(app)