+ int selections = -1;
+ pid_t const dpkgSelections = debSystem::ExecDpkg(Args, &selections, nullptr, DiscardOutput);
+
+ FILE* dpkg = fdopen(selections, "w");
+ std::string state;
+ auto const dpkgName = [&](pkgCache::VerIterator const &V) {
+ pkgCache::PkgIterator P = V.ParentPkg();
+ if (strcmp(V.Arch(), "none") == 0)
+ fprintf(dpkg, "%s %s\n", P.Name(), state.c_str());
+ else if (dpkgMultiArch == false)
+ fprintf(dpkg, "%s %s\n", P.FullName(true).c_str(), state.c_str());
+ else
+ fprintf(dpkg, "%s:%s %s\n", P.Name(), V.Arch(), state.c_str());
+ };
+ for (auto const &V: d->unhold)
+ {
+ if (V.ParentPkg()->CurrentVer != 0)
+ state = "install";
+ else
+ state = "deinstall";
+ dpkgName(V);
+ }
+ if (d->purge.empty() == false)
+ {
+ state = "purge";
+ std::for_each(d->purge.begin(), d->purge.end(), dpkgName);
+ }
+ if (d->deinstall.empty() == false)
+ {
+ state = "deinstall";
+ std::for_each(d->deinstall.begin(), d->deinstall.end(), dpkgName);
+ }
+ if (d->hold.empty() == false)
+ {
+ state = "hold";
+ std::for_each(d->hold.begin(), d->hold.end(), dpkgName);
+ }
+ if (d->install.empty() == false)
+ {
+ state = "install";
+ std::for_each(d->install.begin(), d->install.end(), dpkgName);
+ }
+ fclose(dpkg);