Commits

William Pitcock  committed 37e975d

Initial proof of concept.

  • Participants

Comments (0)

Files changed (7)

+*.pyc
+*.pyo
+#!/usr/bin/env python
+
+from appliancekit.compiler import compile
+import json
+
+data = compile('debian-6.spec')
+tree = json.loads(data)
+
+print json.dumps(tree, indent=1)

File appliancekit/__init__.py

+from jinja2 import Environment, PackageLoader
+env = Environment(loader=PackageLoader(__name__, 'specs'))
+
+import appliancekit.compiler
+

File appliancekit/compiler.py

+from appliancekit import env
+
+def compile(specname):
+     tmpl = env.get_template(specname)
+     return tmpl.render()
+

File appliancekit/specs/base.spec

+{% block base %}
+[
+{% block bootstrap %}
+{% endblock %}
+
+{% block custom %}
+{% endblock %}
+
+{% block cleanup %}
+{% endblock %}
+	{"operation": "noop"}
+]
+{% endblock %}

File appliancekit/specs/debian-6.spec

+{% extends "debian-base.spec" %}
+{% set distribution='squeeze' %}

File appliancekit/specs/debian-base.spec

+{% extends "base.spec" %}
+{% block bootstrap %}
+	{"operation": "runcmd", "chroot": false, "command": ["debootstrap", "{{ distribution }}", "$chroot"]},
+	{"operation": "runcmd", "chroot": true, "command": ["apt-get", "-y", "--force-yes", "update"]},
+	{"operation": "runcmd", "chroot": true, "command": ["apt-get", "-y", "--force-yes", "install", "openssh-server", "e2fsprogs"]},
+{% endblock %}
+{% block packages %}{% for package in packages %}{"operation": "runcmd", "chroot": true, "command": ['apt-get', '-y', '--force-yes', 'install', '{{ package }}']},{% endfor %}{% endblock %}
+{% block cleanup %}{% endblock %}