summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2018-10-05 12:29:39 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2018-10-05 12:45:47 +0200
commit6675601c81de85b40dc89772c1d6d17f1811c5ba (patch)
treee2c03e0c6b540e453440d4aec056f826c86329eb /apt-pkg
parent07d12ed686740c167bb5cbe4fe724e8469432b4a (diff)
Set DPKG_FRONTEND_LOCKED when running {pre,post}-invoke scripts
Some post-invoke scripts install packages, which fails because the environment variable is not set. This sets the variable for all three kinds of scripts {pre,post-}invoke and pre-install-pkgs, but we will only allow post-invoke at a later time. Gbp-Dch: full
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/fileutl.cc3
-rw-r--r--apt-pkg/deb/dpkgpm.cc3
2 files changed, 6 insertions, 0 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 85d7b36c7..eab05de4f 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -24,6 +24,7 @@
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/macros.h>
+#include <apt-pkg/pkgsystem.h>
#include <apt-pkg/sptr.h>
#include <apt-pkg/strutl.h>
@@ -101,6 +102,8 @@ bool RunScripts(const char *Cnf)
// This is the child
if (Child == 0)
{
+ if (_system != nullptr && _system->IsLocked() == true && (stringcasecmp(Cnf, "dpkg::post-invoke") == 0 || stringcasecmp(Cnf, "dpkg::pre-invoke") == 0))
+ setenv("DPKG_FRONTEND_LOCKED", "true", 1);
if (_config->FindDir("DPkg::Chroot-Directory","/") != "/")
{
std::cerr << "Chrooting into "
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index f83b368cd..074e52b3f 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -481,6 +481,9 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
strprintf(hookfd, "%d", InfoFD);
setenv("APT_HOOK_INFO_FD", hookfd.c_str(), 1);
+ if (_system != nullptr && _system->IsLocked() == true && stringcasecmp(Cnf, "DPkg::Pre-Install-Pkgs") == 0)
+ setenv("DPKG_FRONTEND_LOCKED", "true", 1);
+
debSystem::DpkgChrootDirectory();
const char *Args[4];
Args[0] = "/bin/sh";