]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
templatepkg: added function template_delete
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Thu, 5 Apr 2007 16:51:05 +0000 (16:51 +0000)
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Thu, 5 Apr 2007 16:51:05 +0000 (16:51 +0000)
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@245 04377dda-e619-0410-9926-eae83683ac58

trunk/src/templatepkg

index b1847208fa8ce3f2d5b0d89f62011b712a51c49e..1f10ebc9daf7e6acacdb621c71e58c2788527f23 100755 (executable)
@@ -396,7 +396,34 @@ function check_template_exist {
 
 }
 
-# command line parsing
+function template_delete {
+
+  # delete a file from a template
+  # usage: template_delete <file>
+
+  if [ -a "$TEMPLATE_BASE.d/$1" ]; then
+    if use_svn && [ -d "$TEMPLATE_BASE.d/.svn" ]; then
+      cd $TEMPLATE_BASE.d
+      svn del --force ./$1 || rm -rf ./$1
+      echo $BASENAME: please run jail-commit to del $1 in the svn repository
+    else
+      rm -rf $TEMPLATE_BASE.d/$1
+      echo Removed $1 from $TEMPLATE_BASE.d
+    fi
+  else
+    if [ ! -d "$TEMPLATE_BASE.d" ]; then
+      echo $BASENAME: template folder $TEMPLATE_BASE.d not found
+    else
+      echo $BASENAME: file $1 not found at $TEMPLATE_BASE.d
+    fi
+    exit 1
+  fi
+
+}
+
+# -----------------------------------------------------
+#                       main
+# -----------------------------------------------------
 
 if [ -z "$2" ]; then
   usage
@@ -430,18 +457,7 @@ elif [ "$1" == "-d" ] || [ "$1" == "--delete" ]; then
   if [ -z "$3" ]; then
     usage
   else
-
-    if [ -a "$TEMPLATE_BASE.d/$3" ]; then
-      if use_svn && [ -d "$TEMPLATE_BASE.d/.svn" ]; then
-        cd $TEMPLATE_BASE.d
-        svn del --force ./$3 || rm -rf ./$3
-        echo $BASENAME: please run jail-commit to del $3 in the svn repository
-      else
-        rm -rf $TEMPLATE_BASE.d/$3
-        echo Removed $3 from $TEMPLATE_BASE.d
-      fi
-    fi
-
+    template_delete $3
   fi
 
 elif [ "$1" == "-s" ] || [ "$1" == "--sync" ]; then