]>
git.saurik.com Git - apt.git/blob - apt-pkg/vendorlist.cc
1 #include <apt-pkg/fileutl.h>
2 #include <apt-pkg/error.h>
6 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
9 #include <apt-pkg/vendorlist.h>
11 pkgVendorList::~pkgVendorList()
13 for (vector
<const Vendor
*>::const_iterator I
= VendorList
.begin();
14 I
!= VendorList
.end(); I
++)
18 // pkgVendorList::ReadMainList - Read list of known package vendors /*{{{*/
19 // ---------------------------------------------------------------------
20 /* This also scans a directory of vendor files similar to apt.conf.d
21 which can contain the usual suspects of distribution provided data.
22 The APT config mechanism allows the user to override these in their
23 configuration file. */
24 bool pkgVendorList::ReadMainList()
28 string CnfFile
= _config
->FindDir("Dir::Etc::vendorparts");
29 if (DirectoryExists(CnfFile
) == true)
30 if (ReadConfigDir(Cnf
,CnfFile
,true) == false)
32 CnfFile
= _config
->FindFile("Dir::Etc::vendorlist");
33 if (RealFileExists(CnfFile
) == true)
34 if (ReadConfigFile(Cnf
,CnfFile
,true) == false)
37 return CreateList(Cnf
);
40 bool pkgVendorList::Read(string File
) /*{{{*/
43 if (ReadConfigFile(Cnf
,File
,true) == false)
46 return CreateList(Cnf
);
49 bool pkgVendorList::CreateList(Configuration
& Cnf
) /*{{{*/
51 for (vector
<const Vendor
*>::const_iterator I
= VendorList
.begin();
52 I
!= VendorList
.end(); I
++)
54 VendorList
.erase(VendorList
.begin(),VendorList
.end());
56 const Configuration::Item
*Top
= Cnf
.Tree("Vendor");
57 for (Top
= (Top
== 0?0:Top
->Child
); Top
!= 0; Top
= Top
->Next
)
59 Configuration
Block(Top
);
60 string VendorID
= Top
->Tag
;
61 vector
<struct Vendor::Fingerprint
*> *Fingerprints
= new vector
<Vendor::Fingerprint
*>;
62 struct Vendor::Fingerprint
*Fingerprint
= new struct Vendor::Fingerprint
;
63 string Origin
= Block
.Find("Origin");
65 Fingerprint
->Print
= Block
.Find("Fingerprint");
66 Fingerprint
->Description
= Block
.Find("Name");
67 Fingerprints
->push_back(Fingerprint
);
69 if (Fingerprint
->Print
.empty() || Fingerprint
->Description
.empty())
71 _error
->Error(_("Vendor block %s contains no fingerprint"), VendorID
.c_str());
75 if (_config
->FindB("Debug::sourceList", false))
76 std::cerr
<< "Adding vendor with ID: " << VendorID
77 << " Fingerprint: " << Fingerprint
->Print
<< std::endl
;
79 VendorList
.push_back(new Vendor(VendorID
, Origin
, Fingerprints
));
82 /* Process 'group-key' type sections */
83 Top
= Cnf
.Tree("group-key");
84 for (Top
= (Top
== 0?0:Top
->Child
); Top
!= 0; Top
= Top
->Next
)
86 // Configuration Block(Top);
87 // vector<Vendor::Fingerprint *> Fingerprints;
88 // string VendorID = Top->Tag;
90 // while (Block->Next)
92 // struct Vendor::Fingerprint Fingerprint = new struct Vendor::Fingerprint;
93 // Fingerprint->Print = Block.Find("Fingerprint");
94 // Fingerprint->Description = Block.Find("Name");
95 // if (Fingerprint->print.empty() || Fingerprint->Description.empty())
97 // _error->Error(_("Vendor block %s is invalid"),
98 // Vendor->VendorID.c_str());
99 // delete Fingerprint;
102 // Block = Block->Next->Next;
104 // if (_error->PendingError())
106 // for (vector <struct Vendor::Fingerprint *>::iterator I = Fingerprints.begin();
107 // I != Fingerprints.end(); I++)
109 // delete Fingerprints;
113 // VendorList.push_back(new Vendor(VendorID, Fingerprints));
116 return !_error
->PendingError();
119 const Vendor
* pkgVendorList::LookupFingerprint(string Fingerprint
) /*{{{*/
121 for (const_iterator I
= VendorList
.begin(); I
!= VendorList
.end(); ++I
)
123 if ((*I
)->LookupFingerprint(Fingerprint
) != "")
130 const Vendor
* pkgVendorList::FindVendor(const std::vector
<string
> GPGVOutput
) /*{{{*/
132 for (std::vector
<string
>::const_iterator I
= GPGVOutput
.begin(); I
!= GPGVOutput
.end(); I
++)
134 string::size_type pos
= (*I
).find("VALIDSIG ");
135 if (_config
->FindB("Debug::Vendor", false))
136 std::cerr
<< "Looking for VALIDSIG in \"" << (*I
) << "\": pos " << pos
<< std::endl
;
137 if (pos
!= std::string::npos
)
139 string Fingerprint
= (*I
).substr(pos
+sizeof("VALIDSIG"));
140 if (_config
->FindB("Debug::Vendor", false))
141 std::cerr
<< "Looking for \"" << Fingerprint
<< "\" in vendor..." << std::endl
;
142 const Vendor
* vendor
= this->LookupFingerprint(Fingerprint
);
153 #pragma GCC diagnostic warning "-Wdeprecated-declarations"