bootstrap-vz/bootstrapvz/plugins/commands/tasks.py
Anders Ingemann 9364b18288
commands plugin: Run copy files before running commands
This is quite useful in situations where you want to do something
with the assets that you have copied into the image.
One could argue for the opposite case as well, but with the
commands plugin you always have the manual "cp" escape hatch.
2017-08-02 15:42:13 +02:00

18 lines
738 B
Python

from bootstrapvz.base import Task
from bootstrapvz.common import phases
from bootstrapvz.plugins.file_copy.tasks import MkdirCommand
from bootstrapvz.plugins.file_copy.tasks import FileCopyCommand
class ImageExecuteCommand(Task):
description = 'Executing commands in the image'
phase = phases.user_modification
predecessors = [MkdirCommand, FileCopyCommand]
@classmethod
def run(cls, info):
from bootstrapvz.common.tools import log_check_call
for raw_command in info.manifest.plugins['commands']['commands']:
command = map(lambda part: part.format(root=info.root, **info.manifest_vars), raw_command)
shell = len(command) == 1
log_check_call(command, shell=shell)