libzypp: zypp/Capability.cc Source File

libzypp 17.36.6

Capability.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#include <iostream>
13#include <zypp/base/Logger.h>
14
15#include <zypp/base/String.h>
16#include <zypp/base/Regex.h>
17#include <zypp/base/Gettext.h>
18#include <zypp/base/Exception.h>
19
20#include <zypp/Arch.h>
21#include <zypp/Rel.h>
22#include <zypp/Edition.h>
23#include <zypp/Capability.h>
24
25#include <zypp/sat/detail/PoolImpl.h>
26#include <zypp/sat/detail/PoolMember.h>
27#include <zypp/sat/Pool.h>
28#include <zypp/ResPool.h>
29
30using std::endl;
31
33namespace zypp
34{
36 namespace
37 {
38
40 template <unsigned TLen = 5>
41 struct TempStrings
42 {
44 std::string & getNext()
45 { unsigned c = _next; _next = (_next+1) % TLen; _buf[c].clear(); return _buf[c]; }
46
47 private:
48 unsigned _next = 0;
49 std::string _buf[TLen];
50 };
51
53 inline std::string::size_type backskipWs( const std::string & str_r, std::string::size_type pos_r )
54 {
55 for ( ; pos_r != std::string::npos; --pos_r )
56 {
57 char ch = str_r[pos_r];
58 if ( ch != ' ' && ch != '\t' )
59 break;
60 }
61 return pos_r;
62 }
63
65 inline std::string::size_type backskipNWs( const std::string & str_r, std::string::size_type pos_r )
66 {
67 for ( ; pos_r != std::string::npos; --pos_r )
68 {
69 char ch = str_r[pos_r];
70 if ( ch == ' ' || ch == '\t' )
71 break;
72 }
73 return pos_r;
74 }
75
77 void splitOpEdition( std::string & str_r, Rel & op_r, Edition & ed_r )
78 {
79 if ( str_r.empty() )
80 return;
81 std::string::size_type ch( str_r.size()-1 );
82
83 // check whether the one but last word is a valid Rel:
84 if ( (ch = backskipWs( str_r, ch )) != std::string::npos )
85 {
86 std::string::size_type ee( ch );
87 if ( (ch = backskipNWs( str_r, ch )) != std::string::npos )
88 {
89 std::string::size_type eb( ch );
90 if ( (ch = backskipWs( str_r, ch )) != std::string::npos )
91 {
92 std::string::size_type oe( ch );
93 ch = backskipNWs( str_r, ch ); // now before 'op'? begin
94 if ( op_r.parseFrom( str_r.substr( ch+1, oe-ch ) ) )
95 {
96 // found a legal 'op'
97 ed_r = Edition( str_r.substr( eb+1, ee-eb ) );
98 if ( ch != std::string::npos ) // 'op' is not at str_r begin, so skip WS
99 ch = backskipWs( str_r, ch );
100 str_r.erase( ch+1 );
101 return;
102 }
103 }
104 }
105 }
106 // HERE: Didn't find 'name op edition'
107 // As a convenience we check for an embeded 'op' (not surounded by WS).
108 // But just '[<=>]=?|!=' and not inside '()'.
109 ch = str_r.find_last_of( "<=>)" );
110 if ( ch != std::string::npos && str_r[ch] != ')' )
111 {
112 std::string::size_type oe( ch );
113
114 // do edition first:
115 ch = str_r.find_first_not_of( " \t", oe+1 );
116 if ( ch != std::string::npos )
117 ed_r = Edition( str_r.substr( ch ) );
118
119 // now finish op:
120 ch = oe-1;
121 if ( str_r[oe] != '=' ) // '[<>]'
122 {
123 op_r = ( str_r[oe] == '<' ) ? Rel::LT : Rel::GT;
124 }
125 else
126 { // '?='
127 if ( ch != std::string::npos )
128 {
129 switch ( str_r[ch] )
130 {
131 case '<': --ch; op_r = Rel::LE; break;
132 case '>': --ch; op_r = Rel::GE; break;
133 case '!': --ch; op_r = Rel::NE; break;
134 case '=': --ch; // fall through
135 default: op_r = Rel::EQ; break;
136 }
137 }
138 }
139
140 // finally name:
141 if ( ch != std::string::npos ) // 'op' is not at str_r begin, so skip WS
142 ch = backskipWs( str_r, ch );
143 str_r.erase( ch+1 );
144 return;
145 }
146 // HERE: It's a plain 'name'
147 }
148
151 sat::detail::IdType relFromStr( sat::detail::CPool * pool_r,
152 const Arch & arch_r,
153 const std::string & name_r,
154 Rel op_r,
155 const Edition & ed_r,
156 const ResKind & kind_r )
157 {
158 // First build the name, non-packages prefixed by kind
159 sat::Solvable::SplitIdent split( kind_r, name_r );
160 sat::detail::IdType nid( split.ident().id() );
161
162 if ( split.kind() == ResKind::srcpackage )
163 {
164 // map 'kind srcpackage' to 'arch src', the pseudo architecture
165 // libsolv uses.
166 nid = ::pool_rel2id( pool_r, nid, IdString(ARCH_SRC).id(), REL_ARCH, /*create*/true );
167 }
168
169 // Extend name by architecture, if provided and not a srcpackage
170 if ( ! arch_r.empty() && kind_r != ResKind::srcpackage )
171 {
172 nid = ::pool_rel2id( pool_r, nid, arch_r.id(), REL_ARCH, /*create*/true );
173 }
174
175 // Extend 'op edition', if provided
176 if ( op_r != Rel::ANY && ed_r != Edition::noedition )
177 {
178 nid = ::pool_rel2id( pool_r, nid, ed_r.id(), op_r.bits(), /*create*/true );
179 }
180
181 return nid;
182 }
183
187 sat::detail::IdType relFromStr( sat::detail::CPool * pool_r,
188 const std::string & name_r, Rel op_r, const Edition & ed_r,
189 const ResKind & kind_r )
190 {
191 static const Arch srcArch( IdString(ARCH_SRC).asString() );
192 static const Arch nosrcArch( IdString(ARCH_NOSRC).asString() );
193 static const std::string srcKindPrefix( ResKind::srcpackage.asString() + ':' );
194
195 // check for an embedded 'srcpackage:foo' to be mapped to 'foo' and 'ResKind::srcpackage'.
196 if ( kind_r.empty() && str::hasPrefix( name_r, srcKindPrefix ) )
197 {
198 return relFromStr( pool_r, Arch_empty, name_r.substr( srcKindPrefix.size() ), op_r, ed_r, ResKind::srcpackage );
199 }
200
201 Arch arch( Arch_empty );
202 std::string name( name_r );
203
204 std::string::size_type asep( name_r.rfind( '.' ) );
205 if ( asep != std::string::npos )
206 {
207 Arch ext( name_r.substr( asep+1 ) );
208 if ( ext.isBuiltIn() || ext == srcArch || ext == nosrcArch )
209 {
210 arch = ext;
211 name.erase( asep );
212 }
213 }
214
215 return relFromStr( pool_r, arch, name, op_r, ed_r, kind_r );
216 }
217
220 sat::detail::IdType relFromStr( sat::detail::CPool * pool_r,
221 const Arch & arch_r, // parse from name if empty
222 const std::string & str_r, const ResKind & kind_r,
223 Capability::CtorFlag flag_r )
224 {
225 std::string name( str_r );
226 Rel op;
227 Edition ed;
228 if ( flag_r == Capability::UNPARSED )
229 {
230 splitOpEdition( name, op, ed );
231 }
232
233 if ( arch_r.empty() )
234 return relFromStr( pool_r, name, op, ed, kind_r ); // parses for name[.arch]
235 // else
236 return relFromStr( pool_r, arch_r, name, op, ed, kind_r );
237 }
238
240 sat::detail::IdType richOrRelFromStr( sat::detail::CPool * pool_r, const std::string & str_r, const ResKind & prefix_r, Capability::CtorFlag flag_r )
241 {
242 if ( str_r[0] == '(' ) {
243 sat::detail::IdType res { sat::detail::PoolMember::myPool().parserpmrichdep( str_r.c_str() ) };
244 if ( res ) return res;
245 // else: no richdep, so fall back to the ordinary parser which in
246 // case of doubt turns the string into a NAMED cap.
247 }
248 return relFromStr( pool_r, Arch_empty, str_r, prefix_r, flag_r );
249 }
250
252 } // namespace
254
255 const Capability Capability::Null( STRID_NULL );
256 const Capability Capability::Empty( STRID_EMPTY );
257
259
260 Capability::Capability( const char * str_r, const ResKind & prefix_r, CtorFlag flag_r )
261 : _id( richOrRelFromStr( myPool().getPool(), str_r, prefix_r, flag_r ) )
262 {}
263
264 Capability::Capability( const std::string & str_r, const ResKind & prefix_r, CtorFlag flag_r )
265 : _id( richOrRelFromStr( myPool().getPool(), str_r, prefix_r, flag_r ) )
266 {}
267
268 Capability::Capability( const Arch & arch_r, const char * str_r, const ResKind & prefix_r, CtorFlag flag_r )
269 : _id( relFromStr( myPool().getPool(), arch_r, str_r, prefix_r, flag_r ) )
270 {}
271
272 Capability::Capability( const Arch & arch_r, const std::string & str_r, const ResKind & prefix_r, CtorFlag flag_r )
273 : _id( relFromStr( myPool().getPool(), arch_r, str_r, prefix_r, flag_r ) )
274 {}
275
276 Capability::Capability( const char * str_r, CtorFlag flag_r, const ResKind & prefix_r )
277 : _id( relFromStr( myPool().getPool(), Arch_empty, str_r, prefix_r, flag_r ) )
278 {}
279
280 Capability::Capability( const std::string & str_r, CtorFlag flag_r, const ResKind & prefix_r )
281 : _id( relFromStr( myPool().getPool(), Arch_empty, str_r, prefix_r, flag_r ) )
282 {}
283
284 Capability::Capability( const Arch & arch_r, const char * str_r, CtorFlag flag_r, const ResKind & prefix_r )
285 : _id( relFromStr( myPool().getPool(), arch_r, str_r, prefix_r, flag_r ) )
286 {}
287
288 Capability::Capability( const Arch & arch_r, const std::string & str_r, CtorFlag flag_r, const ResKind & prefix_r )
289 : _id( relFromStr( myPool().getPool(), arch_r, str_r, prefix_r, flag_r ) )
290 {}
291
293 // Ctor from <name[.arch] op edition>.
295
296 Capability::Capability( const std::string & name_r, const std::string & op_r, const std::string & ed_r, const ResKind & prefix_r )
297 : _id( relFromStr( myPool().getPool(), name_r, Rel(op_r), Edition(ed_r), prefix_r ) )
298 {}
299 Capability::Capability( const std::string & name_r, Rel op_r, const std::string & ed_r, const ResKind & prefix_r )
300 : _id( relFromStr( myPool().getPool(), name_r, op_r, Edition(ed_r), prefix_r ) )
301 {}
302 Capability::Capability( const std::string & name_r, Rel op_r, const Edition & ed_r, const ResKind & prefix_r )
303 : _id( relFromStr( myPool().getPool(), name_r, op_r, ed_r, prefix_r ) )
304 {}
305
307 // Ctor from <arch name op edition>.
309
310 Capability::Capability( const std::string & arch_r, const std::string & name_r, const std::string & op_r, const std::string & ed_r, const ResKind & prefix_r )
311 : _id( relFromStr( myPool().getPool(), Arch(arch_r), name_r, Rel(op_r), Edition(ed_r), prefix_r ) )
312 {}
313 Capability::Capability( const std::string & arch_r, const std::string & name_r, Rel op_r, const std::string & ed_r, const ResKind & prefix_r )
314 : _id( relFromStr( myPool().getPool(), Arch(arch_r), name_r, op_r, Edition(ed_r), prefix_r ) )
315 {}
316 Capability::Capability( const std::string & arch_r, const std::string & name_r, Rel op_r, const Edition & ed_r, const ResKind & prefix_r )
317 : _id( relFromStr( myPool().getPool(), Arch(arch_r), name_r, op_r, ed_r, prefix_r ) )
318 {}
319 Capability::Capability( const Arch & arch_r, const std::string & name_r, const std::string & op_r, const std::string & ed_r, const ResKind & prefix_r )
320 : _id( relFromStr( myPool().getPool(), arch_r, name_r, Rel(op_r), Edition(ed_r), prefix_r ) )
321 {}
322 Capability::Capability( const Arch & arch_r, const std::string & name_r, Rel op_r, const std::string & ed_r, const ResKind & prefix_r )
323 : _id( relFromStr( myPool().getPool(), arch_r, name_r, op_r, Edition(ed_r), prefix_r ) )
324 {}
325 Capability::Capability( const Arch & arch_r, const std::string & name_r, Rel op_r, const Edition & ed_r, const ResKind & prefix_r )
326 : _id( relFromStr( myPool().getPool(), arch_r, name_r, op_r, ed_r, prefix_r ) )
327 {}
328
330 // Ctor creating a namespace: capability.
332
333 Capability::Capability( ResolverNamespace namespace_r, IdString value_r )
334 : _id( ::pool_rel2id( myPool().getPool(), asIdString(namespace_r).id(), (value_r.empty() ? STRID_NULL : value_r.id() ), REL_NAMESPACE, /*create*/true ) )
335 {}
336
338 // https://rpm-software-management.github.io/rpm/manual/boolean_dependencies.html
339 namespace
340 {
341 inline const char * opstr( int op_r )
342 {
343 switch ( op_r )
344 {
345 case REL_GT: return " > ";
346 case REL_EQ: return " = ";
347 case REL_LT: return " < ";
348 case REL_GT|REL_EQ: return " >= ";
349 case REL_LT|REL_EQ: return " <= ";
350 case REL_GT|REL_LT: return " != ";
351 case REL_GT|REL_LT|REL_EQ: return " <=> ";
352 case REL_AND: return " and ";
353 case REL_OR: return " or ";
354 case REL_COND: return " if ";
355 case REL_UNLESS: return " unless ";
356 case REL_ELSE: return " else ";
357 case REL_WITH: return " with ";
358 case REL_WITHOUT: return " without ";
359 }
360 return "UNKNOWNCAPREL";
361 }
362
363 inline bool isBoolOp( int op_r )
364 {
365 switch ( op_r ) {
366 case REL_AND:
367 case REL_OR:
368 case REL_COND:
369 case REL_UNLESS:
370 case REL_ELSE:
371 case REL_WITH:
372 case REL_WITHOUT:
373 return true;
374 }
375 return false;
376 }
377
378 inline bool needsBrace( int op_r, int parop_r )
379 {
380 return ( isBoolOp( parop_r ) || parop_r == 0 ) && isBoolOp( op_r )
381 && ( parop_r != op_r || op_r == REL_COND || op_r == REL_UNLESS || op_r == REL_ELSE )
382 && not ( ( parop_r == REL_COND || parop_r == REL_UNLESS ) && op_r == REL_ELSE );
383 }
384
385 void cap2strHelper( std::string & outs_r, sat::detail::CPool * pool_r, sat::detail::IdType id_r, int parop_r )
386 {
387 if ( ISRELDEP(id_r) ) {
388 ::Reldep * rd = GETRELDEP( pool_r, id_r );
389 int op = rd->flags;
390
391 if ( op == CapDetail::CAP_ARCH ) {
392 if ( rd->evr == ARCH_SRC || rd->evr == ARCH_NOSRC ) {
393 // map arch .{src,nosrc} to kind srcpackage
394 outs_r += ResKind::srcpackage.c_str();
395 outs_r += ":";
396 outs_r += IdString(rd->name).c_str();
397 return;
398 }
399 cap2strHelper( outs_r, pool_r, rd->name, op );
400 outs_r += ".";
401 cap2strHelper( outs_r, pool_r, rd->evr, op );
402 return;
403 }
404
405 if ( op == CapDetail::CAP_NAMESPACE ) {
406 cap2strHelper( outs_r, pool_r, rd->name, op );
407 outs_r += "(";
408 cap2strHelper( outs_r, pool_r, rd->evr, op );
409 outs_r += ")";
410 return;
411 }
412
413 if ( op == REL_FILECONFLICT )
414 {
415 cap2strHelper( outs_r, pool_r, rd->name, op );
416 return;
417 }
418
419 if ( needsBrace( op, parop_r ) ) {
420 outs_r += "(";
421 cap2strHelper( outs_r, pool_r, rd->name, op );
422 outs_r += opstr( op );
423 cap2strHelper( outs_r, pool_r, rd->evr, op );
424 outs_r += ")";
425 return;
426 }
427
428 cap2strHelper( outs_r, pool_r, rd->name, op );
429 outs_r += opstr( op );
430 cap2strHelper( outs_r, pool_r, rd->evr, op );
431 }
432 else
433 outs_r += IdString(id_r).c_str();
434 }
435 } // namespace
437
438 const char * Capability::c_str() const
439 {
440 if ( not id() ) return "";
441 if ( not ISRELDEP(id()) ) return IdString(id()).c_str();
442
443 static TempStrings<5> tempstrs; // Round Robin buffer to prolong the lifetime of the returned char*
444
445 std::string & outs { tempstrs.getNext() };
446 cap2strHelper( outs, myPool().getPool(), id(), 0 );
447 return outs.c_str();
448 }
449
450 CapMatch Capability::_doMatch( sat::detail::IdType lhs, sat::detail::IdType rhs )
451 {
452 if ( lhs == rhs )
453 return CapMatch::yes;
454
455 CapDetail l( lhs );
456 CapDetail r( rhs );
457
458 switch ( l.kind() )
459 {
460 case CapDetail::NOCAP:
461 return( r.kind() == CapDetail::NOCAP ); // NOCAP matches NOCAP only
462 break;
463 case CapDetail::EXPRESSION:
464 return CapMatch::irrelevant;
465 break;
466 case CapDetail::NAMED:
467 case CapDetail::VERSIONED:
468 break;
469 }
470
471 switch ( r.kind() )
472 {
473 case CapDetail::NOCAP:
474 return CapMatch::no; // match case handled above
475 break;
476 case CapDetail::EXPRESSION:
477 return CapMatch::irrelevant;
478 break;
479 case CapDetail::NAMED:
480 case CapDetail::VERSIONED:
481 break;
482 }
483 // comparing two simple caps:
484 if ( l.name() != r.name() )
485 return CapMatch::no;
486
487 // if both are arch restricted they must match
488 if ( l.arch() != r.arch()
489 && ! ( l.arch().empty() || r.arch().empty() ) )
490 return CapMatch::no;
491
492 // isNamed matches ANY edition:
493 if ( l.isNamed() || r.isNamed() )
494 return CapMatch::yes;
495
496 // both are versioned:
497 return overlaps( Edition::MatchRange( l.op(), l.ed() ),
498 Edition::MatchRange( r.op(), r.ed() ) );
499 }
500
501 bool Capability::isInterestingFileSpec( const char * name_r )
502 {
503 static str::smatch what;
504 static const str::regex filenameRegex(
505 "/(s?bin|lib(64)?|etc)/|^/usr/(games/|share/(dict/words|magic\\.mime)$)|^/opt/gnome/games/",
506 str::regex::nosubs );
507
508 return str::regex_match( name_r, what, filenameRegex );
509 }
510
511 Capability Capability::guessPackageSpec( const std::string & str_r, bool & rewrote_r )
512 {
513 Capability cap( str_r );
514 CapDetail detail( cap.detail() );
515
516 // str_r might be the form "libzypp-1.2.3-4.5(.arch)'
517 // correctly parsed as name capability by the ctor.
518 // TODO: Think about allowing glob char in name - for now don't process
519 if ( detail.isNamed() && !::strpbrk( detail.name().c_str(), "*?[{" )
520 && ::strrchr( detail.name().c_str(), '-' ) && sat::WhatProvides( cap ).empty() )
521 {
522 Arch origArch( detail.arch() ); // to support a trailing .arch
523
524 std::string guess( detail.name().asString() );
525 std::string::size_type pos( guess.rfind( '-' ) );
526 guess[pos] = '=';
527
528 Capability guesscap( origArch, guess );
529 detail = guesscap.detail();
530
531 ResPool pool( ResPool::instance() );
532 // require name part matching a pool items name (not just provides!)
533 if ( pool.byIdentBegin( detail.name() ) != pool.byIdentEnd( detail.name() ) )
534 {
535 rewrote_r = true;
536 return guesscap;
537 }
538
539 // try the one but last '-'
540 if ( pos )
541 {
542 guess[pos] = '-';
543 if ( (pos = guess.rfind( '-', pos-1 )) != std::string::npos )
544 {
545 guess[pos] = '=';
546
547 guesscap = Capability( origArch, guess );
548 detail = guesscap.detail();
549
550 // require name part matching a pool items name (not just provides!)
551 if ( pool.byIdentBegin( detail.name() ) != pool.byIdentEnd( detail.name() ) )
552 {
553 rewrote_r = true;
554 return guesscap;
555 }
556 }
557 }
558 }
559
560 rewrote_r = false;
561 return cap;
562 }
563
564 Capability Capability::guessPackageSpec( const std::string & str_r )
565 {
566 bool dummy = false;
567 return guessPackageSpec( str_r, dummy );
568 }
569
570 /******************************************************************
571 **
572 ** FUNCTION NAME : operator<<
573 ** FUNCTION TYPE : std::ostream &
574 */
575 std::ostream & operator<<( std::ostream & str, const Capability & obj )
576 {
577 return str << obj.c_str();
578 }
579
580 std::ostream & dumpOn( std::ostream & str, const Capability & obj )
581 {
582 return str << ( obj ? ::pool_dep2str( sat::Pool::instance().get(), obj.id() ) : "" );
583 }
584
586 //
587 // CLASS NAME : CapDetail
588 //
590
591 void CapDetail::_init()
592 {
593 // : _kind( NOCAP ), _lhs( id_r ), _rhs( 0 ), _flag( 0 ), _archIfSimple( 0 )
594
595 if ( _lhs == sat::detail::emptyId || _lhs == sat::detail::noId )
596 return; // NOCAP
597
598 if ( ! ISRELDEP(_lhs) )
599 {
600 // this is name without arch!
601 _kind = NAMED;
602 return;
603 }
604
605 ::Reldep * rd = GETRELDEP( myPool().getPool(), _lhs );
606 _lhs = rd->name;
607 _rhs = rd->evr;
608 _flag = rd->flags;
609
610 if ( Rel::isRel( _flag ) )
611 {
612 _kind = VERSIONED;
613 // Check for name.arch...
614 if ( ! ISRELDEP(_lhs) )
615 return; // this is name without arch!
616 rd = GETRELDEP( myPool().getPool(), _lhs );
617 if ( rd->flags != CAP_ARCH )
618 return; // this is not name.arch
619 // This is name.arch:
620 _lhs = rd->name;
621 _archIfSimple = rd->evr;
622 }
623 else if ( rd->flags == CAP_ARCH )
624 {
625 _kind = NAMED;
626 // This is name.arch:
627 _lhs = rd->name;
628 _archIfSimple = rd->evr;
629 }
630 else
631 {
632 _kind = EXPRESSION;
633 return;
634 }
635 // map back libsolvs pseudo arch 'src' to kind srcpackage
636 if ( _archIfSimple == ARCH_SRC || _archIfSimple == ARCH_NOSRC )
637 {
638 _lhs = IdString( (ResKind::srcpackage.asString() + ":" + IdString(_lhs).c_str()).c_str() ).id();
639 _archIfSimple = 0;
640 }
641 }
642
643 /******************************************************************
644 **
645 ** FUNCTION NAME : operator<<
646 ** FUNCTION TYPE : std::ostream &
647 */
648 std::ostream & operator<<( std::ostream & str, const CapDetail & obj )
649 {
650 static const char archsep = '.';
651 switch ( obj.kind() )
652 {
653 case CapDetail::NOCAP:
654 return str << "<NoCap>";
655 break;
656
657 case CapDetail::NAMED:
658 str << obj.name();
659 if ( obj.hasArch() )
660 str << archsep << obj.arch();
661 return str;
662 break;
663
664 case CapDetail::VERSIONED:
665 str << obj.name();
666 if ( obj.hasArch() )
667 str << archsep << obj.arch();
668 return str << " " << obj.op() << " " << obj.ed();
669 break;
670
671 case CapDetail::EXPRESSION:
672 {
673 std::string outs;
674 auto pool = sat::Pool::instance().get();
675 auto op = obj.capRel();
676 if ( obj.capRel() == CapDetail::CAP_NAMESPACE ) {
677 cap2strHelper( outs, pool, obj.lhs().id(), op );
678 outs += "(";
679 cap2strHelper( outs, pool, obj.rhs().id(), op );
680 outs += ")";
681 }
682 else {
683 outs += "(";
684 cap2strHelper( outs, pool, obj.lhs().id(), op );
685 outs += opstr( op );
686 cap2strHelper( outs, pool, obj.rhs().id(), op );
687 outs += ")";
688 }
689 return str << outs;
690 }
691 break;
692 }
693 return str << "<UnknownCap(" << obj.lhs() << " " << obj.capRel() << " " << obj.rhs() << ")>";
694 }
695
696 std::ostream & operator<<( std::ostream & str, CapDetail::Kind obj )
697 {
698 switch ( obj )
699 {
700 case CapDetail::NOCAP: return str << "NoCap"; break;
701 case CapDetail::NAMED: return str << "NamedCap"; break;
702 case CapDetail::VERSIONED: return str << "VersionedCap"; break;
703 case CapDetail::EXPRESSION: return str << "CapExpression"; break;
704 }
705 return str << "UnknownCap";
706 }
707
708 std::ostream & operator<<( std::ostream & str, CapDetail::CapRel obj )
709 {
710 switch ( obj )
711 {
712 case CapDetail::REL_NONE: return str << "NoCapRel"; break;
713 case CapDetail::CAP_AND: return str << "and"; break; // &
714 case CapDetail::CAP_OR: return str << "or"; break; // |
715 case CapDetail::CAP_COND: return str << "if"; break;
716 case CapDetail::CAP_UNLESS: return str << "unless"; break;
717 case CapDetail::CAP_ELSE: return str << "else"; break;
718 case CapDetail::CAP_WITH: return str << "with"; break; // +
719 case CapDetail::CAP_WITHOUT: return str << "without"; break; // -
720 case CapDetail::CAP_NAMESPACE: return str << "NAMESPACE"; break;
721 case CapDetail::CAP_ARCH: return str << "ARCH"; break;
722 }
723 return str << "UnknownCapRel("+str::numstring(obj)+")";
724 }
725
727} // namespace zypp
Arch.h
Capability.h
Edition.h
PoolMember.h
Pool.h
Rel.h
ResPool.h
zypp::Arch
Architecture.
Definition Arch.h:37
zypp::CapDetail
Helper providing more detailed information about a Capability.
Definition Capability.h:310
zypp::CapDetail::CapDetail
CapDetail()
Definition Capability.h:341
zypp::CapDetail::isNamed
bool isNamed() const
Definition Capability.h:354
zypp::CapDetail::Kind
Kind
Definition Capability.h:313
zypp::CapDetail::NAMED
@ NAMED
Definition Capability.h:315
zypp::CapDetail::NOCAP
@ NOCAP
Definition Capability.h:314
zypp::CapDetail::EXPRESSION
@ EXPRESSION
Definition Capability.h:317
zypp::CapDetail::VERSIONED
@ VERSIONED
Definition Capability.h:316
zypp::CapDetail::name
IdString name() const
Definition Capability.h:363
zypp::CapDetail::hasArch
bool hasArch() const
Definition Capability.h:361
zypp::CapDetail::arch
IdString arch() const
Definition Capability.h:362
zypp::CapDetail::rhs
Capability rhs() const
Definition Capability.h:372
zypp::CapDetail::ed
Edition ed() const
Definition Capability.h:365
zypp::CapDetail::op
Rel op() const
Definition Capability.h:364
zypp::CapDetail::_archIfSimple
sat::detail::IdType _archIfSimple
Definition Capability.h:382
zypp::CapDetail::lhs
Capability lhs() const
Definition Capability.h:370
zypp::CapDetail::kind
Kind kind() const
Definition Capability.h:352
zypp::CapDetail::_init
void _init()
Definition Capability.cc:591
zypp::CapDetail::_kind
Kind _kind
Definition Capability.h:378
zypp::CapDetail::_rhs
sat::detail::IdType _rhs
Definition Capability.h:380
zypp::CapDetail::capRel
CapRel capRel() const
Definition Capability.h:371
zypp::CapDetail::_lhs
sat::detail::IdType _lhs
Definition Capability.h:379
zypp::CapDetail::_flag
unsigned _flag
Definition Capability.h:381
zypp::CapDetail::CapRel
CapRel
Enum values corresponding with libsolv defines.
Definition Capability.h:324
zypp::CapDetail::CAP_OR
@ CAP_OR
or
Definition Capability.h:327
zypp::CapDetail::REL_NONE
@ REL_NONE
Not an expression.
Definition Capability.h:325
zypp::CapDetail::CAP_AND
@ CAP_AND
and
Definition Capability.h:326
zypp::CapDetail::CAP_WITHOUT
@ CAP_WITHOUT
without
Definition Capability.h:334
zypp::CapDetail::CAP_ARCH
@ CAP_ARCH
Used internally.
Definition Capability.h:337
zypp::CapDetail::CAP_ELSE
@ CAP_ELSE
else
Definition Capability.h:331
zypp::CapDetail::CAP_UNLESS
@ CAP_UNLESS
unless
Definition Capability.h:330
zypp::CapDetail::CAP_NAMESPACE
@ CAP_NAMESPACE
Definition Capability.h:336
zypp::CapDetail::CAP_WITH
@ CAP_WITH
with
Definition Capability.h:333
zypp::CapDetail::CAP_COND
@ CAP_COND
if
Definition Capability.h:329
zypp::CapMatch
Tri state Capability match result.
Definition CapMatch.h:39
zypp::CapMatch::no
static const CapMatch no
Definition CapMatch.h:53
zypp::CapMatch::irrelevant
static const CapMatch irrelevant
Definition CapMatch.h:54
zypp::CapMatch::yes
static const CapMatch yes
Definition CapMatch.h:52
zypp::Capability
A sat capability.
Definition Capability.h:63
zypp::Capability::id
sat::detail::IdType id() const
Expert backdoor.
Definition Capability.h:263
zypp::Capability::Null
static const Capability Null
No or Null Capability ( Id 0 ).
Definition Capability.h:147
zypp::Capability::_id
sat::detail::IdType _id
Definition Capability.h:269
zypp::Capability::Capability
Capability()
Default ctor, Empty capability.
Definition Capability.h:69
zypp::Capability::empty
bool empty() const
Whether the Capability is empty.
Definition Capability.h:160
zypp::Capability::detail
CapDetail detail() const
Helper providing more detailed information about a Capability.
Definition Capability.h:397
zypp::Capability::c_str
const char * c_str() const
Conversion to const char *
Definition Capability.cc:438
zypp::Capability::_doMatch
static CapMatch _doMatch(sat::detail::IdType lhs, sat::detail::IdType rhs)
Match two Capabilities.
Definition Capability.cc:450
zypp::Capability::isInterestingFileSpec
static bool isInterestingFileSpec(const IdString &name_r)
Test for a filename that is likely being REQUIRED.
Definition Capability.h:226
zypp::Capability::CtorFlag
CtorFlag
Definition Capability.h:65
zypp::Capability::UNPARSED
@ UNPARSED
Definition Capability.h:65
zypp::Capability::Empty
static const Capability Empty
Empty Capability.
Definition Capability.h:150
zypp::Capability::guessPackageSpec
static Capability guessPackageSpec(const std::string &str_r)
Capability parser also guessing "libzypp-1.2.3-4.5.x86_64" formats.
Definition Capability.cc:564
zypp::Edition
Edition represents [epoch:]version[-release]
Definition Edition.h:61
zypp::Edition::MatchRange
Range< Edition, Match > MatchRange
Edition Range based on Match.
Definition Edition.h:169
zypp::Edition::noedition
static const Edition noedition
Value representing noedition ("") This is in fact a valid Edition.
Definition Edition.h:73
zypp::IdString
Access to the sat-pools string space.
Definition IdString.h:44
zypp::IdString::c_str
const char * c_str() const
Conversion to const char *
Definition IdString.cc:50
zypp::IdString::empty
constexpr bool empty() const
Whether the string is empty.
Definition IdString.h:88
zypp::IdString::id
IdType id() const
Expert backdoor.
Definition IdString.h:133
zypp::ResKind
Resolvable kinds.
Definition ResKind.h:33
zypp::ResKind::srcpackage
static const ResKind srcpackage
Definition ResKind.h:44
zypp::ResPool
Global ResObject pool.
Definition ResPool.h:62
zypp::ResPool::instance
static ResPool instance()
Singleton ctor.
Definition ResPool.cc:38
zypp::sat::Pool::instance
static Pool instance()
Singleton ctor.
Definition Pool.h:55
zypp::sat::Pool::get
detail::CPool * get() const
Expert backdoor.
Definition Pool.cc:49
zypp::sat::Solvable::SplitIdent
Helper that splits an identifier into kind and name or vice versa.
Definition Solvable.h:362
zypp::sat::WhatProvides
Container of Solvable providing a Capability (read only).
Definition WhatProvides.h:89
zypp::sat::WhatProvides::empty
bool empty() const
Whether the container is empty.
Definition WhatProvides.cc:129
zypp::sat::detail::PoolImpl::parserpmrichdep
sat::detail::IdType parserpmrichdep(const char *capstr_r)
libsolv capability parser
Definition PoolImpl.h:191
zypp::str::regex
Regular expression.
Definition Regex.h:95
zypp::str::regex::nosubs
@ nosubs
Support for substring addressing of matches is not required.
Definition Regex.h:100
zypp::str::smatch
Regular expression match result.
Definition Regex.h:168
str
String related utilities and Regular expression matching.
zypp::pool
Definition ByIdent.h:24
zypp::sat::detail::emptyId
static const IdType emptyId(1)
zypp::sat::detail::noId
static const IdType noId(0)
zypp::sat::detail::IdType
int IdType
Generic Id type.
Definition PoolMember.h:104
zypp::sat::detail::CPool
::s_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
Definition PoolMember.h:61
zypp::str::numstring
std::string numstring(char n, int w=0)
Definition String.h:289
zypp::str::hasPrefix
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
Definition String.h:1026
zypp::str::regex_match
bool regex_match(const std::string &s, smatch &matches, const regex &regex)
\relates regex \ingroup ZYPP_STR_REGEX \relates regex \ingroup ZYPP_STR_REGEX
Definition Regex.h:70
zypp::url::split
void split(ParamVec &pvec, const std::string &pstr, const std::string &psep)
Split into a parameter vector.
Definition UrlUtils.cc:164
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::ResolverNamespace
ResolverNamespace
The resolver's dependency namespaces.
Definition ResolverNamespace.h:25
zypp::dumpOn
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition Capability.cc:580
zypp::overlaps
bool overlaps(const Range< Tp, TCompare > &lhs, const Range< Tp, TCompare > &rhs)
Definition Range.h:65
zypp::Arch_empty
const Arch Arch_empty(IdString::Empty)
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Definition SerialNumber.cc:52
zypp::asString
std::string asString(const Patch::Category &obj)
Definition Patch.cc:122
PoolImpl.h
zypp::Rel
Relational operators.
Definition Rel.h:46
zypp::Rel::LT
static const Rel LT
Definition Rel.h:54
zypp::Rel::LE
static const Rel LE
Definition Rel.h:55
zypp::Rel::GE
static const Rel GE
Definition Rel.h:57
zypp::Rel::NE
static const Rel NE
Definition Rel.h:53
zypp::Rel::ANY
static const Rel ANY
Definition Rel.h:58
zypp::Rel::EQ
static const Rel EQ
Definition Rel.h:52
zypp::Rel::isRel
static bool isRel(unsigned bits_r)
Test whether bits_r is a valid Rel (no extra bits set).
Definition Rel.h:113
zypp::sat::detail::PoolMember::myPool
static PoolImpl & myPool()
Definition PoolImpl.cc:184
Exception.h
Gettext.h
Interface to gettext.
Logger.h
Regex.h
String.h