*/
#include <iostream>
#include "zypp/base/LogTools.h"
+#include "zypp/base/StrMatcher.h"
#include "zypp/Product.h"
#include "zypp/Url.h"
{
// Look for a provider of 'product(name) = version' of same
// architecture and within the same repo.
+ //
+ // bnc #497696: Update repos may have multiple release package versions
+ // providing the same product. As a workaround we link to the one with
+ // the highest version.
Capability identCap( str::form( "product(%s) = %s", name().c_str(), edition().c_str() ) );
+ sat::Solvable found;
sat::WhatProvides providers( identCap );
for_( it, providers.begin(), providers.end() )
{
if ( it->repository() == repository()
&& it->arch() == arch() )
- return *it;
+ {
+ if ( ! found || found.edition() < it->edition() )
+ found = *it;
+ }
+ }
+
+ if ( ! found && isSystem() )
+ {
+ // bnc#784900: for installed products check whether the file is owned by
+ // some package. If so, ust this as buddy.
+ sat::LookupAttr q( sat::SolvAttr::filelist, repository() );
+ std::string refFile( referenceFilename() );
+ if ( ! refFile.empty() )
+ {
+ StrMatcher matcher( referenceFilename() );
+ q.setStrMatcher( matcher );
+ if ( ! q.empty() )
+ found = q.begin().inSolvable();
+ }
+ else
+ INT << "Product referenceFilename unexpectedly empty!" << endl;
}
- WAR << *this << ": no reference package found: " << identCap << endl;
- return sat::Solvable::noSolvable;
+ if ( ! found )
+ WAR << *this << ": no reference package found: " << identCap << endl;
+ return found;
}
+ std::string Product::referenceFilename() const
+ { return lookupStrAttribute( sat::SolvAttr::productReferenceFile ); }
+
Product::ReplacedProducts Product::replacedProducts() const
{
std::vector<constPtr> ret;
return ret;
}
+ CapabilitySet Product::droplist() const
+ { return poolItem().buddy().valuesOfNamespace( "weakremover" ); }
+
std::string Product::productLine() const
- {
-#warning productLine needs to be implemented.
- return std::string();
- }
+ { return lookupStrAttribute( sat::SolvAttr::productProductLine ); }
///////////////////////////////////////////////////////////////////
std::string Product::shortName() const
- { return lookupStrAttribute( sat::SolvAttr::productShortlabel ); }
+ {
+ std::string ret( lookupStrAttribute( sat::SolvAttr::productShortlabel ) );
+ if ( ret.empty() ) ret = name();
+ return ret;
+
+ }
std::string Product::flavor() const
{
return ret;
}
+ Date Product::endOfLife() const
+ { return Date( lookupNumAttribute( sat::SolvAttr::productEndOfLife ) );}
+
+ std::vector<Repository::ContentIdentifier> Product::updateContentIdentifier() const
+ {
+ std::vector<Repository::ContentIdentifier> ret;
+ sat::LookupAttr q( sat::SolvAttr::productUpdatesRepoid, sat::SolvAttr::productUpdates, *this );
+ if ( ! q.empty() )
+ {
+ ret.reserve( 2 );
+ for_( it, q.begin(), q.end() )
+ ret.push_back( it.asString() );
+ }
+ return ret;
+ }
+
+ bool Product::hasUpdateContentIdentifier( const Repository::ContentIdentifier & cident_r ) const
+ {
+ sat::LookupAttr q( sat::SolvAttr::productUpdatesRepoid, sat::SolvAttr::productUpdates, *this );
+ for_( it, q.begin(), q.end() )
+ {
+ if ( it.asString() == cident_r )
+ return true;
+ }
+ return false;
+ }
+
bool Product::isTargetDistribution() const
- { return isSystem() && type() == "base"; }
+ { return isSystem() && lookupStrAttribute( sat::SolvAttr::productType ) == "base"; }
std::string Product::registerTarget() const
{ return lookupStrAttribute( sat::SolvAttr::productRegisterTarget ); }
std::string Product::registerRelease() const
{ return lookupStrAttribute( sat::SolvAttr::productRegisterRelease ); }
+ std::string Product::registerFlavor() const
+ { return lookupStrAttribute( sat::SolvAttr::productRegisterFlavor ); }
+
/////////////////////////////////////////////////////////////////
Product::UrlList Product::urls( const std::string & key_r ) const