=== modified file 'debian/changelog' --- debian/changelog 2013-09-07 17:52:10 +0000 +++ debian/changelog 2013-09-26 21:56:34 +0000 @@ -1,3 +1,12 @@ +initramfs-tools-ubuntu-touch (0.50) UNRELEASED; urgency=low + + * Add a new "synced" mode to writable-paths which will automatically copy + any new file appearing on the filesystem but won't remove any extra file + from the target (this should be used with care and with full understanding + of the consequences). (LP: #1227520) + + -- Stéphane Graber Thu, 26 Sep 2013 17:55:27 -0400 + initramfs-tools-ubuntu-touch (0.49) saucy; urgency=low * Use stat to restore the file ownership and permissions when diverting === modified file 'scripts/touch' --- scripts/touch 2013-09-07 17:52:04 +0000 +++ scripts/touch 2013-09-26 21:54:57 +0000 @@ -7,6 +7,35 @@ [ "$quiet" != "y" ] && log_end_msg } +sync_dirs() { + base=$1 + source=$2 + target=$3 + + OLD_PWD=$PWD + cd $base + + for file in $source/* + do + # Skip empty directories + [ ! -e "$base/$file" ] && continue + + # If the target already exists as a file, there's nothing we can do + [ -e "$target/$file" ] && [ ! -d "$target/$file" ] && continue + + # If the target doesn't exist, just copy it over + if [ ! -e "$target/$file" ]; then + cp -Ra "$base/$file" "$target/$file" + continue + fi + + # That leaves us with directories and a recursive call + [ -d $file ] && sync_dirs $base $file $target + done + + cd $OLD_PWD +} + mountroot() { # list of possible userdata partition names @@ -107,7 +136,7 @@ if [ "$3" = "temporary" ]; then # Temporary entries are simple, just mount a tmpfs echo "tmpfs $1 tmpfs $5 0 1" >> $FSTAB - elif [ "$3" = "persistent" ]; then + elif [ "$3" = "persistent" ] || [ "$3" = "synced" ]; then # Figure out the source path if [ "$2" = "auto" ]; then srcpath="${rootmnt}/userdata/system-data/$1" @@ -118,9 +147,9 @@ fi if [ ! -e "$srcpath" ]; then + # Process new persistent or synced paths dstown=$(stat -c "%u:%g" $dstpath) dstmode=$(stat -c "%a" $dstpath) - # Process new persistent paths mkdir -p ${srcpath%/*} if [ ! -d "$dstpath" ]; then # Deal with redirected files @@ -141,6 +170,9 @@ chmod $dstmode $srcpath fi fi + elif [ "$3" = "synced" ]; then + # Process existing synced paths + sync_dirs $dstpath . $srcpath fi # Write the fstab entry