[PATCH] fix apply-live-updates failing because of /lib symlink

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since cp won't copy a directory over a symlink, any updates that were
supposed to go into e.g. /lib would get dropped if you had /updates/lib
as an actual directory, but the target system had /lib->/usr/lib.
---
 modules.d/90dmsquash-live/apply-live-updates.sh |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/modules.d/90dmsquash-live/apply-live-updates.sh b/modules.d/90dmsquash-live/apply-live-updates.sh
index f840d1a..144e8b9 100755
--- a/modules.d/90dmsquash-live/apply-live-updates.sh
+++ b/modules.d/90dmsquash-live/apply-live-updates.sh
@@ -1,9 +1,17 @@
 #!/bin/sh
-if [ -b /dev/mapper/live-rw ]; then
-    if [ -d /updates ]; then
-        echo "Applying updates to live image..."
+
+. /tmp/root.info
+
+if [ -b /dev/mapper/live-rw ] && [ -d /updates ]; then
+    info "Applying updates to live image..."
+    # avoid overwriting symlinks (e.g. /lib -> /usr/lib) with directories
+    (
         cd /updates
-        /bin/cp -a -t $NEWROOT .
-        cd -
-    fi
+        find . -depth -type d | while read dir; do
+            [ -d "$NEWROOT/$dir" ] || mkdir -p "$NEWROOT/$dir"
+        done
+        find . -depth \! -type d | while read file; do
+            cp -a "$file" "$NEWROOT/$file"
+        done
+    )
 fi
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux