]>
git.saurik.com Git - apt.git/blob - apt-pkg/vendorlist.cc
3 #include <apt-pkg/fileutl.h>
4 #include <apt-pkg/error.h>
8 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
11 #include <apt-pkg/vendorlist.h>
13 pkgVendorList::~pkgVendorList()
15 for (vector
<const Vendor
*>::const_iterator I
= VendorList
.begin();
16 I
!= VendorList
.end(); ++I
)
20 // pkgVendorList::ReadMainList - Read list of known package vendors /*{{{*/
21 // ---------------------------------------------------------------------
22 /* This also scans a directory of vendor files similar to apt.conf.d
23 which can contain the usual suspects of distribution provided data.
24 The APT config mechanism allows the user to override these in their
25 configuration file. */
26 bool pkgVendorList::ReadMainList()
30 string CnfFile
= _config
->FindDir("Dir::Etc::vendorparts");
31 if (DirectoryExists(CnfFile
) == true)
32 if (ReadConfigDir(Cnf
,CnfFile
,true) == false)
34 CnfFile
= _config
->FindFile("Dir::Etc::vendorlist");
35 if (RealFileExists(CnfFile
) == true)
36 if (ReadConfigFile(Cnf
,CnfFile
,true) == false)
39 return CreateList(Cnf
);
42 bool pkgVendorList::Read(string File
) /*{{{*/
45 if (ReadConfigFile(Cnf
,File
,true) == false)
48 return CreateList(Cnf
);
51 bool pkgVendorList::CreateList(Configuration
& Cnf
) /*{{{*/
53 for (vector
<const Vendor
*>::const_iterator I
= VendorList
.begin();
54 I
!= VendorList
.end(); ++I
)
56 VendorList
.erase(VendorList
.begin(),VendorList
.end());
58 const Configuration::Item
*Top
= Cnf
.Tree("Vendor");
59 for (Top
= (Top
== 0?0:Top
->Child
); Top
!= 0; Top
= Top
->Next
)
61 Configuration
Block(Top
);
62 string VendorID
= Top
->Tag
;
63 vector
<struct Vendor::Fingerprint
*> *Fingerprints
= new vector
<Vendor::Fingerprint
*>;
64 struct Vendor::Fingerprint
*Fingerprint
= new struct Vendor::Fingerprint
;
65 string Origin
= Block
.Find("Origin");
67 Fingerprint
->Print
= Block
.Find("Fingerprint");
68 Fingerprint
->Description
= Block
.Find("Name");
69 Fingerprints
->push_back(Fingerprint
);
71 if (Fingerprint
->Print
.empty() || Fingerprint
->Description
.empty())
73 _error
->Error(_("Vendor block %s contains no fingerprint"), VendorID
.c_str());
77 if (_config
->FindB("Debug::sourceList", false))
78 std::cerr
<< "Adding vendor with ID: " << VendorID
79 << " Fingerprint: " << Fingerprint
->Print
<< std::endl
;
81 VendorList
.push_back(new Vendor(VendorID
, Origin
, Fingerprints
));
84 /* Process 'group-key' type sections */
85 Top
= Cnf
.Tree("group-key");
86 for (Top
= (Top
== 0?0:Top
->Child
); Top
!= 0; Top
= Top
->Next
)
88 // Configuration Block(Top);
89 // vector<Vendor::Fingerprint *> Fingerprints;
90 // string VendorID = Top->Tag;
92 // while (Block->Next)
94 // struct Vendor::Fingerprint Fingerprint = new struct Vendor::Fingerprint;
95 // Fingerprint->Print = Block.Find("Fingerprint");
96 // Fingerprint->Description = Block.Find("Name");
97 // if (Fingerprint->print.empty() || Fingerprint->Description.empty())
99 // _error->Error(_("Vendor block %s is invalid"),
100 // Vendor->VendorID.c_str());
101 // delete Fingerprint;
104 // Block = Block->Next->Next;
106 // if (_error->PendingError())
108 // for (vector <struct Vendor::Fingerprint *>::iterator I = Fingerprints.begin();
109 // I != Fingerprints.end(); I++)
111 // delete Fingerprints;
115 // VendorList.push_back(new Vendor(VendorID, Fingerprints));
118 return !_error
->PendingError();
121 const Vendor
* pkgVendorList::LookupFingerprint(string Fingerprint
) /*{{{*/
123 for (const_iterator I
= VendorList
.begin(); I
!= VendorList
.end(); ++I
)
125 if ((*I
)->LookupFingerprint(Fingerprint
) != "")
132 const Vendor
* pkgVendorList::FindVendor(const std::vector
<string
> GPGVOutput
) /*{{{*/
134 for (std::vector
<string
>::const_iterator I
= GPGVOutput
.begin(); I
!= GPGVOutput
.end(); ++I
)
136 string::size_type pos
= (*I
).find("VALIDSIG ");
137 if (_config
->FindB("Debug::Vendor", false))
138 std::cerr
<< "Looking for VALIDSIG in \"" << (*I
) << "\": pos " << pos
<< std::endl
;
139 if (pos
!= std::string::npos
)
141 string Fingerprint
= (*I
).substr(pos
+sizeof("VALIDSIG"));
142 if (_config
->FindB("Debug::Vendor", false))
143 std::cerr
<< "Looking for \"" << Fingerprint
<< "\" in vendor..." << std::endl
;
144 const Vendor
* vendor
= this->LookupFingerprint(Fingerprint
);
155 #pragma GCC diagnostic warning "-Wdeprecated-declarations"