template.py 2.95 KB
Newer Older
1 2
# -*- python -*-
# -*- coding: utf-8 -*-
3

Seblu's avatar
Seblu committed
4
# This file is part of Installsystems.
5
#
Seblu's avatar
Seblu committed
6 7 8 9
# Installsystems is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
10
#
Seblu's avatar
Seblu committed
11
# Installsystems is distributed in the hope that it will be useful,
12 13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Seblu's avatar
Seblu committed
14
# GNU Lesser General Public License for more details.
15
#
Seblu's avatar
Seblu committed
16 17
# You should have received a copy of the GNU Lesser General Public License
# along with Installsystems.  If not, see <http://www.gnu.org/licenses/>.
18

19
description = u"""[image]
20 21 22 23
name = %(name)s
version = %(version)s
description = %(description)s
author = %(author)s
Seblu's avatar
Seblu committed
24
is_min_version = %(is_min_version)s
25 26 27

[compressor]
%(compressor)s
28 29
"""

30
changelog = u"""[1]
Seblu's avatar
Seblu committed
31 32 33
- Initial version
"""

Seblu's avatar
Seblu committed
34 35 36 37 38 39 40 41 42 43 44 45
build = u"""# -*- python -*-
# -*- coding: utf-8 -*-

# global rebuild object allow you to force rebuild of payloads
# to force rebuild of payload nammed rootfs add it to the rebuild list
# rebuild list is empty by default
#rebuild += ["rootfs"]

# vim:set ts=2 sw=2 noet:
"""


46 47 48
parser = """# -*- python -*-
# -*- coding: utf-8 -*-

Seblu's avatar
Seblu committed
49 50
# global image object is a reference to current image
# global parser object is your installsystems subparser (argparse)
Seblu's avatar
Seblu committed
51 52

import os
Seblu's avatar
Seblu committed
53
import argparse
Seblu's avatar
Seblu committed
54
from installsystems.printer import arrow
Seblu's avatar
Seblu committed
55 56 57 58

class TargetAction(argparse.Action):
  def __call__(self, parser, namespace, values, option_string=None):
    if not os.path.isdir(values):
59
      raise Exception(u"Invalid target directory %s" % values)
Seblu's avatar
Seblu committed
60 61
    namespace.target = values

62
parser.add_argument("-n", "--hostname", dest="hostname", type=str, required=True)
Seblu's avatar
Seblu committed
63
parser.add_argument("target", type=str, action=TargetAction,
64
  help="target installation directory")
65 66 67 68

# vim:set ts=2 sw=2 noet:
"""

69
setup = u"""# -*- python -*-
70 71
# -*- coding: utf-8 -*-

Seblu's avatar
Seblu committed
72
# global image object is a reference to current image
Seblu's avatar
Seblu committed
73 74
# namespace object is the persistant, it can be used to store data accross scripts

Seblu's avatar
Seblu committed
75 76
from installsystems.printer import arrow

77
arrow(u"hostname: %s" % namespace.hostname)
78

Seblu's avatar
Seblu committed
79 80
# uncomment to extract payload named root in namespace.target directory
#image.payload["rootfs"].extract(namespace.target)
81

82 83
# vim:set ts=2 sw=2 noet:
"""
Seblu's avatar
Seblu committed
84

85
createdb = u"""
Seblu's avatar
Seblu committed
86 87
CREATE TABLE image (md5 TEXT NOT NULL PRIMARY KEY,
                    name TEXT NOT NULL,
88
                    version TEXT NOT NULL,
Seblu's avatar
Seblu committed
89 90 91 92 93 94
                    date INTEGER NOT NULL,
                    author TEXT,
                    description TEXT,
                    size INTEGER NOT NULL,
                    UNIQUE(name, version));

Seblu's avatar
Seblu committed
95 96 97 98 99 100
CREATE TABLE payload (md5 TEXT NOT NULL,
                     image_md5 TEXT NOT NULL REFERENCES image(md5),
                     name TEXT NOT NULL,
                     isdir INTEGER NOT NULL,
                     size INTEGER NOT NULL,
                     PRIMARY KEY(md5, image_md5));
Seblu's avatar
Seblu committed
101
"""