From c1607f538559a0b7a1d3f9dc01e88190e543053d Mon Sep 17 00:00:00 2001 From: Nathan Pratta Teodosio Date: Tue, 17 Feb 2026 10:42:13 +0100 Subject: Prevent sleep while running dpkg. As long as we are running dpkg, keep an inhibitor that blocks us from sleeping. --- apt-pkg/deb/dpkgpm.cc | 11 +++++++++-- doc/examples/configure-index | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc index 09f3e4783..0f2467607 100644 --- a/apt-pkg/deb/dpkgpm.cc +++ b/apt-pkg/deb/dpkgpm.cc @@ -1516,8 +1516,15 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress) int Fd = -1; Inhibitor() { - if (_config->FindB("DPkg::Inhibit-Shutdown", true)) - Fd = Inhibit("shutdown", "APT", "APT is installing or removing packages", "block"); + std::string to_inhibit; + if (_config->FindB("DPkg::Inhibit-Shutdown", true)) + to_inhibit.append("shutdown:"); + if (_config->FindB("DPkg::Inhibit-Sleep", true)) + to_inhibit.append("sleep:"); + // Remove trailing : separator + if (to_inhibit.length() > 0) + to_inhibit.pop_back(); + Fd = Inhibit(to_inhibit.c_str(), "APT", "APT is installing or removing packages", "block"); } ~Inhibitor() { diff --git a/doc/examples/configure-index b/doc/examples/configure-index index 9cdacfe34..034399819 100644 --- a/doc/examples/configure-index +++ b/doc/examples/configure-index @@ -540,6 +540,8 @@ DPkg // Set a shutdown block inhibitor on systemd systems while running dpkg Inhibit-Shutdown ""; + // Set a sleep block inhibitor on systemd systems while running dpkg + Inhibit-Sleep ""; } /* Options you can set to see some debugging text They correspond to names -- cgit v1.2.3-70-g09d2