From e2baea15dc24be12342b373627ca4f0534aeeb50 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 30 Nov 2020 13:47:17 +0200 Subject: Don't fail if unable to remove empty directory on uninstall --- libbuild2/install/rule.cxx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'libbuild2') 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; } } -- cgit v1.1