revise the softdeps calculation
This commit is contained in:
parent
e67aa2cbd3
commit
4b069aa3d6
@ -298,6 +298,6 @@ bool Configuration::useRegex() const
|
|||||||
|
|
||||||
bool Configuration::followSoftdeps() const
|
bool Configuration::followSoftdeps() const
|
||||||
{
|
{
|
||||||
return m_followSoftdeps;
|
return ( m_followSoftdeps || m_parser->followSoftdeps() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ InstallTransaction::install( const ArgParser* parser )
|
|||||||
// Set the update flag if the package is installed and out of date,
|
// Set the update flag if the package is installed and out of date,
|
||||||
// or if the user has forced a rebuild.
|
// or if the user has forced a rebuild.
|
||||||
// Proceed to the next target if package is installed and up to date.
|
// Proceed to the next target if package is installed and up to date.
|
||||||
if ( m_pkgDB->isInstalled( package->name(), false ) ) {
|
if ( m_pkgDB->isInstalled( it->first, false ) ) {
|
||||||
VersionComparator::COMP_RESULT
|
VersionComparator::COMP_RESULT
|
||||||
rpDiff = VersionComparator::compareVersions(
|
rpDiff = VersionComparator::compareVersions(
|
||||||
m_repo->getPackageVersion( package->name() ),
|
m_repo->getPackageVersion( package->name() ),
|
||||||
@ -458,9 +458,7 @@ bool InstallTransaction::calculateDependencies()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<string> treeWalk;
|
list<pair<string, const Package*>>::const_iterator it = m_packages.begin();
|
||||||
list< pair<string, const Package*> >::const_iterator it =
|
|
||||||
m_packages.begin();
|
|
||||||
for ( ; it != m_packages.end(); ++it ) {
|
for ( ; it != m_packages.end(); ++it ) {
|
||||||
const Package* package = it->second;
|
const Package* package = it->second;
|
||||||
if ( package ) {
|
if ( package ) {
|
||||||
@ -504,7 +502,7 @@ void InstallTransaction::checkDependencies( bool greedy,
|
|||||||
|
|
||||||
if ( index == -1 ) {
|
if ( index == -1 ) {
|
||||||
index = m_depList.size();
|
index = m_depList.size();
|
||||||
if (( not greedy ) or ( m_pkgDB->isInstalled(package->name(),false) )) {
|
if ( ( not greedy ) or (isRequired( package->name() )) ) {
|
||||||
m_depList.push_back( package->name() );
|
m_depList.push_back( package->name() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -533,11 +531,7 @@ void InstallTransaction::checkDependencies( bool greedy,
|
|||||||
list<string>::iterator it = deps.begin();
|
list<string>::iterator it = deps.begin();
|
||||||
for ( ; it != deps.end(); ++it ) {
|
for ( ; it != deps.end(); ++it ) {
|
||||||
string dep = *it;
|
string dep = *it;
|
||||||
if ( !dep.empty() ) {
|
if ( dep.empty() ) { continue; }
|
||||||
string::size_type pos = dep.find_last_of( '/' );
|
|
||||||
if ( pos != string::npos && (pos+1) < dep.length() ) {
|
|
||||||
dep = dep.substr( pos + 1 );
|
|
||||||
}
|
|
||||||
const Package* p = m_repo->getPackage( dep );
|
const Package* p = m_repo->getPackage( dep );
|
||||||
if ( p ) {
|
if ( p ) {
|
||||||
checkDependencies( greedy, p, index );
|
checkDependencies( greedy, p, index );
|
||||||
@ -547,19 +541,14 @@ void InstallTransaction::checkDependencies( bool greedy,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ( (m_config->followSoftdeps()) and (!package->optionals().empty()) ) {
|
if ( (m_config->followSoftdeps()) and (!package->optionals().empty()) ) {
|
||||||
list<string> softDeps;
|
list<string> optionals;
|
||||||
split( package->optionals(), ',', softDeps );
|
split( package->optionals(), ',', optionals );
|
||||||
list<string>::iterator it = softDeps.begin();
|
list<string>::iterator it = optionals.begin();
|
||||||
for ( ; it != softDeps.end(); ++it ) {
|
for ( ; it != optionals.end(); ++it ) {
|
||||||
string softdep = *it;
|
string softdep = *it;
|
||||||
if ( !softdep.empty() ) {
|
if ( softdep.empty() ) { continue; }
|
||||||
string::size_type pos = softdep.find_last_of( '/' );
|
if ( isRequired(softdep) ) {
|
||||||
if ( pos != string::npos && (pos+1) < softdep.length() ) {
|
|
||||||
softdep = softdep.substr( pos + 1 );
|
|
||||||
}
|
|
||||||
if ( m_pkgDB->isInstalled(softdep, false) or isRequested(softdep) ) {
|
|
||||||
const Package* p = m_repo->getPackage( softdep );
|
const Package* p = m_repo->getPackage( softdep );
|
||||||
if ( p ) {
|
if ( p ) {
|
||||||
checkDependencies( true, p, index );
|
checkDependencies( true, p, index );
|
||||||
@ -571,19 +560,18 @@ void InstallTransaction::checkDependencies( bool greedy,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// reset the tree traversal history
|
// reset the tree traversal history
|
||||||
treeWalk.pop_back();
|
treeWalk.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Method to determine whether a package was passed on the command line
|
Method to determine whether a soft dependency should be part of the transaction
|
||||||
*/
|
*/
|
||||||
bool InstallTransaction::isRequested(const string pname) {
|
bool InstallTransaction::isRequired(const string &pname) {
|
||||||
list< pair<string, const Package*> >::iterator it = m_packages.begin();
|
list<pair<string, const Package*>>::iterator it = m_packages.begin();
|
||||||
for ( ; it != m_packages.end(); ++it ) {
|
for ( ; it != m_packages.end(); ++it ) {
|
||||||
if ( it->first == pname ) { return true; }
|
if ( pname == it->first ) { return true; }
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ private:
|
|||||||
const ArgParser* parser,
|
const ArgParser* parser,
|
||||||
bool update,
|
bool update,
|
||||||
InstallInfo& info ) const;
|
InstallInfo& info ) const;
|
||||||
bool isRequested(const string pname);
|
bool isRequired(const string &pname);
|
||||||
|
|
||||||
PkgDB* m_pkgDB;
|
PkgDB* m_pkgDB;
|
||||||
DepResolver m_resolver;
|
DepResolver m_resolver;
|
||||||
|
Loading…
Reference in New Issue
Block a user