aptconfiguration.cc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. /* ######################################################################
  4. Provide access methods to various configuration settings,
  5. setup defaults and returns validate settings.
  6. ##################################################################### */
  7. /*}}}*/
  8. // Include Files /*{{{*/
  9. #include <config.h>
  10. #include <apt-pkg/aptconfiguration.h>
  11. #include <apt-pkg/configuration.h>
  12. #include <apt-pkg/error.h>
  13. #include <apt-pkg/fileutl.h>
  14. #include <apt-pkg/macros.h>
  15. #include <apt-pkg/strutl.h>
  16. #include <dirent.h>
  17. #include <stdio.h>
  18. #include <fcntl.h>
  19. #include <ctype.h>
  20. #include <stddef.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include <unistd.h>
  24. #include <algorithm>
  25. #include <string>
  26. #include <vector>
  27. #include <apti18n.h>
  28. /*}}}*/
  29. namespace APT {
  30. // setDefaultConfigurationForCompressors /*{{{*/
  31. static void setDefaultConfigurationForCompressors() {
  32. // Set default application paths to check for optional compression types
  33. _config->CndSet("Dir::Bin::bzip2", "/bin/bzip2");
  34. _config->CndSet("Dir::Bin::xz", "/usr/bin/xz");
  35. if (FileExists(_config->FindFile("Dir::Bin::xz")) == true) {
  36. _config->Set("Dir::Bin::lzma", _config->FindFile("Dir::Bin::xz"));
  37. _config->Set("APT::Compressor::lzma::Binary", "xz");
  38. if (_config->Exists("APT::Compressor::lzma::CompressArg") == false) {
  39. _config->Set("APT::Compressor::lzma::CompressArg::", "--format=lzma");
  40. _config->Set("APT::Compressor::lzma::CompressArg::", "-9");
  41. }
  42. if (_config->Exists("APT::Compressor::lzma::UncompressArg") == false) {
  43. _config->Set("APT::Compressor::lzma::UncompressArg::", "--format=lzma");
  44. _config->Set("APT::Compressor::lzma::UncompressArg::", "-d");
  45. }
  46. } else {
  47. _config->CndSet("Dir::Bin::lzma", "/usr/bin/lzma");
  48. if (_config->Exists("APT::Compressor::lzma::CompressArg") == false) {
  49. _config->Set("APT::Compressor::lzma::CompressArg::", "--suffix=");
  50. _config->Set("APT::Compressor::lzma::CompressArg::", "-9");
  51. }
  52. if (_config->Exists("APT::Compressor::lzma::UncompressArg") == false) {
  53. _config->Set("APT::Compressor::lzma::UncompressArg::", "--suffix=");
  54. _config->Set("APT::Compressor::lzma::UncompressArg::", "-d");
  55. }
  56. }
  57. }
  58. /*}}}*/
  59. // getCompressionTypes - Return Vector of usable compressiontypes /*{{{*/
  60. // ---------------------------------------------------------------------
  61. /* return a vector of compression types in the preferred order. */
  62. std::vector<std::string>
  63. const Configuration::getCompressionTypes(bool const &Cached) {
  64. static std::vector<std::string> types;
  65. if (types.empty() == false) {
  66. if (Cached == true)
  67. return types;
  68. else
  69. types.clear();
  70. }
  71. // setup the defaults for the compressiontypes => method mapping
  72. _config->CndSet("Acquire::CompressionTypes::bz2","bzip2");
  73. _config->CndSet("Acquire::CompressionTypes::xz","xz");
  74. _config->CndSet("Acquire::CompressionTypes::lzma","lzma");
  75. _config->CndSet("Acquire::CompressionTypes::gz","gzip");
  76. setDefaultConfigurationForCompressors();
  77. std::vector<APT::Configuration::Compressor> const compressors = getCompressors();
  78. // load the order setting into our vector
  79. std::vector<std::string> const order = _config->FindVector("Acquire::CompressionTypes::Order");
  80. for (std::vector<std::string>::const_iterator o = order.begin();
  81. o != order.end(); ++o) {
  82. if ((*o).empty() == true)
  83. continue;
  84. // ignore types we have no method ready to use
  85. std::string const method = std::string("Acquire::CompressionTypes::").append(*o);
  86. if (_config->Exists(method) == false)
  87. continue;
  88. // ignore types we have no app ready to use
  89. std::string const app = _config->Find(method);
  90. std::vector<APT::Configuration::Compressor>::const_iterator c = compressors.begin();
  91. for (; c != compressors.end(); ++c)
  92. if (c->Name == app)
  93. break;
  94. if (c == compressors.end())
  95. continue;
  96. types.push_back(*o);
  97. }
  98. // move again over the option tree to add all missing compression types
  99. ::Configuration::Item const *Types = _config->Tree("Acquire::CompressionTypes");
  100. if (Types != 0)
  101. Types = Types->Child;
  102. for (; Types != 0; Types = Types->Next) {
  103. if (Types->Tag == "Order" || Types->Tag.empty() == true)
  104. continue;
  105. // ignore types we already have in the vector
  106. if (std::find(types.begin(),types.end(),Types->Tag) != types.end())
  107. continue;
  108. // ignore types we have no app ready to use
  109. std::vector<APT::Configuration::Compressor>::const_iterator c = compressors.begin();
  110. for (; c != compressors.end(); ++c)
  111. if (c->Name == Types->Value)
  112. break;
  113. if (c == compressors.end())
  114. continue;
  115. types.push_back(Types->Tag);
  116. }
  117. // add the special "uncompressed" type
  118. if (std::find(types.begin(), types.end(), "uncompressed") == types.end())
  119. {
  120. std::string const uncompr = _config->FindFile("Dir::Bin::uncompressed", "");
  121. if (uncompr.empty() == true || FileExists(uncompr) == true)
  122. types.push_back("uncompressed");
  123. }
  124. return types;
  125. }
  126. /*}}}*/
  127. // GetLanguages - Return Vector of Language Codes /*{{{*/
  128. // ---------------------------------------------------------------------
  129. /* return a vector of language codes in the preferred order.
  130. the special word "environment" will be replaced with the long and the short
  131. code of the local settings and it will be insured that this will not add
  132. duplicates. So in an german local the setting "environment, de_DE, en, de"
  133. will result in "de_DE, de, en".
  134. The special word "none" is the stopcode for the not-All code vector */
  135. std::vector<std::string> const Configuration::getLanguages(bool const &All,
  136. bool const &Cached, char const ** const Locale) {
  137. using std::string;
  138. // The detection is boring and has a lot of cornercases,
  139. // so we cache the results to calculated it only once.
  140. std::vector<string> static allCodes;
  141. std::vector<string> static codes;
  142. // we have something in the cache
  143. if (codes.empty() == false || allCodes.empty() == false) {
  144. if (Cached == true) {
  145. if(All == true && allCodes.empty() == false)
  146. return allCodes;
  147. else
  148. return codes;
  149. } else {
  150. allCodes.clear();
  151. codes.clear();
  152. }
  153. }
  154. // Include all Language codes we have a Translation file for in /var/lib/apt/lists
  155. // so they will be all included in the Cache.
  156. std::vector<string> builtin;
  157. DIR *D = opendir(_config->FindDir("Dir::State::lists").c_str());
  158. if (D != NULL) {
  159. builtin.push_back("none");
  160. for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D)) {
  161. string const name = SubstVar(Ent->d_name, "%5f", "_");
  162. size_t const foundDash = name.rfind("-");
  163. size_t const foundUnderscore = name.rfind("_", foundDash);
  164. if (foundDash == string::npos || foundUnderscore == string::npos ||
  165. foundDash <= foundUnderscore ||
  166. name.substr(foundUnderscore+1, foundDash-(foundUnderscore+1)) != "Translation")
  167. continue;
  168. string const c = name.substr(foundDash+1);
  169. if (unlikely(c.empty() == true) || c == "en")
  170. continue;
  171. // Skip unusual files, like backups or that alike
  172. string::const_iterator s = c.begin();
  173. for (;s != c.end(); ++s) {
  174. if (isalpha(*s) == 0 && *s != '_')
  175. break;
  176. }
  177. if (s != c.end())
  178. continue;
  179. if (std::find(builtin.begin(), builtin.end(), c) != builtin.end())
  180. continue;
  181. builtin.push_back(c);
  182. }
  183. closedir(D);
  184. }
  185. // FIXME: Remove support for the old APT::Acquire::Translation
  186. // it was undocumented and so it should be not very widthly used
  187. string const oldAcquire = _config->Find("APT::Acquire::Translation","");
  188. if (oldAcquire.empty() == false && oldAcquire != "environment") {
  189. // TRANSLATORS: the two %s are APT configuration options
  190. _error->Notice("Option '%s' is deprecated. Please use '%s' instead, see 'man 5 apt.conf' for details.",
  191. "APT::Acquire::Translation", "Acquire::Languages");
  192. if (oldAcquire != "none")
  193. codes.push_back(oldAcquire);
  194. codes.push_back("en");
  195. allCodes = codes;
  196. for (std::vector<string>::const_iterator b = builtin.begin();
  197. b != builtin.end(); ++b)
  198. if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end())
  199. allCodes.push_back(*b);
  200. if (All == true)
  201. return allCodes;
  202. else
  203. return codes;
  204. }
  205. // get the environment language codes: LC_MESSAGES (and later LANGUAGE)
  206. // we extract both, a long and a short code and then we will
  207. // check if we actually need both (rare) or if the short is enough
  208. string const envMsg = string(Locale == 0 ? std::setlocale(LC_MESSAGES, NULL) : *Locale);
  209. size_t const lenShort = (envMsg.find('_') != string::npos) ? envMsg.find('_') : 2;
  210. size_t const lenLong = (envMsg.find_first_of(".@") != string::npos) ? envMsg.find_first_of(".@") : (lenShort + 3);
  211. string const envLong = envMsg.substr(0,lenLong);
  212. string const envShort = envLong.substr(0,lenShort);
  213. // It is very likely we will need the environment codes later,
  214. // so let us generate them now from LC_MESSAGES and LANGUAGE
  215. std::vector<string> environment;
  216. if (envShort != "C") {
  217. // take care of LC_MESSAGES
  218. if (envLong != envShort)
  219. environment.push_back(envLong);
  220. environment.push_back(envShort);
  221. // take care of LANGUAGE
  222. const char *language_env = getenv("LANGUAGE") == 0 ? "" : getenv("LANGUAGE");
  223. string envLang = Locale == 0 ? language_env : *(Locale+1);
  224. if (envLang.empty() == false) {
  225. std::vector<string> env = VectorizeString(envLang,':');
  226. short addedLangs = 0; // add a maximum of 3 fallbacks from the environment
  227. for (std::vector<string>::const_iterator e = env.begin();
  228. e != env.end() && addedLangs < 3; ++e) {
  229. if (unlikely(e->empty() == true) || *e == "en")
  230. continue;
  231. if (*e == envLong || *e == envShort)
  232. continue;
  233. if (std::find(environment.begin(), environment.end(), *e) != environment.end())
  234. continue;
  235. ++addedLangs;
  236. environment.push_back(*e);
  237. }
  238. }
  239. } else {
  240. // cornercase: LANG=C, so we use only "en" Translation
  241. environment.push_back("en");
  242. }
  243. std::vector<string> const lang = _config->FindVector("Acquire::Languages", "environment,en");
  244. // the configs define the order, so add the environment
  245. // then needed and ensure the codes are not listed twice.
  246. bool noneSeen = false;
  247. for (std::vector<string>::const_iterator l = lang.begin();
  248. l != lang.end(); ++l) {
  249. if (*l == "environment") {
  250. for (std::vector<string>::const_iterator e = environment.begin();
  251. e != environment.end(); ++e) {
  252. if (std::find(allCodes.begin(), allCodes.end(), *e) != allCodes.end())
  253. continue;
  254. if (noneSeen == false)
  255. codes.push_back(*e);
  256. allCodes.push_back(*e);
  257. }
  258. continue;
  259. } else if (*l == "none") {
  260. noneSeen = true;
  261. continue;
  262. } else if (std::find(allCodes.begin(), allCodes.end(), *l) != allCodes.end())
  263. continue;
  264. if (noneSeen == false)
  265. codes.push_back(*l);
  266. allCodes.push_back(*l);
  267. }
  268. if (allCodes.empty() == false) {
  269. for (std::vector<string>::const_iterator b = builtin.begin();
  270. b != builtin.end(); ++b)
  271. if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end())
  272. allCodes.push_back(*b);
  273. } else {
  274. // "none" was forced
  275. allCodes.push_back("none");
  276. }
  277. if (All == true)
  278. return allCodes;
  279. else
  280. return codes;
  281. }
  282. /*}}}*/
  283. // checkLanguage - are we interested in the given Language? /*{{{*/
  284. bool Configuration::checkLanguage(std::string Lang, bool const All) {
  285. // the empty Language is always interesting as it is the original
  286. if (Lang.empty() == true)
  287. return true;
  288. // filenames are encoded, so undo this
  289. Lang = SubstVar(Lang, "%5f", "_");
  290. std::vector<std::string> const langs = getLanguages(All, true);
  291. return (std::find(langs.begin(), langs.end(), Lang) != langs.end());
  292. }
  293. /*}}}*/
  294. // getArchitectures - Return Vector of preferred Architectures /*{{{*/
  295. std::vector<std::string> const Configuration::getArchitectures(bool const &Cached) {
  296. using std::string;
  297. std::vector<string> static archs;
  298. if (likely(Cached == true) && archs.empty() == false)
  299. return archs;
  300. string const arch = _config->Find("APT::Architecture");
  301. archs = _config->FindVector("APT::Architectures");
  302. if (unlikely(arch.empty() == true))
  303. return archs;
  304. // FIXME: It is a bit unclean to have debian specific code here…
  305. if (archs.empty() == true) {
  306. archs.push_back(arch);
  307. // Generate the base argument list for dpkg
  308. std::vector<const char *> Args;
  309. string Tmp = _config->Find("Dir::Bin::dpkg","dpkg");
  310. {
  311. string const dpkgChrootDir = _config->FindDir("DPkg::Chroot-Directory", "/");
  312. size_t dpkgChrootLen = dpkgChrootDir.length();
  313. if (dpkgChrootDir != "/" && Tmp.find(dpkgChrootDir) == 0) {
  314. if (dpkgChrootDir[dpkgChrootLen - 1] == '/')
  315. --dpkgChrootLen;
  316. Tmp = Tmp.substr(dpkgChrootLen);
  317. }
  318. }
  319. Args.push_back(Tmp.c_str());
  320. // Stick in any custom dpkg options
  321. ::Configuration::Item const *Opts = _config->Tree("DPkg::Options");
  322. if (Opts != 0) {
  323. Opts = Opts->Child;
  324. for (; Opts != 0; Opts = Opts->Next)
  325. {
  326. if (Opts->Value.empty() == true)
  327. continue;
  328. Args.push_back(Opts->Value.c_str());
  329. }
  330. }
  331. Args.push_back("--print-foreign-architectures");
  332. Args.push_back(NULL);
  333. int external[2] = {-1, -1};
  334. if (pipe(external) != 0)
  335. {
  336. _error->WarningE("getArchitecture", "Can't create IPC pipe for dpkg --print-foreign-architectures");
  337. return archs;
  338. }
  339. pid_t dpkgMultiArch = ExecFork();
  340. if (dpkgMultiArch == 0) {
  341. close(external[0]);
  342. std::string const chrootDir = _config->FindDir("DPkg::Chroot-Directory");
  343. int const nullfd = open("/dev/null", O_RDONLY);
  344. dup2(nullfd, STDIN_FILENO);
  345. dup2(external[1], STDOUT_FILENO);
  346. dup2(nullfd, STDERR_FILENO);
  347. if (chrootDir != "/" && chroot(chrootDir.c_str()) != 0 && chdir("/") != 0)
  348. _error->WarningE("getArchitecture", "Couldn't chroot into %s for dpkg --print-foreign-architectures", chrootDir.c_str());
  349. execvp(Args[0], (char**) &Args[0]);
  350. _error->WarningE("getArchitecture", "Can't detect foreign architectures supported by dpkg!");
  351. _exit(100);
  352. }
  353. close(external[1]);
  354. FILE *dpkg = fdopen(external[0], "r");
  355. if(dpkg != NULL) {
  356. char buf[1024];
  357. while (fgets(buf, sizeof(buf), dpkg) != NULL) {
  358. char* arch = strtok(buf, " ");
  359. while (arch != NULL) {
  360. for (; isspace(*arch) != 0; ++arch);
  361. if (arch[0] != '\0') {
  362. char const* archend = arch;
  363. for (; isspace(*archend) == 0 && *archend != '\0'; ++archend);
  364. string a(arch, (archend - arch));
  365. if (std::find(archs.begin(), archs.end(), a) == archs.end())
  366. archs.push_back(a);
  367. }
  368. arch = strtok(NULL, " ");
  369. }
  370. }
  371. fclose(dpkg);
  372. }
  373. ExecWait(dpkgMultiArch, "dpkg --print-foreign-architectures", true);
  374. return archs;
  375. }
  376. if (archs.empty() == true ||
  377. std::find(archs.begin(), archs.end(), arch) == archs.end())
  378. archs.insert(archs.begin(), arch);
  379. // erase duplicates and empty strings
  380. for (std::vector<string>::reverse_iterator a = archs.rbegin();
  381. a != archs.rend(); ++a) {
  382. if (a->empty() == true || std::find(a + 1, archs.rend(), *a) != archs.rend())
  383. archs.erase(a.base()-1);
  384. if (a == archs.rend())
  385. break;
  386. }
  387. return archs;
  388. }
  389. /*}}}*/
  390. // checkArchitecture - are we interested in the given Architecture? /*{{{*/
  391. bool Configuration::checkArchitecture(std::string const &Arch) {
  392. if (Arch == "all")
  393. return true;
  394. std::vector<std::string> const archs = getArchitectures(true);
  395. return (std::find(archs.begin(), archs.end(), Arch) != archs.end());
  396. }
  397. /*}}}*/
  398. // getCompressors - Return Vector of usealbe compressors /*{{{*/
  399. // ---------------------------------------------------------------------
  400. /* return a vector of compressors used by apt-ftparchive in the
  401. multicompress functionality or to detect data.tar files */
  402. std::vector<APT::Configuration::Compressor>
  403. const Configuration::getCompressors(bool const Cached) {
  404. static std::vector<APT::Configuration::Compressor> compressors;
  405. if (compressors.empty() == false) {
  406. if (Cached == true)
  407. return compressors;
  408. else
  409. compressors.clear();
  410. }
  411. setDefaultConfigurationForCompressors();
  412. compressors.push_back(Compressor(".", "", "", NULL, NULL, 1));
  413. if (_config->Exists("Dir::Bin::gzip") == false || FileExists(_config->FindFile("Dir::Bin::gzip")) == true)
  414. compressors.push_back(Compressor("gzip",".gz","gzip","-9n","-d",2));
  415. #ifdef HAVE_ZLIB
  416. else
  417. compressors.push_back(Compressor("gzip",".gz","false", NULL, NULL, 2));
  418. #endif
  419. if (_config->Exists("Dir::Bin::bzip2") == false || FileExists(_config->FindFile("Dir::Bin::bzip2")) == true)
  420. compressors.push_back(Compressor("bzip2",".bz2","bzip2","-9","-d",3));
  421. #ifdef HAVE_BZ2
  422. else
  423. compressors.push_back(Compressor("bzip2",".bz2","false", NULL, NULL, 3));
  424. #endif
  425. if (_config->Exists("Dir::Bin::xz") == false || FileExists(_config->FindFile("Dir::Bin::xz")) == true)
  426. compressors.push_back(Compressor("xz",".xz","xz","-6","-d",4));
  427. #ifdef HAVE_LZMA
  428. else
  429. compressors.push_back(Compressor("xz",".xz","false", NULL, NULL, 4));
  430. #endif
  431. if (_config->Exists("Dir::Bin::lzma") == false || FileExists(_config->FindFile("Dir::Bin::lzma")) == true)
  432. compressors.push_back(Compressor("lzma",".lzma","lzma","-9","-d",5));
  433. #ifdef HAVE_LZMA
  434. else
  435. compressors.push_back(Compressor("lzma",".lzma","false", NULL, NULL, 5));
  436. #endif
  437. std::vector<std::string> const comp = _config->FindVector("APT::Compressor");
  438. for (std::vector<std::string>::const_iterator c = comp.begin();
  439. c != comp.end(); ++c) {
  440. if (c->empty() || *c == "." || *c == "gzip" || *c == "bzip2" || *c == "lzma" || *c == "xz")
  441. continue;
  442. compressors.push_back(Compressor(c->c_str(), std::string(".").append(*c).c_str(), c->c_str(), "-9", "-d", 100));
  443. }
  444. return compressors;
  445. }
  446. /*}}}*/
  447. // getCompressorExtensions - supported data.tar extensions /*{{{*/
  448. // ---------------------------------------------------------------------
  449. /* */
  450. std::vector<std::string> const Configuration::getCompressorExtensions() {
  451. std::vector<APT::Configuration::Compressor> const compressors = getCompressors();
  452. std::vector<std::string> ext;
  453. for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressors.begin();
  454. c != compressors.end(); ++c)
  455. if (c->Extension.empty() == false && c->Extension != ".")
  456. ext.push_back(c->Extension);
  457. return ext;
  458. }
  459. /*}}}*/
  460. // Compressor constructor /*{{{*/
  461. // ---------------------------------------------------------------------
  462. /* */
  463. Configuration::Compressor::Compressor(char const *name, char const *extension,
  464. char const *binary,
  465. char const *compressArg, char const *uncompressArg,
  466. unsigned short const cost) {
  467. std::string const config = std::string("APT::Compressor::").append(name).append("::");
  468. Name = _config->Find(std::string(config).append("Name"), name);
  469. Extension = _config->Find(std::string(config).append("Extension"), extension);
  470. Binary = _config->Find(std::string(config).append("Binary"), binary);
  471. Cost = _config->FindI(std::string(config).append("Cost"), cost);
  472. std::string const compConf = std::string(config).append("CompressArg");
  473. if (_config->Exists(compConf) == true)
  474. CompressArgs = _config->FindVector(compConf);
  475. else if (compressArg != NULL)
  476. CompressArgs.push_back(compressArg);
  477. std::string const uncompConf = std::string(config).append("UncompressArg");
  478. if (_config->Exists(uncompConf) == true)
  479. UncompressArgs = _config->FindVector(uncompConf);
  480. else if (uncompressArg != NULL)
  481. UncompressArgs.push_back(uncompressArg);
  482. }
  483. /*}}}*/
  484. // getBuildProfiles - return a vector of enabled build profiles /*{{{*/
  485. std::vector<std::string> const Configuration::getBuildProfiles() {
  486. // order is: override value (~= commandline), environment variable, list (~= config file)
  487. std::string profiles_env = getenv("DEB_BUILD_PROFILES") == 0 ? "" : getenv("DEB_BUILD_PROFILES");
  488. if (profiles_env.empty() == false) {
  489. profiles_env = SubstVar(profiles_env, " ", ",");
  490. std::string const bp = _config->Find("APT::Build-Profiles");
  491. _config->Clear("APT::Build-Profiles");
  492. if (bp.empty() == false)
  493. _config->Set("APT::Build-Profiles", bp);
  494. }
  495. return _config->FindVector("APT::Build-Profiles", profiles_env);
  496. }
  497. std::string const Configuration::getBuildProfilesString() {
  498. std::vector<std::string> profiles = getBuildProfiles();
  499. if (profiles.empty() == true)
  500. return "";
  501. std::vector<std::string>::const_iterator p = profiles.begin();
  502. std::string list = *p;
  503. for (++p; p != profiles.end(); ++p)
  504. list.append(",").append(*p);
  505. return list;
  506. }
  507. /*}}}*/
  508. }