This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=cf55e9f07217749dee34125be2bb0407fde75374

commit cf55e9f07217749dee34125be2bb0407fde75374
Author: Guillem Jover <[email protected]>
AuthorDate: Sat Nov 20 18:41:35 2021 +0100

    dpkg-fsys-usrunmess: Do not fail when removing lingering directories
    
    These directories might contain untracked files, if they are not empty,
    failing the whole script will be worse. Keep track of them, and print a
    summary at the end of the run.
    
    Stable-Candidate: 1.20.x
---
 man/dpkg-fsys-usrunmess.pod    |  4 ++++
 scripts/dpkg-fsys-usrunmess.pl | 17 ++++++++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/man/dpkg-fsys-usrunmess.pod b/man/dpkg-fsys-usrunmess.pod
index 08df56b59..818eec3af 100644
--- a/man/dpkg-fsys-usrunmess.pod
+++ b/man/dpkg-fsys-usrunmess.pod
@@ -110,6 +110,10 @@ B<Note>: When running the program from some shells such as 
L<bash(1)> or
 L<zsh(1)>, after executing it, you might need to request the shell to
 forget all remembered executable locations with for example C<hash -r>.
 
+B<Note>: Some directories might linger after the migration in case they
+contain untracked files. A list is printed once the script has finished
+for further investigation.
+
 B<Warning>: Note that this operation has the potential to render the system
 unusable or broken in case of a sudden crash or reboot, unexpected state of
 the system, or possible bugs in the script. Be prepared with recovery media
diff --git a/scripts/dpkg-fsys-usrunmess.pl b/scripts/dpkg-fsys-usrunmess.pl
index ec2cb97b5..7a38caae0 100755
--- a/scripts/dpkg-fsys-usrunmess.pl
+++ b/scripts/dpkg-fsys-usrunmess.pl
@@ -341,17 +341,21 @@ foreach my $dir (keys %deferred_dirnames) {
     $batch_size = 0;
 }
 
+my @dirs_linger;
+
 if (not $opt_noact) {
     foreach my $dirname (reverse sort keys %deferred_dirnames) {
-        rmdir $dirname
-            or sysfatal("cannot remove shadow directory $dirname");
+        next if rmdir $dirname;
+        warning("cannot remove shadow directory $dirname: $!");
+
+        push @dirs_linger, $dirname;
     }
 }
 
 if (not $opt_noact) {
     debug("cleaning up shadow root dir = $sroot");
     rmdir $sroot
-        or sysfatal("cannot remove shadow directory $sroot");
+        or warning("cannot remove shadow directory $sroot: $!");
 }
 
 #
@@ -403,6 +407,13 @@ if (not $opt_noact) {
 
 print "\n";
 
+if (@dirs_linger) {
+    warning("lingering directories that could not be removed:");
+    foreach my $dir (@dirs_linger) {
+        warning("  $dir");
+    }
+}
+
 print "Done, hierarchy unmessed, congrats!\n";
 print "Rebooting now is very strongly advised.\n";
 

-- 
Dpkg.Org's dpkg

Reply via email to