set $TARGET_MOUNT_POINT when running late-commands
so one does not have to pass --target to curtin in-target in a late-command
This commit is contained in:
parent
10035ab28f
commit
d7e295d500
|
@ -13,6 +13,8 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
from subiquitycore.context import with_context
|
from subiquitycore.context import with_context
|
||||||
from subiquitycore.utils import arun_command
|
from subiquitycore.utils import arun_command
|
||||||
|
|
||||||
|
@ -35,14 +37,18 @@ class CmdListController(NoUIController):
|
||||||
def load_autoinstall_data(self, data):
|
def load_autoinstall_data(self, data):
|
||||||
self.cmds = data
|
self.cmds = data
|
||||||
|
|
||||||
|
def env(self):
|
||||||
|
return os.environ.copy()
|
||||||
|
|
||||||
@with_context()
|
@with_context()
|
||||||
async def run(self, context):
|
async def run(self, context):
|
||||||
|
env = self.env()
|
||||||
for i, cmd in enumerate(self.cmds):
|
for i, cmd in enumerate(self.cmds):
|
||||||
with context.child("command_{}".format(i), cmd):
|
with context.child("command_{}".format(i), cmd):
|
||||||
if isinstance(cmd, str):
|
if isinstance(cmd, str):
|
||||||
cmd = ['sh', '-c', cmd]
|
cmd = ['sh', '-c', cmd]
|
||||||
await arun_command(
|
await arun_command(
|
||||||
cmd,
|
cmd, env=env,
|
||||||
stdin=None, stdout=None, stderr=None,
|
stdin=None, stdout=None, stderr=None,
|
||||||
check=self.cmd_check)
|
check=self.cmd_check)
|
||||||
|
|
||||||
|
@ -56,6 +62,11 @@ class LateController(CmdListController):
|
||||||
|
|
||||||
autoinstall_key = 'late-commands'
|
autoinstall_key = 'late-commands'
|
||||||
|
|
||||||
|
def env(self):
|
||||||
|
env = super().env()
|
||||||
|
env['TARGET_MOUNT_POINT'] = self.app.base_model.target
|
||||||
|
return env
|
||||||
|
|
||||||
@with_context()
|
@with_context()
|
||||||
async def apply_autoinstall_config(self, context):
|
async def apply_autoinstall_config(self, context):
|
||||||
await self.run(context=context)
|
await self.run(context=context)
|
||||||
|
|
Loading…
Reference in New Issue