From 979a018c2fd3fa253c7edc05f35f202f631c2d05 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 13 Apr 2024 19:27:32 +0200 Subject: Space needed: Show space available in /usr --- apt-private/private-install.cc | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc index 4cf10b481..a7fa54f31 100644 --- a/apt-private/private-install.cc +++ b/apt-private/private-install.cc @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -333,10 +334,30 @@ bool InstallPackages(CacheFile &Cache, APT::PackageVector &HeldBackPackages, boo // Size delta if (Cache->UsrSize() >= 0) + { //TRANSLATOR: The required space between number and unit is already included // in the replacement string, so %sB will be correctly translate in e.g. 1,5 MB - ioprintf(c1out,outVer < 30 ? _("After this operation, %sB of additional disk space will be used.\n") : _(" Space needed: %sB\n"), - SizeToStr(Cache->UsrSize()).c_str()); + if (outVer < 30) + ioprintf(c1out, _("After this operation, %sB of additional disk space will be used.\n"), + SizeToStr(Cache->UsrSize()).c_str()); + else + { + struct statvfs st; + if (statvfs("/usr", &st) == 0) + { + // TRANSLATOR: The required space between number and unit is already included + // in the replacement string, so %sB will be correctly translate in e.g. 1,5 MB + ioprintf(c1out, _(" Space needed: %sB / approx. %sB available\n"), + SizeToStr(Cache->UsrSize()).c_str(), SizeToStr((st.f_bsize * st.f_bavail)).c_str()); + } + else + { + // TRANSLATOR: The required space between number and unit is already included + // in the replacement string, so %sB will be correctly translate in e.g. 1,5 MB + ioprintf(c1out, _(" Space needed: %sB\n"), SizeToStr(Cache->UsrSize()).c_str()); + } + } + } else //TRANSLATOR: The required space between number and unit is already included // in the replacement string, so %sB will be correctly translate in e.g. 1,5 MB -- cgit v1.2.3-70-g09d2