[PATCH] Simplify template precedence
Hello,
Currently it is not possible to override the templates for a single package - its either you maintain a copy of what you need in config/templates or in another directory which you specify wit the LH_TEMPLATES option. To faciliate, for example, only customizing the syslinux template files I've created this patch which simplifies the logic in functions/templates.sh to if config/templates/${PACKAGE} exists then use that else if ${LH_TEMPLATES}/${PACKAGE} exists then use that else error out. Which not only does it allow for the extra flexability but it also makes the templates.sh file much easier to read/understand plus I was personally surprised it didn't already work like this.
templates.sh | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
Cheers,
--
Cody A.W. Somerville
Software Systems Release Engineer
Foundations Team
Custom Engineering Solutions Group
Canonical OEM Services
Phone: +1-781-850-2087
Cell: +1-506-471-8402
Email: cody.somerville@canonical.com
diff --git a/functions/templates.sh b/functions/templates.sh
index 846034b..3735b21 100755
--- a/functions/templates.sh
+++ b/functions/templates.sh
@@ -11,23 +11,13 @@ Check_templates ()
{
PACKAGE="${1}"
- # Check user defined templates directory
- if [ ! -e "${LH_TEMPLATES}" ]
- then
- if [ -d config/templates ]
- then
- LH_TEMPLATES=config/templates
- else
- Echo_error "templates not accessible in %s nor config/templates" "${LH_TEMPLATES}"
- exit 1
- fi
- fi
-
- if [ -d "${LH_TEMPLATES}/${PACKAGE}" ]
+ if [ -d "config/templates/${PACKAGE}" ]
then
+ TEMPLATES="config/templates/${PACKAGE}"
+ elif [ -d "${LH_TEMPLATES}/${PACKAGE}" ]
TEMPLATES="${LH_TEMPLATES}/${PACKAGE}"
else
- Echo_error "%s templates not accessible in %s" "${PACKAGE}" "${LH_TEMPLATES}"
+ Echo_error "%s templates not accessible in %s nor config/templates" "${PACKAGE}" "${LH_TEMPLATES}"
exit 1
fi
}
Reply to: