aptconfiguration.cc 20 KB

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