aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-11-30 13:47:17 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-11-30 13:47:17 +0200
commite2baea15dc24be12342b373627ca4f0534aeeb50 (patch)
tree25c1fa5c770f7531d809f4745b8ddbad9e9d499c /libbuild2
parent92b07419515b7c9a18608684ceef97287b97bcf1 (diff)
Don't fail if unable to remove empty directory on uninstall
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/install/rule.cxx18
1 files changed, 15 insertions, 3 deletions
diff --git a/libbuild2/install/rule.cxx b/libbuild2/install/rule.cxx
index a6a0aaf..d4921ae 100644
--- a/libbuild2/install/rule.cxx
+++ b/libbuild2/install/rule.cxx
@@ -1050,6 +1050,11 @@ namespace build2
// used can get complicated. So we will always use rm/rmdir from
// MSYS2/Cygwin which go above and beyond to accomplish the mission.
//
+ // Note also that it's possible we didn't create the directory and
+ // won't be able to remove it due to permissions (for example, on Mac
+ // OS we cannot remove empty /usr/local even with sudo). So instead of
+ // failing we issue a warning and skip the directory.
+ //
#ifndef _WIN32
if (base.sudo == nullptr)
{
@@ -1065,9 +1070,9 @@ namespace build2
{
try_rmdir (chd);
}
- catch (const system_error& e)
+ catch (const system_error&)
{
- fail << "unable to remove directory " << chd << ": " << e;
+ r = false;
}
}
else
@@ -1091,7 +1096,14 @@ namespace build2
text << "uninstall " << reld;
}
- run (pp, args);
+ process pr (run_start (pp, args));
+ r = run_finish_code (args, pr);
+ }
+
+ if (!r)
+ {
+ warn << "unable to remove empty directory " << chd << ", ignoring";
+ return false;
}
}