[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [PATCH] Simplify template precedence



Apologizes, I had a typo in my previous patch. Please see the attachment to this e-mail for the correct version of patch.

 templates.sh |   17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

On Fri, Jun 5, 2009 at 2:41 PM, Cody A.W. Somerville <cody.somerville@canonical.com> wrote:
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..eec52f3 100755
--- a/functions/templates.sh
+++ b/functions/templates.sh
@@ -11,23 +11,14 @@ Check_templates ()
 {
 	PACKAGE="${1}"
 
-	# Check user defined templates directory
-	if [ ! -e "${LH_TEMPLATES}" ]
+	if [ -d "config/templates/${PACKAGE}" ]
 	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}" ]
+		TEMPLATES="config/templates/${PACKAGE}"
+	elif [ -d "${LH_TEMPLATES}/${PACKAGE}" ]
 	then
 		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: