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