mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
Fix image_commands and user_packages plugins
This commit is contained in:
parent
302efea55c
commit
86fa48f201
6 changed files with 67 additions and 34 deletions
|
@ -1,11 +1,11 @@
|
|||
|
||||
|
||||
def validate_manifest(data, schema_validate):
|
||||
from os import path
|
||||
schema_path = path.normpath(path.join(path.dirname(__file__), 'manifest-schema.json'))
|
||||
schema_validate(data, schema_path)
|
||||
|
||||
|
||||
def tasks(tasklist, manifest):
|
||||
from image_commands import ImageExecuteCommand
|
||||
tasklist.add(ImageExecuteCommand())
|
||||
|
||||
def validate_manifest(data, schema_validate):
|
||||
from os import path
|
||||
schema_path = path.normpath(path.join(path.dirname(__file__), 'manifest-schema.json'))
|
||||
schema_validate(data, schema_path)
|
||||
|
||||
from image_commands import ImageExecuteCommand
|
||||
tasklist.add(ImageExecuteCommand)
|
||||
|
|
|
@ -3,20 +3,17 @@ from common import phases
|
|||
|
||||
|
||||
class ImageExecuteCommand(Task):
|
||||
description = 'Execute command in the image'
|
||||
phase = phases.system_modification
|
||||
|
||||
def run(self, info):
|
||||
from common.tools import log_check_call
|
||||
|
||||
for user_cmd in info.manifest.plugins['image_commands']['commands']:
|
||||
command = []
|
||||
for elt in user_cmd:
|
||||
fragment = elt.format(
|
||||
root=info.root,
|
||||
image=info.loopback_file,
|
||||
filesystem=info.manifest.volume['filesystem'])
|
||||
command.append(fragment)
|
||||
log_check_call(command)
|
||||
description = 'Execute command in the image'
|
||||
phase = phases.system_modification
|
||||
|
||||
def run(self, info):
|
||||
from common.tools import log_check_call
|
||||
|
||||
for user_cmd in info.manifest.plugins['image_commands']['commands']:
|
||||
command = []
|
||||
for elt in user_cmd:
|
||||
fragment = elt.format(root=info.root,
|
||||
image=info.loopback_file,
|
||||
filesystem=info.manifest.volume['filesystem'])
|
||||
command.append(fragment)
|
||||
log_check_call(command)
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
"type": "array",
|
||||
"items": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
"items": {"type": "string"},
|
||||
"minItems": 1
|
||||
},
|
||||
"minItems": 1
|
||||
}
|
||||
},
|
||||
"required": ["commands"]
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
|
||||
|
||||
def validate_manifest(data, schema_validate):
|
||||
from os import path
|
||||
schema_path = path.normpath(path.join(path.dirname(__file__), 'manifest-schema.json'))
|
||||
schema_validate(data, schema_path)
|
||||
|
||||
|
||||
def tasks(tasklist, manifest):
|
||||
from user_packages import AddUserPackages, AddLocalUserPackages
|
||||
tasklist.add(AddUserPackages,
|
||||
AddLocalUserPackages)
|
||||
if 'repo' in manifest.plugins['user_packages']:
|
||||
tasklist.add(AddUserPackages)
|
||||
if 'local' in manifest.plugins['user_packages']:
|
||||
tasklist.add(AddLocalUserPackages)
|
||||
|
|
33
plugins/user_packages/manifest-schema.json
Normal file
33
plugins/user_packages/manifest-schema.json
Normal file
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"title": "Image commands plugin manifest",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"plugins": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"user_packages": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"repo": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"},
|
||||
"minItems": 1
|
||||
},
|
||||
"local": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"},
|
||||
"minItems": 1
|
||||
}
|
||||
},
|
||||
"anyOf": [
|
||||
{"required": ["repo"]},
|
||||
{"required": ["local"]}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": ["user_packages"]
|
||||
}
|
||||
},
|
||||
"required": ["plugins"]
|
||||
}
|
|
@ -13,8 +13,6 @@ class AddUserPackages(Task):
|
|||
successors = [CheckPackages]
|
||||
|
||||
def run(self, info):
|
||||
if 'repo' not in info.manifest.plugins['user_packages']:
|
||||
return
|
||||
for pkg in info.manifest.plugins['user_packages']['repo']:
|
||||
info.img_packages[0].add(pkg)
|
||||
|
||||
|
@ -25,9 +23,6 @@ class AddLocalUserPackages(Task):
|
|||
predecessors = [MountRoot]
|
||||
|
||||
def run(self, info):
|
||||
if 'local' not in info.manifest.plugins['user_packages']:
|
||||
return
|
||||
|
||||
import stat
|
||||
rwxr_xr_x = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
|
||||
stat.S_IRGRP | stat.S_IXGRP |
|
||||
|
|
Loading…
Add table
Reference in a new issue