diff --git a/src/prtget.cpp b/src/prtget.cpp index b03515e..94665cf 100644 --- a/src/prtget.cpp +++ b/src/prtget.cpp @@ -602,30 +602,41 @@ void PrtGet::install( bool update, bool group, bool dependencies ) // this can be done without initRepo() const list& args = m_parser->otherArgs(); + list compatible_args; list::const_iterator it = args.begin(); - if ( args.size() == 1 ) { + if ( update ) { for ( ; it != args.end(); ++it ) { string s = *it; - if ( !update && m_pkgDB->isInstalled( s ) ) { - cout << "package " << s << " is installed" << endl; - m_returnValue = PG_GENERAL_ERROR; - return; - } else if ( update && !m_pkgDB->isInstalled( s ) ) { - // can't upgrade - cout << "package " << s << " is not installed" << endl; - m_returnValue = PG_GENERAL_ERROR; - return; - } + if ( !m_pkgDB->isInstalled( s ) ) { + // can't upgrade what isn't installed + cout << "package " << s << " not installed; try prt-get install instead." << endl; + } else { + compatible_args.push_back(s); + } } + } else { + for ( ; it != args.end(); ++it ) { + string s = *it; + if ( m_pkgDB->isInstalled( s ) ) { + // pkgadd will fail on these, since it won't be given the -u flag + cout << "package " << s << " already installed; try prt-get update instead." << endl; + } else { + compatible_args.push_back(s); + } + } + } + + if ( compatible_args.size() < 1 ) { + m_returnValue = PG_GENERAL_ERROR ; + return; } initRepo(); if (dependencies) { // calc dependencies - InstallTransaction depTransaction( m_parser->otherArgs(), - m_repo, m_pkgDB, m_config ); + InstallTransaction depTransaction( compatible_args, m_repo, m_pkgDB, m_config ); InstallTransaction::InstallResult result = depTransaction.calcDependencies(); @@ -652,8 +663,7 @@ void PrtGet::install( bool update, bool group, bool dependencies ) InstallTransaction transaction( deps, m_repo, m_pkgDB, m_config ); executeTransaction( transaction, update, group ); } else { - InstallTransaction transaction( m_parser->otherArgs(), - m_repo, m_pkgDB, m_config ); + InstallTransaction transaction( compatible_args, m_repo, m_pkgDB, m_config ); executeTransaction( transaction, update, group ); } }