Imported Upstream version 15.19.3
[platform/upstream/libzypp.git] / zypp / sat / Solvable.cc
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/sat/Solvable.cc
10  *
11 */
12 #include <iostream>
13
14 #include "zypp/base/Logger.h"
15 #include "zypp/base/Gettext.h"
16 #include "zypp/base/Exception.h"
17 #include "zypp/base/Functional.h"
18 #include "zypp/base/Collector.h"
19 #include "zypp/base/Xml.h"
20
21 #include "zypp/sat/detail/PoolImpl.h"
22 #include "zypp/sat/Solvable.h"
23 #include "zypp/sat/Pool.h"
24 #include "zypp/sat/LookupAttr.h"
25
26 #include "zypp/Repository.h"
27 #include "zypp/OnMediaLocation.h"
28 #include "zypp/ZConfig.h"
29
30 #include "zypp/ui/Selectable.h"
31
32 using std::endl;
33
34 ///////////////////////////////////////////////////////////////////
35 namespace zypp
36 {
37   ///////////////////////////////////////////////////////////////////
38   namespace sat
39   {
40     ///////////////////////////////////////////////////////////////////
41     namespace
42     {
43       void _doSplit( IdString & _ident, ResKind & _kind, IdString & _name )
44       {
45         if ( ! _ident )
46           return;
47
48         ResKind explicitKind = ResKind::explicitBuiltin( _ident.c_str() );
49         // NOTE: kind package and srcpackage do not have namespaced ident!
50         if ( ! explicitKind  )
51         {
52           _name = _ident;
53           // No kind defaults to package
54           if ( !_kind )
55             _kind = ResKind::package;
56           else if ( ! ( _kind == ResKind::package || _kind == ResKind::srcpackage ) )
57             _ident = IdString( str::form( "%s:%s", _kind.c_str(), _ident.c_str() ) );
58         }
59         else
60         {
61           // strip kind spec from name
62           _name = IdString( ::strchr( _ident.c_str(), ':' )+1 );
63           _kind = explicitKind;
64           if ( _kind == ResKind::package || _kind == ResKind::srcpackage )
65             _ident = _name;
66         }
67         return;
68       }
69     } // namespace
70     ///////////////////////////////////////////////////////////////////
71
72     Solvable::SplitIdent::SplitIdent( IdString ident_r )
73     : _ident( ident_r )
74     { _doSplit( _ident, _kind, _name ); }
75
76     Solvable::SplitIdent::SplitIdent( const char * ident_r )
77     : _ident( ident_r )
78     { _doSplit( _ident, _kind, _name ); }
79
80     Solvable::SplitIdent::SplitIdent( const std::string & ident_r )
81     : _ident( ident_r )
82     { _doSplit( _ident, _kind, _name ); }
83
84     Solvable::SplitIdent::SplitIdent( ResKind kind_r, IdString name_r )
85     : _ident( name_r )
86     , _kind( kind_r )
87     { _doSplit( _ident, _kind, _name ); }
88
89     Solvable::SplitIdent::SplitIdent( ResKind kind_r, const C_Str & name_r )
90     : _ident( name_r )
91     , _kind( kind_r )
92     { _doSplit( _ident, _kind, _name ); }
93
94     /////////////////////////////////////////////////////////////////
95     //  class Solvable
96     /////////////////////////////////////////////////////////////////
97
98     const Solvable Solvable::noSolvable;
99
100     /////////////////////////////////////////////////////////////////
101
102     detail::CSolvable * Solvable::get() const
103     { return myPool().getSolvable( _id ); }
104
105 #define NO_SOLVABLE_RETURN( VAL ) \
106     detail::CSolvable * _solvable( get() ); \
107     if ( ! _solvable ) return VAL
108
109     Solvable Solvable::nextInPool() const
110     { return Solvable( myPool().getNextId( _id ) ); }
111
112     Solvable Solvable::nextInRepo() const
113     {
114       NO_SOLVABLE_RETURN( noSolvable );
115       for ( detail::SolvableIdType next = _id+1; next < unsigned(_solvable->repo->end); ++next )
116       {
117         detail::CSolvable * nextS( myPool().getSolvable( next ) );
118         if ( nextS && nextS->repo == _solvable->repo )
119         {
120           return Solvable( next );
121         }
122       }
123       return noSolvable;
124     }
125
126     std::string Solvable::lookupStrAttribute( const SolvAttr & attr ) const
127     {
128       NO_SOLVABLE_RETURN( std::string() );
129       const char * s = ::solvable_lookup_str( _solvable, attr.id() );
130       return s ? s : std::string();
131     }
132
133     std::string Solvable::lookupStrAttribute( const SolvAttr & attr, const Locale & lang_r ) const
134     {
135       NO_SOLVABLE_RETURN( std::string() );
136       const char * s = 0;
137       if ( !lang_r )
138       {
139         s = ::solvable_lookup_str_poollang( _solvable, attr.id() );
140       }
141       else
142       {
143         for ( Locale l( lang_r ); l; l = l.fallback() )
144           if ( (s = ::solvable_lookup_str_lang( _solvable, attr.id(), l.c_str(), 0 )) )
145             return s;
146           // here: no matching locale, so use default
147           s = ::solvable_lookup_str_lang( _solvable, attr.id(), 0, 0 );
148       }
149       return s ? s : std::string();
150    }
151
152     unsigned long long Solvable::lookupNumAttribute( const SolvAttr & attr ) const
153     {
154       NO_SOLVABLE_RETURN( 0 );
155       return ::solvable_lookup_num( _solvable, attr.id(), 0 );
156     }
157
158     bool Solvable::lookupBoolAttribute( const SolvAttr & attr ) const
159     {
160       NO_SOLVABLE_RETURN( false );
161       return ::solvable_lookup_bool( _solvable, attr.id() );
162     }
163
164     detail::IdType Solvable::lookupIdAttribute( const SolvAttr & attr ) const
165     {
166       NO_SOLVABLE_RETURN( detail::noId );
167       return ::solvable_lookup_id( _solvable, attr.id() );
168     }
169
170     CheckSum Solvable::lookupCheckSumAttribute( const SolvAttr & attr ) const
171     {
172       NO_SOLVABLE_RETURN( CheckSum() );
173       detail::IdType chksumtype = 0;
174       const char * s = ::solvable_lookup_checksum( _solvable, attr.id(), &chksumtype );
175       if ( ! s )
176         return CheckSum();
177       switch ( chksumtype )
178       {
179         case REPOKEY_TYPE_MD5:    return CheckSum::md5( s );
180         case REPOKEY_TYPE_SHA1:   return CheckSum::sha1( s );
181         case REPOKEY_TYPE_SHA224: return CheckSum::sha224( s );
182         case REPOKEY_TYPE_SHA256: return CheckSum::sha256( s );
183         case REPOKEY_TYPE_SHA384: return CheckSum::sha384( s );
184         case REPOKEY_TYPE_SHA512: return CheckSum::sha512( s );
185       }
186       return CheckSum( std::string(), s ); // try to autodetect
187     }
188
189     ///////////////////////////////////////////////////////////////////
190     namespace
191     {
192       inline Pathname lookupDatadirIn( Repository repor_r )
193       {
194         static const SolvAttr susetagsDatadir( "susetags:datadir" );
195         Pathname ret;
196         // First look for repo attribute "susetags:datadir". If not found,
197         // look into the solvables as Code11 libsolv placed it there.
198         LookupRepoAttr datadir( susetagsDatadir, repor_r );
199         if ( ! datadir.empty() )
200           ret = datadir.begin().asString();
201         else
202         {
203           LookupAttr datadir( susetagsDatadir, repor_r );
204           if ( ! datadir.empty() )
205             ret = datadir.begin().asString();
206         }
207         return ret;
208       }
209     } // namespace
210     ///////////////////////////////////////////////////////////////////
211
212     OnMediaLocation Solvable::lookupLocation() const
213     {
214       NO_SOLVABLE_RETURN( OnMediaLocation() );
215       // medianumber and path
216       unsigned medianr;
217       const char * file = ::solvable_lookup_location( _solvable, &medianr );
218       if ( ! file )
219         return OnMediaLocation();
220       if ( ! medianr )
221         medianr = 1;
222
223       OnMediaLocation ret;
224
225       Pathname path;
226       switch ( repository().info().type().toEnum() )
227       {
228         case repo::RepoType::NONE_e:
229         {
230           path = lookupDatadirIn( repository() );
231           if ( ! path.empty() )
232             repository().info().setProbedType( repo::RepoType::YAST2_e );
233         }
234         break;
235
236         case repo::RepoType::YAST2_e:
237         {
238           path = lookupDatadirIn( repository() );
239           if ( path.empty() )
240             path = "suse";
241         }
242         break;
243
244         default:
245           break;
246       }
247       ret.setLocation    ( path/file, medianr );
248       ret.setDownloadSize( ByteCount( lookupNumAttribute( SolvAttr::downloadsize ) ) );
249       ret.setChecksum    ( lookupCheckSumAttribute( SolvAttr::checksum ) );
250       // Not needed/available for solvables?
251       //ret.setOpenSize    ( ByteCount( lookupNumAttribute( SolvAttr::opensize ) ) );
252       //ret.setOpenChecksum( lookupCheckSumAttribute( SolvAttr::openchecksum ) );
253       return ret;
254     }
255
256
257     IdString Solvable::ident() const
258     {
259       NO_SOLVABLE_RETURN( IdString() );
260       return IdString( _solvable->name );
261     }
262
263      ResKind Solvable::kind() const
264     {
265       NO_SOLVABLE_RETURN( ResKind() );
266       // detect srcpackages by 'arch'
267       switch ( _solvable->arch )
268       {
269         case ARCH_SRC:
270         case ARCH_NOSRC:
271           return ResKind::srcpackage;
272           break;
273       }
274
275       // either explicitly prefixed...
276       const char * ident = IdString( _solvable->name ).c_str();
277       ResKind knownKind( ResKind::explicitBuiltin( ident ) );
278       if ( knownKind )
279         return knownKind;
280
281       // ...or no ':' in package names (hopefully)...
282       const char * sep = ::strchr( ident, ':' );
283       if ( ! sep )
284         return ResKind::package;
285
286       // ...or something unknown.
287       return ResKind( std::string( ident, sep-ident ) );
288     }
289
290     bool Solvable::isKind( const ResKind & kind_r ) const
291     {
292       NO_SOLVABLE_RETURN( false );
293
294       // detect srcpackages by 'arch'
295       switch ( _solvable->arch )
296       {
297         case ARCH_SRC:
298         case ARCH_NOSRC:
299           return( kind_r == ResKind::srcpackage );
300           break;
301       }
302
303       // no ':' in package names (hopefully)
304       const char * ident = IdString( _solvable->name ).c_str();
305       if ( kind_r == ResKind::package )
306       {
307         return( ::strchr( ident, ':' ) == 0 );
308       }
309
310       // look for a 'kind:' prefix
311       const char * kind = kind_r.c_str();
312       unsigned     ksize = ::strlen( kind );
313       return( ::strncmp( ident, kind, ksize ) == 0
314               && ident[ksize] == ':' );
315     }
316
317     std::string Solvable::name() const
318     {
319       NO_SOLVABLE_RETURN( std::string() );
320       const char * ident = IdString( _solvable->name ).c_str();
321       const char * sep = ::strchr( ident, ':' );
322       return( sep ? sep+1 : ident );
323     }
324
325     Edition Solvable::edition() const
326     {
327       NO_SOLVABLE_RETURN( Edition() );
328       return Edition( _solvable->evr );
329     }
330
331     Arch Solvable::arch() const
332     {
333       NO_SOLVABLE_RETURN( Arch_noarch ); //ArchId() );
334       switch ( _solvable->arch )
335       {
336         case ARCH_SRC:
337         case ARCH_NOSRC:
338           return Arch_noarch; //ArchId( ARCH_NOARCH );
339           break;
340       }
341       return Arch( IdString(_solvable->arch).asString() );
342       //return ArchId( _solvable->arch );
343     }
344
345     IdString Solvable::vendor() const
346     {
347       NO_SOLVABLE_RETURN( IdString() );
348       return IdString( _solvable->vendor );
349     }
350
351    Repository Solvable::repository() const
352     {
353       NO_SOLVABLE_RETURN( Repository::noRepository );
354       return Repository( _solvable->repo );
355     }
356
357     RepoInfo Solvable::repoInfo() const
358     { return repository().info(); }
359
360
361     bool Solvable::isSystem() const
362     {
363       NO_SOLVABLE_RETURN( _id == detail::systemSolvableId );
364       return myPool().isSystemRepo( _solvable->repo );
365     }
366
367     bool Solvable::onSystemByUser() const
368     {
369       return isSystem() && myPool().isOnSystemByUser( ident() );
370     }
371
372     bool Solvable::multiversionInstall() const
373     {
374       NO_SOLVABLE_RETURN( false );
375       return myPool().isMultiversion( *this );
376     }
377
378     Date Solvable::buildtime() const
379     {
380       NO_SOLVABLE_RETURN( Date() );
381       return Date( lookupNumAttribute( SolvAttr::buildtime ) );
382     }
383
384     Date Solvable::installtime() const
385     {
386       NO_SOLVABLE_RETURN( Date() );
387       return Date( lookupNumAttribute( SolvAttr::installtime ) );
388     }
389
390     std::string Solvable::asString() const
391     {
392       NO_SOLVABLE_RETURN( (_id == detail::systemSolvableId ? "systemSolvable" : "noSolvable") );
393       return str::form( "%s-%s.%s",
394                         IdString( _solvable->name ).c_str(),
395                         IdString( _solvable->evr ).c_str(),
396                         IdString( _solvable->arch ).c_str() );
397     }
398
399     std::string Solvable::asUserString() const\
400     {
401       NO_SOLVABLE_RETURN( (_id == detail::systemSolvableId ? "systemSolvable" : "noSolvable") );
402       return str::form( "%s-%s.%s (%s)",
403                         IdString( _solvable->name ).c_str(),
404                         IdString( _solvable->evr ).c_str(),
405                         IdString( _solvable->arch ).c_str(),
406                         repository().asUserString().c_str() );
407     }
408
409     bool Solvable::identical( const Solvable & rhs ) const
410     {
411       NO_SOLVABLE_RETURN( ! rhs.get() );
412       detail::CSolvable * rhssolvable( rhs.get() );
413       return rhssolvable && ( _solvable == rhssolvable || ::solvable_identical( _solvable, rhssolvable ) );
414     }
415
416     ///////////////////////////////////////////////////////////////////
417     namespace
418     {
419       inline Capabilities _getCapabilities( detail::IdType * idarraydata_r, ::Offset offs_r )
420       {
421         return offs_r ? Capabilities( idarraydata_r + offs_r ) : Capabilities();
422       }
423     } // namespace
424     ///////////////////////////////////////////////////////////////////
425
426     Capabilities Solvable::provides() const
427     {
428       NO_SOLVABLE_RETURN( Capabilities() );
429       return _getCapabilities( _solvable->repo->idarraydata, _solvable->provides );
430     }
431     Capabilities Solvable::requires() const
432     {
433       NO_SOLVABLE_RETURN( Capabilities() );
434       return _getCapabilities( _solvable->repo->idarraydata, _solvable->requires );
435     }
436     Capabilities Solvable::conflicts() const
437     {
438       NO_SOLVABLE_RETURN( Capabilities() );
439       return _getCapabilities( _solvable->repo->idarraydata, _solvable->conflicts );
440     }
441     Capabilities Solvable::obsoletes() const
442     {
443       NO_SOLVABLE_RETURN( Capabilities() );
444       return _getCapabilities( _solvable->repo->idarraydata, _solvable->obsoletes );
445     }
446     Capabilities Solvable::recommends() const
447     {
448       NO_SOLVABLE_RETURN( Capabilities() );
449       return _getCapabilities( _solvable->repo->idarraydata, _solvable->recommends );
450     }
451     Capabilities Solvable::suggests() const
452     {
453       NO_SOLVABLE_RETURN( Capabilities() );
454       return _getCapabilities( _solvable->repo->idarraydata, _solvable->suggests );
455     }
456     Capabilities Solvable::enhances() const
457     {
458       NO_SOLVABLE_RETURN( Capabilities() );
459       return _getCapabilities( _solvable->repo->idarraydata, _solvable->enhances );
460     }
461     Capabilities Solvable::supplements() const
462     {
463       NO_SOLVABLE_RETURN( Capabilities() );
464       return _getCapabilities( _solvable->repo->idarraydata, _solvable->supplements );
465     }
466     Capabilities Solvable::prerequires() const
467     {
468       NO_SOLVABLE_RETURN( Capabilities() );
469       // prerequires are a subset of requires
470        ::Offset offs = _solvable->requires;
471        return offs ? Capabilities( _solvable->repo->idarraydata + offs, detail::solvablePrereqMarker )
472                    : Capabilities();
473     }
474
475     CapabilitySet Solvable::providesNamespace( const std::string & namespace_r ) const
476     {
477       NO_SOLVABLE_RETURN( CapabilitySet() );
478       CapabilitySet ret;
479       Capabilities caps( provides() );
480       for_( it, caps.begin(), caps.end() )
481       {
482         CapDetail caprep( it->detail() );
483         if ( str::hasPrefix( caprep.name().c_str(), namespace_r ) && *(caprep.name().c_str()+namespace_r.size()) == '(' )
484           ret.insert( *it );
485       }
486       return ret;
487     }
488
489     CapabilitySet Solvable::valuesOfNamespace( const std::string & namespace_r ) const
490     {
491       NO_SOLVABLE_RETURN( CapabilitySet() );
492       CapabilitySet ret;
493       Capabilities caps( provides() );
494       for_( it, caps.begin(), caps.end() )
495       {
496         CapDetail caprep( it->detail() );
497         if ( str::hasPrefix( caprep.name().c_str(), namespace_r ) && *(caprep.name().c_str()+namespace_r.size()) == '(' )
498         {
499           std::string value( caprep.name().c_str()+namespace_r.size()+1 );
500           value[value.size()-1] = '\0'; // erase the trailing ')'
501           ret.insert( Capability( value, caprep.op(), caprep.ed() ) );
502         }
503       }
504       return ret;
505     }
506
507     ///////////////////////////////////////////////////////////////////
508     namespace
509     {
510       /** Expand \ref Capability and call \c fnc_r for each namescpace:language
511        * dependency. Return #invocations of fnc_r, negative if fnc_r returned
512        * false to indicate abort.
513        */
514       int invokeOnEachSupportedLocale( Capability cap_r, function<bool (const Locale &)> fnc_r )
515       {
516         CapDetail detail( cap_r );
517         if ( detail.kind() == CapDetail::EXPRESSION )
518         {
519           switch ( detail.capRel() )
520           {
521             case CapDetail::CAP_AND:
522             case CapDetail::CAP_OR:
523                 // expand
524               {
525                 int res = invokeOnEachSupportedLocale( detail.lhs(), fnc_r );
526                 if ( res < 0 )
527                   return res; // negative on abort.
528                 int res2 = invokeOnEachSupportedLocale( detail.rhs(), fnc_r );
529                 if ( res2 < 0 )
530                   return -res + res2; // negative on abort.
531                 return res + res2;
532               }
533               break;
534
535             case CapDetail::CAP_NAMESPACE:
536               if ( detail.lhs().id() == NAMESPACE_LANGUAGE )
537               {
538                 return ( !fnc_r || fnc_r( Locale( IdString(detail.rhs().id()) ) ) ) ? 1 : -1; // negative on abort.
539               }
540               break;
541
542             case CapDetail::REL_NONE:
543             case CapDetail::CAP_WITH:
544             case CapDetail::CAP_ARCH:
545               break; // unwanted
546           }
547         }
548         return 0;
549       }
550
551        /** Expand \ref Capability and call \c fnc_r for each namescpace:language
552        * dependency. Return #invocations of fnc_r, negative if fnc_r returned
553        * false to indicate abort.
554        */
555       inline int invokeOnEachSupportedLocale( Capabilities cap_r, function<bool (Locale)> fnc_r )
556       {
557         int cnt = 0;
558         for_( cit, cap_r.begin(), cap_r.end() )
559         {
560           int res = invokeOnEachSupportedLocale( *cit, fnc_r );
561           if ( res < 0 )
562             return -cnt + res; // negative on abort.
563           cnt += res;
564         }
565         return cnt;
566       }
567       //@}
568
569       // Functor returning false if a Locale is in the set.
570       struct NoMatchIn
571       {
572         NoMatchIn( const LocaleSet & locales_r ) : _locales( locales_r ) {}
573
574         bool operator()( const Locale & locale_r ) const
575         {
576           return _locales.find( locale_r ) == _locales.end();
577         }
578
579         const LocaleSet & _locales;
580       };
581     } // namespace
582     ///////////////////////////////////////////////////////////////////
583
584     bool Solvable::supportsLocales() const
585     {
586       // false_c stops on 1st Locale.
587       return invokeOnEachSupportedLocale( supplements(), functor::false_c() ) < 0;
588     }
589
590     bool Solvable::supportsLocale( const Locale & locale_r ) const
591     {
592       // not_equal_to stops on == Locale.
593       return invokeOnEachSupportedLocale( supplements(), bind( std::not_equal_to<Locale>(), locale_r, _1 ) ) < 0;
594     }
595
596     bool Solvable::supportsLocale( const LocaleSet & locales_r ) const
597     {
598       if ( locales_r.empty() )
599         return false;
600       // NoMatchIn stops if Locale is included.
601       return invokeOnEachSupportedLocale( supplements(), NoMatchIn(locales_r) ) < 0;
602     }
603
604     bool Solvable::supportsRequestedLocales() const
605     { return supportsLocale( myPool().getRequestedLocales() ); }
606
607     LocaleSet Solvable::getSupportedLocales() const
608     {
609       LocaleSet ret;
610       invokeOnEachSupportedLocale( supplements(), functor::collector( std::inserter( ret, ret.begin() ) ) );
611       return ret;
612     }
613
614     CpeId Solvable::cpeId() const
615     {
616       NO_SOLVABLE_RETURN( CpeId() );
617       return CpeId( lookupStrAttribute( SolvAttr::cpeid ), CpeId::noThrow );
618     }
619
620     unsigned Solvable::mediaNr() const
621     {
622       NO_SOLVABLE_RETURN( 0U );
623       return lookupNumAttribute( SolvAttr::medianr );
624     }
625
626     ByteCount Solvable::installSize() const
627     {
628       NO_SOLVABLE_RETURN( ByteCount() );
629       return ByteCount( lookupNumAttribute( SolvAttr::installsize ) );
630     }
631
632     ByteCount Solvable::downloadSize() const
633     {
634       NO_SOLVABLE_RETURN( ByteCount() );
635       return ByteCount( lookupNumAttribute( SolvAttr::downloadsize ) );
636     }
637
638     std::string Solvable::distribution() const
639     {
640       NO_SOLVABLE_RETURN( std::string() );
641       return lookupStrAttribute( SolvAttr::distribution );
642     }
643
644     std::string Solvable::summary( const Locale & lang_r ) const
645     {
646       NO_SOLVABLE_RETURN( std::string() );
647       return lookupStrAttribute( SolvAttr::summary, lang_r );
648     }
649
650     std::string Solvable::description( const Locale & lang_r ) const
651     {
652       NO_SOLVABLE_RETURN( std::string() );
653       return lookupStrAttribute( SolvAttr::description, lang_r );
654     }
655
656     std::string Solvable::insnotify( const Locale & lang_r ) const
657     {
658       NO_SOLVABLE_RETURN( std::string() );
659       return lookupStrAttribute( SolvAttr::insnotify, lang_r );
660     }
661
662     std::string Solvable::delnotify( const Locale & lang_r ) const
663     {
664       NO_SOLVABLE_RETURN( std::string() );
665       return lookupStrAttribute( SolvAttr::delnotify, lang_r );
666     }
667
668     std::string Solvable::licenseToConfirm( const Locale & lang_r ) const
669     {
670       NO_SOLVABLE_RETURN( std::string() );
671       std::string ret = lookupStrAttribute( SolvAttr::eula, lang_r );
672       if ( ret.empty() && isKind<Product>() )
673       {
674         const RepoInfo & ri( repoInfo() );
675         if ( ri.needToAcceptLicense() || ! ui::Selectable::get( *this )->hasInstalledObj() )
676           ret = ri.getLicense( lang_r ); // bnc#908976: suppress informal license upon update
677       }
678       return ret;
679     }
680
681     bool Solvable::needToAcceptLicense() const
682     {
683       NO_SOLVABLE_RETURN( false );
684       return ( isKind<Product>() ? repoInfo().needToAcceptLicense() : true );
685     }
686
687
688     std::ostream & operator<<( std::ostream & str, const Solvable & obj )
689     {
690       if ( ! obj )
691         return str << (obj.isSystem() ? "systemSolvable" : "noSolvable" );
692
693       return str << "(" << obj.id() << ")"
694           << ( obj.isKind( ResKind::srcpackage ) ? "srcpackage:" : "" ) << obj.ident()
695           << '-' << obj.edition() << '.' << obj.arch() << "("
696           << obj.repository().alias() << ")";
697     }
698
699     std::ostream & dumpOn( std::ostream & str, const Solvable & obj )
700     {
701       str << obj;
702       if ( obj )
703       {
704 #define OUTS(X) if ( ! obj[Dep::X].empty() ) str << endl << " " #X " " << obj[Dep::X]
705         OUTS(PROVIDES);
706         OUTS(PREREQUIRES);
707         OUTS(REQUIRES);
708         OUTS(CONFLICTS);
709         OUTS(OBSOLETES);
710         OUTS(RECOMMENDS);
711         OUTS(SUGGESTS);
712         OUTS(ENHANCES);
713         OUTS(SUPPLEMENTS);
714 #undef OUTS
715       }
716       return str;
717     }
718
719     std::ostream & dumpAsXmlOn( std::ostream & str, const Solvable & obj )
720     {
721       xmlout::Node guard( str, "solvable" );
722
723       dumpAsXmlOn( *guard, obj.kind() );
724       *xmlout::Node( *guard, "name" ) << obj.name();
725       dumpAsXmlOn( *guard, obj.edition() );
726       dumpAsXmlOn( *guard, obj.arch() );
727       dumpAsXmlOn( *guard, obj.repository() );
728       return str;
729     }
730
731   } // namespace sat
732   ///////////////////////////////////////////////////////////////////
733 } // namespace zypp
734 ///////////////////////////////////////////////////////////////////