livemedia-creator: Add /usr/share/lorax/templates.d/ support
This commit is contained in:
parent
76bce910e0
commit
c15349c3da
@ -148,14 +148,8 @@ class Lorax(BaseLoraxClass):
|
|||||||
Otherwise use the sharedir
|
Otherwise use the sharedir
|
||||||
"""
|
"""
|
||||||
if not self._templatedir:
|
if not self._templatedir:
|
||||||
templatedir = self.conf.get("lorax", "sharedir")
|
self._templatedir = find_templates(self.conf.get("lorax", "sharedir"))
|
||||||
if os.path.isdir(joinpaths(templatedir, "templates.d")):
|
logger.info("Using templatedir %s", self._templatedir)
|
||||||
try:
|
|
||||||
templatedir = sorted(glob(joinpaths(templatedir, "templates.d", "*")))[0]
|
|
||||||
except IndexError:
|
|
||||||
pass
|
|
||||||
logger.info("Using templatedir %s", templatedir)
|
|
||||||
self._templatedir = templatedir
|
|
||||||
return self._templatedir
|
return self._templatedir
|
||||||
|
|
||||||
def init_stream_logging(self):
|
def init_stream_logging(self):
|
||||||
@ -424,3 +418,23 @@ def setup_logging(logfile, theLogger):
|
|||||||
fh = logging.FileHandler(filename=f, mode="w")
|
fh = logging.FileHandler(filename=f, mode="w")
|
||||||
fh.setLevel(logging.DEBUG)
|
fh.setLevel(logging.DEBUG)
|
||||||
program_log.addHandler(fh)
|
program_log.addHandler(fh)
|
||||||
|
|
||||||
|
|
||||||
|
def find_templates(templatedir="/usr/share/lorax"):
|
||||||
|
""" Find the templates to use.
|
||||||
|
|
||||||
|
:param str templatedir: Top directory to search for templates
|
||||||
|
:returns: Path to templates
|
||||||
|
:rtype: str
|
||||||
|
|
||||||
|
If there is a templates.d directory under templatedir the
|
||||||
|
lowest numbered directory entry is returned.
|
||||||
|
|
||||||
|
eg. /usr/share/lorax/templates.d/99-generic/
|
||||||
|
"""
|
||||||
|
if os.path.isdir(joinpaths(templatedir, "templates.d")):
|
||||||
|
try:
|
||||||
|
templatedir = sorted(glob(joinpaths(templatedir, "templates.d", "*")))[0]
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
return templatedir
|
||||||
|
@ -45,7 +45,7 @@ from mako.template import Template
|
|||||||
from mako.exceptions import text_error_template
|
from mako.exceptions import text_error_template
|
||||||
|
|
||||||
# Use the Lorax treebuilder branch for iso creation
|
# Use the Lorax treebuilder branch for iso creation
|
||||||
from pylorax import ArchData, setup_logging
|
from pylorax import ArchData, setup_logging, find_templates
|
||||||
from pylorax.base import DataHolder
|
from pylorax.base import DataHolder
|
||||||
from pylorax.treebuilder import TreeBuilder, RuntimeBuilder, udev_escape
|
from pylorax.treebuilder import TreeBuilder, RuntimeBuilder, udev_escape
|
||||||
from pylorax.treebuilder import findkernels
|
from pylorax.treebuilder import findkernels
|
||||||
@ -1091,7 +1091,7 @@ def main():
|
|||||||
type=os.path.abspath,
|
type=os.path.abspath,
|
||||||
help="Name and path for primary logfile, other logs will "
|
help="Name and path for primary logfile, other logs will "
|
||||||
"be created in the same directory.")
|
"be created in the same directory.")
|
||||||
parser.add_argument("--lorax-templates", default="/usr/share/lorax/",
|
parser.add_argument("--lorax-templates", default=None,
|
||||||
type=os.path.abspath,
|
type=os.path.abspath,
|
||||||
help="Path to mako templates for lorax")
|
help="Path to mako templates for lorax")
|
||||||
parser.add_argument("--tmp", default="/var/tmp", type=os.path.abspath,
|
parser.add_argument("--tmp", default="/var/tmp", type=os.path.abspath,
|
||||||
@ -1205,6 +1205,9 @@ def main():
|
|||||||
|
|
||||||
log.debug( opts )
|
log.debug( opts )
|
||||||
|
|
||||||
|
# Find the lorax templates
|
||||||
|
opts.lorax_templates = find_templates(opts.lorax_templates or "/usr/share/lorax")
|
||||||
|
|
||||||
# Check for invalid combinations of options, print all the errors and exit.
|
# Check for invalid combinations of options, print all the errors and exit.
|
||||||
errors = []
|
errors = []
|
||||||
if not opts.disk_image and not opts.fs_image and not opts.ks:
|
if not opts.disk_image and not opts.fs_image and not opts.ks:
|
||||||
|
Loading…
Reference in New Issue
Block a user