1 #define INCLUDE_TESTSETUP_WITHOUT_BOOST
2 #include "zypp/../tests/lib/TestSetup.h"
3 #undef INCLUDE_TESTSETUP_WITHOUT_BOOST
5 #include "zypp/PoolQuery.h"
10 static std::string appname( "patch_find_bug" );
12 int errexit( const std::string & msg_r = std::string(), int exit_r = 101 )
14 if ( ! msg_r.empty() )
16 cerr << endl << msg_r << endl << endl;
22 int usage( const std::string & msg_r = std::string(), int exit_r = 100 )
24 if ( ! msg_r.empty() )
26 cerr << endl << msg_r << endl << endl;
28 cerr << "Usage: " << appname << "[OPTIONS] bugnumber..." << endl;
29 cerr << " Find patches refering to bugnumber (substring)." << endl;
30 cerr << " --root SYSROOT: Load system located below directory SYSROOT" << endl;
34 /******************************************************************
36 ** FUNCTION NAME : main
37 ** FUNCTION TYPE : int
39 int main( int argc, char * argv[] )
41 INT << "===[START]==========================================" << endl;
42 appname = Pathname::basename( argv[0] );
51 ///////////////////////////////////////////////////////////////////
54 Pathname sysRoot("/");
56 if ( (*argv) == std::string("--root") )
60 return errexit("--root requires an argument.");
62 if ( ! PathInfo( *argv ).isDir() )
63 return errexit("--root requires a directory.");
69 TestSetup::LoadSystemAt( sysRoot );
71 for ( ; argc; --argc,++argv )
74 q.setMatchSubstring();
75 q.setCaseSensitive( false );
76 q.addAttribute( sat::SolvAttr::updateReferenceId, *argv );
80 cout << "BUG REFERENCE '" << *argv << "': No match found." << endl;
84 cout << "BUG REFERENCE '" << *argv << endl;
85 for_( it , q.begin(), q.end() )
87 // print the solvable that has a match:
88 cout << " - " << *it << endl;
92 // Print details about each match in that solvable:
93 for_( d, it.matchesBegin(), it.matchesEnd() )
95 // directly access specific attribute like "subFind(updateReferenceType)":
96 cout << " - " << d->inSolvAttr() << "\t\"" << d->asString() << "\" has type \""
97 << d->subFind( sat::SolvAttr::updateReferenceType ).asString() << "\"" << endl;
99 // list the whole updateReference structure:
100 for_( s, d->subBegin(), d->subEnd() )
102 cout << " -" << s.inSolvAttr() << "\t\"" << s.asString() << "\"" << endl;
110 ///////////////////////////////////////////////////////////////////
111 INT << "===[END]============================================" << endl << endl;