Okay, attachments aren't working. Here's the patch:

--- apkg.orig    2014-09-18 23:20:09.000000000 -0700
+++ apkg    2014-10-15 15:54:37.625305482 -0700
@@ -200,24 +200,42 @@
 # figure out which files have changed from this package
 
 package_changed_files () {
-    local tmp
+    local tmp tmpdir mktmpd s_syms s_dirs s_files
     tmp=$TMP/$SESSIONID.sha1
+    tmpdir=$TMP/$SESSIONID.tar
 
     (
     cd $PKGROOT
     echo > $tmp
     
+    NL="
+"
     for pkg in $@ ; do
-        if [ -f $PKGDIR/$pkg.local ]; then
-            for a in $(find $(cat $PKGDIR/$pkg.local) -type f 2>/dev/null); do
-                ! grep -h "[ /]${a}\$" $PKGDIR/*.sha1 >>$tmp 2>/dev/null && \
-                echo "0000000000000000000000000000000000000000  ${a}" >>$tmp
-            done
-        fi    
+       if [ -f $PKGDIR/$pkg.local ] ; then
+          for a in $(find $(cat $PKGDIR/$pkg.local) 2>/dev/null); do
+             if [ -L $a ] ; then
+                [ "$mktmpd" != "1" ] && mkdir $tmpdir && mktmpd=1
+                # if symlink doesn't exist or if it changed
+                if ! tar xzf $STORAGE_MEDIA/$pkg.lrp -C $tmpdir $a 2>/dev/null 
|| \
+                      [ "$(readlink $a)" != "$(readlink $tmpdir/$a)" ] ; then
+                   s_syms=$s_syms"$a"$NL
+                fi
+             elif  [ -d $a ] ; then
+                # Only add empty directories, non-empty dirs are always backed 
up
+                if ! [ "$(ls -A $a)" ] ; then
+                   s_dirs=$s_dirs"$a"$NL
+                fi
+             elif [ -f $a ] ; then
+                ! grep -h "[ /]${a}\$" $PKGDIR/*.sha1 >>$tmp 2>/dev/null && \
+                   echo "0000000000000000000000000000000000000000  ${a}" >>$tmp
+             fi    
+          done
+          [ "$mktmpd" = "1" ] && rm -rf $tmpdir && mktmpd=0
+       fi    
     done        
-    
-    sha1sum -c $tmp 2>/dev/null | grep FAILED | sed -e "s/: FAILED//" | \
-        sort | uniq
+
+    s_files=$(sha1sum -c $tmp 2>/dev/null | grep FAILED | sed -e "s/: 
FAILED//")
+    echo "$s_syms$s_dirs$s_files" | sort | uniq
     )
 
     rm -f $tmp
@@ -407,7 +425,7 @@
 #
 
 rundiff () {
-    local backup_path vs_saved saved changed interest lrp
+    local backup_path vs_saved saved changed interest lrp run_sym sav_sym
     vs_saved=$1
 
     if [ ! -f $BACKUP_PATH/$configdb.lrp ] ; then
@@ -442,15 +460,33 @@
     interest=$(for file in $interest ; do echo $file ; done | sort | uniq)
 
     for file in $interest ; do
-        if [ ! -f running/$file ] ; then
-        echo "*** $file has been deleted"
-        elif [ -f $vs_saved/$file ] ; then
-        diff -u $vs_saved/$file running/$file
-        elif [ -f distribution/$file ] ; then
-        diff -u distribution/$file running/$file
-        else
-        diff -u /dev/null running/$file
-        fi
+       if [ -L running/$file ] ; then
+          run_sym=$(readlink running/$file)
+          sav_sym=$(readlink $vs_saved/$file)
+          if [ "$run_sym" != "" ] && [ "$sav_sym" = "" ]; then
+             echo "*** $file is NEW symbolic link"
+          elif [ "$run_sym" != "$sav_sym" ]; then
+             echo "*** $file is MODIFIED symbolic link"
+          fi
+       elif [ -d running/$file ] ; then
+          if ! [ -d $vs_saved/$file ] && ! [ -d distribution/$file ] ; then
+             echo "*** $file is NEW empty directory"
+          fi
+       elif [ ! -f running/$file ] ; then
+          if [ -L $vs_saved/$file ] ; then
+             echo "*** $file is DELETED symbolic link"
+          else
+             echo "*** $file has been DELETED"
+          fi
+       elif [ "$(stat -c %s running/$file)" = "0" ] && ! [ -f $vs_saved/$file 
] ; then
+          echo "*** $file is NEW empty file"
+       elif [ -f $vs_saved/$file ] ; then
+          diff -u $vs_saved/$file running/$file
+       elif [ -f distribution/$file ] ; then
+          diff -u distribution/$file running/$file
+       else
+          diff -u /dev/null running/$file
+       fi
     done
     }




----- Original Message -----
From: cpu memhd <cpume...@yahoo.com>
To: "leaf-devel@lists.sourceforge.net" <leaf-devel@lists.sourceforge.net>
Cc: 
Sent: Wednesday, October 15, 2014 4:23 PM
Subject: Re: [leaf-devel] apkg and configdb.lrp, symlinks and empty directories

Sorry, this went private.

In the example below that is in the 'replied to' text, apkg does not backup 
symlinks or empty directories and is confirmed by KP. But it's not a bug. 
That's how it was designed. Symlinks are very important to me and I can't 
imagine not using them. The only other way is to create them on the fly during 
bootup. Same goes for empty directories.

I've attached a diff that will allow apkg to backup empty directories and 
symbolic links. It also has a more informative rundiff() which shows more of 
what changed.

I've use this daily for the past week or so. Just cleaned it up a little today. 
If anyone is interested in the new features, please give it a try.


On Wednesday, October 15, 2014 10:04 AM, kp kirchdoerfer 
<kap...@users.sourceforge.net> wrote:
Hi;

Am Dienstag, 14. Oktober 2014, 21:43:56 schrieben Sie:
> When you specify a directory in a .local file (eg., usr/local) it will
> backup everything inside that directory except for empty directories or
> symlinks. I have not tried a symlink specified in a .local. I don't see
> that there is a way for it to work the way I think it should based on the
> code.
>
> Here's an example:
>
> Add this to buildtool.cfg for the local.lrp and rebuild package:
>
>
> <File>
>    Filename    = usr/local
>    Type        = directory
>    Type        = local
>    Permissions = 755
> </File>
>
>
> Or maybe you can just add:
>
> usr/local
>
> ...to the existing local.local file. Then...
>
>
> cd /usr/local
> ln -s /tmp .
> mkdir emptydir
>
>
> Now run a backup with:
>
> with_storage -r $MNT apkg -r
>
> Then restore the local.lrp file to your temp directory and you will find
> that neither symlinks or empty directories are backed up.

You are right - it does not work, neither for empty directories nor for
symlinked files.

What is this a real problem for you?
I mean any chance we can solve this with our current logic?

You're of course welcome to improve apkg, but it will require a lot of testing
- but that's what betas are meant to be. 

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho

_______________________________________________
leaf-devel mailing list
leaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/leaf-devel

Reply via email to