summaryrefslogtreecommitdiff
path: root/apt-pkg/init.cc
blob: da11e3b408232cf8891d348dde36ec7149fcf698 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// -*- mode: cpp; mode: fold -*-
// Description								/*{{{*/
// $Id: init.cc,v 1.9 1998/10/30 07:53:39 jgg Exp $
/* ######################################################################

   Init - Initialize the package library
   
   ##################################################################### */
									/*}}}*/
// Include files							/*{{{*/
#include <apt-pkg/init.h>
#include <config.h>

#include <sys/stat.h>
#include <unistd.h>
									/*}}}*/

// pkgInitialize - Initialize the configuration class			/*{{{*/
// ---------------------------------------------------------------------
/* Directories are specified in such a way that the FindDir function will
   understand them. That is, if they don't start with a / then their parent
   is prepended, this allows a fair degree of flexability. */
bool pkgInitialize(Configuration &Cnf)
{
   // General APT things
   Cnf.Set("APT::Architecture",ARCHITECTURE);

   // State
   Cnf.Set("Dir::State","/var/state/apt/");
   Cnf.Set("Dir::State::lists","lists/");
   
   /* These really should be jammed into a generic 'Local Database' engine
      which is yet to be determined. The functions in pkgcachegen should
      be the only users of these */
   Cnf.Set("Dir::State::xstatus","xstatus");
   Cnf.Set("Dir::State::userstatus","status.user");   
   Cnf.Set("Dir::State::status","/var/lib/dpkg/status");
   
   // Cache
   Cnf.Set("Dir::Cache","/var/cache/apt/");
   Cnf.Set("Dir::Cache::archives","archives/");
   Cnf.Set("Dir::Cache::srcpkgcache","srcpkgcache.bin");
   Cnf.Set("Dir::Cache::pkgcache","pkgcache.bin");
   
   // Configuration
   Cnf.Set("Dir::Etc","/etc/apt/");
   Cnf.Set("Dir::Etc::sourcelist","sources.list");
   Cnf.Set("Dir::Etc::main","apt.conf");
   Cnf.Set("Dir::Bin::methods","/usr/lib/apt/metods");
   
   // Read the main config file
   string FName = Cnf.FindFile("Dir::Etc::main");
   struct stat Buf;   
   if (stat(FName.c_str(),&Buf) != 0)
      return true;
   
   // Read an alternate config file
   const char *Cfg = getenv("APT_CONFIG");
   
   if (ReadConfigFile(Cnf,FName) != true || ReadConfigFile(Cnf,Cfg) != true)
      return false;
   
   if (Cnf.FindB("Debug::pkgInitialize",false) == true)
      Cnf.Dump();
      
   return true;
}
									/*}}}*/