summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2021-10-19 08:32:57 +0000
committerJulian Andres Klode <jak@debian.org>2021-10-19 08:32:57 +0000
commitbdc8526819d288f6076e1d1854138f139f2df32f (patch)
tree91339ead58e92f1fb11b7f266ba0c0f00ed1f616
parent4a73fd686a882dd9cae0e6a44a0f4e23602d9d6f (diff)
parente6f7bfb02ef254ec6922c1a3b3f9a2c741db6a79 (diff)
Merge branch 'fakechroot' into 'main'
apt-pkg/deb/dpkgpm.cc: make DPkg::Chroot-Directory work under fakechroot See merge request apt-team/apt!189
-rw-r--r--apt-pkg/deb/dpkgpm.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 09d605feb..93effa959 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -1874,8 +1874,18 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
strprintf(linkpath, "%s/%.*lu-%s", tmpdir_for_dpkg_recursive.get(), p, n, file.c_str());
else
strprintf(linkpath, "%s/%s", tmpdir_for_dpkg_recursive.get(), file.c_str());
- if (symlink(I->File.c_str(), linkpath.c_str()) != 0)
- return _error->Errno("DPkg::Go", "Symlinking %s to %s failed!", I->File.c_str(), linkpath.c_str());
+ std::string linktarget = I->File;
+ if (dpkg_chroot_dir != "/") {
+ char * fakechroot = getenv("FAKECHROOT");
+ if (fakechroot != nullptr && strcmp(fakechroot, "true") == 0) {
+ // if apt is run with DPkg::Chroot-Directory under
+ // fakechroot, absolulte symbolic links must be prefixed
+ // with the chroot path to be valid inside fakechroot
+ strprintf(linktarget, "%s/%s", dpkg_chroot_dir.c_str(), I->File.c_str());
+ }
+ }
+ if (symlink(linktarget.c_str(), linkpath.c_str()) != 0)
+ return _error->Errno("DPkg::Go", "Symlinking %s to %s failed!", linktarget.c_str(), linkpath.c_str());
}
Args.push_back("--recursive");
Args.push_back(debSystem::StripDpkgChrootDirectory(tmpdir_for_dpkg_recursive.get()));