diff options
author | Julian Andres Klode <jak@debian.org> | 2024-04-13 19:27:32 +0200 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2024-04-13 19:27:32 +0200 |
commit | 979a018c2fd3fa253c7edc05f35f202f631c2d05 (patch) | |
tree | 0b4beaddd713240413df52418d6e8a1503780c38 | |
parent | 9d864c7dab6499eb99d8ec8c932826b1db67c335 (diff) |
Space needed: Show space available in /usr
-rw-r--r-- | apt-private/private-install.cc | 25 |
1 files 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 <map> #include <set> #include <vector> +#include <sys/statvfs.h> #include <apt-private/acqprogress.h> #include <apt-private/private-cachefile.h> @@ -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 |