1337 multiline bash support
This commit is contained in:
parent
47db32ad0c
commit
8ee415e642
@ -29,14 +29,22 @@ class BuildScript(Script):
|
|||||||
def config(self, line):
|
def config(self, line):
|
||||||
self.append(f'buildah config {line} $ctr')
|
self.append(f'buildah config {line} $ctr')
|
||||||
|
|
||||||
def _run(self, cmd):
|
def _run(self, cmd, inject=False):
|
||||||
user = self.container.variable('username')
|
user = self.container.variable('username')
|
||||||
|
_cmd = cmd
|
||||||
if cmd.startswith('sudo '):
|
if cmd.startswith('sudo '):
|
||||||
return f'buildah run --user root $ctr -- {cmd[5:]}'
|
_cmd = _cmd[5:]
|
||||||
|
|
||||||
|
if '\n' in _cmd.strip():
|
||||||
|
# 1337: multiline supports, kindof breaks sudo but really fixes cd
|
||||||
|
_cmd = ' '.join(['bash -eux <<__EOF\n', _cmd, '\n__EOF'])
|
||||||
|
|
||||||
|
if cmd.startswith('sudo '):
|
||||||
|
return f'buildah run --user root $ctr -- {_cmd}'
|
||||||
elif user and self.container.variable('user_created'):
|
elif user and self.container.variable('user_created'):
|
||||||
return f'buildah run --user {user} $ctr -- {cmd}'
|
return f'buildah run --user {user} $ctr -- {_cmd}'
|
||||||
else:
|
else:
|
||||||
return f'buildah run $ctr -- {cmd}'
|
return f'buildah run $ctr -- {_cmd}'
|
||||||
|
|
||||||
def run(self, cmd):
|
def run(self, cmd):
|
||||||
self.append(self._run(cmd))
|
self.append(self._run(cmd))
|
||||||
|
|||||||
@ -4,6 +4,4 @@ class Run:
|
|||||||
|
|
||||||
def build(self, script):
|
def build(self, script):
|
||||||
for command in self.commands:
|
for command in self.commands:
|
||||||
for line in command.split('\n'):
|
script.run(command)
|
||||||
if line.strip():
|
|
||||||
script.run(line.strip())
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user