Fix image_commands and user_packages plugins

This commit is contained in:
Anders Ingemann 2013-11-24 16:15:01 +01:00
parent 302efea55c
commit 86fa48f201
6 changed files with 67 additions and 34 deletions

View file

@ -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): def tasks(tasklist, manifest):
from image_commands import ImageExecuteCommand from image_commands import ImageExecuteCommand
tasklist.add(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)

View file

@ -3,20 +3,17 @@ from common import phases
class ImageExecuteCommand(Task): class ImageExecuteCommand(Task):
description = 'Execute command in the image' description = 'Execute command in the image'
phase = phases.system_modification 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)
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)

View file

@ -13,10 +13,10 @@
"type": "array", "type": "array",
"items": { "items": {
"type": "array", "type": "array",
"items": { "items": {"type": "string"},
"type": "string" "minItems": 1
} },
} "minItems": 1
} }
}, },
"required": ["commands"] "required": ["commands"]

View file

@ -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): def tasks(tasklist, manifest):
from user_packages import AddUserPackages, AddLocalUserPackages from user_packages import AddUserPackages, AddLocalUserPackages
tasklist.add(AddUserPackages, if 'repo' in manifest.plugins['user_packages']:
AddLocalUserPackages) tasklist.add(AddUserPackages)
if 'local' in manifest.plugins['user_packages']:
tasklist.add(AddLocalUserPackages)

View 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"]
}

View file

@ -13,8 +13,6 @@ class AddUserPackages(Task):
successors = [CheckPackages] successors = [CheckPackages]
def run(self, info): def run(self, info):
if 'repo' not in info.manifest.plugins['user_packages']:
return
for pkg in info.manifest.plugins['user_packages']['repo']: for pkg in info.manifest.plugins['user_packages']['repo']:
info.img_packages[0].add(pkg) info.img_packages[0].add(pkg)
@ -25,9 +23,6 @@ class AddLocalUserPackages(Task):
predecessors = [MountRoot] predecessors = [MountRoot]
def run(self, info): def run(self, info):
if 'local' not in info.manifest.plugins['user_packages']:
return
import stat import stat
rwxr_xr_x = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | rwxr_xr_x = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
stat.S_IRGRP | stat.S_IXGRP | stat.S_IRGRP | stat.S_IXGRP |