]>
git.saurik.com Git - apt.git/blob - apt-pkg/vendorlist.cc
2ccb556ab60b8f652bc1624b1fd2c2b220641d03
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>
16 pkgVendorList::~pkgVendorList()
18 for (vector
<const Vendor
*>::const_iterator I
= VendorList
.begin();
19 I
!= VendorList
.end(); ++I
)
23 // pkgVendorList::ReadMainList - Read list of known package vendors /*{{{*/
24 // ---------------------------------------------------------------------
25 /* This also scans a directory of vendor files similar to apt.conf.d
26 which can contain the usual suspects of distribution provided data.
27 The APT config mechanism allows the user to override these in their
28 configuration file. */
29 bool pkgVendorList::ReadMainList()
33 string CnfFile
= _config
->FindDir("Dir::Etc::vendorparts");
34 if (DirectoryExists(CnfFile
) == true)
35 if (ReadConfigDir(Cnf
,CnfFile
,true) == false)
37 CnfFile
= _config
->FindFile("Dir::Etc::vendorlist");
38 if (RealFileExists(CnfFile
) == true)
39 if (ReadConfigFile(Cnf
,CnfFile
,true) == false)
42 return CreateList(Cnf
);
45 bool pkgVendorList::Read(string File
) /*{{{*/
48 if (ReadConfigFile(Cnf
,File
,true) == false)
51 return CreateList(Cnf
);
54 bool pkgVendorList::CreateList(Configuration
& Cnf
) /*{{{*/
56 for (vector
<const Vendor
*>::const_iterator I
= VendorList
.begin();
57 I
!= VendorList
.end(); ++I
)
59 VendorList
.erase(VendorList
.begin(),VendorList
.end());
61 const Configuration::Item
*Top
= Cnf
.Tree("Vendor");
62 for (Top
= (Top
== 0?0:Top
->Child
); Top
!= 0; Top
= Top
->Next
)
64 Configuration
Block(Top
);
65 string VendorID
= Top
->Tag
;
66 vector
<struct Vendor::Fingerprint
*> *Fingerprints
= new vector
<Vendor::Fingerprint
*>;
67 struct Vendor::Fingerprint
*Fingerprint
= new struct Vendor::Fingerprint
;
68 string Origin
= Block
.Find("Origin");
70 Fingerprint
->Print
= Block
.Find("Fingerprint");
71 Fingerprint
->Description
= Block
.Find("Name");
72 Fingerprints
->push_back(Fingerprint
);
74 if (Fingerprint
->Print
.empty() || Fingerprint
->Description
.empty())
76 _error
->Error(_("Vendor block %s contains no fingerprint"), VendorID
.c_str());
80 if (_config
->FindB("Debug::sourceList", false))
81 std::cerr
<< "Adding vendor with ID: " << VendorID
82 << " Fingerprint: " << Fingerprint
->Print
<< std::endl
;
84 VendorList
.push_back(new Vendor(VendorID
, Origin
, Fingerprints
));
87 /* Process 'group-key' type sections */
88 Top
= Cnf
.Tree("group-key");
89 for (Top
= (Top
== 0?0:Top
->Child
); Top
!= 0; Top
= Top
->Next
)
91 // Configuration Block(Top);
92 // vector<Vendor::Fingerprint *> Fingerprints;
93 // string VendorID = Top->Tag;
95 // while (Block->Next)
97 // struct Vendor::Fingerprint Fingerprint = new struct Vendor::Fingerprint;
98 // Fingerprint->Print = Block.Find("Fingerprint");
99 // Fingerprint->Description = Block.Find("Name");
100 // if (Fingerprint->print.empty() || Fingerprint->Description.empty())
102 // _error->Error(_("Vendor block %s is invalid"),
103 // Vendor->VendorID.c_str());
104 // delete Fingerprint;
107 // Block = Block->Next->Next;
109 // if (_error->PendingError())
111 // for (vector <struct Vendor::Fingerprint *>::iterator I = Fingerprints.begin();
112 // I != Fingerprints.end(); I++)
114 // delete Fingerprints;
118 // VendorList.push_back(new Vendor(VendorID, Fingerprints));
121 return !_error
->PendingError();
124 const Vendor
* pkgVendorList::LookupFingerprint(string Fingerprint
) /*{{{*/
126 for (const_iterator I
= VendorList
.begin(); I
!= VendorList
.end(); ++I
)
128 if ((*I
)->LookupFingerprint(Fingerprint
) != "")
135 const Vendor
* pkgVendorList::FindVendor(const std::vector
<string
> GPGVOutput
) /*{{{*/
137 for (std::vector
<string
>::const_iterator I
= GPGVOutput
.begin(); I
!= GPGVOutput
.end(); ++I
)
139 string::size_type pos
= (*I
).find("VALIDSIG ");
140 if (_config
->FindB("Debug::Vendor", false))
141 std::cerr
<< "Looking for VALIDSIG in \"" << (*I
) << "\": pos " << pos
<< std::endl
;
142 if (pos
!= std::string::npos
)
144 string Fingerprint
= (*I
).substr(pos
+sizeof("VALIDSIG"));
145 if (_config
->FindB("Debug::Vendor", false))
146 std::cerr
<< "Looking for \"" << Fingerprint
<< "\" in vendor..." << std::endl
;
147 const Vendor
* vendor
= this->LookupFingerprint(Fingerprint
);
158 #pragma GCC diagnostic warning "-Wdeprecated-declarations"