revise the softdeps calculation

This commit is contained in:
John McQuah 2023-08-22 15:03:21 -04:00
parent e7d2481dcb
commit af59c55bed
3 changed files with 27 additions and 37 deletions

View File

@ -252,6 +252,6 @@ bool Configuration::useRegex() const
bool Configuration::followSoftdeps() const bool Configuration::followSoftdeps() const
{ {
return m_followSoftdeps; return ( m_followSoftdeps || m_parser->followSoftdeps() );
} }

View File

@ -481,7 +481,6 @@ bool InstallTransaction::calculateDependencies()
return false; return false;
} }
vector<string> treeWalk;
list< pair<string, const Package*> >::const_iterator it = list< pair<string, const Package*> >::const_iterator it =
m_packages.begin(); m_packages.begin();
for ( ; it != m_packages.end(); ++it ) { for ( ; it != m_packages.end(); ++it ) {
@ -527,8 +526,8 @@ 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 ( (!greedy) or isRequired( package->name() ) ) {
m_depList.push_back( package->name() ); m_depList.push_back( package->name() );
} }
} }
@ -556,41 +555,31 @@ 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( '/' ); const Package* p = m_repo->getPackage( dep );
if ( pos != string::npos && (pos+1) < dep.length() ) { if ( p ) {
dep = dep.substr( pos + 1 ); checkDependencies( greedy, p, index );
} } else {
const Package* p = m_repo->getPackage( dep ); m_missingPackages.
if ( p ) { push_back( make_pair( dep, package->name() ) );
checkDependencies( greedy, p, index );
} else {
m_missingPackages.
push_back( make_pair( dep, package->name() ) );
}
} }
} }
} }
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() ) { const Package* p = m_repo->getPackage( softdep );
softdep = softdep.substr( pos + 1 ); if ( p ) {
checkDependencies( true, p, index );
} else {
m_missingPackages.
push_back( make_pair( softdep, package->name() ) );
} }
if ( m_pkgDB->isInstalled(softdep, false) or isRequested(softdep) ) {
const Package* p = m_repo->getPackage( softdep );
if ( p ) {
checkDependencies( true, p, index );
} else {
m_missingPackages.
push_back( make_pair( softdep, package->name() ) );
}
}
} }
} }
} }
@ -601,12 +590,13 @@ void InstallTransaction::checkDependencies( bool greedy,
} }
/*! /*!
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) {
if ( m_pkgDB->isInstalled(pname,false) ) { return true; }
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;
} }

View File

@ -109,7 +109,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);
static string getPkgmkSetting(const string& setting); static string getPkgmkSetting(const string& setting);
static string getPkgmkSettingFromFile(const string& setting, static string getPkgmkSettingFromFile(const string& setting,