]>
git.saurik.com Git - apt.git/blob - apt-pkg/vendorlist.cc
72694dd756c0a3564e14143861925b44ae0349cd
1 #include <apt-pkg/vendorlist.h>
2 #include <apt-pkg/fileutl.h>
3 #include <apt-pkg/error.h>
6 pkgVendorList::~pkgVendorList()
8 for (vector
<const Vendor
*>::const_iterator I
= VendorList
.begin();
9 I
!= VendorList
.end(); I
++)
13 // pkgVendorList::ReadMainList - Read list of known package vendors /*{{{*/
14 // ---------------------------------------------------------------------
15 /* This also scans a directory of vendor files similar to apt.conf.d
16 which can contain the usual suspects of distribution provided data.
17 The APT config mechanism allows the user to override these in their
18 configuration file. */
19 bool pkgVendorList::ReadMainList()
23 string CnfFile
= _config
->FindDir("Dir::Etc::vendorparts");
24 if (FileExists(CnfFile
) == true)
25 if (ReadConfigDir(Cnf
,CnfFile
,true) == false)
27 CnfFile
= _config
->FindFile("Dir::Etc::vendorlist");
28 if (FileExists(CnfFile
) == true)
29 if (ReadConfigFile(Cnf
,CnfFile
,true) == false)
32 return CreateList(Cnf
);
35 bool pkgVendorList::Read(string File
)
38 if (ReadConfigFile(Cnf
,File
,true) == false)
41 return CreateList(Cnf
);
44 bool pkgVendorList::CreateList(Configuration
& Cnf
)
46 for (vector
<const Vendor
*>::const_iterator I
= VendorList
.begin();
47 I
!= VendorList
.end(); I
++)
49 VendorList
.erase(VendorList
.begin(),VendorList
.end());
51 const Configuration::Item
*Top
= Cnf
.Tree("Vendor");
52 for (Top
= (Top
== 0?0:Top
->Child
); Top
!= 0; Top
= Top
->Next
)
54 Configuration
Block(Top
);
55 string VendorID
= Top
->Tag
;
56 vector
<struct Vendor::Fingerprint
*> *Fingerprints
= new vector
<Vendor::Fingerprint
*>;
57 struct Vendor::Fingerprint
*Fingerprint
= new struct Vendor::Fingerprint
;
58 string Origin
= Block
.Find("Origin");
60 Fingerprint
->Print
= Block
.Find("Fingerprint");
61 Fingerprint
->Description
= Block
.Find("Name");
62 Fingerprints
->push_back(Fingerprint
);
64 if (Fingerprint
->Print
.empty() || Fingerprint
->Description
.empty())
66 _error
->Error(_("Vendor block %s contains no fingerprint"), VendorID
.c_str());
70 if (_config
->FindB("Debug::sourceList", false))
71 std::cerr
<< "Adding vendor with ID: " << VendorID
72 << " Fingerprint: " << Fingerprint
->Print
<< std::endl
;
74 VendorList
.push_back(new Vendor(VendorID
, Origin
, Fingerprints
));
77 /* Process 'group-key' type sections */
78 Top
= Cnf
.Tree("group-key");
79 for (Top
= (Top
== 0?0:Top
->Child
); Top
!= 0; Top
= Top
->Next
)
81 // Configuration Block(Top);
82 // vector<Vendor::Fingerprint *> Fingerprints;
83 // string VendorID = Top->Tag;
85 // while (Block->Next)
87 // struct Vendor::Fingerprint Fingerprint = new struct Vendor::Fingerprint;
88 // Fingerprint->Print = Block.Find("Fingerprint");
89 // Fingerprint->Description = Block.Find("Name");
90 // if (Fingerprint->print.empty() || Fingerprint->Description.empty())
92 // _error->Error(_("Vendor block %s is invalid"),
93 // Vendor->VendorID.c_str());
94 // delete Fingerprint;
97 // Block = Block->Next->Next;
99 // if (_error->PendingError())
101 // for (vector <struct Vendor::Fingerprint *>::iterator I = Fingerprints.begin();
102 // I != Fingerprints.end(); I++)
104 // delete Fingerprints;
108 // VendorList.push_back(new Vendor(VendorID, Fingerprints));
111 return !_error
->PendingError();
114 const Vendor
* pkgVendorList::LookupFingerprint(string Fingerprint
)
116 for (const_iterator I
= begin(); I
!= end(); ++I
)
118 if ((*I
)->LookupFingerprint(Fingerprint
) != "")
125 const Vendor
* pkgVendorList::FindVendor(const std::vector
<string
> GPGVOutput
)
127 for (std::vector
<string
>::const_iterator I
= GPGVOutput
.begin(); I
!= GPGVOutput
.end(); I
++)
129 string::size_type pos
= (*I
).find("VALIDSIG ");
130 if (_config
->FindB("Debug::Vendor", false))
131 std::cerr
<< "Looking for VALIDSIG in \"" << (*I
) << "\": pos " << pos
<< std::endl
;
132 if (pos
!= std::string::npos
)
134 string Fingerprint
= (*I
).substr(pos
+sizeof("VALIDSIG"));
135 if (_config
->FindB("Debug::Vendor", false))
136 std::cerr
<< "Looking for \"" << Fingerprint
<< "\" in vendor..." << std::endl
;
137 const Vendor
* vendor
= this->LookupFingerprint(Fingerprint
);