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