libzypp 17.38.15
PoolImpl.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#include <algorithm>
13#include <iostream>
14#include <fstream>
15#include <boost/mpl/int.hpp>
16#include <boost/mpl/assert.hpp>
17
18#include <zypp-core/base/Easy.h>
22#include <zypp/base/Measure.h>
23#include <zypp-core/fs/WatchFile>
24#include <zypp-core/parser/Sysconfig>
26
27#include <zypp/ZConfig.h>
28
30extern "C"
31{
32#include <solv/pool_snapshot.h>
33}
37#include <zypp/sat/Pool.h>
38#include <zypp/Capability.h>
39#include <zypp/Locale.h>
40#include <zypp/PoolItem.h>
41
44
45extern "C"
46{
47// Workaround libsolv project not providing a common include
48// directory. (the -devel package does, but the git repo doesn't).
49// #include <solv/repo_helix.h>
50// #include <solv/testcase.h>
51int repo_add_helix( ::Repo *repo, FILE *fp, int flags );
52int testcase_add_testtags(Repo *repo, FILE *fp, int flags);
53}
54
55using std::endl;
56
57#undef ZYPP_BASE_LOGGER_LOGGROUP
58#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::satpool"
59
60// ///////////////////////////////////////////////////////////////////
61namespace zypp
62{
64 namespace env
65 {
67 inline int LIBSOLV_DEBUGMASK()
68 {
69 const char * envp = getenv("LIBSOLV_DEBUGMASK");
70 return envp ? str::strtonum<int>( envp ) : 0;
71 }
72
75 inline bool ZYPP_POOL_SNAPSHOT()
76 {
77 const char * envp = getenv("ZYPP_POOL_SNAPSHOT");
78 return !( envp && strcmp( envp, "0" ) == 0 );
79 }
80 } // namespace env
82 namespace sat
83 {
84
86 namespace detail
87 {
88
89 // MPL checks for satlib constants we redefine to avoid
90 // includes and defines.
91 BOOST_MPL_ASSERT_RELATION( noId, ==, STRID_NULL );
92 BOOST_MPL_ASSERT_RELATION( emptyId, ==, STRID_EMPTY );
93
94 BOOST_MPL_ASSERT_RELATION( noSolvableId, ==, ID_NULL );
95 BOOST_MPL_ASSERT_RELATION( systemSolvableId, ==, SYSTEMSOLVABLE );
96
97 BOOST_MPL_ASSERT_RELATION( solvablePrereqMarker, ==, SOLVABLE_PREREQMARKER );
98 BOOST_MPL_ASSERT_RELATION( solvableFileMarker, ==, SOLVABLE_FILEMARKER );
99
109
110 BOOST_MPL_ASSERT_RELATION( namespaceModalias, ==, NAMESPACE_MODALIAS );
111 BOOST_MPL_ASSERT_RELATION( namespaceLanguage, ==, NAMESPACE_LANGUAGE );
112 BOOST_MPL_ASSERT_RELATION( namespaceFilesystem, ==, NAMESPACE_FILESYSTEM );
113
115
116 const std::string & PoolImpl::systemRepoAlias()
117 {
118 static const std::string _val( "@System" );
119 return _val;
120 }
121
123 {
124 static const Pathname _val( "/etc/sysconfig/storage" );
125 return _val;
126 }
127
129
130 static void logSat( CPool *, void *data, int type, const char *logString )
131 {
132 // "1234567890123456789012345678901234567890
133 if ( 0 == strncmp( logString, "job: drop orphaned", 18 ) )
134 return;
135 if ( 0 == strncmp( logString, "job: user installed", 19 ) )
136 return;
137 if ( 0 == strncmp( logString, "job: multiversion", 17 ) )
138 return;
139 if ( 0 == strncmp( logString, " - no rule created", 19 ) )
140 return;
141 if ( 0 == strncmp( logString, " next rules: 0 0", 19 ) )
142 return;
143
144 if ( type & (SOLV_FATAL|SOLV_ERROR) ) {
145 L_ERR("libsolv") << logString;
146 } else if ( type & SOLV_DEBUG_STATS ) {
147 L_DBG("libsolv") << logString;
148 } else {
149 L_MIL("libsolv") << logString;
150 }
151 }
152
154 {
155 // lhs: the namespace identifier, e.g. NAMESPACE:MODALIAS
156 // rhs: the value, e.g. pci:v0000104Cd0000840[01]sv*sd*bc*sc*i*
157 // return: 0 if not supportded
158 // 1 if supported by the system
159 // -1 AFAIK it's also possible to return a list of solvables that support it, but don't know how.
160
161 static const detail::IdType RET_unsupported = 0;
162 static const detail::IdType RET_systemProperty = 1;
163 switch ( lhs )
164 {
165 case NAMESPACE_LANGUAGE:
166 {
167 const TrackedLocaleIds & localeIds( reinterpret_cast<PoolImpl*>(data)->trackedLocaleIds() );
168 return localeIds.contains( IdString(rhs) ) ? RET_systemProperty : RET_unsupported;
169 }
170 break;
171
172 case NAMESPACE_MODALIAS:
173 {
174 // modalias strings in capability may be hexencoded because rpm does not allow
175 // ',', ' ' or other special chars.
176 return target::Modalias::instance().query( str::hexdecode( IdString(rhs).c_str() ) )
177 ? RET_systemProperty
178 : RET_unsupported;
179 }
180 break;
181
182 case NAMESPACE_FILESYSTEM:
183 {
184 const std::set<std::string> & requiredFilesystems( reinterpret_cast<PoolImpl*>(data)->requiredFilesystems() );
185 return requiredFilesystems.find( IdString(rhs).asString() ) != requiredFilesystems.end() ? RET_systemProperty : RET_unsupported;
186 }
187 break;
188
189 }
190
191 WAR << "Unhandled " << Capability( lhs ) << " vs. " << Capability( rhs ) << endl;
192 return RET_unsupported;
193 }
194
196 //
197 // METHOD NAME : PoolImpl::PoolImpl
198 // METHOD TYPE : Ctor
199 //
201 : _pool( zyppng::sat::StringPool::instance().getPool() )
202 {
203 // libzypp#726: ::pool_setdisttype(_pool, DISTTYPE_RPM )
204 // is already set by the StringPool::instance because the
205 // disttype affects the version string comparison.
206
207 // initialialize logging
209 {
210 ::pool_setdebugmask(_pool, env::LIBSOLV_DEBUGMASK() );
211 }
212 else
213 {
214 if ( getenv("ZYPP_LIBSOLV_FULLLOG") || getenv("ZYPP_LIBSAT_FULLLOG") )
215 ::pool_setdebuglevel( _pool, 3 );
216 else if ( getenv("ZYPP_FULLLOG") )
217 ::pool_setdebuglevel( _pool, 2 );
218 else
219 ::pool_setdebugmask(_pool, SOLV_DEBUG_JOB|SOLV_DEBUG_STATS );
220 }
221
222 ::pool_setdebugcallback( _pool, logSat, NULL );
223
224 // We keep interning ids after the pool is built (locales, queries,
225 // PoolItems), and pool_createwhatprovides would drop the hashes just
226 // before that, making the next lookup rebuild them for every string.
227 ::pool_set_flag( _pool, POOL_FLAG_KEEPIDHASHES, 1 );
228
229 // Unifying the whatprovides data sorts every id that has providers,
230 // which costs more than the few MB of data it saves us. With the
231 // pool snapshot the trade turns around: the index is stored in and
232 // restored from the snapshot, so the writer pays the sort once and
233 // every mapped run copies an eightfold smaller index.
234 if ( ! env::ZYPP_POOL_SNAPSHOT() )
235 ::pool_set_flag( _pool, POOL_FLAG_NOWHATPROVIDESSHRINK, 1 );
236
237 // set namespace callback
238 _pool->nscallback = &nsCallback;
239 _pool->nscallbackdata = (void*)this;
240
241 // CAVEAT: We'd like to do it here, but in side the Pool ctor we can not
242 // yet use IdString types. We do in setDirty, when the 1st
243 // _retractedSpec.addProvides( Capability( Solvable::retractedToken.id() ) );
244 // _ptfMasterSpec.addProvides( Capability( Solvable::ptfMasterToken.id() ) );
245 // _ptfPackageSpec.addProvides( Capability( Solvable::ptfPackageToken.id() ) );
246 _retractedSpec.addIdenticalInstalledToo( true ); // retracted indicator is not part of the package!
247 }
248
250 //
251 // METHOD NAME : PoolImpl::~PoolImpl
252 // METHOD TYPE : Dtor
253 //
255 {
256 }
257
259
260 void PoolImpl::setDirty( const char * a1, const char * a2, const char * a3 )
261 {
262 if ( _retractedSpec.empty() ) {
263 // lazy init IdString types we can not use inside the ctor
267 }
268
269 if ( a1 )
270 {
271 if ( a3 ) MIL << a1 << " " << a2 << " " << a3 << endl;
272 else if ( a2 ) MIL << a1 << " " << a2 << endl;
273 else MIL << a1 << endl;
274 }
275 _serial.setDirty(); // pool content change
276 _availableLocalesPtr.reset(); // available locales may change
277 _multiversionListPtr.reset(); // re-evaluate ZConfig::multiversionSpec.
278 _needrebootSpec.setDirty(); // re-evaluate needrebootSpec
279
280 _retractedSpec.setDirty(); // re-evaluate blacklisted spec
281 _ptfMasterSpec.setDirty(); // --"--
282 _ptfPackageSpec.setDirty(); // --"--
283
284 depSetDirty(); // invaldate dependency/namespace related indices
285 }
286
287 void PoolImpl::localeSetDirty( const char * a1, const char * a2, const char * a3 )
288 {
289 if ( a1 )
290 {
291 if ( a3 ) MIL << a1 << " " << a2 << " " << a3 << endl;
292 else if ( a2 ) MIL << a1 << " " << a2 << endl;
293 else MIL << a1 << endl;
294 }
295 _trackedLocaleIdsPtr.reset(); // requested locales changed
296 depSetDirty(); // invaldate dependency/namespace related indices
297 }
298
299 void PoolImpl::depSetDirty( const char * a1, const char * a2, const char * a3 )
300 {
301 if ( a1 )
302 {
303 if ( a3 ) MIL << a1 << " " << a2 << " " << a3 << endl;
304 else if ( a2 ) MIL << a1 << " " << a2 << endl;
305 else MIL << a1 << endl;
306 }
307 ::pool_freewhatprovides( _pool );
308 }
309
310 bool PoolImpl::mapSnapshot( const Pathname & path_r, const std::string & cookie_r )
311 {
312 AutoFILE fp { ::fopen( path_r.c_str(), "re" ) };
313 if ( !fp )
314 return false;
315 unsigned char buf[4096];
316 unsigned int len = sizeof(buf);
317 if ( ::pool_snapshot_read_cookie( fp, buf, &len ) != 0
318 || cookie_r != std::string( reinterpret_cast<char*>(buf), len ) )
319 {
320 MIL << "Pool snapshot " << path_r << " is stale" << endl;
321 return false;
322 }
323 // Invalidate before mapping: afterwards it would free the
324 // whatprovides index restored from the snapshot.
325 setDirty( "mapSnapshot", path_r.c_str() );
326 int res = ::pool_snapshot_map( _pool, fp );
327 if ( res == -2 )
328 {
329 // Another client's pre-load interned ids differ from ours.
330 // The file is fine for that client: fall back, but do not
331 // rewrite it, or the two of us would take turns clobbering
332 // each other's snapshot on every run.
333 MIL << "Pool snapshot " << path_r << " belongs to a different client, not replacing it" << endl;
334 _snapshotCookie.clear();
335 return false;
336 }
337 if ( res != 0 )
338 {
339 WAR << "Pool snapshot " << path_r << " failed to map" << endl;
340 return false;
341 }
342 MIL << "Mapped pool snapshot " << path_r << endl;
343 {
344 // wire up the system repo like _createRepo would; a no-op
345 // where the snapshot already restored pool->installed
346 CPool * pool = _pool;
347 ::Repo * repo;
348 int i;
349 FOR_REPOS( i, repo )
350 if ( repo->name && systemRepoAlias() == repo->name )
351 {
352 ::pool_set_installed( _pool, repo );
353 // autoprovide the dummy RepoInfo Pool::reposInsert would
354 // have attached when creating the system repo; assigned
355 // directly as setRepoInfo's priority sync might setDirty,
356 // freeing the whatprovides index just restored
358 info.setAlias( systemRepoAlias() );
359 info.setName( systemRepoAlias() );
360 info.setAutorefresh( true );
361 info.setEnabled( true );
363 }
364 // The application claims the repos it wants via setRepoInfo;
365 // whatever stays unclaimed is erased in prepare(). Otherwise
366 // e.g. 'zypper --repo foo' would silently operate on the
367 // whole snapshot instead of just foo.
368 _snapshotUnclaimed.clear();
369 FOR_REPOS( i, repo )
370 if ( repo != pool->installed )
371 _snapshotUnclaimed.insert( repo );
372 }
373 return true;
374 }
375
377 {
378 if ( _snapshotCookie.empty() || Pool::snapshotMapped() )
379 return;
380 // the pool must contain exactly the repo set the cookie was
381 // computed for, e.g. no temporary cli repos
382 std::vector<std::string> aliases;
383 CPool * pool = _pool;
384 ::Repo * repo;
385 int i;
386 FOR_REPOS( i, repo )
387 aliases.push_back( repo->name ? repo->name : "" );
388 std::sort( aliases.begin(), aliases.end() );
389 if ( aliases != _snapshotAliases )
390 {
391 MIL << "Not writing pool snapshot: pool does not match the known repos" << endl;
392 _snapshotCookie.clear();
393 return;
394 }
395 // no staleness check: reaching this point means the snapshot
396 // was not mapped although the repo set qualifies, e.g. it is
397 // missing, stale, or a referenced solv file changed
399 _snapshotCookie.clear(); // once per process
400 }
401
402 void PoolImpl::prepare() const
403 {
404 if ( ! _snapshotUnclaimed.empty() )
405 {
406 // Snapshot repos the application never claimed in this run
407 // (e.g. zypper --repo limits the repo set): erase them so the
408 // pool matches what was actually requested.
409 std::set<RepoIdType> unclaimed;
410 unclaimed.swap( _snapshotUnclaimed );
411 for ( CRepo * repo : unclaimed )
412 {
413 MIL << "Erase unclaimed snapshot repo " << ( repo->name ? repo->name : "" ) << endl;
414 const_cast<PoolImpl*>(this)->_deleteRepo( repo );
415 }
416 }
417 // additional /etc/sysconfig/storage check:
418 static WatchFile sysconfigFile( sysconfigStoragePath(), WatchFile::NO_INIT );
419 if ( sysconfigFile.hasChanged() )
420 {
421 _requiredFilesystemsPtr.reset(); // recreated on demand
422 const_cast<PoolImpl*>(this)->depSetDirty( "/etc/sysconfig/storage change" );
423 }
424 if ( _watcher.remember( _serial ) )
425 {
426 // After repo/solvable add/remove:
427 // set pool architecture
428 ::pool_setarch( _pool, ZConfig::instance().systemArchitecture().asString().c_str() );
429 }
430 if ( ! _pool->whatprovides )
431 {
432 MIL << "pool_createwhatprovides..." << endl;
433
434 if ( ! Pool::snapshotMapped() ) // a mapped snapshot already contains them
435 ::pool_addfileprovides( _pool );
436 ::pool_createwhatprovides( _pool );
438 }
439 if ( ! _pool->languages )
440 {
441 // initial seting
442 const_cast<PoolImpl*>(this)->setTextLocale( ZConfig::instance().textLocale() );
443 }
444 }
445
447
448 CRepo * PoolImpl::_createRepo( const std::string & name_r )
449 {
450 setDirty(__FUNCTION__, name_r.c_str() );
451 CRepo * ret = ::repo_create( _pool, name_r.c_str() );
452 if ( ret && name_r == systemRepoAlias() )
453 ::pool_set_installed( _pool, ret );
454 return ret;
455 }
456
458 {
459 setDirty(__FUNCTION__, repo_r->name );
460 _snapshotUnclaimed.erase( repo_r ); // pointer must not dangle
461 if ( isSystemRepo( repo_r ) )
462 _autoinstalled.clear();
463 eraseRepoInfo( repo_r );
464 ::repo_free( repo_r, /*resusePoolIDs*/false );
465 // If the last repo is removed clear the pool to actually reuse all IDs.
466 // NOTE: the explicit ::repo_free above asserts all solvables are memset(0)!
467 if ( !_pool->urepos )
468 {
469 _serialIDs.setDirty(); // Indicate resusePoolIDs - ResPool must also invalidate its PoolItems
470 ::pool_freeallrepos( _pool, /*resusePoolIDs*/true );
471 }
472 }
473
474 int PoolImpl::_addSolv( CRepo * repo_r, FILE * file_r )
475 {
476 setDirty(__FUNCTION__, repo_r->name );
477 int ret = ::repo_add_solv( repo_r, file_r, 0 );
478 if ( ret == 0 )
479 _postRepoAdd( repo_r );
480 return ret;
481 }
482
483 int PoolImpl::_addHelix( CRepo * repo_r, FILE * file_r )
484 {
485 setDirty(__FUNCTION__, repo_r->name );
486 int ret = ::repo_add_helix( repo_r, file_r, 0 );
487 if ( ret == 0 )
488 _postRepoAdd( repo_r );
489 return 0;
490 }
491
492 int PoolImpl::_addTesttags(CRepo *repo_r, FILE *file_r)
493 {
494 setDirty(__FUNCTION__, repo_r->name );
495 int ret = ::testcase_add_testtags( repo_r, file_r, 0 );
496 if ( ret == 0 )
497 _postRepoAdd( repo_r );
498 return 0;
499 }
500
502 {
503 if ( ! isSystemRepo( repo_r ) )
504 {
505 // Filter out unwanted archs
506 std::set<detail::IdType> sysids;
507 {
508 Arch::CompatSet sysarchs( Arch::compatSet( ZConfig::instance().systemArchitecture() ) );
509 for_( it, sysarchs.begin(), sysarchs.end() )
510 sysids.insert( it->id() );
511
512 // unfortunately libsolv treats src/nosrc as architecture:
513 sysids.insert( ARCH_SRC );
514 sysids.insert( ARCH_NOSRC );
515 }
516
517 detail::IdType blockBegin = 0;
518 unsigned blockSize = 0;
519 for ( detail::IdType i = repo_r->start; i < repo_r->end; ++i )
520 {
521 CSolvable * s( _pool->solvables + i );
522 if ( s->repo == repo_r && sysids.find( s->arch ) == sysids.end() )
523 {
524 // Remember an unwanted arch entry:
525 if ( ! blockBegin )
526 blockBegin = i;
527 ++blockSize;
528 }
529 else if ( blockSize )
530 {
531 // Free remembered entries
532 ::repo_free_solvable_block( repo_r, blockBegin, blockSize, /*resusePoolIDs*/false );
533 blockBegin = blockSize = 0;
534 }
535 }
536 if ( blockSize )
537 {
538 // Free remembered entries
539 ::repo_free_solvable_block( repo_r, blockBegin, blockSize, /*resusePoolIDs*/false );
540 blockBegin = blockSize = 0;
541 }
542 }
543 }
544
546 {
547 setDirty(__FUNCTION__, repo_r->name );
548 return ::repo_add_solvable_block( repo_r, count_r );
549 }
550
551 void PoolImpl::setRepoInfo( RepoIdType id_r, const RepoInfo & info_r )
552 {
553 _snapshotUnclaimed.erase( id_r ); // this run wants the repo
554 CRepo * repo( getRepo( id_r ) );
555 if ( repo )
556 {
557 bool dirty = false;
558
559 // libsolv priority is based on '<', while yum's repoinfo
560 // uses 1(highest)->99(lowest). Thus we use -info_r.priority.
561 if ( repo->priority != int(-info_r.priority()) )
562 {
563 repo->priority = -info_r.priority();
564 dirty = true;
565 }
566
567 // subpriority is used to e.g. prefer http over dvd iff
568 // both have same priority.
569 int mediaPriority( media::MediaPriority( info_r.url() ) );
570 if ( repo->subpriority != mediaPriority )
571 {
572 repo->subpriority = mediaPriority;
573 dirty = true;
574 }
575
576 if ( dirty )
577 setDirty(__FUNCTION__, info_r.alias().c_str() );
578 }
579 _repoinfos[id_r] = info_r;
580 }
581
583
584 void PoolImpl::setTextLocale( const Locale & locale_r )
585 {
586 if ( ! locale_r )
587 {
588 // We need one, so "en" is the last resort
589 const char *needone[] { "en" };
590 ::pool_set_languages( _pool, needone, 1 );
591 return;
592 }
593
594 std::vector<std::string> fallbacklist;
595 for ( Locale l( locale_r ); l; l = l.fallback() )
596 {
597 fallbacklist.push_back( l.code() );
598 }
599 dumpRangeLine( MIL << "pool_set_languages: ", fallbacklist.begin(), fallbacklist.end() ) << endl;
600
601 std::vector<const char *> fallbacklist_cstr;
602 for_( it, fallbacklist.begin(), fallbacklist.end() )
603 {
604 fallbacklist_cstr.push_back( it->c_str() );
605 }
606 ::pool_set_languages( _pool, &fallbacklist_cstr.front(), fallbacklist_cstr.size() );
607 }
608
610 {
611 if ( _requestedLocalesTracker.setInitial( locales_r ) )
612 {
613 localeSetDirty( "initRequestedLocales" );
614 MIL << "Init RequestedLocales: " << _requestedLocalesTracker << " =" << locales_r << endl;
615 }
616 }
617
618 void PoolImpl::setRequestedLocales( const LocaleSet & locales_r )
619 {
620 if ( _requestedLocalesTracker.set( locales_r ) )
621 {
622 localeSetDirty( "setRequestedLocales" );
623 MIL << "New RequestedLocales: " << _requestedLocalesTracker << " =" << locales_r << endl;
624 }
625 }
626
627 bool PoolImpl::addRequestedLocale( const Locale & locale_r )
628 {
629 bool done = _requestedLocalesTracker.add( locale_r );
630 if ( done )
631 {
632 localeSetDirty( "addRequestedLocale", locale_r.code().c_str() );
633 MIL << "New RequestedLocales: " << _requestedLocalesTracker << " +" << locale_r << endl;
634 }
635 return done;
636 }
637
638 bool PoolImpl::eraseRequestedLocale( const Locale & locale_r )
639 {
640 bool done = _requestedLocalesTracker.remove( locale_r );
641 if ( done )
642 {
643 localeSetDirty( "eraseRequestedLocale", locale_r.code().c_str() );
644 MIL << "New RequestedLocales: " << _requestedLocalesTracker << " -" << locale_r << endl;
645 }
646 return done;
647 }
648
649
651 {
652 if ( ! _trackedLocaleIdsPtr )
653 {
655
658
659 // Add current locales+fallback except for added ones
660 for ( Locale lang: localesTracker.current() )
661 {
662 if ( localesTracker.wasAdded( lang ) )
663 continue;
664 for ( ; lang; lang = lang.fallback() )
665 { localeIds.current().insert( IdString(lang) ); }
666 }
667
668 // Add added locales+fallback except they are already in current
669 for ( Locale lang: localesTracker.added() )
670 {
671 for ( ; lang && localeIds.current().insert( IdString(lang) ).second; lang = lang.fallback() )
672 { localeIds.added().insert( IdString(lang) ); }
673 }
674
675 // Add removed locales+fallback except they are still in current
676 for ( Locale lang: localesTracker.removed() )
677 {
678 for ( ; lang && ! localeIds.current().count( IdString(lang) ); lang = lang.fallback() )
679 { localeIds.removed().insert( IdString(lang) ); }
680 }
681
682 // bsc#1155678: We try to differ between an empty RequestedLocales
683 // and one containing 'en' (explicit or as fallback). An empty RequestedLocales
684 // should not even drag in recommended 'en' packages. So we no longer enforce
685 // 'en' being in the set.
686 }
687 return *_trackedLocaleIdsPtr;
688 }
689
690
691 static void _getLocaleDeps( const Capability & cap_r, LocaleSet & store_r )
692 {
693 // Collect locales from any 'namespace:language(lang)' dependency
694 CapDetail detail( cap_r );
695 if ( detail.kind() == CapDetail::EXPRESSION )
696 {
697 switch ( detail.capRel() )
698 {
701 // expand
702 _getLocaleDeps( detail.lhs(), store_r );
703 _getLocaleDeps( detail.rhs(), store_r );
704 break;
705
707 if ( detail.lhs().id() == NAMESPACE_LANGUAGE )
708 {
709 store_r.insert( Locale( IdString(detail.rhs().id()) ) );
710 }
711 break;
712
713 default:
714 break; // unwanted
715 }
716 }
717 }
718
720 {
722 {
723 _availableLocalesPtr.reset( new LocaleSet );
724 LocaleSet & localeSet( *_availableLocalesPtr );
725
726 for ( const Solvable & pi : Pool::instance().solvables() )
727 {
728 for ( const Capability & cap : pi.dep_supplements() )
729 {
730 _getLocaleDeps( cap, localeSet );
731 }
732 }
733 }
734 return *_availableLocalesPtr;
735 }
736
738
740 {
743
745 for ( const std::string & spec : ZConfig::instance().multiversionSpec() )
746 {
747 static const std::string prefix( "provides:" );
748 bool provides = str::hasPrefix( spec, prefix );
749
750 for ( Solvable solv : WhatProvides( Capability( provides ? spec.c_str() + prefix.size() : spec.c_str() ) ) )
751 {
752 if ( provides || solv.ident() == spec )
753 multiversionList.insert( solv );
754 }
755
757 MIL << "Multiversion install " << spec << ": " << (nsize-size) << " matches" << endl;
758 size = nsize;
759 }
760 }
761
764
771
772 bool PoolImpl::isMultiversion( const Solvable & solv_r ) const
773 { return multiversionList().contains( solv_r ); }
774
776
777 const std::set<std::string> & PoolImpl::requiredFilesystems() const
778 {
780 {
781 _requiredFilesystemsPtr.reset( new std::set<std::string> );
782 std::set<std::string> & requiredFilesystems( *_requiredFilesystemsPtr );
784 std::inserter( requiredFilesystems, requiredFilesystems.end() ) );
785 }
787 }
788
790 } // namespace detail
791
793 } // namespace sat
796} // namespace zypp
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition Easy.h:27
#define L_ERR(GROUP)
Definition Logger.h:141
#define MIL
Definition Logger.h:130
#define WAR
Definition Logger.h:131
#define L_MIL(GROUP)
Definition Logger.h:139
#define L_DBG(GROUP)
Definition Logger.h:138
static CompatSet compatSet(const Arch &targetArch_r)
Return a set of all Arch's compatibleWith a targetArch_r.
Definition Arch.cc:793
std::set< Arch, CompareByGT< Arch > > CompatSet
Reversed arch order, best Arch first.
Definition Arch.h:122
Helper providing more detailed information about a Capability.
Definition Capability.h:366
A sat capability.
Definition Capability.h:63
@ CAP_WITHOUT
without
Definition Capability.h:161
@ CAP_ARCH
Used internally.
Definition Capability.h:164
Access to the sat-pools string space.
Definition IdString.h:55
'Language[_Country]' codes.
Definition Locale.h:51
Locale fallback() const
Return the fallback locale for this locale, if no fallback exists the empty Locale::noCode.
Definition Locale.cc:211
std::string code() const
Return the locale code asString.
Definition Locale.h:89
What is known about a repository.
Definition RepoInfo.h:72
Url url() const
Pars pro toto: The first repository url, this is either baseUrls().front() or if no baseUrl is define...
Definition RepoInfo.cc:894
unsigned priority() const
Repository priority for solver.
Definition RepoInfo.cc:600
Remember a files attributes to detect content changes.
Definition watchfile.h:50
bool hasChanged()
Definition watchfile.h:80
static ZConfig & instance()
Singleton ctor.
Definition ZConfig.cc:794
const char * c_str() const
String representation.
Definition Pathname.h:113
Derive a numeric priority from Url scheme according to zypp.conf(download.media_preference).
std::string alias() const
unique identifier for this source.
static Pool instance()
Singleton ctor.
Definition Pool.h:56
bool writeSnapshot(const Pathname &path_r, const std::string &cookie_r) const
Definition Pool.cc:223
static bool snapshotMapped()
Whether mapSnapshot succeeded in this process.
Definition Pool.cc:195
Container::size_type size_type
Definition SolvableSet.h:42
bool contains(const TSolv &solv_r) const
Definition SolvableSet.h:68
A Solvable object within the sat Pool.
Definition Solvable.h:54
static const IdString ptfMasterToken
Indicator provides ptf()
Definition Solvable.h:62
static const IdString ptfPackageToken
Indicator provides ptf-package()
Definition Solvable.h:63
static const IdString retractedToken
Indicator provides retracted-patch-package()
Definition Solvable.h:61
Container of Solvable providing a Capability (read only).
sat::SolvableSpec _needrebootSpec
Solvables which should trigger the reboot-needed hint if installed/updated.
Definition PoolImpl.h:403
scoped_ptr< TrackedLocaleIds > _trackedLocaleIdsPtr
Definition PoolImpl.h:391
std::string _snapshotCookie
Experimental pool snapshot (see Pool::mapSnapshot)
Definition PoolImpl.h:374
base::SetTracker< IdStringSet > TrackedLocaleIds
Definition PoolImpl.h:302
CPool * getPool() const
Definition PoolImpl.h:184
sat::SolvableSpec _retractedSpec
Blacklisted specs:
Definition PoolImpl.h:406
scoped_ptr< LocaleSet > _availableLocalesPtr
Definition PoolImpl.h:393
scoped_ptr< MultiversionList > _multiversionListPtr
Definition PoolImpl.h:397
bool isSystemRepo(CRepo *repo_r) const
Definition PoolImpl.h:113
static detail::IdType nsCallback(CPool *, void *data, detail::IdType lhs, detail::IdType rhs)
Callback to resolve namespace dependencies (language, modalias, filesystem, etc.).
Definition PoolImpl.cc:153
CRepo * getRepo(RepoIdType id_r) const
Definition PoolImpl.h:188
void setTextLocale(const Locale &locale_r)
Definition PoolImpl.cc:584
void initRequestedLocales(const LocaleSet &locales_r)
Start tracking changes based on this locales_r.
Definition PoolImpl.cc:609
sat::StringQueue _autoinstalled
Definition PoolImpl.h:400
int _addTesttags(CRepo *repo_r, FILE *file_r)
Adding testtags file to a repo.
Definition PoolImpl.cc:492
void multiversionListInit() const
Definition PoolImpl.cc:739
const LocaleSet & getAvailableLocales() const
All Locales occurring in any repo.
Definition PoolImpl.cc:719
std::map< RepoIdType, RepoInfo > _repoinfos
Additional RepoInfo.
Definition PoolImpl.h:386
void _deleteRepo(CRepo *repo_r)
Delete repo repo_r from pool.
Definition PoolImpl.cc:457
bool eraseRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition PoolImpl.cc:638
sat::SolvableSpec _ptfMasterSpec
Definition PoolImpl.h:407
void eraseRepoInfo(RepoIdType id_r)
Definition PoolImpl.h:236
const TrackedLocaleIds & trackedLocaleIds() const
Expanded _requestedLocalesTracker for solver.
Definition PoolImpl.cc:650
void localeSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate locale related housekeeping data.
Definition PoolImpl.cc:287
scoped_ptr< std::set< std::string > > _requiredFilesystemsPtr
filesystems mentioned in /etc/sysconfig/storage
Definition PoolImpl.h:411
base::SetTracker< LocaleSet > _requestedLocalesTracker
Definition PoolImpl.h:390
void setRequestedLocales(const LocaleSet &locales_r)
User change (tracked).
Definition PoolImpl.cc:618
std::vector< std::string > _snapshotAliases
Definition PoolImpl.h:376
const MultiversionList & multiversionList() const
Definition PoolImpl.cc:765
void snapshotWriteIfNeeded() const
Definition PoolImpl.cc:376
CRepo * _createRepo(const std::string &name_r)
Creating a new repo named name_r.
Definition PoolImpl.cc:448
SerialNumberWatcher _watcher
Watch serial number.
Definition PoolImpl.h:382
SerialNumber _serial
Serial number - changes with each Pool content change.
Definition PoolImpl.h:372
const std::set< std::string > & requiredFilesystems() const
accessor for etc/sysconfig/storage reading file on demand
Definition PoolImpl.cc:777
void _postRepoAdd(CRepo *repo_r)
Helper postprocessing the repo after adding solv or helix files.
Definition PoolImpl.cc:501
bool mapSnapshot(const Pathname &path_r, const std::string &cookie_r)
Experimental pool snapshot (see Pool::mapSnapshot)
Definition PoolImpl.cc:310
bool addRequestedLocale(const Locale &locale_r)
User change (tracked).
Definition PoolImpl.cc:627
int _addSolv(CRepo *repo_r, FILE *file_r)
Adding solv file to a repo.
Definition PoolImpl.cc:474
int _addHelix(CRepo *repo_r, FILE *file_r)
Adding helix file to a repo.
Definition PoolImpl.cc:483
sat::SolvableSpec _ptfPackageSpec
Definition PoolImpl.h:408
detail::SolvableIdType _addSolvables(CRepo *repo_r, unsigned count_r)
Adding Solvables to a repo.
Definition PoolImpl.cc:545
std::set< RepoIdType > _snapshotUnclaimed
Snapshot repos not (yet) requested via setRepoInfo; erased in prepare.
Definition PoolImpl.h:378
SerialNumber _serialIDs
Serial number of IDs - changes whenever resusePoolIDs==true - ResPool must also invalidate its PoolIt...
Definition PoolImpl.h:380
bool isMultiversion(const Solvable &solv_r) const
Definition PoolImpl.cc:772
void prepare() const
Update housekeeping data (e.g.
Definition PoolImpl.cc:402
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
Definition PoolImpl.cc:116
CPool * _pool
sat-pool.
Definition PoolImpl.h:370
void setRepoInfo(RepoIdType id_r, const RepoInfo &info_r)
Also adjust repo priority and subpriority accordingly.
Definition PoolImpl.cc:551
void setDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
Definition PoolImpl.cc:260
void depSetDirty(const char *a1=0, const char *a2=0, const char *a3=0)
Invalidate housekeeping data (e.g.
Definition PoolImpl.cc:299
bool query(IdString cap_r) const
Checks if a device on the system matches a modalias pattern.
Definition Modalias.h:70
static Modalias & instance()
Singleton access.
Definition Modalias.cc:223
Singleton manager for the underlying libsolv string pool.
Definition stringpool.h:46
nullptr CURL handle void p CURLversion nullptr struct curl_slist list CURLM CURLM_INTERNAL_ERROR CURLM CURL CURLM_INTERNAL_ERROR CURLM curl_socket_t s
Definition curl_dl.cc:111
nullptr CURL handle void p CURLversion nullptr struct curl_slist list CURLM CURLM_INTERNAL_ERROR CURLM CURL CURLM_INTERNAL_ERROR CURLM curl_socket_t int int CURLM_INTERNAL_ERROR CURLINFO info
Definition curl_dl.cc:117
std::map< std::string, std::string > read(const Pathname &_path)
Read sysconfig file path_r and return (key,valye) pairs.
Definition sysconfig.cc:34
bool ZYPP_POOL_SNAPSHOT()
Same gate as RepoManager::poolSnapshotEnabled.
Definition PoolImpl.cc:75
int LIBSOLV_DEBUGMASK()
Definition PoolImpl.cc:67
static void _getLocaleDeps(const Capability &cap_r, LocaleSet &store_r)
Definition PoolImpl.cc:691
unsigned int SolvableIdType
Id type to connect Solvable and sat-solvable.
Definition PoolDefines.h:65
::s_Repo CRepo
Wrapped libsolv C data type exposed as backdoor.
Definition PoolDefines.h:38
const Pathname & sysconfigStoragePath()
Definition PoolImpl.cc:122
int IdType
Generic Id type.
Definition PoolDefines.h:44
::s_Solvable CSolvable
Wrapped libsolv C data type exposed as backdoor.
Definition PoolDefines.h:39
::s_Pool CPool
Wrapped libsolv C data type exposed as backdoor.
Definition PoolDefines.h:36
BOOST_MPL_ASSERT_RELATION(noId,==, STRID_NULL)
CRepo * RepoIdType
Id to denote Solvable::noSolvable.
Definition PoolDefines.h:73
static void logSat(CPool *, void *data, int type, const char *logString)
Definition PoolImpl.cc:130
Libsolv interface
void setDirty() const
Explicitly flag the cache as dirty, so it will be rebuilt on the next request.
bool dirty() const
Whether the cache is needed and dirty.
std::string hexdecode(const C_Str &str_r)
Decode hexencoded XX sequences.
Definition String.cc:148
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
Definition String.h:1097
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \t", const Trim trim_r=NO_TRIM)
Split line_r into words.
Definition String.h:602
TInt strtonum(const C_Str &str)
Parsing numbers from string.
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & dumpRangeLine(std::ostream &str, TIterator begin, TIterator end)
Print range defined by iterators (single line style).
Definition LogTools.h:442
std::unordered_set< Locale > LocaleSet
Definition Locale.h:29
std::string asString(const Patch::Category &obj)
relates: Patch::Category string representation.
Definition Patch.cc:122
int repo_add_helix(::Repo *repo, FILE *fp, int flags)
int testcase_add_testtags(Repo *repo, FILE *fp, int flags)
AutoDispose<FILE*> calling fclose
Track added/removed set items based on an initial set.
Definition SetTracker.h:39
const set_type & current() const
Return the current set.
Definition SetTracker.h:140
bool wasAdded(const key_type &key_r) const
Whether val_r is tracked as added.
Definition SetTracker.h:133
const set_type & added() const
Return the set of added items.
Definition SetTracker.h:143
const set_type & removed() const
Return the set of removed items.
Definition SetTracker.h:146
bool contains(const key_type &key_r) const
Whether val_r is in the set.
Definition SetTracker.h:130