]> gitweb.fluxo.info Git - simplepkg.git/commitdiff
jail-commit: template_merge with symlink support
authorrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Thu, 5 Apr 2007 14:49:00 +0000 (14:49 +0000)
committerrhatto <rhatto@04377dda-e619-0410-9926-eae83683ac58>
Thu, 5 Apr 2007 14:49:00 +0000 (14:49 +0000)
git-svn-id: svn+slack://slack.fluxo.info/var/svn/simplepkg@239 04377dda-e619-0410-9926-eae83683ac58

trunk/src/jail-commit

index 9fa80aba1e6ee597b5e13ec8d9563e280bc99d66..f4d0f0daff70f222efdf602745554bd9eac6d944 100755 (executable)
@@ -48,22 +48,32 @@ function template_merge {
   cd $TEMPLATE_BASE.d
 
   for file in `find | grep -v -e "/.svn$" | grep -v -e "/.svn/"`; do
-    if [[ -f "$file" && -f "$1/$file" ]]; then
-      if ! diff $file $1/$file; then
-        echo updating $file
-        cp -af $1/$file $file
+
+    if [[ -e "$file" && -e "$1/$file" ]]; then
+
+      if [ ! -d "$file" ] && [ ! -s "$file" ]; then
+        if ! diff $file $1/$file; then
+          echo updating $file
+          cp -af $1/$file $file
+        fi
+      elif [ -s "$file" ]; then
+        if [ "`readlink $file`" != "`readlink $1/$file`" ]; then
+          rm -f $file
+          ln -s \"`readlink $1/$file`\" $file
+        fi
       fi
+
       perms="`numeric_perm $1/$file`"
       owner="`get_owner $1/$file`"
       group="`get_group $1/$file`"
       echo "$file;$owner;$group;$perms" >> $TEMPLATE_BASE.perms
+
     else
-      if [ ! -f "$file" ]; then
-        echo $BASENAME: warning: missing file $file 
-      else
-        echo $BASENAME: warning: missing template file $1/$file 
+      if [ ! -e "$1/$file" ]; then
+        echo $BASENAME: warning: missing file $1/$file 
       fi
     fi
+
   done
 
 }