37 #undef ZYPP_BASE_LOGGER_LOGGROUP
38 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::VendorAttr"
48 typedef std::map<Vendor,unsigned> VendorMap;
50 unsigned vendorGroupCounter;
59 typedef DefaultIntegral<int,0> VendorMatchEntry;
60 typedef std::unordered_map<IdString, VendorMatchEntry> VendorMatch;
62 VendorMatch _vendorMatch;
65 inline void vendorMatchIdReset()
79 inline unsigned vendorMatchId( IdString vendor )
81 VendorMatchEntry & ent( _vendorMatch[vendor] );
85 VendorMatchEntry & lcent( _vendorMatch[lcvendor] );
90 static const IdString openSUSE(
"opensuse" );
91 if ( lcvendor == openSUSE || !
str::hasPrefix( lcvendor.c_str(), openSUSE.c_str() ) )
95 for ( VendorMap::reverse_iterator it = _vendorMap.rbegin(); it != _vendorMap.rend(); ++it )
129 vendorGroupCounter = 1;
134 vendorPath = trg->root() / vendorPath;
142 if ( _vendorMap.find(
"suse") == _vendorMap.end() )
143 _vendorMap[
"suse"] = ++vendorGroupCounter;
145 if ( _vendorMap.find(
"opensuse") == _vendorMap.end() )
146 _vendorMap[
"opensuse"] = ++vendorGroupCounter;
148 MIL << *
this << endl;
153 unsigned int nextId = vendorGroupCounter + 1;
157 for_( it, vendorList_r.begin(), vendorList_r.end() )
160 if (_vendorMap.find(*it) != _vendorMap.end())
162 if (nextId != vendorGroupCounter + 1 &&
163 nextId != _vendorMap[*it])
166 unsigned int moveID = _vendorMap[*it];
167 for_( itMap, _vendorMap.begin(), _vendorMap.end() )
169 if (itMap->second == moveID)
170 itMap->second = nextId;
175 nextId = _vendorMap[*it];
176 WAR <<
"Vendor " << *it <<
" is already used in another vendor group. --> mixing these groups" << endl;
181 for_( it, vendorList_r.begin(), vendorList_r.end() )
183 _vendorMap[*it] = nextId;
186 if (nextId == vendorGroupCounter + 1)
187 ++vendorGroupCounter;
190 vendorMatchIdReset();
197 if ( PathInfo(filename).isExist())
204 MIL << filename <<
" not found." << endl;
212 std::string section(*sit);
218 std::string entry(it->first);
219 std::string value(it->second);
220 if ( section ==
"main" )
222 if ( entry ==
"vendors" )
225 str::split( value, back_inserter(vendorlist),
"," );
238 if ( ! PathInfo(dirname).isExist() )
240 MIL << dirname <<
" not found." << endl;
244 std::list<Pathname> filenames;
246 for_( it, filenames.begin(), filenames.end() ) {
247 MIL <<
"Adding file " << *it << endl;
259 if ( lVendor == rVendor )
261 return vendorMatchId( lVendor ) == vendorMatchId( rVendor );
278 str <<
"Equivalent vendors:";
279 for_( it, _vendorMap.begin(), _vendorMap.end() )
281 str << endl <<
" [" << it->second <<
"] " << it->first;
A Solvable object within the sat Pool.
MapKVIteratorTraits< SectionSet >::Key_const_iterator section_const_iterator
static ZConfig & instance()
Singleton ctor.
std::vector< std::string > VendorList
Access to the sat-pools string space.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
void read(const InputStream &is, const ProgressData::ReceiverFnc &progress=ProgressData::ReceiverFnc())
Fill a dictionary from a InputStream containing a ini structured file.
bool equivalent(const Vendor &lVendor, const Vendor &rVendor) const
Return whether two vendor strings should be treated as the same vendor.
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \t")
Split line_r into words.
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition of vendor equivalence.
section_const_iterator sectionsBegin() const
entry_const_iterator entriesEnd(const std::string §ion) const
bool addVendorDirectory(const Pathname &dirname) const
Adding new equivalent vendors described in a directory.
std::string toLower(const std::string &s)
Return lowercase version of s.
Parses a INI file and offers its structure as a dictionary.
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
void _addVendorList(VendorList &) const
IdString vendor() const
The vendor.
entry_const_iterator entriesBegin(const std::string §ion) const
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Combining sat::Solvable and ResStatus.
EntrySet::const_iterator entry_const_iterator
static const VendorAttr & instance()
Singleton.
section_const_iterator sectionsEnd() const
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
bool addVendorFile(const Pathname &filename) const
Adding new equivalent vendors described in a file.