diff options
-rw-r--r-- | apt-pkg/aptconfiguration.cc | 2 | ||||
-rw-r--r-- | apt-private/private-install.cc | 49 |
2 files changed, 33 insertions, 18 deletions
diff --git a/apt-pkg/aptconfiguration.cc b/apt-pkg/aptconfiguration.cc index 0e4cecd99..dbfa00bb3 100644 --- a/apt-pkg/aptconfiguration.cc +++ b/apt-pkg/aptconfiguration.cc @@ -557,7 +557,7 @@ bool Configuration::checkUsrMerged() if (stat(dirInUsr.c_str(), &usr)) continue; if (root.st_ino != usr.st_ino) - return _error->Error("%s resolved to a different inode than %s", dirInRoot.c_str(), dirInUsr.c_str()); + return _error->Warning("%s resolved to a different inode than %s", dirInRoot.c_str(), dirInUsr.c_str()), false; } return true; diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index a195df848..e366634ad 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -111,8 +111,39 @@ static void RemoveDownloadNeedingItemsFromFetcher(pkgAcquire &Fetcher, bool &Tra I = Fetcher.ItemsBegin(); } } +#ifdef REQUIRE_MERGED_USR +// \brief Issues a warning about usrmerge when destructed so we can call it after install finished or failed or whatever. +struct WarnUsrMerge { + CacheFile &Cache; + WarnUsrMerge(CacheFile &Cache) : Cache(Cache) { + + } + void warn() { + auto usrmergePkg = Cache->FindPkg("usrmerge"); + if (not APT::Configuration::isChroot() && _config->FindDir("Dir") == std::string("/") && + not usrmergePkg.end() && not usrmergePkg.VersionList().end() && + not Cache[usrmergePkg].Install() && not APT::Configuration::checkUsrMerged()) + { + _error->Warning(_("Unmerged usr is no longer supported, use usrmerge to convert to a merged-usr system.")); + for (auto VF = usrmergePkg.VersionList().FileList(); not VF.end(); ++VF) + if (VF.File().Origin() != nullptr && VF.File().Origin() == std::string("Debian")) + { + // TRANSLATORS: %s is a url to a page describing merged-usr (bookworm release notes) + _error->Notice(_("See %s for more details."), "https://www.debian.org/releases/bookworm/amd64/release-notes/ch-information.en.html#a-merged-usr-is-now-required"); + break; + } + } + } + ~WarnUsrMerge() { + warn(); + } +}; +#endif bool InstallPackages(CacheFile &Cache, APT::PackageVector &HeldBackPackages, bool ShwKept, bool Ask, bool Safety, std::string const &Hook, CommandLine const &CmdL) { +#ifdef REQUIRE_MERGED_USR + WarnUsrMerge warnUsrMerge(Cache); +#endif if (not RunScripts("APT::Install::Pre-Invoke")) return false; if (_config->FindB("APT::Get::Purge", false) == true) @@ -216,23 +247,7 @@ bool InstallPackages(CacheFile &Cache, APT::PackageVector &HeldBackPackages, boo return _error->Error(_("Packages need to be removed but remove is disabled.")); #ifdef REQUIRE_MERGED_USR - _error->PushToStack(); - auto usrmergePkg = Cache->FindPkg("usrmerge"); - if (not APT::Configuration::isChroot() && _config->FindDir("Dir") == std::string("/") && - not usrmergePkg.end() && not usrmergePkg.VersionList().end() && - not Cache[usrmergePkg].Install() && not APT::Configuration::checkUsrMerged()) - { - _error->Error(_("Unmerged usr is no longer supported, install usrmerge to continue.")); - for (auto VF = usrmergePkg.VersionList().FileList(); not VF.end(); ++VF) - if (VF.File().Origin() == std::string("Debian")) - { - // TRANSLATORS: %s is a url to a page describing merged-usr (bookworm release notes) - _error->Notice(_("See %s for more details."), "https://www.debian.org/releases/bookworm/amd64/release-notes/ch-information.en.html#a-merged-usr-is-now-required"); - break; - } - return false; - } - _error->RevertToStack(); + warnUsrMerge.warn(); #endif // Fail safe check |