r1234 - in tools/prt-get/trunk: . doc src
Author: jw Date: 2006-04-12 18:06:17 +0200 (Wed, 12 Apr 2006) New Revision: 1234 Modified: tools/prt-get/trunk/ChangeLog tools/prt-get/trunk/TODO tools/prt-get/trunk/configure tools/prt-get/trunk/configure.in tools/prt-get/trunk/doc/prt-get.8 tools/prt-get/trunk/src/argparser.cpp tools/prt-get/trunk/src/argparser.h tools/prt-get/trunk/src/main.cpp tools/prt-get/trunk/src/prtget.cpp tools/prt-get/trunk/src/prtget.h Log: prt-get: support recursive dependent and a tree view Modified: tools/prt-get/trunk/ChangeLog =================================================================== --- tools/prt-get/trunk/ChangeLog 2006-04-12 14:44:21 UTC (rev 1233) +++ tools/prt-get/trunk/ChangeLog 2006-04-12 16:06:17 UTC (rev 1234) @@ -12,6 +12,7 @@ - update default prt-get.conf to reflect new port hierarchy (core/opt/contrib) - add timestamps to log files - 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 - add --path to 'ls' Modified: tools/prt-get/trunk/TODO =================================================================== --- tools/prt-get/trunk/TODO 2006-04-12 14:44:21 UTC (rev 1233) +++ tools/prt-get/trunk/TODO 2006-04-12 16:06:17 UTC (rev 1234) @@ -1,3 +1,5 @@ +- add --rebuild-set to dependent +--------------------------- - use `eval $(fgrep -h 'PKGMK_PACKAGE_DIR=' $(which pkgmk) /etc/pkgmk.conf) && echo $PKGMK_PACKAGE_DIR` to determine PACKAGE_DIR - add update-footprint, update-md5sum commands (patch in trac) Modified: tools/prt-get/trunk/configure =================================================================== --- tools/prt-get/trunk/configure 2006-04-12 14:44:21 UTC (rev 1233) +++ tools/prt-get/trunk/configure 2006-04-12 16:06:17 UTC (rev 1234) @@ -1614,7 +1614,7 @@ # Define the identity of the package. PACKAGE=prt-get - VERSION=0.5.12pre2 + VERSION=0.5.12pre4 cat >>confdefs.h <<_ACEOF Modified: tools/prt-get/trunk/configure.in =================================================================== --- tools/prt-get/trunk/configure.in 2006-04-12 14:44:21 UTC (rev 1233) +++ tools/prt-get/trunk/configure.in 2006-04-12 16:06:17 UTC (rev 1234) @@ -1,7 +1,7 @@ # Process this file with autoconf to produce a configure script. AC_INIT 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 Modified: tools/prt-get/trunk/doc/prt-get.8 =================================================================== --- tools/prt-get/trunk/doc/prt-get.8 2006-04-12 14:44:21 UTC (rev 1233) +++ tools/prt-get/trunk/doc/prt-get.8 2006-04-12 16:06:17 UTC (rev 1234) @@ -209,9 +209,11 @@ .TP .B dependent <package> print a list of package which depend on -.B package. -Only list direct dependencies. Usually shows dependent packages which -are installed. To see all dependencies, add the --all switch +.B package. + +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 .B deptree <package> Modified: tools/prt-get/trunk/src/argparser.cpp =================================================================== --- tools/prt-get/trunk/src/argparser.cpp 2006-04-12 14:44:21 UTC (rev 1233) +++ tools/prt-get/trunk/src/argparser.cpp 2006-04-12 16:06:17 UTC (rev 1234) @@ -45,7 +45,9 @@ m_preferHigher( false ), m_strictDiff( false ), m_useRegex(false), - m_fullPath(false) + m_fullPath(false), + m_recursive(false), + m_printTree(false) { } @@ -196,6 +198,10 @@ m_useRegex = true; } else if ( s == "--full" ) { m_fullPath = true; + } else if ( s == "--recursive" ) { + m_recursive = true; + } else if ( s == "--tree" ) { + m_printTree = true; } else if ( s == "-f" ) { m_pkgaddArgs += " " + s; @@ -382,6 +388,16 @@ return m_printPath; } +bool ArgParser::recursive() const +{ + return m_recursive; +} + +bool ArgParser::printTree() const +{ + return m_printTree; +} + const string& ArgParser::commandName() const { return m_commandName; Modified: tools/prt-get/trunk/src/argparser.h =================================================================== --- tools/prt-get/trunk/src/argparser.h 2006-04-12 14:44:21 UTC (rev 1233) +++ tools/prt-get/trunk/src/argparser.h 2006-04-12 16:06:17 UTC (rev 1234) @@ -57,6 +57,8 @@ bool strictDiff() const; bool useRegex() const; bool fullPath() const; + bool recursive() const; + bool printTree() const; const string& alternateConfigFile() const; const string& pkgmkArgs() const; @@ -107,6 +109,9 @@ bool m_useRegex; bool m_fullPath; + bool m_recursive; + bool m_printTree; + string m_alternateConfigFile; string m_pkgmkArgs; string m_pkgaddArgs; Modified: tools/prt-get/trunk/src/main.cpp =================================================================== --- tools/prt-get/trunk/src/main.cpp 2006-04-12 14:44:21 UTC (rev 1233) +++ tools/prt-get/trunk/src/main.cpp 2006-04-12 16:06:17 UTC (rev 1234) @@ -26,7 +26,7 @@ << endl; } else if ( !argParser.isCommandGiven() ) { if (argParser.commandName() != "") { - cerr << "prt-get: Unknown command '" + cerr << "prt-get: Unknown command '" << argParser.commandName() << "'. " << "try prt-get help for more information" << endl; } else { @@ -122,7 +122,7 @@ prtGet.readme(); break; case ArgParser::DEPENDENT: - prtGet.printDependendent(); + prtGet.printDependent(); break; case ArgParser::SYSUP: prtGet.sysup(); Modified: tools/prt-get/trunk/src/prtget.cpp =================================================================== --- tools/prt-get/trunk/src/prtget.cpp 2006-04-12 14:44:21 UTC (rev 1233) +++ tools/prt-get/trunk/src/prtget.cpp 2006-04-12 16:06:17 UTC (rev 1234) @@ -1244,37 +1244,58 @@ return true; } -void PrtGet::printDependendent() +void PrtGet::printDependent() { assertExactArgCount(1); initRepo(); 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(); + static map<string, bool> shownMap; set<const Package*> dependent; for ( ; it != m_repo->packages().end(); ++it ) { // TODO: is the following line needed? const Package* p = it->second; - if ( p && p->dependencies().find( arg ) != string::npos ) { + if ( p && p->dependencies().find( dep ) != string::npos ) { list<string> tokens; StringHelper::split( p->dependencies(), ',', tokens ); list<string>::iterator it = find( tokens.begin(), tokens.end(), - arg ); + dep ); if ( it != tokens.end() ) { dependent.insert( p ); } } } - + // 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(); for ( ; it2 != dependent.end(); ++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() ) ) { - cout << p->name(); + + cout << indent << p->name(); if ( m_parser->verbose() > 0 ) { cout << " " << p->version() << "-" << p->release(); } @@ -1283,6 +1304,10 @@ } cout << endl; + + if (m_parser->recursive()) { + printDependent( p->name(), level+2 ); + } } } } Modified: tools/prt-get/trunk/src/prtget.h =================================================================== --- tools/prt-get/trunk/src/prtget.h 2006-04-12 14:44:21 UTC (rev 1233) +++ tools/prt-get/trunk/src/prtget.h 2006-04-12 16:06:17 UTC (rev 1234) @@ -67,7 +67,7 @@ void current(); void printDepends( bool simpleListing=false ); void printDependTree(); - void printDependendent(); + void printDependent(); void printDiff(); void printQuickDiff(); @@ -96,6 +96,8 @@ protected: void printDepsLevel(int indent, const Package* package); + + void printDependent(const std::string& dep, int level); void executeTransaction( InstallTransaction& transaction, bool update, bool group ); @@ -140,7 +142,7 @@ void assertMaxArgCount(int count); void assertExactArgCount(int count); void argCountFailure(int count, const string& specifier); - + bool greaterThan( const string& v1, const string& v2 ); static bool printFile(const string& file); };
participants (1)
-
crux@crux.nu