init.cc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: init.cc,v 1.14 1998/11/25 23:54:06 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. Cnf.Set("Dir::State::cdroms","cdroms.list");
  32. // Cache
  33. Cnf.Set("Dir::Cache","/var/cache/apt/");
  34. Cnf.Set("Dir::Cache::archives","archives/");
  35. Cnf.Set("Dir::Cache::srcpkgcache","srcpkgcache.bin");
  36. Cnf.Set("Dir::Cache::pkgcache","pkgcache.bin");
  37. // Configuration
  38. Cnf.Set("Dir::Etc","/etc/apt/");
  39. Cnf.Set("Dir::Etc::sourcelist","sources.list");
  40. Cnf.Set("Dir::Etc::main","apt.conf");
  41. Cnf.Set("Dir::Bin::methods","/usr/lib/apt/methods");
  42. Cnf.Set("Dir::Bin::dpkg","/usr/bin/dpkg");
  43. // Read the main config file
  44. string FName = Cnf.FindFile("Dir::Etc::main");
  45. bool Res = true;
  46. if (FileExists(FName) == true)
  47. Res &= ReadConfigFile(Cnf,FName);
  48. // Read an alternate config file
  49. const char *Cfg = getenv("APT_CONFIG");
  50. if (Cfg != 0 && FileExists(Cfg) == true)
  51. Res &= ReadConfigFile(Cnf,Cfg);
  52. if (Res == false)
  53. return false;
  54. if (Cnf.FindB("Debug::pkgInitialize",false) == true)
  55. Cnf.Dump();
  56. return true;
  57. }
  58. /*}}}*/