]>
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>
15 #pragma GCC diagnostic push
16 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
19 #include <apt-pkg/vendor.h>
20 #include <apt-pkg/vendorlist.h>
25 pkgVendorList::~pkgVendorList()
27 for (vector
<const Vendor
*>::const_iterator I
= VendorList
.begin();
28 I
!= VendorList
.end(); ++I
)
32 // pkgVendorList::ReadMainList - Read list of known package vendors /*{{{*/
33 // ---------------------------------------------------------------------
34 /* This also scans a directory of vendor files similar to apt.conf.d
35 which can contain the usual suspects of distribution provided data.
36 The APT config mechanism allows the user to override these in their
37 configuration file. */
38 bool pkgVendorList::ReadMainList()
42 string CnfFile
= _config
->FindDir("Dir::Etc::vendorparts");
43 if (DirectoryExists(CnfFile
) == true)
44 if (ReadConfigDir(Cnf
,CnfFile
,true) == false)
46 CnfFile
= _config
->FindFile("Dir::Etc::vendorlist");
47 if (RealFileExists(CnfFile
) == true)
48 if (ReadConfigFile(Cnf
,CnfFile
,true) == false)
51 return CreateList(Cnf
);
54 bool pkgVendorList::Read(string File
) /*{{{*/
57 if (ReadConfigFile(Cnf
,File
,true) == false)
60 return CreateList(Cnf
);
63 bool pkgVendorList::CreateList(Configuration
& Cnf
) /*{{{*/
65 for (vector
<const Vendor
*>::const_iterator I
= VendorList
.begin();
66 I
!= VendorList
.end(); ++I
)
68 VendorList
.erase(VendorList
.begin(),VendorList
.end());
70 const Configuration::Item
*Top
= Cnf
.Tree("Vendor");
71 for (Top
= (Top
== 0?0:Top
->Child
); Top
!= 0; Top
= Top
->Next
)
73 Configuration
Block(Top
);
74 string VendorID
= Top
->Tag
;
75 vector
<struct Vendor::Fingerprint
*> *Fingerprints
= new vector
<Vendor::Fingerprint
*>;
76 struct Vendor::Fingerprint
*Fingerprint
= new struct Vendor::Fingerprint();
77 string Origin
= Block
.Find("Origin");
79 Fingerprint
->Print
= Block
.Find("Fingerprint");
80 Fingerprint
->Description
= Block
.Find("Name");
81 Fingerprints
->push_back(Fingerprint
);
83 if (Fingerprint
->Print
.empty() || Fingerprint
->Description
.empty())
85 _error
->Error(_("Vendor block %s contains no fingerprint"), VendorID
.c_str());
89 if (_config
->FindB("Debug::sourceList", false))
90 std::cerr
<< "Adding vendor with ID: " << VendorID
91 << " Fingerprint: " << Fingerprint
->Print
<< std::endl
;
93 VendorList
.push_back(new Vendor(VendorID
, Origin
, Fingerprints
));
96 /* Process 'group-key' type sections */
97 Top
= Cnf
.Tree("group-key");
98 for (Top
= (Top
== 0?0:Top
->Child
); Top
!= 0; Top
= Top
->Next
)
100 // Configuration Block(Top);
101 // vector<Vendor::Fingerprint *> Fingerprints;
102 // string VendorID = Top->Tag;
104 // while (Block->Next)
106 // struct Vendor::Fingerprint Fingerprint = new struct Vendor::Fingerprint;
107 // Fingerprint->Print = Block.Find("Fingerprint");
108 // Fingerprint->Description = Block.Find("Name");
109 // if (Fingerprint->print.empty() || Fingerprint->Description.empty())
111 // _error->Error(_("Vendor block %s is invalid"),
112 // Vendor->VendorID.c_str());
113 // delete Fingerprint;
116 // Block = Block->Next->Next;
118 // if (_error->PendingError())
120 // for (vector <struct Vendor::Fingerprint *>::iterator I = Fingerprints.begin();
121 // I != Fingerprints.end(); I++)
123 // delete Fingerprints;
127 // VendorList.push_back(new Vendor(VendorID, Fingerprints));
130 return !_error
->PendingError();
133 const Vendor
* pkgVendorList::LookupFingerprint(string Fingerprint
) /*{{{*/
135 for (const_iterator I
= VendorList
.begin(); I
!= VendorList
.end(); ++I
)
137 if ((*I
)->LookupFingerprint(Fingerprint
) != "")
144 const Vendor
* pkgVendorList::FindVendor(const std::vector
<string
> GPGVOutput
) /*{{{*/
146 for (std::vector
<string
>::const_iterator I
= GPGVOutput
.begin(); I
!= GPGVOutput
.end(); ++I
)
148 string::size_type pos
= (*I
).find("VALIDSIG ");
149 if (_config
->FindB("Debug::Vendor", false))
150 std::cerr
<< "Looking for VALIDSIG in \"" << (*I
) << "\": pos " << pos
<< std::endl
;
151 if (pos
!= std::string::npos
)
153 string Fingerprint
= (*I
).substr(pos
+sizeof("VALIDSIG"));
154 if (_config
->FindB("Debug::Vendor", false))
155 std::cerr
<< "Looking for \"" << Fingerprint
<< "\" in vendor..." << std::endl
;
156 const Vendor
* vendor
= this->LookupFingerprint(Fingerprint
);
167 #pragma GCC diagnostic pop