3 #include <apt-pkg/fileutl.h>
4 #include <apt-pkg/error.h>
5 #include <apt-pkg/configuration.h>
14 // The whole vendor system is deprecated
15 APT_IGNORE_DEPRECATED_PUSH
17 #include <apt-pkg/vendor.h>
18 #include <apt-pkg/vendorlist.h>
23 pkgVendorList::~pkgVendorList()
25 for (vector
<const Vendor
*>::const_iterator I
= VendorList
.begin();
26 I
!= VendorList
.end(); ++I
)
30 // pkgVendorList::ReadMainList - Read list of known package vendors /*{{{*/
31 // ---------------------------------------------------------------------
32 /* This also scans a directory of vendor files similar to apt.conf.d
33 which can contain the usual suspects of distribution provided data.
34 The APT config mechanism allows the user to override these in their
35 configuration file. */
36 bool pkgVendorList::ReadMainList()
40 string CnfFile
= _config
->FindDir("Dir::Etc::vendorparts");
41 if (DirectoryExists(CnfFile
) == true)
42 if (ReadConfigDir(Cnf
,CnfFile
,true) == false)
44 CnfFile
= _config
->FindFile("Dir::Etc::vendorlist");
45 if (RealFileExists(CnfFile
) == true)
46 if (ReadConfigFile(Cnf
,CnfFile
,true) == false)
49 return CreateList(Cnf
);
52 bool pkgVendorList::Read(string File
) /*{{{*/
55 if (ReadConfigFile(Cnf
,File
,true) == false)
58 return CreateList(Cnf
);
61 bool pkgVendorList::CreateList(Configuration
& Cnf
) /*{{{*/
63 for (vector
<const Vendor
*>::const_iterator I
= VendorList
.begin();
64 I
!= VendorList
.end(); ++I
)
66 VendorList
.erase(VendorList
.begin(),VendorList
.end());
68 const Configuration::Item
*Top
= Cnf
.Tree("Vendor");
69 for (Top
= (Top
== 0?0:Top
->Child
); Top
!= 0; Top
= Top
->Next
)
71 Configuration
Block(Top
);
72 string VendorID
= Top
->Tag
;
73 vector
<struct Vendor::Fingerprint
*> *Fingerprints
= new vector
<Vendor::Fingerprint
*>;
74 struct Vendor::Fingerprint
*Fingerprint
= new struct Vendor::Fingerprint();
75 string Origin
= Block
.Find("Origin");
77 Fingerprint
->Print
= Block
.Find("Fingerprint");
78 Fingerprint
->Description
= Block
.Find("Name");
79 Fingerprints
->push_back(Fingerprint
);
81 if (Fingerprint
->Print
.empty() || Fingerprint
->Description
.empty())
83 _error
->Error(_("Vendor block %s contains no fingerprint"), VendorID
.c_str());
87 if (_config
->FindB("Debug::sourceList", false))
88 std::cerr
<< "Adding vendor with ID: " << VendorID
89 << " Fingerprint: " << Fingerprint
->Print
<< std::endl
;
91 VendorList
.push_back(new Vendor(VendorID
, Origin
, Fingerprints
));
94 /* Process 'group-key' type sections */
95 Top
= Cnf
.Tree("group-key");
96 for (Top
= (Top
== 0?0:Top
->Child
); Top
!= 0; Top
= Top
->Next
)
98 // Configuration Block(Top);
99 // vector<Vendor::Fingerprint *> Fingerprints;
100 // string VendorID = Top->Tag;
102 // while (Block->Next)
104 // struct Vendor::Fingerprint Fingerprint = new struct Vendor::Fingerprint;
105 // Fingerprint->Print = Block.Find("Fingerprint");
106 // Fingerprint->Description = Block.Find("Name");
107 // if (Fingerprint->print.empty() || Fingerprint->Description.empty())
109 // _error->Error(_("Vendor block %s is invalid"),
110 // Vendor->VendorID.c_str());
111 // delete Fingerprint;
114 // Block = Block->Next->Next;
116 // if (_error->PendingError())
118 // for (vector <struct Vendor::Fingerprint *>::iterator I = Fingerprints.begin();
119 // I != Fingerprints.end(); I++)
121 // delete Fingerprints;
125 // VendorList.push_back(new Vendor(VendorID, Fingerprints));
128 return !_error
->PendingError();
131 const Vendor
* pkgVendorList::LookupFingerprint(string Fingerprint
) /*{{{*/
133 for (const_iterator I
= VendorList
.begin(); I
!= VendorList
.end(); ++I
)
135 if ((*I
)->LookupFingerprint(Fingerprint
) != "")
142 const Vendor
* pkgVendorList::FindVendor(const std::vector
<string
> GPGVOutput
) /*{{{*/
144 for (std::vector
<string
>::const_iterator I
= GPGVOutput
.begin(); I
!= GPGVOutput
.end(); ++I
)
146 string::size_type pos
= (*I
).find("VALIDSIG ");
147 if (_config
->FindB("Debug::Vendor", false))
148 std::cerr
<< "Looking for VALIDSIG in \"" << (*I
) << "\": pos " << pos
<< std::endl
;
149 if (pos
!= std::string::npos
)
151 string Fingerprint
= (*I
).substr(pos
+sizeof("VALIDSIG"));
152 if (_config
->FindB("Debug::Vendor", false))
153 std::cerr
<< "Looking for \"" << Fingerprint
<< "\" in vendor..." << std::endl
;
154 const Vendor
* vendor
= this->LookupFingerprint(Fingerprint
);
164 APT_IGNORE_DEPRECATED_POP