diff options
author | David Kalnischkies <david@kalnischkies.de> | 2015-09-15 12:44:53 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2015-11-04 15:02:36 +0100 |
commit | 8d6d3f00b14217e69ecabd68379b1e29bf4a3ccd (patch) | |
tree | b72f8bb2b10b46ad2b81acce2128d07ed4668e4a /cmdline | |
parent | fa74b4ece008f6600d530e28a609f31312c8c864 (diff) |
implement a public pkgSystem::MultiArchSupported
Some codepaths need to check if the system (in our case usually dpkg)
supports MultiArch or not. We had copy-pasted the check so far into
these paths, but having it as a system check is better for reusability.
Diffstat (limited to 'cmdline')
-rw-r--r-- | cmdline/apt-mark.cc | 37 |
1 files changed, 1 insertions, 36 deletions
diff --git a/cmdline/apt-mark.cc b/cmdline/apt-mark.cc index 02c73fc2e..20166b312 100644 --- a/cmdline/apt-mark.cc +++ b/cmdline/apt-mark.cc @@ -201,28 +201,7 @@ static bool DoHold(CommandLine &CmdL) Args.push_back(Opts->Value.c_str()); } } - size_t const BaseArgs = Args.size(); - // we need to detect if we can qualify packages with the architecture or not - Args.push_back("--assert-multi-arch"); - Args.push_back(NULL); - - - pid_t dpkgAssertMultiArch = ExecFork(); - if (dpkgAssertMultiArch == 0) - { - std::string const chrootDir = _config->FindDir("DPkg::Chroot-Directory"); - // redirect everything to the ultimate sink as we only need the exit-status - int const nullfd = open("/dev/null", O_RDONLY); - dup2(nullfd, STDIN_FILENO); - dup2(nullfd, STDOUT_FILENO); - dup2(nullfd, STDERR_FILENO); - if (chrootDir != "/" && chroot(chrootDir.c_str()) != 0 && chdir("/") != 0) - _error->WarningE("getArchitecture", "Couldn't chroot into %s for dpkg --assert-multi-arch", chrootDir.c_str()); - execvp(Args[0], (char**) &Args[0]); - _error->WarningE("dpkgGo", "Can't detect if dpkg supports multi-arch!"); - _exit(2); - } APT::PackageList pkgset = APT::PackageList::FromCommandLine(CacheFile, CmdL.FileList + 1); if (pkgset.empty() == true) @@ -244,21 +223,6 @@ static bool DoHold(CommandLine &CmdL) ++Pkg; } - bool dpkgMultiArch = false; - if (dpkgAssertMultiArch > 0) - { - int Status = 0; - while (waitpid(dpkgAssertMultiArch, &Status, 0) != dpkgAssertMultiArch) - { - if (errno == EINTR) - continue; - _error->WarningE("dpkgGo", _("Waited for %s but it wasn't there"), "dpkg --assert-multi-arch"); - break; - } - if (WIFEXITED(Status) == true && WEXITSTATUS(Status) == 0) - dpkgMultiArch = true; - } - if (pkgset.empty() == true) return true; @@ -359,6 +323,7 @@ static bool DoHold(CommandLine &CmdL) _exit(2); } + bool const dpkgMultiArch = _system->MultiArchSupported(); FILE* dpkg = fdopen(external[1], "w"); for (APT::PackageList::iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg) { |