+std::vector<std::string> debSystem::SupportedArchitectures() /*{{{*/
+{
+ std::vector<std::string> archs;
+ {
+ string const arch = _config->Find("APT::Architecture");
+ if (arch.empty() == false)
+ archs.push_back(std::move(arch));
+ }
+
+ std::vector<std::string> sArgs = GetDpkgBaseCommand();
+ sArgs.push_back("--print-foreign-architectures");
+ int outputFd = -1;
+ pid_t const dpkgMultiArch = ExecDpkg(sArgs, nullptr, &outputFd, true);
+ if (dpkgMultiArch == -1)
+ return archs;
+
+ FILE *dpkg = fdopen(outputFd, "r");
+ if(dpkg != NULL) {
+ char* buf = NULL;
+ size_t bufsize = 0;
+ while (getline(&buf, &bufsize, dpkg) != -1)
+ {
+ char* tok_saveptr;
+ char* arch = strtok_r(buf, " ", &tok_saveptr);
+ while (arch != NULL) {
+ for (; isspace_ascii(*arch) != 0; ++arch);
+ if (arch[0] != '\0') {
+ char const* archend = arch;
+ for (; isspace_ascii(*archend) == 0 && *archend != '\0'; ++archend);
+ string a(arch, (archend - arch));
+ if (std::find(archs.begin(), archs.end(), a) == archs.end())
+ archs.push_back(a);
+ }
+ arch = strtok_r(NULL, " ", &tok_saveptr);
+ }
+ }
+ free(buf);
+ fclose(dpkg);
+ }
+ ExecWait(dpkgMultiArch, "dpkg --print-foreign-architectures", true);
+ return archs;
+}
+ /*}}}*/