init.cc 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: init.cc,v 1.12 1998/11/06 02:52:21 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. // Read the main config file
  42. string FName = Cnf.FindFile("Dir::Etc::main");
  43. bool Res = true;
  44. if (FileExists(FName) == true)
  45. Res &= ReadConfigFile(Cnf,FName);
  46. // Read an alternate config file
  47. const char *Cfg = getenv("APT_CONFIG");
  48. if (Cfg != 0 && FileExists(Cfg) == true)
  49. Res &= ReadConfigFile(Cnf,Cfg);
  50. if (Res == false)
  51. return false;
  52. if (Cnf.FindB("Debug::pkgInitialize",false) == true)
  53. Cnf.Dump();
  54. return true;
  55. }
  56. /*}}}*/