From 2d979f783b11c05450d449633ba55e6702b4e798 Mon Sep 17 00:00:00 2001 From: rhatto Date: Wed, 4 Apr 2007 16:40:21 +0000 Subject: templatepkg: added function check_template_exist git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@232 04377dda-e619-0410-9926-eae83683ac58 --- trunk/src/templatepkg | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'trunk/src') diff --git a/trunk/src/templatepkg b/trunk/src/templatepkg index e2feaa7..b0afb3b 100755 --- a/trunk/src/templatepkg +++ b/trunk/src/templatepkg @@ -214,14 +214,7 @@ function template_update { # update the template package list - components="$TEMPLATE_BASE.template $TEMPLATE_BASE.perms $TEMPLATE_BASE.d $TEMPLATE_BASE.s" - for component in $components; do - if [ ! -e "$component" ]; then - echo $BASENAME: template component not found: $component - echo $BASENAME: please run $BASENAME -c before update a template - exit 1 - fi - done + check_template_exist if [ ! -d "$ROOT/var/log/packages" ]; then echo $ROOT/var/log/packages: directory not found @@ -279,6 +272,8 @@ function template_add { return 1 fi + check_template_exist + jail="/$1" file="$2" @@ -363,6 +358,29 @@ function slash { } +function check_template_exist { + + # check if a template exists + + local components + + components="$TEMPLATE_BASE.template $TEMPLATE_BASE.perms $TEMPLATE_BASE.d $TEMPLATE_BASE.s" + + if [ ! -d "`dirname $TEMPLATE_BASE`" ]; then + echo $BASENAME: template not found + exit 1 + fi + + for component in $components; do + if [ ! -e "$component" ]; then + echo $BASENAME: template component not found: $component + echo $BASENAME: please run $BASENAME -c before update a template + exit 1 + fi + done + +} + # command line parsing if [ -z "$2" ]; then -- cgit v1.2.3