aboutsummaryrefslogtreecommitdiff
path: root/lib/common.sh
diff options
context:
space:
mode:
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2007-02-08 23:58:09 +0000
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>2007-02-08 23:58:09 +0000
commitf7595585fae0e0844877ad111388837aaf74028b (patch)
treec8d1d2804b91b31afcc8a7df68396da3561dbdd3 /lib/common.sh
parent3a77360e6a7f41db20c126a6a91d46591b0390d0 (diff)
downloadsimplepkg-f7595585fae0e0844877ad111388837aaf74028b.tar.gz
simplepkg-f7595585fae0e0844877ad111388837aaf74028b.tar.bz2
changing template location procedures
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@163 04377dda-e619-0410-9926-eae83683ac58
Diffstat (limited to 'lib/common.sh')
-rw-r--r--lib/common.sh52
1 files changed, 52 insertions, 0 deletions
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: <search-template> <template-name> [--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
+
+}
+