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. // getCompressionTypes - Return Vector of usable compressiontypes /*{{{*/
  31. // ---------------------------------------------------------------------
  32. /* return a vector of compression types in the preferred order. */
  33. std::vector<std::string>
  34. const Configuration::getCompressionTypes(bool const &Cached) {
  35. static std::vector<std::string> types;
  36. if (types.empty() == false) {
  37. if (Cached == true)
  38. return types;
  39. else
  40. types.clear();
  41. }
  42. // setup the defaults for the compressiontypes => method mapping
  43. _config->CndSet("Acquire::CompressionTypes::bz2","bzip2");
  44. _config->CndSet("Acquire::CompressionTypes::xz","xz");
  45. _config->CndSet("Acquire::CompressionTypes::lzma","lzma");
  46. _config->CndSet("Acquire::CompressionTypes::gz","gzip");
  47. setDefaultConfigurationForCompressors();
  48. std::vector<APT::Configuration::Compressor> const compressors = getCompressors();
  49. // load the order setting into our vector
  50. std::vector<std::string> const order = _config->FindVector("Acquire::CompressionTypes::Order");
  51. for (std::vector<std::string>::const_iterator o = order.begin();
  52. o != order.end(); ++o) {
  53. if ((*o).empty() == true)
  54. continue;
  55. // ignore types we have no method ready to use
  56. std::string const method = std::string("Acquire::CompressionTypes::").append(*o);
  57. if (_config->Exists(method) == false)
  58. continue;
  59. // ignore types we have no app ready to use
  60. std::string const app = _config->Find(method);
  61. std::vector<APT::Configuration::Compressor>::const_iterator c = compressors.begin();
  62. for (; c != compressors.end(); ++c)
  63. if (c->Name == app)
  64. break;
  65. if (c == compressors.end())
  66. continue;
  67. types.push_back(*o);
  68. }
  69. // move again over the option tree to add all missing compression types
  70. ::Configuration::Item const *Types = _config->Tree("Acquire::CompressionTypes");
  71. if (Types != 0)
  72. Types = Types->Child;
  73. for (; Types != 0; Types = Types->Next) {
  74. if (Types->Tag == "Order" || Types->Tag.empty() == true)
  75. continue;
  76. // ignore types we already have in the vector
  77. if (std::find(types.begin(),types.end(),Types->Tag) != types.end())
  78. continue;
  79. // ignore types we have no app ready to use
  80. std::vector<APT::Configuration::Compressor>::const_iterator c = compressors.begin();
  81. for (; c != compressors.end(); ++c)
  82. if (c->Name == Types->Value)
  83. break;
  84. if (c == compressors.end())
  85. continue;
  86. types.push_back(Types->Tag);
  87. }
  88. // add the special "uncompressed" type
  89. if (std::find(types.begin(), types.end(), "uncompressed") == types.end())
  90. {
  91. std::string const uncompr = _config->FindFile("Dir::Bin::uncompressed", "");
  92. if (uncompr.empty() == true || FileExists(uncompr) == true)
  93. types.push_back("uncompressed");
  94. }
  95. return types;
  96. }
  97. /*}}}*/
  98. // GetLanguages - Return Vector of Language Codes /*{{{*/
  99. // ---------------------------------------------------------------------
  100. /* return a vector of language codes in the preferred order.
  101. the special word "environment" will be replaced with the long and the short
  102. code of the local settings and it will be insured that this will not add
  103. duplicates. So in an german local the setting "environment, de_DE, en, de"
  104. will result in "de_DE, de, en".
  105. The special word "none" is the stopcode for the not-All code vector */
  106. std::vector<std::string> const Configuration::getLanguages(bool const &All,
  107. bool const &Cached, char const ** const Locale) {
  108. using std::string;
  109. // The detection is boring and has a lot of cornercases,
  110. // so we cache the results to calculated it only once.
  111. std::vector<string> static allCodes;
  112. std::vector<string> static codes;
  113. // we have something in the cache
  114. if (codes.empty() == false || allCodes.empty() == false) {
  115. if (Cached == true) {
  116. if(All == true && allCodes.empty() == false)
  117. return allCodes;
  118. else
  119. return codes;
  120. } else {
  121. allCodes.clear();
  122. codes.clear();
  123. }
  124. }
  125. // Include all Language codes we have a Translation file for in /var/lib/apt/lists
  126. // so they will be all included in the Cache.
  127. std::vector<string> builtin;
  128. DIR *D = opendir(_config->FindDir("Dir::State::lists").c_str());
  129. if (D != NULL) {
  130. builtin.push_back("none");
  131. for (struct dirent *Ent = readdir(D); Ent != 0; Ent = readdir(D)) {
  132. string const name = SubstVar(Ent->d_name, "%5f", "_");
  133. size_t const foundDash = name.rfind("-");
  134. size_t const foundUnderscore = name.rfind("_", foundDash);
  135. if (foundDash == string::npos || foundUnderscore == string::npos ||
  136. foundDash <= foundUnderscore ||
  137. name.substr(foundUnderscore+1, foundDash-(foundUnderscore+1)) != "Translation")
  138. continue;
  139. string const c = name.substr(foundDash+1);
  140. if (unlikely(c.empty() == true) || c == "en")
  141. continue;
  142. // Skip unusual files, like backups or that alike
  143. string::const_iterator s = c.begin();
  144. for (;s != c.end(); ++s) {
  145. if (isalpha(*s) == 0 && *s != '_')
  146. break;
  147. }
  148. if (s != c.end())
  149. continue;
  150. if (std::find(builtin.begin(), builtin.end(), c) != builtin.end())
  151. continue;
  152. builtin.push_back(c);
  153. }
  154. closedir(D);
  155. }
  156. // FIXME: Remove support for the old APT::Acquire::Translation
  157. // it was undocumented and so it should be not very widthly used
  158. string const oldAcquire = _config->Find("APT::Acquire::Translation","");
  159. if (oldAcquire.empty() == false && oldAcquire != "environment") {
  160. // TRANSLATORS: the two %s are APT configuration options
  161. _error->Notice("Option '%s' is deprecated. Please use '%s' instead, see 'man 5 apt.conf' for details.",
  162. "APT::Acquire::Translation", "Acquire::Languages");
  163. if (oldAcquire != "none")
  164. codes.push_back(oldAcquire);
  165. codes.push_back("en");
  166. allCodes = codes;
  167. for (std::vector<string>::const_iterator b = builtin.begin();
  168. b != builtin.end(); ++b)
  169. if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end())
  170. allCodes.push_back(*b);
  171. if (All == true)
  172. return allCodes;
  173. else
  174. return codes;
  175. }
  176. // get the environment language codes: LC_MESSAGES (and later LANGUAGE)
  177. // we extract both, a long and a short code and then we will
  178. // check if we actually need both (rare) or if the short is enough
  179. string const envMsg = string(Locale == 0 ? std::setlocale(LC_MESSAGES, NULL) : *Locale);
  180. size_t const lenShort = (envMsg.find('_') != string::npos) ? envMsg.find('_') : 2;
  181. size_t const lenLong = (envMsg.find_first_of(".@") != string::npos) ? envMsg.find_first_of(".@") : (lenShort + 3);
  182. string const envLong = envMsg.substr(0,lenLong);
  183. string const envShort = envLong.substr(0,lenShort);
  184. // It is very likely we will need the environment codes later,
  185. // so let us generate them now from LC_MESSAGES and LANGUAGE
  186. std::vector<string> environment;
  187. if (envShort != "C") {
  188. // take care of LC_MESSAGES
  189. if (envLong != envShort)
  190. environment.push_back(envLong);
  191. environment.push_back(envShort);
  192. // take care of LANGUAGE
  193. const char *language_env = getenv("LANGUAGE") == 0 ? "" : getenv("LANGUAGE");
  194. string envLang = Locale == 0 ? language_env : *(Locale+1);
  195. if (envLang.empty() == false) {
  196. std::vector<string> env = VectorizeString(envLang,':');
  197. short addedLangs = 0; // add a maximum of 3 fallbacks from the environment
  198. for (std::vector<string>::const_iterator e = env.begin();
  199. e != env.end() && addedLangs < 3; ++e) {
  200. if (unlikely(e->empty() == true) || *e == "en")
  201. continue;
  202. if (*e == envLong || *e == envShort)
  203. continue;
  204. if (std::find(environment.begin(), environment.end(), *e) != environment.end())
  205. continue;
  206. ++addedLangs;
  207. environment.push_back(*e);
  208. }
  209. }
  210. } else {
  211. // cornercase: LANG=C, so we use only "en" Translation
  212. environment.push_back("en");
  213. }
  214. std::vector<string> const lang = _config->FindVector("Acquire::Languages", "environment,en");
  215. // the configs define the order, so add the environment
  216. // then needed and ensure the codes are not listed twice.
  217. bool noneSeen = false;
  218. for (std::vector<string>::const_iterator l = lang.begin();
  219. l != lang.end(); ++l) {
  220. if (*l == "environment") {
  221. for (std::vector<string>::const_iterator e = environment.begin();
  222. e != environment.end(); ++e) {
  223. if (std::find(allCodes.begin(), allCodes.end(), *e) != allCodes.end())
  224. continue;
  225. if (noneSeen == false)
  226. codes.push_back(*e);
  227. allCodes.push_back(*e);
  228. }
  229. continue;
  230. } else if (*l == "none") {
  231. noneSeen = true;
  232. continue;
  233. } else if (std::find(allCodes.begin(), allCodes.end(), *l) != allCodes.end())
  234. continue;
  235. if (noneSeen == false)
  236. codes.push_back(*l);
  237. allCodes.push_back(*l);
  238. }
  239. if (allCodes.empty() == false) {
  240. for (std::vector<string>::const_iterator b = builtin.begin();
  241. b != builtin.end(); ++b)
  242. if (std::find(allCodes.begin(), allCodes.end(), *b) == allCodes.end())
  243. allCodes.push_back(*b);
  244. } else {
  245. // "none" was forced
  246. allCodes.push_back("none");
  247. }
  248. if (All == true)
  249. return allCodes;
  250. else
  251. return codes;
  252. }
  253. /*}}}*/
  254. // checkLanguage - are we interested in the given Language? /*{{{*/
  255. bool Configuration::checkLanguage(std::string Lang, bool const All) {
  256. // the empty Language is always interesting as it is the original
  257. if (Lang.empty() == true)
  258. return true;
  259. // filenames are encoded, so undo this
  260. Lang = SubstVar(Lang, "%5f", "_");
  261. std::vector<std::string> const langs = getLanguages(All, true);
  262. return (std::find(langs.begin(), langs.end(), Lang) != langs.end());
  263. }
  264. /*}}}*/
  265. // getArchitectures - Return Vector of preferred Architectures /*{{{*/
  266. std::vector<std::string> const Configuration::getArchitectures(bool const &Cached) {
  267. using std::string;
  268. std::vector<string> static archs;
  269. if (likely(Cached == true) && archs.empty() == false)
  270. return archs;
  271. string const arch = _config->Find("APT::Architecture");
  272. archs = _config->FindVector("APT::Architectures");
  273. if (unlikely(arch.empty() == true))
  274. return archs;
  275. // FIXME: It is a bit unclean to have debian specific code here…
  276. if (archs.empty() == true) {
  277. archs.push_back(arch);
  278. // Generate the base argument list for dpkg
  279. std::vector<const char *> Args;
  280. string Tmp = _config->Find("Dir::Bin::dpkg","dpkg");
  281. {
  282. string const dpkgChrootDir = _config->FindDir("DPkg::Chroot-Directory", "/");
  283. size_t dpkgChrootLen = dpkgChrootDir.length();
  284. if (dpkgChrootDir != "/" && Tmp.find(dpkgChrootDir) == 0) {
  285. if (dpkgChrootDir[dpkgChrootLen - 1] == '/')
  286. --dpkgChrootLen;
  287. Tmp = Tmp.substr(dpkgChrootLen);
  288. }
  289. }
  290. Args.push_back(Tmp.c_str());
  291. // Stick in any custom dpkg options
  292. ::Configuration::Item const *Opts = _config->Tree("DPkg::Options");
  293. if (Opts != 0) {
  294. Opts = Opts->Child;
  295. for (; Opts != 0; Opts = Opts->Next)
  296. {
  297. if (Opts->Value.empty() == true)
  298. continue;
  299. Args.push_back(Opts->Value.c_str());
  300. }
  301. }
  302. Args.push_back("--print-foreign-architectures");
  303. Args.push_back(NULL);
  304. int external[2] = {-1, -1};
  305. if (pipe(external) != 0)
  306. {
  307. _error->WarningE("getArchitecture", "Can't create IPC pipe for dpkg --print-foreign-architectures");
  308. return archs;
  309. }
  310. pid_t dpkgMultiArch = ExecFork();
  311. if (dpkgMultiArch == 0) {
  312. close(external[0]);
  313. std::string const chrootDir = _config->FindDir("DPkg::Chroot-Directory");
  314. int const nullfd = open("/dev/null", O_RDONLY);
  315. dup2(nullfd, STDIN_FILENO);
  316. dup2(external[1], STDOUT_FILENO);
  317. dup2(nullfd, STDERR_FILENO);
  318. if (chrootDir != "/" && chroot(chrootDir.c_str()) != 0 && chdir("/") != 0)
  319. _error->WarningE("getArchitecture", "Couldn't chroot into %s for dpkg --print-foreign-architectures", chrootDir.c_str());
  320. execvp(Args[0], (char**) &Args[0]);
  321. _error->WarningE("getArchitecture", "Can't detect foreign architectures supported by dpkg!");
  322. _exit(100);
  323. }
  324. close(external[1]);
  325. FILE *dpkg = fdopen(external[0], "r");
  326. if(dpkg != NULL) {
  327. char buf[1024];
  328. while (fgets(buf, sizeof(buf), dpkg) != NULL) {
  329. char* arch = strtok(buf, " ");
  330. while (arch != NULL) {
  331. for (; isspace(*arch) != 0; ++arch);
  332. if (arch[0] != '\0') {
  333. char const* archend = arch;
  334. for (; isspace(*archend) == 0 && *archend != '\0'; ++archend);
  335. string a(arch, (archend - arch));
  336. if (std::find(archs.begin(), archs.end(), a) == archs.end())
  337. archs.push_back(a);
  338. }
  339. arch = strtok(NULL, " ");
  340. }
  341. }
  342. fclose(dpkg);
  343. }
  344. ExecWait(dpkgMultiArch, "dpkg --print-foreign-architectures", true);
  345. return archs;
  346. }
  347. if (archs.empty() == true ||
  348. std::find(archs.begin(), archs.end(), arch) == archs.end())
  349. archs.insert(archs.begin(), arch);
  350. // erase duplicates and empty strings
  351. for (std::vector<string>::reverse_iterator a = archs.rbegin();
  352. a != archs.rend(); ++a) {
  353. if (a->empty() == true || std::find(a + 1, archs.rend(), *a) != archs.rend())
  354. archs.erase(a.base()-1);
  355. if (a == archs.rend())
  356. break;
  357. }
  358. return archs;
  359. }
  360. /*}}}*/
  361. // checkArchitecture - are we interested in the given Architecture? /*{{{*/
  362. bool Configuration::checkArchitecture(std::string const &Arch) {
  363. if (Arch == "all")
  364. return true;
  365. std::vector<std::string> const archs = getArchitectures(true);
  366. return (std::find(archs.begin(), archs.end(), Arch) != archs.end());
  367. }
  368. /*}}}*/
  369. // setDefaultConfigurationForCompressors /*{{{*/
  370. void Configuration::setDefaultConfigurationForCompressors() {
  371. // Set default application paths to check for optional compression types
  372. _config->CndSet("Dir::Bin::bzip2", "/bin/bzip2");
  373. _config->CndSet("Dir::Bin::xz", "/usr/bin/xz");
  374. if (FileExists(_config->FindFile("Dir::Bin::xz")) == true) {
  375. _config->Set("Dir::Bin::lzma", _config->FindFile("Dir::Bin::xz"));
  376. _config->Set("APT::Compressor::lzma::Binary", "xz");
  377. if (_config->Exists("APT::Compressor::lzma::CompressArg") == false) {
  378. _config->Set("APT::Compressor::lzma::CompressArg::", "--format=lzma");
  379. _config->Set("APT::Compressor::lzma::CompressArg::", "-9");
  380. }
  381. if (_config->Exists("APT::Compressor::lzma::UncompressArg") == false) {
  382. _config->Set("APT::Compressor::lzma::UncompressArg::", "--format=lzma");
  383. _config->Set("APT::Compressor::lzma::UncompressArg::", "-d");
  384. }
  385. } else {
  386. _config->CndSet("Dir::Bin::lzma", "/usr/bin/lzma");
  387. if (_config->Exists("APT::Compressor::lzma::CompressArg") == false) {
  388. _config->Set("APT::Compressor::lzma::CompressArg::", "--suffix=");
  389. _config->Set("APT::Compressor::lzma::CompressArg::", "-9");
  390. }
  391. if (_config->Exists("APT::Compressor::lzma::UncompressArg") == false) {
  392. _config->Set("APT::Compressor::lzma::UncompressArg::", "--suffix=");
  393. _config->Set("APT::Compressor::lzma::UncompressArg::", "-d");
  394. }
  395. }
  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. }