From 8d6d3f00b14217e69ecabd68379b1e29bf4a3ccd Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 15 Sep 2015 12:44:53 +0200 Subject: 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. --- cmdline/apt-mark.cc | 37 +------------------------------------ 1 file changed, 1 insertion(+), 36 deletions(-) (limited to 'cmdline/apt-mark.cc') 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) { -- cgit v1.2.3