Page 1 of 1

snapmergepuppy - gets branch directories from aufs

Posted: Mon 18 May 2015, 08:15
by gyro
This is a version of the "snapmergepuppy" script that does not rely on puppy default directory names to find the appropriate branches of the stack. It queries the aufs files in /sys to get them, so it works no matter what the directories are.

The advantage in a normal puppy is that when processing ".wh." files, it searches all the lower branches, and only the actual branches, no matter what they are called.

Of course it also works if the lower branches are ordinary directories rather than mounted sfs files.

Here is the patch against tahrpup 6.0.2:

Code: Select all

--- snapmergepuppy.orig	2015-03-18 08:26:43.030087000 +1000
+++ snapmergepuppy	2015-05-15 13:42:36.359076293 +1000
@@ -57,19 +57,11 @@
 PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R7/bin"
 WD="`pwd`"
 
-SNAP="/initrd/pup_rw"
+SNAP="`cat /sys/fs/aufs/si_*/br0 | head -1 | cut -f1 -d'='`"
 cd $SNAP || exit 1
 
-if [ "$SAVE_LAYER" ]; then #defined in PUPSTATE
- BASE="/initrd${SAVE_LAYER}"
-else
- BASE="/initrd/pup_ro1"
-fi
-BASEMTP="`df-FULL --output=target "$BASE" | tail -1`"
-
-if [ -L $BASE ]; then #we have savefolder based on symbolic links
- BASE="`readlink -n -m $BASE`"
-fi
+BASE="`cat /sys/fs/aufs/si_*/br1 | head -1 | cut -f1 -d'='`"
+BASEMTP="`df-FULL --output=target \"$BASE\" | tail -1`"
 
 # Precautions
 [ $PUPMODE -eq 3 -o $PUPMODE -eq 7 -o $PUPMODE -eq 13 ] || { echo "Wrong PUPMODE ($PUPMODE)!"; exit 1; }
@@ -81,7 +73,12 @@
 # WHITEOUTS
 # =============================================================================
 
-SFSPoints=$( grep -o -E "/initrd/pup_ro[0-9]+|/initrd/pup_[ayz]" /proc/mounts )	#110206 Dougal: get a list of the sfs mountpoints	SFR: increase amount of mountpoints (sfs_load can load >=10) and add pup_[ayz]
+for XFL in /sys/fs/aufs/si_*/br[0-9]* #get aufs branch list
+do
+ XFN="${XFL##*/}"
+ [ ${XFN:2} -lt 2 ] && continue
+ SFSPoints="${SFSPoints}`cat ${XFL} | cut -f1 -d'='` "
+done
 
 find . -mount \( -regex '.*/\.wh\.[^/]*' -type f \) | sed -e 's/\.\///;s/\.wh\.//' |
 while read -r N
I have also attached a patched version of the "snapmergepuppy" from tahrpup 6.0.2

gyro