diff options
author | Johannes Schauer Marin Rodrigues <josch@mister-muffin.de> | 2021-09-19 19:03:29 +0200 |
---|---|---|
committer | Johannes Schauer Marin Rodrigues <josch@mister-muffin.de> | 2021-09-19 19:03:29 +0200 |
commit | e6f7bfb02ef254ec6922c1a3b3f9a2c741db6a79 (patch) | |
tree | 4608ca89bc90ef5888befb48a3a7ed71b6280e1b /apt-pkg | |
parent | 883a12310a4130370965eab0a710a2c8fae6cc09 (diff) |
apt-pkg/deb/dpkgpm.cc: make DPkg::Chroot-Directory work under fakechroot
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 14 |
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())); |