]>
git.saurik.com Git - apt.git/blob - apt-pkg/vendorlist.cc
3 #include <apt-pkg/fileutl.h>
4 #include <apt-pkg/error.h>
5 #include <apt-pkg/configuration.h>
9 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
12 #include <apt-pkg/vendor.h>
13 #include <apt-pkg/vendorlist.h>
18 pkgVendorList::~pkgVendorList()
20 for (vector
<const Vendor
*>::const_iterator I
= VendorList
.begin();
21 I
!= VendorList
.end(); ++I
)
25 // pkgVendorList::ReadMainList - Read list of known package vendors /*{{{*/
26 // ---------------------------------------------------------------------
27 /* This also scans a directory of vendor files similar to apt.conf.d
28 which can contain the usual suspects of distribution provided data.
29 The APT config mechanism allows the user to override these in their
30 configuration file. */
31 bool pkgVendorList::ReadMainList()
35 string CnfFile
= _config
->FindDir("Dir::Etc::vendorparts");
36 if (DirectoryExists(CnfFile
) == true)
37 if (ReadConfigDir(Cnf
,CnfFile
,true) == false)
39 CnfFile
= _config
->FindFile("Dir::Etc::vendorlist");
40 if (RealFileExists(CnfFile
) == true)
41 if (ReadConfigFile(Cnf
,CnfFile
,true) == false)
44 return CreateList(Cnf
);
47 bool pkgVendorList::Read(string File
) /*{{{*/
50 if (ReadConfigFile(Cnf
,File
,true) == false)
53 return CreateList(Cnf
);
56 bool pkgVendorList::CreateList(Configuration
& Cnf
) /*{{{*/
58 for (vector
<const Vendor
*>::const_iterator I
= VendorList
.begin();
59 I
!= VendorList
.end(); ++I
)
61 VendorList
.erase(VendorList
.begin(),VendorList
.end());
63 const Configuration::Item
*Top
= Cnf
.Tree("Vendor");
64 for (Top
= (Top
== 0?0:Top
->Child
); Top
!= 0; Top
= Top
->Next
)
66 Configuration
Block(Top
);
67 string VendorID
= Top
->Tag
;
68 vector
<struct Vendor::Fingerprint
*> *Fingerprints
= new vector
<Vendor::Fingerprint
*>;
69 struct Vendor::Fingerprint
*Fingerprint
= new struct Vendor::Fingerprint
;
70 string Origin
= Block
.Find("Origin");
72 Fingerprint
->Print
= Block
.Find("Fingerprint");
73 Fingerprint
->Description
= Block
.Find("Name");
74 Fingerprints
->push_back(Fingerprint
);
76 if (Fingerprint
->Print
.empty() || Fingerprint
->Description
.empty())
78 _error
->Error(_("Vendor block %s contains no fingerprint"), VendorID
.c_str());
82 if (_config
->FindB("Debug::sourceList", false))
83 std::cerr
<< "Adding vendor with ID: " << VendorID
84 << " Fingerprint: " << Fingerprint
->Print
<< std::endl
;
86 VendorList
.push_back(new Vendor(VendorID
, Origin
, Fingerprints
));
89 /* Process 'group-key' type sections */
90 Top
= Cnf
.Tree("group-key");
91 for (Top
= (Top
== 0?0:Top
->Child
); Top
!= 0; Top
= Top
->Next
)
93 // Configuration Block(Top);
94 // vector<Vendor::Fingerprint *> Fingerprints;
95 // string VendorID = Top->Tag;
97 // while (Block->Next)
99 // struct Vendor::Fingerprint Fingerprint = new struct Vendor::Fingerprint;
100 // Fingerprint->Print = Block.Find("Fingerprint");
101 // Fingerprint->Description = Block.Find("Name");
102 // if (Fingerprint->print.empty() || Fingerprint->Description.empty())
104 // _error->Error(_("Vendor block %s is invalid"),
105 // Vendor->VendorID.c_str());
106 // delete Fingerprint;
109 // Block = Block->Next->Next;
111 // if (_error->PendingError())
113 // for (vector <struct Vendor::Fingerprint *>::iterator I = Fingerprints.begin();
114 // I != Fingerprints.end(); I++)
116 // delete Fingerprints;
120 // VendorList.push_back(new Vendor(VendorID, Fingerprints));
123 return !_error
->PendingError();
126 const Vendor
* pkgVendorList::LookupFingerprint(string Fingerprint
) /*{{{*/
128 for (const_iterator I
= VendorList
.begin(); I
!= VendorList
.end(); ++I
)
130 if ((*I
)->LookupFingerprint(Fingerprint
) != "")
137 const Vendor
* pkgVendorList::FindVendor(const std::vector
<string
> GPGVOutput
) /*{{{*/
139 for (std::vector
<string
>::const_iterator I
= GPGVOutput
.begin(); I
!= GPGVOutput
.end(); ++I
)
141 string::size_type pos
= (*I
).find("VALIDSIG ");
142 if (_config
->FindB("Debug::Vendor", false))
143 std::cerr
<< "Looking for VALIDSIG in \"" << (*I
) << "\": pos " << pos
<< std::endl
;
144 if (pos
!= std::string::npos
)
146 string Fingerprint
= (*I
).substr(pos
+sizeof("VALIDSIG"));
147 if (_config
->FindB("Debug::Vendor", false))
148 std::cerr
<< "Looking for \"" << Fingerprint
<< "\" in vendor..." << std::endl
;
149 const Vendor
* vendor
= this->LookupFingerprint(Fingerprint
);
160 #pragma GCC diagnostic warning "-Wdeprecated-declarations"