Author: schubi2
Date: Wed Jan 30 17:08:00 2008
New Revision: 8415
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8415&view=rev
Log:
- vendor handling by "group vendors"
- removed trusted vendor stuff
- configuration of equivalent vendors in /etc/zypp/vendors.d
Modified:
branches/tmp/ma/jump_sat/libzypp/zypp.conf
branches/tmp/ma/jump_sat/libzypp/zypp/PoolItem.cc
branches/tmp/ma/jump_sat/libzypp/zypp/PoolItem.h
branches/tmp/ma/jump_sat/libzypp/zypp/VendorAttr.cc
branches/tmp/ma/jump_sat/libzypp/zypp/VendorAttr.h
branches/tmp/ma/jump_sat/libzypp/zypp/ZConfig.cc
branches/tmp/ma/jump_sat/libzypp/zypp/ZConfig.h
branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc
Modified: branches/tmp/ma/jump_sat/libzypp/zypp.conf
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp.conf?rev=8415&r1=8414&r2=8415&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp.conf (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp.conf Wed Jan 30 17:08:00 2008
@@ -116,14 +116,11 @@
# download.use_deltarpm = true
-[locking]
-
-
-## DEPRECATED
-## Mimic old-fashioned behavior of locking all foreign vendor packages.
+##
+## Defining directory for equivalent vendors
##
-## Valid values: boolean
-## Default value: false
+## Valid values: A directory
+## Default value: /etc/zypp/vondors.d
##
-# autolock_untrustedvendor = false
+# vendordir = /etc/zypp/vondors.d
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/PoolItem.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/PoolItem.cc?rev=8415&r1=8414&r2=8415&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/PoolItem.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/PoolItem.cc Wed Jan 30 17:08:00 2008
@@ -37,27 +37,14 @@
: _status( status_r )
, _resolvable( res_r )
{
- autoprotect();
}
ResStatus & status() const
{ return _status; }
- ResStatus & statusReset() const
- {
- if ( ! autoprotect() )
- {
- _status.setLock( false, zypp::ResStatus::USER );
- _status.resetTransact( zypp::ResStatus::USER );
- }
- return _status;
- }
-
ResObject::constPtr resolvable() const
{ return _resolvable; }
- bool autoprotect() const;
-
private:
mutable ResStatus _status;
ResObject::constPtr _resolvable;
@@ -105,19 +92,6 @@
return str;
}
- inline bool PoolItem::Impl::autoprotect() const
- {
- if ( _status.isInstalled()
- && isKind<Package>( _resolvable )
- && VendorAttr::instance().autoProtect( _resolvable->vendor() ) )
- {
- _status.setLock( true, zypp::ResStatus::USER );
- MIL << "Protect vendor '" << _resolvable->vendor() << "' " << *this << endl;
- return true;
- }
- return false;
- }
-
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : PoolItem
@@ -168,9 +142,6 @@
ResStatus & PoolItem::status() const
{ return _pimpl->status(); }
- ResStatus & PoolItem::statusReset() const
- { return _pimpl->statusReset(); }
-
ResObject::constPtr PoolItem::resolvable() const
{ return _pimpl->resolvable(); }
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/PoolItem.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/PoolItem.h?rev=8415&r1=8414&r2=8415&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/PoolItem.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/PoolItem.h Wed Jan 30 17:08:00 2008
@@ -66,9 +66,6 @@
/** Returns the current status. */
ResStatus & status() const;
- /** Reset status (applies autoprotection). */
- ResStatus & statusReset() const;
-
/** Returns the ResObject::constPtr.
* \see \ref operator->
*/
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/VendorAttr.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/VendorAttr.cc?rev=8415&r1=8414&r2=8415&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/VendorAttr.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/VendorAttr.cc Wed Jan 30 17:08:00 2008
@@ -20,6 +20,7 @@
#include <fstream>
#include <set>
#include <map>
+#include <vector>
#include "zypp/base/LogTools.h"
#include "zypp/base/IOStream.h"
@@ -30,6 +31,8 @@
#include "zypp/ZYppFactory.h"
#include "zypp/ZConfig.h"
+#include "zypp/PathInfo.h"
+#include "zypp/parser/IniDict.h"
using namespace std;
@@ -44,130 +47,216 @@
namespace
{ /////////////////////////////////////////////////////////////////
- typedef std::map TrustMap;
- TrustMap _trustMap;
-
- typedef std::setstd::string VendorList;
- VendorList _trustedVendors;
+ typedef map VendorMap;
+ typedef vector<string> VendorList;
+
+ VendorMap _vendorMap;
+ VendorMap _matchMap;
+ unsigned int vendorGroupCounter;
- bool addTrustedVendor( const std::string & str_r )
+ void addEquivalentVendors( VendorList & vendorList )
{
- std::string line( str::trim( str_r ) );
- if ( ! line.empty() && line[0] != '#')
- {
- _trustedVendors.insert( str::toLower( line ) );
- }
- return true;
+ unsigned int nextId = vendorGroupCounter + 1;
+ // convert to lowercase and check if a vendor is already defined
+ // in an existing group.
+
+ for (VendorList::iterator it = vendorList.begin();
+ it != vendorList.end();
+ it++) {
+ *it = str::toLower( *it );
+ if (_vendorMap.find(*it) != _vendorMap.end()) {
+ if (nextId != vendorGroupCounter + 1 &&
+ nextId != _vendorMap[*it]) {
+ // We have at least 3 groups which has to be mixed --> mix the third group to the first
+ unsigned int moveID = _vendorMap[*it];
+ for (VendorMap::iterator itMap = _vendorMap.begin();
+ itMap != _vendorMap.end();
+ itMap++) {
+ if (itMap->second == moveID)
+ itMap->second = nextId;
+ }
+ } else {
+ nextId = _vendorMap[*it];
+ WAR << "Vendor " << *it << " is already used in another vendor group. --> mixing these groups"
+ << endl;
+ }
+ }
+ }
+ // add new entries
+ for (VendorList::iterator it = vendorList.begin();
+ it != vendorList.end();
+ it++) {
+ _vendorMap[*it] = nextId;
+ }
+
+ if (nextId == vendorGroupCounter + 1)
+ vendorGroupCounter++;
}
- bool trusted( const Vendor & vendor_r )
- {
- TrustMap::value_type val( vendor_r, false );
- pair res = _trustMap.insert( val );
- if ( res.second )
- {
- // check the new vendor in map
- for ( VendorList::const_iterator it = _trustedVendors.begin();
- it != _trustedVendors.end(); ++it )
- {
- if ( str::toLower( res.first->first.substr( 0, it->size() ) )
- == str::toLower( *it ) )
- {
- // match
- res.first->second = true;
- break;
- }
- }
- }
- return res.first->second;
- }
/////////////////////////////////////////////////////////////////
} // namespace
///////////////////////////////////////////////////////////////////
const VendorAttr & VendorAttr::instance()
{
- static VendorAttr _val;
- return _val;
+ static VendorAttr _val;
+ return _val;
}
VendorAttr::VendorAttr ()
{
- const char * vendors[] = {
- "jpackage project",
- "novell",
- "opensuse",
- "sgi",
- "silicon graphics",
- "suse",
- "ati technologies inc.",
- "nvidia"
- };
- _trustedVendors.insert( vendors, vendors+(sizeof(vendors)/sizeof(const char *)) );
-
- Pathname vendorrcPath( "/etc/zypp/trustedVendors" );
- try
- {
- Target_Ptr trg( getZYpp()->target() );
- if ( trg )
- vendorrcPath = trg->root() / vendorrcPath;
- }
- catch ( ... )
- {
- // noop: Someone decided to let target() throw if the ptr is NULL ;(
- }
-
- PathInfo vendorrc( vendorrcPath );
- if ( vendorrc.isFile() )
- {
- MIL << "Reading " << vendorrc << endl;
- ifstream inp( vendorrc.asString().c_str() );
- iostr::forEachLine( inp, addTrustedVendor );
+ vendorGroupCounter = 1;
+
+ Pathname vendorPath (ZConfig::instance().vendorPath());
+ try
+ {
+ Target_Ptr trg( getZYpp()->target() );
+ if ( trg )
+ vendorPath = trg->root() / vendorPath;
+ }
+ catch ( ... )
+ {
+ // noop: Someone decided to let target() throw if the ptr is NULL ;(
}
- MIL << "Trusted Vendors: " << _trustedVendors << endl;
- }
- void VendorAttr::enableAutoProtect()
- {
- MIL << "FIXME: Not implemented." << endl;
- // FIXME use ZConfig
- }
+ // creating entries
+ addVendorDirectory (vendorPath);
- void VendorAttr::disableAutoProtect()
- {
- MIL << "FIXME: Not implemented." << endl;
- // FIXME use ZConfig
+ //checking if suse,opensuse has been defined. If not create entries
+ if (_vendorMap.find("suse") != _vendorMap.end()) {
+ if (_vendorMap.find("opensuse") == _vendorMap.end()) {
+ _vendorMap["opensuse"] = ++vendorGroupCounter;
+ }
+ } else {
+ if (_vendorMap.find("opensuse") == _vendorMap.end()) {
+ // both are not available. Create one group with suse,opensuse
+ _vendorMap["opensuse"] = ++vendorGroupCounter;
+ _vendorMap["suse"] = vendorGroupCounter;
+ } else {
+ _vendorMap["suse"] = ++vendorGroupCounter;
+ }
+ }
+
}
- bool VendorAttr::isKnown( const Vendor & vendor_r ) const
- { return trusted( vendor_r ); }
-
+ bool VendorAttr::addVendorFile( const Pathname & filename ) const
+ {
+ parser::IniDict dict;
+
+ if ( PathInfo(filename).isExist())
+ {
+ InputStream is(filename);
+ dict.read(is);
+ }
+ else
+ {
+ MIL << filename << " not found." << endl;
+ return false;
+ }
- bool VendorAttr::autoProtect( const Vendor & vendor_r ) const
- { return( ZConfig::instance().autolock_untrustedvendor() && ! trusted( vendor_r ) ); }
+ for ( parser::IniDict::section_const_iterator sit = dict.sectionsBegin();
+ sit != dict.sectionsEnd();
+ ++sit )
+ {
+ string section(*sit);
+ //MIL << section << endl;
+ for ( parser::IniDict::entry_const_iterator it = dict.entriesBegin(*sit);
+ it != dict.entriesEnd(*sit);
+ ++it )
+ {
+ string entry(it->first);
+ string value(it->second);
+ if ( section == "main" )
+ {
+ if ( entry == "vendors" )
+ {
+ VendorList vendorlist;
+ str::split( value, back_inserter(vendorlist), "," );
+ addEquivalentVendors (vendorlist);
+ break;
+ }
+ }
+ }
+ }
- /** Helper: Lowercase prefix */
- inline bool hasLcPrefix( const std::string & str_r, const std::string & pref_r )
- { return str::toLower( str_r.substr( 0, pref_r.size() ) ) == pref_r; }
+ MIL << "Equivalent vendors:" << endl;
+ for (VendorMap::iterator it = _vendorMap.begin();
+ it != _vendorMap.end();
+ it ++) {
+ MIL << " " << it->first << "(group " << it->second << ")" << endl;
+ }
+
+ return true;
+ }
- /** Helper: SuSE and equivalent vendors */
- inline bool isSUSE( const Vendor & vnd_r )
+ bool VendorAttr::addVendorDirectory( const Pathname & dirname ) const
{
- static const std::string defSUSE ( "suse" );
- static const std::string defopenSUSE( "opensuse" );
+ parser::IniDict dict;
+
+ if ( PathInfo(dirname).isExist())
+ {
+ InputStream is(dirname);
+ dict.read(is);
+ }
+ else
+ {
+ MIL << dirname << " not found." << endl;
+ return false;
+ }
- return( hasLcPrefix( vnd_r, defSUSE )
- || hasLcPrefix( vnd_r, defopenSUSE ) );
+ list<Pathname> filenames;
+
+ filesystem::readdir( filenames,
+ dirname, false );
+ for (list<Pathname>::iterator it = filenames.begin();
+ it != filenames.end(); it++) {
+ MIL << "Adding file " << *it << endl;
+ addVendorFile( *it );
+ }
+ return true;
}
+
bool VendorAttr::equivalent( const Vendor & lhs, const Vendor & rhs ) const
{
- if ( lhs == rhs )
- return true;
+ if ( lhs == rhs )
+ return true;
- // By now handcrafted equivalence definition:
- return( isSUSE( lhs ) && isSUSE( rhs ) );
+ unsigned int lhsID = 0;
+ unsigned int rhsID = 0;
+
+ if (_matchMap.find(lhs) != _matchMap.end()) {
+ lhsID = _matchMap[lhs];
+ } else {
+ // compare this entry with the vendor map
+ for (VendorMap::reverse_iterator it = _vendorMap.rbegin();
+ it != _vendorMap.rend();
+ it++) {
+ if (lhs.substr (0, it->first.size()) == it->first) {
+ lhsID = it->second;
+ _matchMap[lhs] = lhsID;
+ break; // exit for
+ }
+ }
+ }
+
+ if (_matchMap.find(rhs) != _matchMap.end()) {
+ rhsID = _matchMap[rhs];
+ } else {
+ // compare this entry with the vendor map
+ for (VendorMap::reverse_iterator it = _vendorMap.rbegin();
+ it != _vendorMap.rend();
+ it++) {
+ if (rhs.substr (0, it->first.size()) == it->first) {
+ rhsID = it->second;
+ _matchMap[rhs] = rhsID;
+ break; // exit for
+ }
+ }
+ }
+
+ return( lhsID == lhsID );
}
/////////////////////////////////////////////////////////////////
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/VendorAttr.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/VendorAttr.h?rev=8415&r1=8414&r2=8415&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/VendorAttr.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/VendorAttr.h Wed Jan 30 17:08:00 2008
@@ -17,6 +17,7 @@
#include "zypp/base/NonCopyable.h"
#include "zypp/NeedAType.h"
+#include "zypp/PathInfo.h"
///////////////////////////////////////////////////////////////////
namespace zypp {
@@ -28,29 +29,15 @@
/** Singleton */
static const VendorAttr & instance();
- /** Enable autoprotection of foreign vendor packages.
- * This is the default.
- * \note This will \b not change the status of already
- * loaded pool items.
- */
- static void enableAutoProtect();
- /** Disable autoprotection of foreign vendor packages.
- * Autoprotection is on per defult.
- * \note This will \b not change the status of already
- * loaded pool items.
- */
- static void disableAutoProtect();
-
/**
- * Return whether it's a known vendor
+ * Adding new equivalent vendors described in a directory
**/
- bool isKnown( const Vendor & vendor_r ) const;
+ bool addVendorDirectory( const Pathname & dirname ) const;
/**
- * Return whether this vendors packages should be
- * protected by default.
+ * Adding new equivalent vendors described in a file
**/
- bool autoProtect( const Vendor & vendor_r ) const;
+ bool addVendorFile( const Pathname & filename) const;
/** Return whether two vendor strings shold be treated as the same vendor.
* Usually the solver is allowed to automatically select a package of an
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/ZConfig.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/ZConfig.cc?rev=8415&r1=8414&r2=8415&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/ZConfig.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/ZConfig.cc Wed Jan 30 17:08:00 2008
@@ -44,7 +44,6 @@
, repo_refresh_delay ( 10 )
, download_use_patchrpm ( true )
, download_use_deltarpm ( true )
- , autolock_untrustedvendor( false )
{
MIL << "ZConfig singleton created." << endl;
@@ -112,9 +111,9 @@
download_use_deltarpm = str::strToBool( value, download_use_deltarpm );
}
}
- else if ( section == "locking" )
+ else if ( section == "vendordir" )
{
- autolock_untrustedvendor = str::strToBool( value, autolock_untrustedvendor );
+ cfg_vendor_path = Pathname(value);
}
}
@@ -133,6 +132,7 @@
Pathname cfg_metadata_path;
Pathname cfg_cache_path;
Pathname cfg_known_repos_path;
+ Pathname cfg_vendor_path;
bool repo_add_probe;
unsigned repo_refresh_delay;
@@ -140,8 +140,6 @@
bool download_use_patchrpm;
bool download_use_deltarpm;
- // [locking]
- bool autolock_untrustedvendor;
};
///////////////////////////////////////////////////////////////////
@@ -254,9 +252,10 @@
bool ZConfig::download_use_deltarpm() const
{ return _pimpl->download_use_deltarpm; }
- bool ZConfig::autolock_untrustedvendor() const
+ Pathname ZConfig::vendorPath() const
{
- return _pimpl->autolock_untrustedvendor;
+ return ( _pimpl->cfg_vendor_path.empty()
+ ? Pathname("/etc/zypp/vondors.d") : _pimpl->cfg_vendor_path );
}
/////////////////////////////////////////////////////////////////
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/ZConfig.h
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/ZConfig.h?rev=8415&r1=8414&r2=8415&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/ZConfig.h (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/ZConfig.h Wed Jan 30 17:08:00 2008
@@ -105,11 +105,9 @@
bool download_use_deltarpm() const;
/**
- * Whether untrusted vendor should be autolocked
- / config option
- * repo.add.probe
+ * Directory for equivalent vendor definitions
*/
- bool autolock_untrustedvendor() const;
+ Pathname vendorPath() const;
public:
class Impl;
Modified: branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc
URL: http://svn.opensuse.org/viewcvs/zypp/branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc?rev=8415&r1=8414&r2=8415&view=diff
==============================================================================
--- branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc (original)
+++ branches/tmp/ma/jump_sat/libzypp/zypp/solver/detail/ResolverUpgrade.cc Wed Jan 30 17:08:00 2008
@@ -126,7 +126,7 @@
DBG << "Candidate vendor '" << cpkg->vendor() << "'" << endl;
if (cpkg
- && VendorAttr::instance().isKnown( cpkg->vendor() ) )
+ && VendorAttr::instance().equivalent( ipkg->vendor(), cpkg->vendor() ) )
{
if ( silent_downgrades )
return true;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org