init.cc 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: init.cc,v 1.13 1998/11/22 03:20:32 jgg Exp $
  4. /* ######################################################################
  5. Init - Initialize the package library
  6. ##################################################################### */
  7. /*}}}*/
  8. // Include files /*{{{*/
  9. #include <apt-pkg/init.h>
  10. #include <apt-pkg/fileutl.h>
  11. #include <config.h>
  12. /*}}}*/
  13. // pkgInitialize - Initialize the configuration class /*{{{*/
  14. // ---------------------------------------------------------------------
  15. /* Directories are specified in such a way that the FindDir function will
  16. understand them. That is, if they don't start with a / then their parent
  17. is prepended, this allows a fair degree of flexability. */
  18. bool pkgInitialize(Configuration &Cnf)
  19. {
  20. // General APT things
  21. Cnf.Set("APT::Architecture",ARCHITECTURE);
  22. // State
  23. Cnf.Set("Dir::State","/var/state/apt/");
  24. Cnf.Set("Dir::State::lists","lists/");
  25. /* These really should be jammed into a generic 'Local Database' engine
  26. which is yet to be determined. The functions in pkgcachegen should
  27. be the only users of these */
  28. Cnf.Set("Dir::State::xstatus","xstatus");
  29. Cnf.Set("Dir::State::userstatus","status.user");
  30. Cnf.Set("Dir::State::status","/var/lib/dpkg/status");
  31. // Cache
  32. Cnf.Set("Dir::Cache","/var/cache/apt/");
  33. Cnf.Set("Dir::Cache::archives","archives/");
  34. Cnf.Set("Dir::Cache::srcpkgcache","srcpkgcache.bin");
  35. Cnf.Set("Dir::Cache::pkgcache","pkgcache.bin");
  36. // Configuration
  37. Cnf.Set("Dir::Etc","/etc/apt/");
  38. Cnf.Set("Dir::Etc::sourcelist","sources.list");
  39. Cnf.Set("Dir::Etc::main","apt.conf");
  40. Cnf.Set("Dir::Bin::methods","/usr/lib/apt/methods");
  41. Cnf.Set("Dir::Bin::dpkg","/usr/bin/dpkg");
  42. // Read the main config file
  43. string FName = Cnf.FindFile("Dir::Etc::main");
  44. bool Res = true;
  45. if (FileExists(FName) == true)
  46. Res &= ReadConfigFile(Cnf,FName);
  47. // Read an alternate config file
  48. const char *Cfg = getenv("APT_CONFIG");
  49. if (Cfg != 0 && FileExists(Cfg) == true)
  50. Res &= ReadConfigFile(Cnf,Cfg);
  51. if (Res == false)
  52. return false;
  53. if (Cnf.FindB("Debug::pkgInitialize",false) == true)
  54. Cnf.Dump();
  55. return true;
  56. }
  57. /*}}}*/