Samuel Thibault, le mer. 21 sept. 2022 23:46:09 +0000, a ecrit:
> Can't exec "cp": No such file or directory at 
> /usr/lib/usrmerge/convert-usrmerge line 418.
> 
> FATAL ERROR:
> Failed to execute cp --no-dereference --preserve=all --reflink=auto 
> --sparse=always /lib/ld.so.1 /usr/lib/ld.so.1: No such file or directory
> 
> You can try correcting the errors reported and running again
> /usr/lib/usrmerge/convert-usrmerge until it will complete without errors.
> Do not install or update other Debian packages until the program
> has been run successfully.
> 
> E: usrmerge failed.
> 
> 
> Apparently it is trying to move ld.so but fails to do it properly. I
> didn't find which code takes care of doing it properly?

It seems the code is cautious about symlinks, but only at one level of
recursion. The attached patch fixes it by continuing deferring symlinks
whose eventual target still doesn't exist yet.

Samuel
--- /usr/lib/usrmerge//convert-usrmerge 2022-09-18 21:04:17.000000000 +0000
+++ convert-usrmerge    2022-09-22 00:23:44.000000000 +0000
@@ -57,7 +57,11 @@
 
        # symlinks must be converted after the rest to avoid races, because
        # they may point to binaries which have not been converted yet
-       convert_file($_) foreach @later;
+       while (@later) {
+               my @newlater;
+               convert_file($_, \@newlater) foreach @later;
+               @later = @newlater;
+       }
 
        verify_links_only($_) foreach @dirs;
 
@@ -95,9 +99,16 @@
        }
 
        # is a link and the destination does not exist, but defer the conversion
-       if (-l $n and not -e "/usr$n" and $later) {
-               push(@$later, $n);
-               return;
+       if (-l $n and not -e "/usr$n") {
+               my $l = readlink($n);
+               my ($basedir) = $n =~ m#^(.+)/[^/]+$#;
+               if ($l !~ /^\// and not -e "/usr$basedir/$l") {
+                       if (not ($later)) {
+                               fatal("Converted link /usr$n would point to 
non-existing /usr$basedir/$l but we are not deferring conversion\n");
+                       }
+                       push(@$later, $n);
+                       return;
+               }
        }
 
        # is a file or link and the destination does not exist

Reply via email to