implement --depsort for listinst
This commit is contained in:
parent
497c60f0a8
commit
23d8373672
@ -1,5 +1,6 @@
|
|||||||
* 5.15 27.09.2006 Johannes Winkelmann
|
* 5.15 27.09.2006 Johannes Winkelmann
|
||||||
- fix PKGMK_PACKAGE_DIR determination
|
- fix PKGMK_PACKAGE_DIR determination
|
||||||
|
- add --depsort to 'listinst'
|
||||||
|
|
||||||
* 5.14 13.09.2006 Johannes Winkelmann
|
* 5.14 13.09.2006 Johannes Winkelmann
|
||||||
- Remove handling of external dependency list
|
- Remove handling of external dependency list
|
||||||
|
@ -332,7 +332,7 @@ to filter by package name.
|
|||||||
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B listinst [\-v|\-vv] [filter] [--regex]
|
.B listinst [\-v|\-vv] [filter] [--regex] [--depsort]
|
||||||
List installed ports. It's basically the same as
|
List installed ports. It's basically the same as
|
||||||
.B pkginfo \-i,
|
.B pkginfo \-i,
|
||||||
but omits version when called without verbose (\-v, \-vv) switch. Plus
|
but omits version when called without verbose (\-v, \-vv) switch. Plus
|
||||||
@ -343,7 +343,9 @@ adds version and description.
|
|||||||
both the ports database and the ports tree.
|
both the ports database and the ports tree.
|
||||||
It's also possible to use shell like
|
It's also possible to use shell like
|
||||||
.B wildcards
|
.B wildcards
|
||||||
for the listinst command. Make sure you escape where needed
|
for the listinst command. Make sure you escape where needed. Finally, by
|
||||||
|
default it's sorted alphabetically; use the \-\-depsort switch to sort by
|
||||||
|
dependencies
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B listorphans [\-v|\-vv]
|
.B listorphans [\-v|\-vv]
|
||||||
|
@ -47,7 +47,8 @@ ArgParser::ArgParser( int argc, char** argv )
|
|||||||
m_useRegex(false),
|
m_useRegex(false),
|
||||||
m_fullPath(false),
|
m_fullPath(false),
|
||||||
m_recursive(false),
|
m_recursive(false),
|
||||||
m_printTree(false)
|
m_printTree(false),
|
||||||
|
m_depSort(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,6 +204,8 @@ bool ArgParser::parse()
|
|||||||
m_recursive = true;
|
m_recursive = true;
|
||||||
} else if ( s == "--tree" ) {
|
} else if ( s == "--tree" ) {
|
||||||
m_printTree = true;
|
m_printTree = true;
|
||||||
|
} else if ( s == "--depsort" ) {
|
||||||
|
m_depSort = true;
|
||||||
|
|
||||||
} else if ( s == "-f" ) {
|
} else if ( s == "-f" ) {
|
||||||
m_pkgaddArgs += " " + s;
|
m_pkgaddArgs += " " + s;
|
||||||
@ -399,6 +402,11 @@ bool ArgParser::printTree() const
|
|||||||
return m_printTree;
|
return m_printTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ArgParser::depSort() const
|
||||||
|
{
|
||||||
|
return m_depSort;
|
||||||
|
}
|
||||||
|
|
||||||
const string& ArgParser::commandName() const
|
const string& ArgParser::commandName() const
|
||||||
{
|
{
|
||||||
return m_commandName;
|
return m_commandName;
|
||||||
|
@ -59,6 +59,7 @@ public:
|
|||||||
bool fullPath() const;
|
bool fullPath() const;
|
||||||
bool recursive() const;
|
bool recursive() const;
|
||||||
bool printTree() const;
|
bool printTree() const;
|
||||||
|
bool depSort() const;
|
||||||
|
|
||||||
const string& alternateConfigFile() const;
|
const string& alternateConfigFile() const;
|
||||||
const string& pkgmkArgs() const;
|
const string& pkgmkArgs() const;
|
||||||
@ -112,6 +113,8 @@ private:
|
|||||||
bool m_recursive;
|
bool m_recursive;
|
||||||
bool m_printTree;
|
bool m_printTree;
|
||||||
|
|
||||||
|
bool m_depSort;
|
||||||
|
|
||||||
string m_alternateConfigFile;
|
string m_alternateConfigFile;
|
||||||
string m_pkgmkArgs;
|
string m_pkgmkArgs;
|
||||||
string m_pkgaddArgs;
|
string m_pkgaddArgs;
|
||||||
|
@ -41,7 +41,27 @@ const string InstallTransaction::PKGMK_DEFAULT_COMMAND = "/usr/bin/pkgmk";
|
|||||||
const string InstallTransaction::PKGADD_DEFAULT_COMMAND = "/usr/bin/pkgadd";
|
const string InstallTransaction::PKGADD_DEFAULT_COMMAND = "/usr/bin/pkgadd";
|
||||||
const string InstallTransaction::PKGRM_DEFAULT_COMMAND = "/usr/bin/pkgrm";
|
const string InstallTransaction::PKGRM_DEFAULT_COMMAND = "/usr/bin/pkgrm";
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Create a nice InstallTransaction
|
||||||
|
\param names a list of port names to be installed
|
||||||
|
\param repo the repository to look for packages
|
||||||
|
\param pkgDB the pkgDB with already installed packages
|
||||||
|
*/
|
||||||
|
InstallTransaction::InstallTransaction( const list<string>& names,
|
||||||
|
const Repository* repo,
|
||||||
|
PkgDB* pkgDB,
|
||||||
|
const Configuration* config )
|
||||||
|
: m_repo( repo ),
|
||||||
|
m_pkgDB( pkgDB ),
|
||||||
|
m_depCalced( false ),
|
||||||
|
m_config( config )
|
||||||
|
{
|
||||||
|
list<string>::const_iterator it = names.begin();
|
||||||
|
for ( ; it != names.end(); ++it ) {
|
||||||
|
m_packages.push_back( make_pair( *it, m_repo->getPackage( *it ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Create a nice InstallTransaction
|
Create a nice InstallTransaction
|
||||||
@ -65,13 +85,15 @@ InstallTransaction::InstallTransaction( const list<char*>& names,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Create a nice InstallTransaction
|
Create a nice InstallTransaction
|
||||||
\param names a list of port names to be installed
|
\param names a list of port names to be installed
|
||||||
\param repo the repository to look for packages
|
\param repo the repository to look for packages
|
||||||
\param pkgDB the pkgDB with already installed packages
|
\param pkgDB the pkgDB with already installed packages
|
||||||
*/
|
*/
|
||||||
InstallTransaction::InstallTransaction( const list<string>& names,
|
InstallTransaction::InstallTransaction( const string& name,
|
||||||
const Repository* repo,
|
const Repository* repo,
|
||||||
PkgDB* pkgDB,
|
PkgDB* pkgDB,
|
||||||
const Configuration* config )
|
const Configuration* config )
|
||||||
@ -80,10 +102,7 @@ InstallTransaction::InstallTransaction( const list<string>& names,
|
|||||||
m_depCalced( false ),
|
m_depCalced( false ),
|
||||||
m_config( config )
|
m_config( config )
|
||||||
{
|
{
|
||||||
list<string>::const_iterator it = names.begin();
|
m_packages.push_back( make_pair( name, m_repo->getPackage( name ) ) );
|
||||||
for ( ; it != names.end(); ++it ) {
|
|
||||||
m_packages.push_back( make_pair( *it, m_repo->getPackage( *it ) ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,10 @@ public:
|
|||||||
const Repository* repo,
|
const Repository* repo,
|
||||||
PkgDB* pkgDB,
|
PkgDB* pkgDB,
|
||||||
const Configuration* config );
|
const Configuration* config );
|
||||||
|
InstallTransaction( const string& name,
|
||||||
|
const Repository* repo,
|
||||||
|
PkgDB* pkgDB,
|
||||||
|
const Configuration* config );
|
||||||
|
|
||||||
static const std::string PKGMK_DEFAULT_COMMAND;
|
static const std::string PKGMK_DEFAULT_COMMAND;
|
||||||
static const std::string PKGADD_DEFAULT_COMMAND;
|
static const std::string PKGADD_DEFAULT_COMMAND;
|
||||||
|
@ -111,7 +111,7 @@ void PrtGet::printUsage()
|
|||||||
cout << " printf <format> print formatted list of available"
|
cout << " printf <format> print formatted list of available"
|
||||||
<< " ports"
|
<< " ports"
|
||||||
<< endl;
|
<< endl;
|
||||||
cout << " listinst [<filter>] show a list of installed ports"
|
cout << " listinst [<filter>][--depsort] show a list of installed ports"
|
||||||
<< endl;
|
<< endl;
|
||||||
cout << " listorphans list of ports with no "
|
cout << " listorphans list of ports with no "
|
||||||
<< "packages depending on them" << endl;
|
<< "packages depending on them" << endl;
|
||||||
@ -536,12 +536,40 @@ void PrtGet::listInstalled()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_parser->depSort()) {
|
||||||
|
// sort by dependency, without injecting missing ones
|
||||||
|
// calcDependencies chokes on the full list, so go through the
|
||||||
|
// ports one by one
|
||||||
|
|
||||||
|
initRepo();
|
||||||
|
map<string, string>::iterator mit;
|
||||||
|
string name;
|
||||||
|
while (!l.empty()) {
|
||||||
|
mit = l.begin();
|
||||||
|
name = mit->first;
|
||||||
|
l.erase(mit);
|
||||||
|
|
||||||
|
InstallTransaction trans( name, m_repo, m_pkgDB, m_config );
|
||||||
|
InstallTransaction::InstallResult result = trans.calcDependencies();
|
||||||
|
const list<string>& depRef = trans.dependencies();
|
||||||
|
list<string>::const_iterator it = depRef.begin();
|
||||||
|
|
||||||
|
|
||||||
|
for (; it != depRef.end(); ++it) {
|
||||||
|
if (l.find(*it) != l.end()) {
|
||||||
|
cout << *it << endl;
|
||||||
|
l.erase(*it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << name << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
for ( ; it != l.end(); ++it ) {
|
||||||
if ( m_parser->verbose() > 1 ) {
|
if ( m_parser->verbose() > 1 ) {
|
||||||
// warning: will slow down the process...
|
// warning: will slow down the process...
|
||||||
initRepo();
|
initRepo();
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( ; it != l.end(); ++it ) {
|
|
||||||
cout << it->first.c_str();
|
cout << it->first.c_str();
|
||||||
if ( m_parser->verbose() > 0 ) {
|
if ( m_parser->verbose() > 0 ) {
|
||||||
cout << " " << it->second.c_str();
|
cout << " " << it->second.c_str();
|
||||||
@ -556,6 +584,7 @@ void PrtGet::listInstalled()
|
|||||||
cout << endl;
|
cout << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
install package
|
install package
|
||||||
|
Loading…
Reference in New Issue
Block a user