]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix apply-live-updates failing because of /lib symlink
authorWill Woods <wwoods@redhat.com>
Wed, 7 Mar 2012 22:22:18 +0000 (17:22 -0500)
committerHarald Hoyer <harald@redhat.com>
Thu, 8 Mar 2012 09:58:42 +0000 (10:58 +0100)
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

index f840d1a28cad832d2f45cd0bd6e8704fe5304ff7..144e8b9138bbfd571354db505865fec4b0ac875f 100755 (executable)
@@ -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