Merge pull request #100 from JamesBromberger/python

sed search&replace plugin
This commit is contained in:
Anders Ingemann 2013-10-07 23:53:35 -07:00
commit f3b89f08ff
4 changed files with 89 additions and 0 deletions

11
plugins/sed/__init__.py Normal file
View file

@ -0,0 +1,11 @@
def tasks(tasklist, manifest):
import tasks
tasklist.add(tasks.DoSeds())
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

@ -0,0 +1,28 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Backports setup and package install",
"type": "object",
"properties": {
"plugins": {
"type": "object",
"properties": {
"sed": {
"type": "object",
"properties": {
"file": {
"type": "string"
},
"find": {
"type": "string"
},
"replace": {
"type": "string"
}
}
}
},
"required": ["sed"]
}
},
"required": ["plugins"]
}

19
plugins/sed/tasks.py Normal file
View file

@ -0,0 +1,19 @@
from base import Task
from common import phases
from common.tasks.apt import AptUpgrade
from common.tools import sed_i
import os
class DoSeds(Task):
description = 'Sedding files'
phase = phases.system_modification
after = [AptUpgrade]
def run(self, info):
chroot_path = os.path.join(info.root, info.manifest.plugins['sed']['file'])
print chroot_path
print info.manifest.plugins['sed']['file']
print info.manifest.plugins['sed']['find']
print info.manifest.plugins['sed']['replace']
sed_i(chroot_path, info.manifest.plugins['sed']['find'], info.manifest.plugins['sed']['replace'])

31
plugins/sed/temp Normal file
View file

@ -0,0 +1,31 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Backports setup and package install",
"type": "object",
"properties": {
"plugins": {
"type": "object",
"properties": {
"sed": {
"type": "array",
"items": {
"type": "object",
"properties": {
"file": {
"type": "string"
},
"find": {
"type": "string"
},
"replace": {
"type": "string"
}
}
}
}
},
"required": ["sed"]
}
},
"required": ["plugins"]
}