]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
templatepkg: added function check_template_exist
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Wed, 4 Apr 2007 16:40:21 +0000 (16:40 +0000)
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Wed, 4 Apr 2007 16:40:21 +0000 (16:40 +0000)
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@232 04377dda-e619-0410-9926-eae83683ac58

trunk/lib/common.sh
trunk/src/templatepkg

index 9a1f1e00d94fa3cbf7b3ed810fcb661564cc9887..6d2326269d2680ba712a85fcfbc3f74a067eb376 100644 (file)
@@ -372,7 +372,6 @@ function search_template {
         TEMPLATE_BASE="$BASE_CONF/templates/$1"
       else
         TEMPLATE_BASE="$BASE_CONF/templates/$1/$1"
-        mkdir -p $BASE_CONF/templates/$1
       fi
     elif [ "$2" == "--update" ]; then
       return 1
index e2feaa7a23e0bf21050464c59c929fc5ad4d810f..b0afb3bc145d1178ef3dec8aaacfcddb0101c381 100755 (executable)
@@ -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