summaryrefslogtreecommitdiff
path: root/apt-pkg/deb/debsystem.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2020-03-06 13:10:04 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2020-03-06 13:14:37 +0100
commit1b81f6bd13bb31e59da3f53cfdc7caab43abf887 (patch)
treecf511b030725b1a7bb97f3c402ff5df773b84382 /apt-pkg/deb/debsystem.cc
parent68a83a64cd424385b613f58e23c03e262d840b91 (diff)
Show absolute time while waiting for lock instead of %, rework message
Showing a percentage for a timeout is pretty non-standard. Rework the progress class so it can show an absolute progress (currently hardcoded to use seconds as a unit). If there is a timeout (aka if it's not the maximum long long unsigned -1llu), then show the timeout, otherwise just count up seconds, e.g. Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 33842 (apt)... 1/120s or Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 33842 (apt)... 1s Also improve the error message to use "Waiting for cache lock: %s" instead of "... (%s)", as having multiple sentences inside parenthesis is super weird, as is having two closing parens. We pass the information via _config, as that's reasonably easy and avoids ABI hackage. It also provides an interesting debugging tool for other kinds of progress.
Diffstat (limited to 'apt-pkg/deb/debsystem.cc')
-rw-r--r--apt-pkg/deb/debsystem.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/apt-pkg/deb/debsystem.cc b/apt-pkg/deb/debsystem.cc
index da7ae2e42..6904879b6 100644
--- a/apt-pkg/deb/debsystem.cc
+++ b/apt-pkg/deb/debsystem.cc
@@ -79,6 +79,11 @@ debSystem::~debSystem()
checking of the updates directory. */
static int GetLockMaybeWait(std::string const &file, OpProgress *Progress, int &timeoutSec)
{
+ struct ScopedAbsoluteProgress
+ {
+ ScopedAbsoluteProgress() { _config->Set("APT::Internal::OpProgress::Absolute", true); }
+ ~ScopedAbsoluteProgress() { _config->Set("APT::Internal::OpProgress::Absolute", false); }
+ } _scopedAbsoluteProgress;
int fd = -1;
if (timeoutSec == 0 || Progress == nullptr)
return GetLock(file);
@@ -102,7 +107,7 @@ static int GetLockMaybeWait(std::string const &file, OpProgress *Progress, int &
_error->PopMessage(poppedError);
_error->RevertToStack();
- strprintf(completeError, _("Waiting for cache lock (%s)"), poppedError.c_str());
+ strprintf(completeError, _("Waiting for cache lock: %s"), poppedError.c_str());
sleep(1);
Progress->OverallProgress(i, timeoutSec, 0, completeError);
}