prt-get: support recursive dependent and a tree view
git-svn-id: https://crux.nu/svn/tools/prt-get/trunk@1234 0b5ae1c7-2405-0410-a7fc-ba219f786e1e
This commit is contained in:
parent
a4a40a4b02
commit
ab768a4a88
@ -12,6 +12,7 @@
|
|||||||
- update default prt-get.conf to reflect new port hierarchy (core/opt/contrib)
|
- update default prt-get.conf to reflect new port hierarchy (core/opt/contrib)
|
||||||
- add timestamps to log files
|
- add timestamps to log files
|
||||||
- fix aliasing bug introduce earlier in the .12 session (thanks Mark)
|
- fix aliasing bug introduce earlier in the .12 session (thanks Mark)
|
||||||
|
- add --recursive and --tree for dependent
|
||||||
|
|
||||||
* 0.5.11 29.05.2005 Johannes Winkelmann
|
* 0.5.11 29.05.2005 Johannes Winkelmann
|
||||||
- add --path to 'ls'
|
- add --path to 'ls'
|
||||||
|
2
TODO
2
TODO
@ -1,3 +1,5 @@
|
|||||||
|
- add --rebuild-set to dependent
|
||||||
|
---------------------------
|
||||||
- use `eval $(fgrep -h 'PKGMK_PACKAGE_DIR=' $(which pkgmk) /etc/pkgmk.conf) && echo
|
- use `eval $(fgrep -h 'PKGMK_PACKAGE_DIR=' $(which pkgmk) /etc/pkgmk.conf) && echo
|
||||||
$PKGMK_PACKAGE_DIR` to determine PACKAGE_DIR
|
$PKGMK_PACKAGE_DIR` to determine PACKAGE_DIR
|
||||||
- add update-footprint, update-md5sum commands (patch in trac)
|
- add update-footprint, update-md5sum commands (patch in trac)
|
||||||
|
2
configure
vendored
2
configure
vendored
@ -1614,7 +1614,7 @@ fi
|
|||||||
|
|
||||||
# Define the identity of the package.
|
# Define the identity of the package.
|
||||||
PACKAGE=prt-get
|
PACKAGE=prt-get
|
||||||
VERSION=0.5.12pre2
|
VERSION=0.5.12pre4
|
||||||
|
|
||||||
|
|
||||||
cat >>confdefs.h <<_ACEOF
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
AC_INIT
|
AC_INIT
|
||||||
AC_CONFIG_SRCDIR([src/prtget.cpp])
|
AC_CONFIG_SRCDIR([src/prtget.cpp])
|
||||||
AM_INIT_AUTOMAKE(prt-get,0.5.12pre2)
|
AM_INIT_AUTOMAKE(prt-get,0.5.12pre4)
|
||||||
|
|
||||||
|
|
||||||
dnl Determine default prefix
|
dnl Determine default prefix
|
||||||
|
@ -209,9 +209,11 @@ to make an install including dependencies
|
|||||||
.TP
|
.TP
|
||||||
.B dependent <package>
|
.B dependent <package>
|
||||||
print a list of package which depend on
|
print a list of package which depend on
|
||||||
.B package.
|
.B package.
|
||||||
Only list direct dependencies. Usually shows dependent packages which
|
|
||||||
are installed. To see all dependencies, add the --all switch
|
Usually shows dependent packages which are installed. To see all dependencies,
|
||||||
|
add the --all switch; use --recursive to get a recursive list (without
|
||||||
|
duplication), and --tree to get a nicely indented one
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B deptree <package>
|
.B deptree <package>
|
||||||
|
@ -45,7 +45,9 @@ ArgParser::ArgParser( int argc, char** argv )
|
|||||||
m_preferHigher( false ),
|
m_preferHigher( false ),
|
||||||
m_strictDiff( false ),
|
m_strictDiff( false ),
|
||||||
m_useRegex(false),
|
m_useRegex(false),
|
||||||
m_fullPath(false)
|
m_fullPath(false),
|
||||||
|
m_recursive(false),
|
||||||
|
m_printTree(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,6 +198,10 @@ bool ArgParser::parse()
|
|||||||
m_useRegex = true;
|
m_useRegex = true;
|
||||||
} else if ( s == "--full" ) {
|
} else if ( s == "--full" ) {
|
||||||
m_fullPath = true;
|
m_fullPath = true;
|
||||||
|
} else if ( s == "--recursive" ) {
|
||||||
|
m_recursive = true;
|
||||||
|
} else if ( s == "--tree" ) {
|
||||||
|
m_printTree = true;
|
||||||
|
|
||||||
} else if ( s == "-f" ) {
|
} else if ( s == "-f" ) {
|
||||||
m_pkgaddArgs += " " + s;
|
m_pkgaddArgs += " " + s;
|
||||||
@ -382,6 +388,16 @@ bool ArgParser::printPath() const
|
|||||||
return m_printPath;
|
return m_printPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ArgParser::recursive() const
|
||||||
|
{
|
||||||
|
return m_recursive;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ArgParser::printTree() const
|
||||||
|
{
|
||||||
|
return m_printTree;
|
||||||
|
}
|
||||||
|
|
||||||
const string& ArgParser::commandName() const
|
const string& ArgParser::commandName() const
|
||||||
{
|
{
|
||||||
return m_commandName;
|
return m_commandName;
|
||||||
|
@ -57,6 +57,8 @@ public:
|
|||||||
bool strictDiff() const;
|
bool strictDiff() const;
|
||||||
bool useRegex() const;
|
bool useRegex() const;
|
||||||
bool fullPath() const;
|
bool fullPath() const;
|
||||||
|
bool recursive() const;
|
||||||
|
bool printTree() const;
|
||||||
|
|
||||||
const string& alternateConfigFile() const;
|
const string& alternateConfigFile() const;
|
||||||
const string& pkgmkArgs() const;
|
const string& pkgmkArgs() const;
|
||||||
@ -107,6 +109,9 @@ private:
|
|||||||
bool m_useRegex;
|
bool m_useRegex;
|
||||||
bool m_fullPath;
|
bool m_fullPath;
|
||||||
|
|
||||||
|
bool m_recursive;
|
||||||
|
bool m_printTree;
|
||||||
|
|
||||||
string m_alternateConfigFile;
|
string m_alternateConfigFile;
|
||||||
string m_pkgmkArgs;
|
string m_pkgmkArgs;
|
||||||
string m_pkgaddArgs;
|
string m_pkgaddArgs;
|
||||||
|
@ -26,7 +26,7 @@ int main( int argc, char** argv )
|
|||||||
<< endl;
|
<< endl;
|
||||||
} else if ( !argParser.isCommandGiven() ) {
|
} else if ( !argParser.isCommandGiven() ) {
|
||||||
if (argParser.commandName() != "") {
|
if (argParser.commandName() != "") {
|
||||||
cerr << "prt-get: Unknown command '"
|
cerr << "prt-get: Unknown command '"
|
||||||
<< argParser.commandName() << "'. "
|
<< argParser.commandName() << "'. "
|
||||||
<< "try prt-get help for more information" << endl;
|
<< "try prt-get help for more information" << endl;
|
||||||
} else {
|
} else {
|
||||||
@ -122,7 +122,7 @@ int main( int argc, char** argv )
|
|||||||
prtGet.readme();
|
prtGet.readme();
|
||||||
break;
|
break;
|
||||||
case ArgParser::DEPENDENT:
|
case ArgParser::DEPENDENT:
|
||||||
prtGet.printDependendent();
|
prtGet.printDependent();
|
||||||
break;
|
break;
|
||||||
case ArgParser::SYSUP:
|
case ArgParser::SYSUP:
|
||||||
prtGet.sysup();
|
prtGet.sysup();
|
||||||
|
@ -1244,37 +1244,58 @@ bool PrtGet::printFile(const string& file)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrtGet::printDependendent()
|
void PrtGet::printDependent()
|
||||||
{
|
{
|
||||||
assertExactArgCount(1);
|
assertExactArgCount(1);
|
||||||
|
|
||||||
initRepo();
|
initRepo();
|
||||||
string arg = *(m_parser->otherArgs().begin());
|
string arg = *(m_parser->otherArgs().begin());
|
||||||
|
printDependent(arg, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrtGet::printDependent(const string& dep, int level)
|
||||||
|
{
|
||||||
map<string, Package*>::const_iterator it = m_repo->packages().begin();
|
map<string, Package*>::const_iterator it = m_repo->packages().begin();
|
||||||
|
static map<string, bool> shownMap;
|
||||||
|
|
||||||
set<const Package*> dependent;
|
set<const Package*> dependent;
|
||||||
for ( ; it != m_repo->packages().end(); ++it ) {
|
for ( ; it != m_repo->packages().end(); ++it ) {
|
||||||
|
|
||||||
// TODO: is the following line needed?
|
// TODO: is the following line needed?
|
||||||
const Package* p = it->second;
|
const Package* p = it->second;
|
||||||
if ( p && p->dependencies().find( arg ) != string::npos ) {
|
if ( p && p->dependencies().find( dep ) != string::npos ) {
|
||||||
list<string> tokens;
|
list<string> tokens;
|
||||||
StringHelper::split( p->dependencies(), ',', tokens );
|
StringHelper::split( p->dependencies(), ',', tokens );
|
||||||
list<string>::iterator it = find( tokens.begin(),
|
list<string>::iterator it = find( tokens.begin(),
|
||||||
tokens.end(),
|
tokens.end(),
|
||||||
arg );
|
dep );
|
||||||
if ( it != tokens.end() ) {
|
if ( it != tokens.end() ) {
|
||||||
dependent.insert( p );
|
dependent.insert( p );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepared for recursive search
|
// prepared for recursive search
|
||||||
|
string indent = "";
|
||||||
|
if (m_parser->printTree()) {
|
||||||
|
for (int i = 0; i < level; ++i) {
|
||||||
|
indent += " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
set<const Package*>::iterator it2 = dependent.begin();
|
set<const Package*>::iterator it2 = dependent.begin();
|
||||||
for ( ; it2 != dependent.end(); ++it2 ) {
|
for ( ; it2 != dependent.end(); ++it2 ) {
|
||||||
const Package* p = *it2;
|
const Package* p = *it2;
|
||||||
|
|
||||||
|
if (m_parser->recursive() && !m_parser->printTree()) {
|
||||||
|
if (shownMap[p->name()]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
shownMap[p->name()] = true;
|
||||||
|
}
|
||||||
|
|
||||||
if ( m_parser->all() || m_pkgDB->isInstalled( p->name() ) ) {
|
if ( m_parser->all() || m_pkgDB->isInstalled( p->name() ) ) {
|
||||||
cout << p->name();
|
|
||||||
|
cout << indent << p->name();
|
||||||
if ( m_parser->verbose() > 0 ) {
|
if ( m_parser->verbose() > 0 ) {
|
||||||
cout << " " << p->version() << "-" << p->release();
|
cout << " " << p->version() << "-" << p->release();
|
||||||
}
|
}
|
||||||
@ -1283,6 +1304,10 @@ void PrtGet::printDependendent()
|
|||||||
}
|
}
|
||||||
|
|
||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
|
if (m_parser->recursive()) {
|
||||||
|
printDependent( p->name(), level+2 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public:
|
|||||||
void current();
|
void current();
|
||||||
void printDepends( bool simpleListing=false );
|
void printDepends( bool simpleListing=false );
|
||||||
void printDependTree();
|
void printDependTree();
|
||||||
void printDependendent();
|
void printDependent();
|
||||||
void printDiff();
|
void printDiff();
|
||||||
void printQuickDiff();
|
void printQuickDiff();
|
||||||
|
|
||||||
@ -96,6 +96,8 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
|
|
||||||
void printDepsLevel(int indent, const Package* package);
|
void printDepsLevel(int indent, const Package* package);
|
||||||
|
|
||||||
|
void printDependent(const std::string& dep, int level);
|
||||||
|
|
||||||
void executeTransaction( InstallTransaction& transaction,
|
void executeTransaction( InstallTransaction& transaction,
|
||||||
bool update, bool group );
|
bool update, bool group );
|
||||||
@ -140,7 +142,7 @@ protected:
|
|||||||
void assertMaxArgCount(int count);
|
void assertMaxArgCount(int count);
|
||||||
void assertExactArgCount(int count);
|
void assertExactArgCount(int count);
|
||||||
void argCountFailure(int count, const string& specifier);
|
void argCountFailure(int count, const string& specifier);
|
||||||
|
|
||||||
bool greaterThan( const string& v1, const string& v2 );
|
bool greaterThan( const string& v1, const string& v2 );
|
||||||
static bool printFile(const string& file);
|
static bool printFile(const string& file);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user