From f7595585fae0e0844877ad111388837aaf74028b Mon Sep 17 00:00:00 2001 From: rhatto Date: Thu, 8 Feb 2007 23:58:09 +0000 Subject: changing template location procedures git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@163 04377dda-e619-0410-9926-eae83683ac58 --- lib/common.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'lib') diff --git a/lib/common.sh b/lib/common.sh index 2b78c10..5b82469 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -198,6 +198,10 @@ function eval_config { FTP_TOOL="`eval_parameter FTP_TOOL curl`" HTTP_TOOL="`eval_parameter HTTP_TOOL curl`" CONNECT_TIMEOUT="`eval_parameter CONNECT_TIMEOUT 0`" + TEMPLATE_FOLDER="`eval_parameter TEMPLATE_BASE /etc/simplepkg/templates`" + + # TODO: also add this stuff in simplepkg.conf.new + # TEMPLATE_STORAGE_STYLE SIMPLARET_CLEAN="`eval_boolean_parameter SIMPLARET_CLEAN 1`" SIMPLARET_DELETE_DOWN="`eval_boolean_parameter SIMPLARET_DELETE_DOWN 1`" @@ -307,3 +311,51 @@ function default_arch { } +function search_default_template { + + if [ -f "$BASE_CONF/templates/default.template" ]; then + TEMPLATE_BASE="$BASE_CONF/templates/default" + echo $BASENAME: using default template + elif [ -f "$BASE_CONF/default.template" ]; then + TEMPLATE_BASE="$BASE_CONF/default" + echo $BASENAME using default template + else + echo $BASENAME: error: default template not found + echo $BASENAME: please create a template using templatepkg + return 1 + fi +} + +function search_template { + + # determine the template to be used + # usage: [--new] + + # + # templates can be stored either on + # + # - $BASE_CONF/template_name.template + # - $BASE_CONF/templates/template_name.template + # - $BASE_CONF/templates/template_name/template_name.template + # + + if [ -f "$BASE_CONF/$1.template" ]; then + TEMPLATE_BASE="$BASE_CONF/$1" + elif [ -f "$BASE_CONF/templates/$1.template" ]; then + TEMPLATE_BASE="$BASE_CONF/templates/$1" + elif [ -f "$BASE_CONF/templates/$1/$1.template" ]; then + TEMPLATE_BASE="$BASE_CONF/templates/$1/$1" + else + if [ "$2" == "--new" ]; then + # we need to return the path for a new template + # TODO: set a path for the new template + # TODO: TEMPLATE_STORAGE_STYLE + true + else + echo $BASENAME: template $1 not found + search_default_template + fi + fi + +} + -- cgit v1.2.3