]> rtime.felk.cvut.cz Git - jailhouse.git/commitdiff
tools: config-create: locate templates next to script or in given dir
authorHenning Schild <henning.schild@siemens.com>
Tue, 5 Aug 2014 12:08:50 +0000 (14:08 +0200)
committerJan Kiszka <jan.kiszka@siemens.com>
Thu, 7 Aug 2014 11:30:55 +0000 (13:30 +0200)
When the script was called from outside the tools dir the templates
could not be found.
This patch assumes the templates are next to the script, one can also
specify a path.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
tools/jailhouse-config-create

index 4a04444ddded145a717d0691976fe1686f62b2ce..3bce969ea9f6a8b07b01b9ff93ecc59ffe37000b 100755 (executable)
@@ -20,6 +20,8 @@ import argparse
 import struct
 from mako.template import Template
 
+abspath = os.path.abspath(os.path.dirname(sys.argv[0]))
+
 # pretend to be part of the jailhouse tool
 sys.argv[0] = sys.argv[0].replace('-', ' ')
 
@@ -34,6 +36,12 @@ parser.add_argument('-r', '--root',
                     default='/',
                     action='store',
                     type=str)
+parser.add_argument('-t', '--template-dir',
+                    help='the directory where the templates are located,'
+                         'the default is "' + abspath + '"',
+                    default=abspath,
+                    action='store',
+                    type=str)
 
 memargs = [['--mem-inmates', '2M', 'inmate'],
            ['--mem-hv', '64M', 'hypervisor']]
@@ -494,10 +502,12 @@ if options.generate_collector:
     filelist = ' '.join(inputs['files'].union(inputs['dirs']))
     filelist_opt = ' '.join(inputs['files_opt'])
 
-    tmpl = Template(filename='jailhouse-config-collect.tmpl')
+    tmpl = Template(filename=os.path.join(options.template_dir,
+                                          'jailhouse-config-collect.tmpl'))
     f.write(tmpl.render(filelist=filelist, filelist_opt=filelist_opt))
 else:
-    tmpl = Template(filename='root-cell-config.c.tmpl')
+    tmpl = Template(filename=os.path.join(options.template_dir,
+                                          'root-cell-config.c.tmpl'))
     f.write(tmpl.render(regions=regions,
                         ourmem=ourmem,
                         argstr=' '.join(sys.argv),