libzypp  17.30.0
ZConfig.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 extern "C"
13 {
14 #include <features.h>
15 #include <sys/utsname.h>
16 #if __GLIBC_PREREQ (2,16)
17 #include <sys/auxv.h> // getauxval for PPC64P7 detection
18 #endif
19 #include <unistd.h>
20 #include <solv/solvversion.h>
21 }
22 #include <iostream>
23 #include <fstream>
24 #include <optional>
25 #include <zypp/base/LogTools.h>
26 #include <zypp/base/IOStream.h>
27 #include <zypp-core/base/InputStream>
28 #include <zypp/base/String.h>
29 #include <zypp/base/Regex.h>
30 
31 #include <zypp/ZConfig.h>
32 #include <zypp/ZYppFactory.h>
33 #include <zypp/PathInfo.h>
34 #include <zypp-core/parser/IniDict>
35 
36 #include <zypp/sat/Pool.h>
37 #include <zypp/sat/detail/PoolImpl.h>
38 
39 #include <zypp-media/MediaConfig>
40 
41 using std::endl;
42 using namespace zypp::filesystem;
43 using namespace zypp::parser;
44 
45 #undef ZYPP_BASE_LOGGER_LOGGROUP
46 #define ZYPP_BASE_LOGGER_LOGGROUP "zconfig"
47 
49 namespace zypp
50 {
61  namespace
62  {
63 
66  Arch _autodetectSystemArchitecture()
67  {
68  struct ::utsname buf;
69  if ( ::uname( &buf ) < 0 )
70  {
71  ERR << "Can't determine system architecture" << endl;
72  return Arch_noarch;
73  }
74 
75  Arch architecture( buf.machine );
76  MIL << "Uname architecture is '" << buf.machine << "'" << endl;
77 
78  if ( architecture == Arch_i686 )
79  {
80  // some CPUs report i686 but dont implement cx8 and cmov
81  // check for both flags in /proc/cpuinfo and downgrade
82  // to i586 if either is missing (cf bug #18885)
83  std::ifstream cpuinfo( "/proc/cpuinfo" );
84  if ( cpuinfo )
85  {
86  for( iostr::EachLine in( cpuinfo ); in; in.next() )
87  {
88  if ( str::hasPrefix( *in, "flags" ) )
89  {
90  if ( in->find( "cx8" ) == std::string::npos
91  || in->find( "cmov" ) == std::string::npos )
92  {
93  architecture = Arch_i586;
94  WAR << "CPU lacks 'cx8' or 'cmov': architecture downgraded to '" << architecture << "'" << endl;
95  }
96  break;
97  }
98  }
99  }
100  else
101  {
102  ERR << "Cant open " << PathInfo("/proc/cpuinfo") << endl;
103  }
104  }
105  else if ( architecture == Arch_sparc || architecture == Arch_sparc64 )
106  {
107  // Check for sun4[vum] to get the real arch. (bug #566291)
108  std::ifstream cpuinfo( "/proc/cpuinfo" );
109  if ( cpuinfo )
110  {
111  for( iostr::EachLine in( cpuinfo ); in; in.next() )
112  {
113  if ( str::hasPrefix( *in, "type" ) )
114  {
115  if ( in->find( "sun4v" ) != std::string::npos )
116  {
117  architecture = ( architecture == Arch_sparc64 ? Arch_sparc64v : Arch_sparcv9v );
118  WAR << "CPU has 'sun4v': architecture upgraded to '" << architecture << "'" << endl;
119  }
120  else if ( in->find( "sun4u" ) != std::string::npos )
121  {
122  architecture = ( architecture == Arch_sparc64 ? Arch_sparc64 : Arch_sparcv9 );
123  WAR << "CPU has 'sun4u': architecture upgraded to '" << architecture << "'" << endl;
124  }
125  else if ( in->find( "sun4m" ) != std::string::npos )
126  {
127  architecture = Arch_sparcv8;
128  WAR << "CPU has 'sun4m': architecture upgraded to '" << architecture << "'" << endl;
129  }
130  break;
131  }
132  }
133  }
134  else
135  {
136  ERR << "Cant open " << PathInfo("/proc/cpuinfo") << endl;
137  }
138  }
139  else if ( architecture == Arch_armv8l || architecture == Arch_armv7l || architecture == Arch_armv6l )
140  {
141  std::ifstream platform( "/etc/rpm/platform" );
142  if (platform)
143  {
144  for( iostr::EachLine in( platform ); in; in.next() )
145  {
146  if ( str::hasPrefix( *in, "armv8hl-" ) )
147  {
148  architecture = Arch_armv8hl;
149  WAR << "/etc/rpm/platform contains armv8hl-: architecture upgraded to '" << architecture << "'" << endl;
150  break;
151  }
152  if ( str::hasPrefix( *in, "armv7hl-" ) )
153  {
154  architecture = Arch_armv7hl;
155  WAR << "/etc/rpm/platform contains armv7hl-: architecture upgraded to '" << architecture << "'" << endl;
156  break;
157  }
158  if ( str::hasPrefix( *in, "armv6hl-" ) )
159  {
160  architecture = Arch_armv6hl;
161  WAR << "/etc/rpm/platform contains armv6hl-: architecture upgraded to '" << architecture << "'" << endl;
162  break;
163  }
164  }
165  }
166  }
167 #if __GLIBC_PREREQ (2,16)
168  else if ( architecture == Arch_ppc64 )
169  {
170  const char * platform = (const char *)getauxval( AT_PLATFORM );
171  int powerlvl;
172  if ( platform && sscanf( platform, "power%d", &powerlvl ) == 1 && powerlvl > 6 )
173  architecture = Arch_ppc64p7;
174  }
175 #endif
176  return architecture;
177  }
178 
196  Locale _autodetectTextLocale()
197  {
198  Locale ret( Locale::enCode );
199  const char * envlist[] = { "LC_ALL", "LC_MESSAGES", "LANG", NULL };
200  for ( const char ** envvar = envlist; *envvar; ++envvar )
201  {
202  const char * envlang = getenv( *envvar );
203  if ( envlang )
204  {
205  std::string envstr( envlang );
206  if ( envstr != "POSIX" && envstr != "C" )
207  {
208  Locale lang( envstr );
209  if ( lang )
210  {
211  MIL << "Found " << *envvar << "=" << envstr << endl;
212  ret = lang;
213  break;
214  }
215  }
216  }
217  }
218  MIL << "Default text locale is '" << ret << "'" << endl;
219 #warning HACK AROUND BOOST_TEST_CATCH_SYSTEM_ERRORS
220  setenv( "BOOST_TEST_CATCH_SYSTEM_ERRORS", "no", 1 );
221  return ret;
222  }
223 
224 
225  inline Pathname _autodetectSystemRoot()
226  {
227  Target_Ptr target( getZYpp()->getTarget() );
228  return target ? target->root() : Pathname();
229  }
230 
231  inline Pathname _autodetectZyppConfPath()
232  {
233  const char *env_confpath = getenv( "ZYPP_CONF" );
234  return env_confpath ? env_confpath : "/etc/zypp/zypp.conf";
235  }
236 
238  } // namespace zypp
240 
242  template<class Tp>
243  struct Option
244  {
245  typedef Tp value_type;
246 
248  Option( value_type initial_r )
249  : _val( std::move(initial_r) )
250  {}
251 
253  { set( std::move(newval_r) ); return *this; }
254 
256  const value_type & get() const
257  { return _val; }
258 
260  operator const value_type &() const
261  { return _val; }
262 
264  void set( value_type newval_r )
265  { _val = std::move(newval_r); }
266 
267  private:
269  };
270 
272  template<class Tp>
273  struct DefaultOption : public Option<Tp>
274  {
275  typedef Tp value_type;
277 
278  explicit DefaultOption( value_type initial_r )
279  : Option<Tp>( initial_r )
280  , _default( std::move(initial_r) )
281  {}
282 
284  { this->set( std::move(newval_r) ); return *this; }
285 
288  { this->set( _default.get() ); }
289 
291  void restoreToDefault( value_type newval_r )
292  { setDefault( std::move(newval_r) ); restoreToDefault(); }
293 
295  const value_type & getDefault() const
296  { return _default.get(); }
297 
299  void setDefault( value_type newval_r )
300  { _default.set( std::move(newval_r) ); }
301 
302  private:
304  };
305 
307  //
308  // CLASS NAME : ZConfig::Impl
309  //
316  {
317  typedef std::set<std::string> MultiversionSpec;
318 
321  {
323  : solver_focus ( ResolverFocus::Default )
324  , solver_onlyRequires ( false )
325  , solver_allowVendorChange ( false )
326  , solver_dupAllowDowngrade ( true )
327  , solver_dupAllowNameChange ( true )
328  , solver_dupAllowArchChange ( true )
329  , solver_dupAllowVendorChange ( true )
330  , solver_cleandepsOnRemove ( false )
331  , solver_upgradeTestcasesToKeep ( 2 )
332  , solverUpgradeRemoveDroppedPackages ( true )
333  {}
334 
335  bool consume( const std::string & entry, const std::string & value )
336  {
337  if ( entry == "solver.focus" )
338  {
339  fromString( value, solver_focus );
340  }
341  else if ( entry == "solver.onlyRequires" )
342  {
343  solver_onlyRequires.set( str::strToBool( value, solver_onlyRequires ) );
344  }
345  else if ( entry == "solver.allowVendorChange" )
346  {
347  solver_allowVendorChange.set( str::strToBool( value, solver_allowVendorChange ) );
348  }
349  else if ( entry == "solver.dupAllowDowngrade" )
350  {
351  solver_dupAllowDowngrade.set( str::strToBool( value, solver_dupAllowDowngrade ) );
352  }
353  else if ( entry == "solver.dupAllowNameChange" )
354  {
355  solver_dupAllowNameChange.set( str::strToBool( value, solver_dupAllowNameChange ) );
356  }
357  else if ( entry == "solver.dupAllowArchChange" )
358  {
359  solver_dupAllowArchChange.set( str::strToBool( value, solver_dupAllowArchChange ) );
360  }
361  else if ( entry == "solver.dupAllowVendorChange" )
362  {
363  solver_dupAllowVendorChange.set( str::strToBool( value, solver_dupAllowVendorChange ) );
364  }
365  else if ( entry == "solver.cleandepsOnRemove" )
366  {
367  solver_cleandepsOnRemove.set( str::strToBool( value, solver_cleandepsOnRemove ) );
368  }
369  else if ( entry == "solver.upgradeTestcasesToKeep" )
370  {
371  solver_upgradeTestcasesToKeep.set( str::strtonum<unsigned>( value ) );
372  }
373  else if ( entry == "solver.upgradeRemoveDroppedPackages" )
374  {
375  solverUpgradeRemoveDroppedPackages.restoreToDefault( str::strToBool( value, solverUpgradeRemoveDroppedPackages.getDefault() ) );
376  }
377  else
378  return false;
379 
380  return true;
381  }
382 
393  };
394 
395  public:
397  : _parsedZyppConf ( _autodetectZyppConfPath() )
398  , cfg_arch ( defaultSystemArchitecture() )
399  , cfg_textLocale ( defaultTextLocale() )
400  , cfg_cache_path { "/var/cache/zypp" }
401  , cfg_metadata_path { "" } // empty - follows cfg_cache_path
402  , cfg_solvfiles_path { "" } // empty - follows cfg_cache_path
403  , cfg_packages_path { "" } // empty - follows cfg_cache_path
404  , updateMessagesNotify ( "" )
405  , repo_add_probe ( false )
406  , repo_refresh_delay ( 10 )
407  , repoLabelIsAlias ( false )
408  , download_use_deltarpm ( true )
409  , download_use_deltarpm_always ( false )
410  , download_media_prefer_download( true )
411  , download_mediaMountdir ( "/var/adm/mount" )
412  , commit_downloadMode ( DownloadDefault )
413  , gpgCheck ( true )
414  , repoGpgCheck ( indeterminate )
415  , pkgGpgCheck ( indeterminate )
416  , apply_locks_file ( true )
417  , pluginsPath ( "/usr/lib/zypp/plugins" )
418  {
419  MIL << "libzypp: " LIBZYPP_VERSION_STRING << endl;
420  if ( PathInfo(_parsedZyppConf).isExist() )
421  {
422  parser::IniDict dict( _parsedZyppConf );
424  sit != dict.sectionsEnd();
425  ++sit )
426  {
427  std::string section(*sit);
428  //MIL << section << endl;
429  for ( IniDict::entry_const_iterator it = dict.entriesBegin(*sit);
430  it != dict.entriesEnd(*sit);
431  ++it )
432  {
433  std::string entry(it->first);
434  std::string value(it->second);
435 
436  if ( _mediaConf.setConfigValue( section, entry, value ) )
437  continue;
438 
439  //DBG << (*it).first << "=" << (*it).second << endl;
440  if ( section == "main" )
441  {
442  if ( _initialTargetDefaults.consume( entry, value ) )
443  continue;
444 
445  if ( entry == "arch" )
446  {
447  Arch carch( value );
448  if ( carch != cfg_arch )
449  {
450  WAR << "Overriding system architecture (" << cfg_arch << "): " << carch << endl;
451  cfg_arch = carch;
452  }
453  }
454  else if ( entry == "cachedir" )
455  {
456  cfg_cache_path.restoreToDefault( value );
457  }
458  else if ( entry == "metadatadir" )
459  {
460  cfg_metadata_path.restoreToDefault( value );
461  }
462  else if ( entry == "solvfilesdir" )
463  {
464  cfg_solvfiles_path.restoreToDefault( value );
465  }
466  else if ( entry == "packagesdir" )
467  {
468  cfg_packages_path.restoreToDefault( value );
469  }
470  else if ( entry == "configdir" )
471  {
472  cfg_config_path = Pathname(value);
473  }
474  else if ( entry == "reposdir" )
475  {
476  cfg_known_repos_path = Pathname(value);
477  }
478  else if ( entry == "servicesdir" )
479  {
480  cfg_known_services_path = Pathname(value);
481  }
482  else if ( entry == "varsdir" )
483  {
484  cfg_vars_path = Pathname(value);
485  }
486  else if ( entry == "repo.add.probe" )
487  {
488  repo_add_probe = str::strToBool( value, repo_add_probe );
489  }
490  else if ( entry == "repo.refresh.delay" )
491  {
492  str::strtonum(value, repo_refresh_delay);
493  }
494  else if ( entry == "repo.refresh.locales" )
495  {
496  std::vector<std::string> tmp;
497  str::split( value, back_inserter( tmp ), ", \t" );
498 
499  boost::function<Locale(const std::string &)> transform(
500  [](const std::string & str_r)->Locale{ return Locale(str_r); }
501  );
502  repoRefreshLocales.insert( make_transform_iterator( tmp.begin(), transform ),
503  make_transform_iterator( tmp.end(), transform ) );
504  }
505  else if ( entry == "download.use_deltarpm" )
506  {
507  download_use_deltarpm = str::strToBool( value, download_use_deltarpm );
508  }
509  else if ( entry == "download.use_deltarpm.always" )
510  {
511  download_use_deltarpm_always = str::strToBool( value, download_use_deltarpm_always );
512  }
513  else if ( entry == "download.media_preference" )
514  {
515  download_media_prefer_download.restoreToDefault( str::compareCI( value, "volatile" ) != 0 );
516  }
517  else if ( entry == "download.media_mountdir" )
518  {
519  download_mediaMountdir.restoreToDefault( Pathname(value) );
520  }
521  else if ( entry == "commit.downloadMode" )
522  {
523  commit_downloadMode.set( deserializeDownloadMode( value ) );
524  }
525  else if ( entry == "gpgcheck" )
526  {
527  gpgCheck.restoreToDefault( str::strToBool( value, gpgCheck ) );
528  }
529  else if ( entry == "repo_gpgcheck" )
530  {
531  repoGpgCheck.restoreToDefault( str::strToTriBool( value ) );
532  }
533  else if ( entry == "pkg_gpgcheck" )
534  {
535  pkgGpgCheck.restoreToDefault( str::strToTriBool( value ) );
536  }
537  else if ( entry == "vendordir" )
538  {
539  cfg_vendor_path = Pathname(value);
540  }
541  else if ( entry == "multiversiondir" )
542  {
543  cfg_multiversion_path = Pathname(value);
544  }
545  else if ( entry == "multiversion.kernels" )
546  {
547  cfg_kernel_keep_spec = value;
548  }
549  else if ( entry == "solver.checkSystemFile" )
550  {
551  solver_checkSystemFile = Pathname(value);
552  }
553  else if ( entry == "solver.checkSystemFileDir" )
554  {
555  solver_checkSystemFileDir = Pathname(value);
556  }
557  else if ( entry == "multiversion" )
558  {
559  MultiversionSpec & defSpec( _multiversionMap.getDefaultSpec() );
560  str::splitEscaped( value, std::inserter( defSpec, defSpec.end() ), ", \t" );
561  }
562  else if ( entry == "locksfile.path" )
563  {
564  locks_file = Pathname(value);
565  }
566  else if ( entry == "locksfile.apply" )
567  {
568  apply_locks_file = str::strToBool( value, apply_locks_file );
569  }
570  else if ( entry == "update.datadir" )
571  {
572  update_data_path = Pathname(value);
573  }
574  else if ( entry == "update.scriptsdir" )
575  {
576  update_scripts_path = Pathname(value);
577  }
578  else if ( entry == "update.messagessdir" )
579  {
580  update_messages_path = Pathname(value);
581  }
582  else if ( entry == "update.messages.notify" )
583  {
584  updateMessagesNotify.set( value );
585  }
586  else if ( entry == "rpm.install.excludedocs" )
587  {
588  rpmInstallFlags.setFlag( target::rpm::RPMINST_EXCLUDEDOCS,
589  str::strToBool( value, false ) );
590  }
591  else if ( entry == "history.logfile" )
592  {
593  history_log_path = Pathname(value);
594  }
595  else if ( entry == "techpreview.ZYPP_SINGLE_RPMTRANS" )
596  {
597  DBG << "techpreview.ZYPP_SINGLE_RPMTRANS=" << value << endl;
598  ::setenv( "ZYPP_SINGLE_RPMTRANS", value.c_str(), 1 );
599  }
600  else if ( entry == "techpreview.ZYPP_MEDIANETWORK" )
601  {
602  DBG << "techpreview.ZYPP_MEDIANETWORK=" << value << endl;
603  ::setenv( "ZYPP_MEDIANETWORK", value.c_str(), 1 );
604  }
605  }
606  }
607  }
608  }
609  else
610  {
611  MIL << _parsedZyppConf << " not found, using defaults instead." << endl;
612  _parsedZyppConf = _parsedZyppConf.extend( " (NOT FOUND)" );
613  }
614 
615  // legacy:
616  if ( getenv( "ZYPP_TESTSUITE_FAKE_ARCH" ) )
617  {
618  Arch carch( getenv( "ZYPP_TESTSUITE_FAKE_ARCH" ) );
619  if ( carch != cfg_arch )
620  {
621  WAR << "ZYPP_TESTSUITE_FAKE_ARCH: Overriding system architecture (" << cfg_arch << "): " << carch << endl;
622  cfg_arch = carch;
623  }
624  }
625  MIL << "ZConfig singleton created." << endl;
626  }
627 
629  {}
630 
632  {
633  Pathname newRoot { _autodetectSystemRoot() };
634  MIL << "notifyTargetChanged (" << newRoot << ")" << endl;
635 
636  if ( newRoot.emptyOrRoot() ) {
637  _currentTargetDefaults.reset(); // to initial settigns from /
638  }
639  else {
640  _currentTargetDefaults = TargetDefaults();
641 
642  Pathname newConf { newRoot/_autodetectZyppConfPath() };
643  if ( PathInfo(newConf).isExist() ) {
644  parser::IniDict dict( newConf );
645  for ( const auto & [entry,value] : dict.entries( "main" ) ) {
646  (*_currentTargetDefaults).consume( entry, value );
647  }
648  }
649  else {
650  MIL << _parsedZyppConf << " not found, using defaults." << endl;
651  }
652  }
653  }
654 
655  public:
658 
661 
662  DefaultOption<Pathname> cfg_cache_path; // Settings from the config file are also remembered
663  DefaultOption<Pathname> cfg_metadata_path; // 'default'. Cleanup in RepoManager e.g needs to tell
664  DefaultOption<Pathname> cfg_solvfiles_path; // whether settings in effect are config values or
665  DefaultOption<Pathname> cfg_packages_path; // custom settings applied vie set...Path().
666 
672 
675  std::string cfg_kernel_keep_spec;
677 
682 
687 
692 
694 
698 
701 
702  MultiversionSpec & multiversion() { return getMultiversion(); }
703  const MultiversionSpec & multiversion() const { return getMultiversion(); }
704 
706 
707  target::rpm::RpmInstFlags rpmInstallFlags;
708 
710 
711  std::string userData;
712 
714 
715  /* Other config singleton instances */
716  MediaConfig &_mediaConf = MediaConfig::instance();
717 
718 
719  public:
720  const TargetDefaults & targetDefaults() const { return _currentTargetDefaults ? *_currentTargetDefaults : _initialTargetDefaults; }
721  TargetDefaults & targetDefaults() { return _currentTargetDefaults ? *_currentTargetDefaults : _initialTargetDefaults; }
722  private:
724  std::optional<TargetDefaults> _currentTargetDefaults;
725 
726  private:
727  // HACK for bnc#906096: let pool re-evaluate multiversion spec
728  // if target root changes. ZConfig returns data sensitive to
729  // current target root.
730  // TODO Actually we'd need to scan the target systems zypp.conf and
731  // overlay all system specific values.
733  {
734  typedef std::map<Pathname,MultiversionSpec> SpecMap;
735 
736  MultiversionSpec & getSpec( Pathname root_r, const Impl & zConfImpl_r ) // from system at root
737  {
738  // _specMap[] - the plain zypp.conf value
739  // _specMap[/] - combine [] and multiversion.d scan
740  // _specMap[root] - scan root/zypp.conf and root/multiversion.d
741 
742  if ( root_r.empty() )
743  root_r = "/";
744  bool cacheHit = _specMap.count( root_r );
745  MultiversionSpec & ret( _specMap[root_r] ); // creates new entry on the fly
746 
747  if ( ! cacheHit )
748  {
749  // bsc#1193488: If no (/root)/.../zypp.conf exists use the default zypp.conf
750  // multiversion settings. It is a legacy that the packaged multiversion setting
751  // in zypp.conf (the kernel) may differ from the builtin default (empty).
752  // But we want a missing config to behave similar to the default one, otherwise
753  // a bare metal install easily runs into trouble.
754  if ( root_r == "/" || scanConfAt( root_r, ret, zConfImpl_r ) == 0 )
755  ret = _specMap[Pathname()];
756  scanDirAt( root_r, ret, zConfImpl_r ); // add multiversion.d at root_r
757  using zypp::operator<<;
758  MIL << "MultiversionSpec '" << root_r << "' = " << ret << endl;
759  }
760  return ret;
761  }
762 
763  MultiversionSpec & getDefaultSpec() // Spec from zypp.conf parsing; called before any getSpec
764  { return _specMap[Pathname()]; }
765 
766  private:
767  int scanConfAt( const Pathname root_r, MultiversionSpec & spec_r, const Impl & zConfImpl_r )
768  {
769  static const str::regex rx( "^multiversion *= *(.*)" );
770  str::smatch what;
771  return iostr::simpleParseFile( InputStream( Pathname::assertprefix( root_r, _autodetectZyppConfPath() ) ),
772  [&]( int num_r, std::string line_r )->bool
773  {
774  if ( line_r[0] == 'm' && str::regex_match( line_r, what, rx ) )
775  {
776  str::splitEscaped( what[1], std::inserter( spec_r, spec_r.end() ), ", \t" );
777  return false; // stop after match
778  }
779  return true;
780  } );
781  }
782 
783  void scanDirAt( const Pathname root_r, MultiversionSpec & spec_r, const Impl & zConfImpl_r )
784  {
785  // NOTE: Actually we'd need to scan and use the root_r! zypp.conf values.
786  Pathname multiversionDir( zConfImpl_r.cfg_multiversion_path );
787  if ( multiversionDir.empty() )
788  multiversionDir = ( zConfImpl_r.cfg_config_path.empty()
789  ? Pathname("/etc/zypp")
790  : zConfImpl_r.cfg_config_path ) / "multiversion.d";
791 
792  filesystem::dirForEach( Pathname::assertprefix( root_r, multiversionDir ),
793  [&spec_r]( const Pathname & dir_r, const char *const & name_r )->bool
794  {
795  MIL << "Parsing " << dir_r/name_r << endl;
796  iostr::simpleParseFile( InputStream( dir_r/name_r ),
797  [&spec_r]( int num_r, std::string line_r )->bool
798  {
799  DBG << " found " << line_r << endl;
800  spec_r.insert( std::move(line_r) );
801  return true;
802  } );
803  return true;
804  } );
805  }
806 
807  private:
809  };
810 
812  { return _multiversionMap.getSpec( _autodetectSystemRoot(), *this ); }
813 
815  };
817 
819  //
820  // METHOD NAME : ZConfig::instance
821  // METHOD TYPE : ZConfig &
822  //
824  {
825  static ZConfig _instance; // The singleton
826  return _instance;
827  }
828 
830  //
831  // METHOD NAME : ZConfig::ZConfig
832  // METHOD TYPE : Ctor
833  //
835  : _pimpl( new Impl )
836  {
837  about( MIL );
838  }
839 
841  //
842  // METHOD NAME : ZConfig::~ZConfig
843  // METHOD TYPE : Dtor
844  //
846  {}
847 
849  { return _pimpl->notifyTargetChanged(); }
850 
852  { return _autodetectSystemRoot(); }
853 
855  {
856  return ( _pimpl->cfg_repo_mgr_root_path.empty()
857  ? systemRoot() : _pimpl->cfg_repo_mgr_root_path );
858  }
859 
861  { _pimpl->cfg_repo_mgr_root_path = root; }
862 
864  //
865  // system architecture
866  //
868 
870  {
871  static Arch _val( _autodetectSystemArchitecture() );
872  return _val;
873  }
874 
876  { return _pimpl->cfg_arch; }
877 
878  void ZConfig::setSystemArchitecture( const Arch & arch_r )
879  {
880  if ( arch_r != _pimpl->cfg_arch )
881  {
882  WAR << "Overriding system architecture (" << _pimpl->cfg_arch << "): " << arch_r << endl;
883  _pimpl->cfg_arch = arch_r;
884  }
885  }
886 
888  //
889  // text locale
890  //
892 
894  {
895  static Locale _val( _autodetectTextLocale() );
896  return _val;
897  }
898 
900  { return _pimpl->cfg_textLocale; }
901 
902  void ZConfig::setTextLocale( const Locale & locale_r )
903  {
904  if ( locale_r != _pimpl->cfg_textLocale )
905  {
906  WAR << "Overriding text locale (" << _pimpl->cfg_textLocale << "): " << locale_r << endl;
907  _pimpl->cfg_textLocale = locale_r;
908  // Propagate changes
909  sat::Pool::instance().setTextLocale( locale_r );
910  }
911  }
912 
914  // user data
916 
917  bool ZConfig::hasUserData() const
918  { return !_pimpl->userData.empty(); }
919 
920  std::string ZConfig::userData() const
921  { return _pimpl->userData; }
922 
923  bool ZConfig::setUserData( const std::string & str_r )
924  {
925  for_( ch, str_r.begin(), str_r.end() )
926  {
927  if ( *ch < ' ' && *ch != '\t' )
928  {
929  ERR << "New user data string rejectded: char " << (int)*ch << " at position " << (ch - str_r.begin()) << endl;
930  return false;
931  }
932  }
933  MIL << "Set user data string to '" << str_r << "'" << endl;
934  _pimpl->userData = str_r;
935  return true;
936  }
937 
939 
941  {
942  return ( _pimpl->cfg_cache_path.get().empty()
943  ? Pathname("/var/cache/zypp") : _pimpl->cfg_cache_path.get() );
944  }
945 
947  {
948  return repoCachePath()/"pubkeys";
949  }
950 
952  {
953  _pimpl->cfg_cache_path = path_r;
954  }
955 
957  {
958  return ( _pimpl->cfg_metadata_path.get().empty()
959  ? (repoCachePath()/"raw") : _pimpl->cfg_metadata_path.get() );
960  }
961 
963  {
964  _pimpl->cfg_metadata_path = path_r;
965  }
966 
968  {
969  return ( _pimpl->cfg_solvfiles_path.get().empty()
970  ? (repoCachePath()/"solv") : _pimpl->cfg_solvfiles_path.get() );
971  }
972 
974  {
975  _pimpl->cfg_solvfiles_path = path_r;
976  }
977 
979  {
980  return ( _pimpl->cfg_packages_path.get().empty()
981  ? (repoCachePath()/"packages") : _pimpl->cfg_packages_path.get() );
982  }
983 
985  {
986  _pimpl->cfg_packages_path = path_r;
987  }
988 
990  { return _pimpl->cfg_cache_path.getDefault().empty() ? Pathname("/var/cache/zypp") : _pimpl->cfg_cache_path.getDefault(); }
991 
993  { return _pimpl->cfg_metadata_path.getDefault().empty() ? (builtinRepoCachePath()/"raw") : _pimpl->cfg_metadata_path.getDefault(); }
994 
996  { return _pimpl->cfg_solvfiles_path.getDefault().empty() ? (builtinRepoCachePath()/"solv") : _pimpl->cfg_solvfiles_path.getDefault(); }
997 
999  { return _pimpl->cfg_packages_path.getDefault().empty() ? (builtinRepoCachePath()/"packages") : _pimpl->cfg_packages_path.getDefault(); }
1000 
1002 
1004  {
1005  return ( _pimpl->cfg_config_path.empty()
1006  ? Pathname("/etc/zypp") : _pimpl->cfg_config_path );
1007  }
1008 
1010  {
1011  return ( _pimpl->cfg_known_repos_path.empty()
1012  ? (configPath()/"repos.d") : _pimpl->cfg_known_repos_path );
1013  }
1014 
1016  {
1017  return ( _pimpl->cfg_known_services_path.empty()
1018  ? (configPath()/"services.d") : _pimpl->cfg_known_services_path );
1019  }
1020 
1022  { return configPath()/"needreboot"; }
1023 
1025  { return configPath()/"needreboot.d"; }
1026 
1028  {
1029  return ( _pimpl->cfg_vars_path.empty()
1030  ? (configPath()/"vars.d") : _pimpl->cfg_vars_path );
1031  }
1032 
1034  {
1035  return ( _pimpl->cfg_vendor_path.empty()
1036  ? (configPath()/"vendors.d") : _pimpl->cfg_vendor_path );
1037  }
1038 
1040  {
1041  return ( _pimpl->locks_file.empty()
1042  ? (configPath()/"locks") : _pimpl->locks_file );
1043  }
1044 
1046 
1048  { return _pimpl->repo_add_probe; }
1049 
1051  { return _pimpl->repo_refresh_delay; }
1052 
1054  { return _pimpl->repoRefreshLocales.empty() ? Target::requestedLocales("") :_pimpl->repoRefreshLocales; }
1055 
1057  { return _pimpl->repoLabelIsAlias; }
1058 
1059  void ZConfig::repoLabelIsAlias( bool yesno_r )
1060  { _pimpl->repoLabelIsAlias = yesno_r; }
1061 
1063  { return _pimpl->download_use_deltarpm; }
1064 
1066  { return download_use_deltarpm() && _pimpl->download_use_deltarpm_always; }
1067 
1069  { return _pimpl->download_media_prefer_download; }
1070 
1072  { _pimpl->download_media_prefer_download.set( yesno_r ); }
1073 
1075  { _pimpl->download_media_prefer_download.restoreToDefault(); }
1076 
1078  { return _pimpl->_mediaConf.download_max_concurrent_connections(); }
1079 
1081  { return _pimpl->_mediaConf.download_min_download_speed(); }
1082 
1084  { return _pimpl->_mediaConf.download_max_download_speed(); }
1085 
1087  { return _pimpl->_mediaConf.download_max_silent_tries(); }
1088 
1090  { return _pimpl->_mediaConf.download_transfer_timeout(); }
1091 
1092  Pathname ZConfig::download_mediaMountdir() const { return _pimpl->download_mediaMountdir; }
1093  void ZConfig::set_download_mediaMountdir( Pathname newval_r ) { _pimpl->download_mediaMountdir.set( std::move(newval_r) ); }
1094  void ZConfig::set_default_download_mediaMountdir() { _pimpl->download_mediaMountdir.restoreToDefault(); }
1095 
1097  { return _pimpl->commit_downloadMode; }
1098 
1099 
1100  bool ZConfig::gpgCheck() const { return _pimpl->gpgCheck; }
1101  TriBool ZConfig::repoGpgCheck() const { return _pimpl->repoGpgCheck; }
1102  TriBool ZConfig::pkgGpgCheck() const { return _pimpl->pkgGpgCheck; }
1103 
1104  void ZConfig::setGpgCheck( bool val_r ) { _pimpl->gpgCheck.set( val_r ); }
1105  void ZConfig::setRepoGpgCheck( TriBool val_r ) { _pimpl->repoGpgCheck.set( val_r ); }
1106  void ZConfig::setPkgGpgCheck( TriBool val_r ) { _pimpl->pkgGpgCheck.set( val_r ); }
1107 
1108  void ZConfig::resetGpgCheck() { _pimpl->gpgCheck.restoreToDefault(); }
1109  void ZConfig::resetRepoGpgCheck() { _pimpl->repoGpgCheck.restoreToDefault(); }
1110  void ZConfig::resetPkgGpgCheck() { _pimpl->pkgGpgCheck.restoreToDefault(); }
1111 
1112 
1113  ResolverFocus ZConfig::solver_focus() const { return _pimpl->targetDefaults().solver_focus; }
1114  bool ZConfig::solver_onlyRequires() const { return _pimpl->targetDefaults().solver_onlyRequires; }
1115  bool ZConfig::solver_allowVendorChange() const { return _pimpl->targetDefaults().solver_allowVendorChange; }
1116  bool ZConfig::solver_dupAllowDowngrade() const { return _pimpl->targetDefaults().solver_dupAllowDowngrade; }
1117  bool ZConfig::solver_dupAllowNameChange() const { return _pimpl->targetDefaults().solver_dupAllowNameChange; }
1118  bool ZConfig::solver_dupAllowArchChange() const { return _pimpl->targetDefaults().solver_dupAllowArchChange; }
1119  bool ZConfig::solver_dupAllowVendorChange() const { return _pimpl->targetDefaults().solver_dupAllowVendorChange; }
1120  bool ZConfig::solver_cleandepsOnRemove() const { return _pimpl->targetDefaults().solver_cleandepsOnRemove; }
1121  unsigned ZConfig::solver_upgradeTestcasesToKeep() const { return _pimpl->targetDefaults().solver_upgradeTestcasesToKeep; }
1122 
1123  bool ZConfig::solverUpgradeRemoveDroppedPackages() const { return _pimpl->targetDefaults().solverUpgradeRemoveDroppedPackages; }
1124  void ZConfig::setSolverUpgradeRemoveDroppedPackages( bool val_r ) { _pimpl->targetDefaults().solverUpgradeRemoveDroppedPackages.set( val_r ); }
1125  void ZConfig::resetSolverUpgradeRemoveDroppedPackages() { _pimpl->targetDefaults().solverUpgradeRemoveDroppedPackages.restoreToDefault(); }
1126 
1127 
1129  { return ( _pimpl->solver_checkSystemFile.empty()
1130  ? (configPath()/"systemCheck") : _pimpl->solver_checkSystemFile ); }
1131 
1133  { return ( _pimpl->solver_checkSystemFileDir.empty()
1134  ? (configPath()/"systemCheck.d") : _pimpl->solver_checkSystemFileDir ); }
1135 
1136 
1137  namespace
1138  {
1139  inline void sigMultiversionSpecChanged()
1140  {
1142  }
1143  }
1144 
1145  const std::set<std::string> & ZConfig::multiversionSpec() const { return _pimpl->multiversion(); }
1146  void ZConfig::multiversionSpec( std::set<std::string> new_r ) { _pimpl->multiversion().swap( new_r ); sigMultiversionSpecChanged(); }
1147  void ZConfig::clearMultiversionSpec() { _pimpl->multiversion().clear(); sigMultiversionSpecChanged(); }
1148  void ZConfig::addMultiversionSpec( const std::string & name_r ) { _pimpl->multiversion().insert( name_r ); sigMultiversionSpecChanged(); }
1149  void ZConfig::removeMultiversionSpec( const std::string & name_r ) { _pimpl->multiversion().erase( name_r ); sigMultiversionSpecChanged(); }
1150 
1152  { return _pimpl->apply_locks_file; }
1153 
1155  {
1156  return ( _pimpl->update_data_path.empty()
1157  ? Pathname("/var/adm") : _pimpl->update_data_path );
1158  }
1159 
1161  {
1162  return ( _pimpl->update_messages_path.empty()
1163  ? Pathname(update_dataPath()/"update-messages") : _pimpl->update_messages_path );
1164  }
1165 
1167  {
1168  return ( _pimpl->update_scripts_path.empty()
1169  ? Pathname(update_dataPath()/"update-scripts") : _pimpl->update_scripts_path );
1170  }
1171 
1172  std::string ZConfig::updateMessagesNotify() const
1173  { return _pimpl->updateMessagesNotify; }
1174 
1175  void ZConfig::setUpdateMessagesNotify( const std::string & val_r )
1176  { _pimpl->updateMessagesNotify.set( val_r ); }
1177 
1179  { _pimpl->updateMessagesNotify.restoreToDefault(); }
1180 
1182 
1183  target::rpm::RpmInstFlags ZConfig::rpmInstallFlags() const
1184  { return _pimpl->rpmInstallFlags; }
1185 
1186 
1188  {
1189  return ( _pimpl->history_log_path.empty() ?
1190  Pathname("/var/log/zypp/history") : _pimpl->history_log_path );
1191  }
1192 
1194  {
1195  return _pimpl->_mediaConf.credentialsGlobalDir();
1196  }
1197 
1199  {
1200  return _pimpl->_mediaConf.credentialsGlobalFile();
1201  }
1202 
1204 
1205  std::string ZConfig::distroverpkg() const
1206  { return "system-release"; }
1207 
1209 
1211  { return _pimpl->pluginsPath.get(); }
1212 
1213  std::string ZConfig::multiversionKernels() const
1214  {
1215  return _pimpl->cfg_kernel_keep_spec;
1216  }
1217 
1219 
1220  std::ostream & ZConfig::about( std::ostream & str ) const
1221  {
1222  str << "libzypp: " LIBZYPP_VERSION_STRING << endl;
1223 
1224  str << "libsolv: " << solv_version;
1225  if ( ::strcmp( solv_version, LIBSOLV_VERSION_STRING ) )
1226  str << " (built against " << LIBSOLV_VERSION_STRING << ")";
1227  str << endl;
1228 
1229  str << "zypp.conf: '" << _pimpl->_parsedZyppConf << "'" << endl;
1230  str << "TextLocale: '" << textLocale() << "' (" << defaultTextLocale() << ")" << endl;
1231  str << "SystemArchitecture: '" << systemArchitecture() << "' (" << defaultSystemArchitecture() << ")" << endl;
1232  return str;
1233  }
1234 
1236 } // namespace zypp
Architecture.
Definition: Arch.h:37
Helper to create and pass std::istream.
Definition: inputstream.h:57
'Language[_Country]' codes.
Definition: Locale.h:50
static const Locale enCode
Last resort "en".
Definition: Locale.h:77
LocaleSet requestedLocales() const
Languages to be supported by the system.
Definition: Target.cc:94
ZConfig implementation.
Definition: ZConfig.cc:316
Pathname cfg_multiversion_path
Definition: ZConfig.cc:674
DefaultOption< Pathname > download_mediaMountdir
Definition: ZConfig.cc:691
std::set< std::string > MultiversionSpec
Definition: ZConfig.cc:317
DefaultOption< Pathname > cfg_metadata_path
Definition: ZConfig.cc:663
Pathname cfg_known_repos_path
Definition: ZConfig.cc:668
Pathname cfg_known_services_path
Definition: ZConfig.cc:669
Pathname cfg_vars_path
Definition: ZConfig.cc:670
DefaultOption< Pathname > cfg_packages_path
Definition: ZConfig.cc:665
bool download_use_deltarpm_always
Definition: ZConfig.cc:689
Pathname _parsedZyppConf
Remember any parsed zypp.conf.
Definition: ZConfig.cc:657
void notifyTargetChanged()
Definition: ZConfig.cc:631
Pathname solver_checkSystemFile
Definition: ZConfig.cc:699
TargetDefaults & targetDefaults()
Definition: ZConfig.cc:721
MultiversionMap _multiversionMap
Definition: ZConfig.cc:814
Pathname update_data_path
Definition: ZConfig.cc:678
Pathname history_log_path
Definition: ZConfig.cc:709
Pathname locks_file
Definition: ZConfig.cc:676
LocaleSet repoRefreshLocales
Definition: ZConfig.cc:685
DefaultOption< Pathname > cfg_cache_path
Definition: ZConfig.cc:662
Pathname update_scripts_path
Definition: ZConfig.cc:679
Option< Pathname > pluginsPath
Definition: ZConfig.cc:713
std::string userData
Definition: ZConfig.cc:711
std::string cfg_kernel_keep_spec
Definition: ZConfig.cc:675
DefaultOption< TriBool > repoGpgCheck
Definition: ZConfig.cc:696
unsigned repo_refresh_delay
Definition: ZConfig.cc:684
Option< DownloadMode > commit_downloadMode
Definition: ZConfig.cc:693
std::optional< TargetDefaults > _currentTargetDefaults
TargetDefaults while –root.
Definition: ZConfig.cc:724
Locale cfg_textLocale
Definition: ZConfig.cc:660
MultiversionSpec & getMultiversion() const
Definition: ZConfig.cc:811
DefaultOption< bool > download_media_prefer_download
Definition: ZConfig.cc:690
bool download_use_deltarpm
Definition: ZConfig.cc:688
Pathname solver_checkSystemFileDir
Definition: ZConfig.cc:700
Pathname cfg_config_path
Definition: ZConfig.cc:667
TargetDefaults _initialTargetDefaults
Initial TargetDefaults from /.
Definition: ZConfig.cc:723
target::rpm::RpmInstFlags rpmInstallFlags
Definition: ZConfig.cc:707
Pathname update_messages_path
Definition: ZConfig.cc:680
Pathname cfg_repo_mgr_root_path
Definition: ZConfig.cc:671
const MultiversionSpec & multiversion() const
Definition: ZConfig.cc:703
DefaultOption< TriBool > pkgGpgCheck
Definition: ZConfig.cc:697
MultiversionSpec & multiversion()
Definition: ZConfig.cc:702
DefaultOption< std::string > updateMessagesNotify
Definition: ZConfig.cc:681
Pathname cfg_vendor_path
Definition: ZConfig.cc:673
const TargetDefaults & targetDefaults() const
Definition: ZConfig.cc:720
DefaultOption< Pathname > cfg_solvfiles_path
Definition: ZConfig.cc:664
DefaultOption< bool > gpgCheck
Definition: ZConfig.cc:695
Interim helper class to collect global options and settings.
Definition: ZConfig.h:64
bool hasUserData() const
Whether a (non empty) user data sting is defined.
Definition: ZConfig.cc:917
bool solver_cleandepsOnRemove() const
Whether removing a package should also remove no longer needed requirements.
Definition: ZConfig.cc:1120
std::string userData() const
User defined string value to be passed to log, history, plugins...
Definition: ZConfig.cc:920
Pathname knownServicesPath() const
Path where the known services .service files are kept (configPath()/services.d).
Definition: ZConfig.cc:1015
void removeMultiversionSpec(const std::string &name_r)
Definition: ZConfig.cc:1149
Pathname repoPackagesPath() const
Path where the repo packages are downloaded and kept (repoCachePath()/packages).
Definition: ZConfig.cc:978
unsigned repo_refresh_delay() const
Amount of time in minutes that must pass before another refresh.
Definition: ZConfig.cc:1050
Arch systemArchitecture() const
The system architecture zypp uses.
Definition: ZConfig.cc:875
Locale textLocale() const
The locale for translated texts zypp uses.
Definition: ZConfig.cc:899
Pathname update_dataPath() const
Path where the update items are kept (/var/adm)
Definition: ZConfig.cc:1154
ResolverFocus solver_focus() const
The resolver's general attitude when resolving jobs.
Definition: ZConfig.cc:1113
Pathname update_messagesPath() const
Path where the repo solv files are created and kept (update_dataPath()/solv).
Definition: ZConfig.cc:1160
Pathname builtinRepoSolvfilesPath() const
The builtin config file value.
Definition: ZConfig.cc:995
Pathname pluginsPath() const
Defaults to /usr/lib/zypp/plugins.
Definition: ZConfig.cc:1210
Pathname repoManagerRoot() const
The RepoManager root directory.
Definition: ZConfig.cc:854
void resetRepoGpgCheck()
Reset to the zconfig default.
Definition: ZConfig.cc:1109
bool gpgCheck() const
Turn signature checking on/off (on)
Definition: ZConfig.cc:1100
Pathname knownReposPath() const
Path where the known repositories .repo files are kept (configPath()/repos.d).
Definition: ZConfig.cc:1009
Pathname update_scriptsPath() const
Path where the repo metadata is downloaded and kept (update_dataPath()/).
Definition: ZConfig.cc:1166
long download_transfer_timeout() const
Maximum time in seconds that you allow a transfer operation to take.
Definition: ZConfig.cc:1089
void setRepoManagerRoot(const Pathname &root)
Sets the RepoManager root directory.
Definition: ZConfig.cc:860
bool solver_dupAllowArchChange() const
DUP tune: Whether to allow package arch changes upon DUP.
Definition: ZConfig.cc:1118
void setTextLocale(const Locale &locale_r)
Set the preferred locale for translated texts.
Definition: ZConfig.cc:902
bool solverUpgradeRemoveDroppedPackages() const
Whether dist upgrade should remove a products dropped packages (true).
Definition: ZConfig.cc:1123
void notifyTargetChanged()
internal
Definition: ZConfig.cc:848
static Locale defaultTextLocale()
The autodetected preferred locale for translated texts.
Definition: ZConfig.cc:893
Pathname download_mediaMountdir() const
Path where media are preferably mounted or downloaded.
Definition: ZConfig.cc:1092
void resetSolverUpgradeRemoveDroppedPackages()
Reset solverUpgradeRemoveDroppedPackages to the zypp.conf default.
Definition: ZConfig.cc:1125
bool apply_locks_file() const
Whether locks file should be read and applied after start (true)
Definition: ZConfig.cc:1151
bool solver_allowVendorChange() const
Whether vendor check is by default enabled.
Definition: ZConfig.cc:1115
void set_default_download_mediaMountdir()
Reset to zypp.cong default.
Definition: ZConfig.cc:1094
Pathname repoCachePath() const
Path where the caches are kept (/var/cache/zypp)
Definition: ZConfig.cc:940
void setPkgGpgCheck(TriBool val_r)
Change the value.
Definition: ZConfig.cc:1106
Pathname needrebootPath() const
Path where the custom needreboot config files are kept (configPath()/needreboot.d).
Definition: ZConfig.cc:1024
bool setUserData(const std::string &str_r)
Set a new userData string.
Definition: ZConfig.cc:923
Pathname systemRoot() const
The target root directory.
Definition: ZConfig.cc:851
long download_max_silent_tries() const
Maximum silent tries.
Definition: ZConfig.cc:1086
bool repo_add_probe() const
Whether repository urls should be probed.
Definition: ZConfig.cc:1047
target::rpm::RpmInstFlags rpmInstallFlags() const
The default target::rpm::RpmInstFlags for ZYppCommitPolicy.
Definition: ZConfig.cc:1183
void setUpdateMessagesNotify(const std::string &val_r)
Set a new command definition (see update.messages.notify in zypp.conf).
Definition: ZConfig.cc:1175
unsigned solver_upgradeTestcasesToKeep() const
When committing a dist upgrade (e.g.
Definition: ZConfig.cc:1121
Pathname repoMetadataPath() const
Path where the repo metadata is downloaded and kept (repoCachePath()/raw).
Definition: ZConfig.cc:956
Pathname vendorPath() const
Directory for equivalent vendor definitions (configPath()/vendors.d)
Definition: ZConfig.cc:1033
long download_min_download_speed() const
Minimum download speed (bytes per second) until the connection is dropped.
Definition: ZConfig.cc:1080
DownloadMode commit_downloadMode() const
Commit download policy to use as default.
Definition: ZConfig.cc:1096
Pathname needrebootFile() const
Path of the default needreboot config file (configPath()/needreboot).
Definition: ZConfig.cc:1021
void setGpgCheck(bool val_r)
Change the value.
Definition: ZConfig.cc:1104
bool solver_dupAllowVendorChange() const
DUP tune: Whether to allow package vendor changes upon DUP.
Definition: ZConfig.cc:1119
~ZConfig()
Dtor.
Definition: ZConfig.cc:845
Pathname locksFile() const
Path where zypp can find or create lock file (configPath()/locks)
Definition: ZConfig.cc:1039
RW_pointer< Impl, rw_pointer::Scoped< Impl > > _pimpl
Pointer to implementation.
Definition: ZConfig.h:571
Pathname repoSolvfilesPath() const
Path where the repo solv files are created and kept (repoCachePath()/solv).
Definition: ZConfig.cc:967
Pathname historyLogFile() const
Path where ZYpp install history is logged.
Definition: ZConfig.cc:1187
void setSystemArchitecture(const Arch &arch_r)
Override the zypp system architecture.
Definition: ZConfig.cc:878
TriBool pkgGpgCheck() const
Check rpm package signatures (indeterminate - according to gpgcheck)
Definition: ZConfig.cc:1102
static ZConfig & instance()
Singleton ctor.
Definition: ZConfig.cc:823
void setRepoPackagesPath(const Pathname &path_r)
Set a new path as the default repo cache path.
Definition: ZConfig.cc:984
void setRepoSolvfilesPath(const Pathname &path_r)
Set a new path as the default repo cache path.
Definition: ZConfig.cc:973
void resetUpdateMessagesNotify()
Reset to the zypp.conf default.
Definition: ZConfig.cc:1178
std::ostream & about(std::ostream &str) const
Print some detail about the current libzypp version.
Definition: ZConfig.cc:1220
const std::set< std::string > & multiversionSpec() const
Definition: ZConfig.cc:1145
void set_download_mediaMountdir(Pathname newval_r)
Set alternate value.
Definition: ZConfig.cc:1093
bool download_use_deltarpm() const
Whether to consider using a deltarpm when downloading a package.
Definition: ZConfig.cc:1062
TriBool repoGpgCheck() const
Check repo matadata signatures (indeterminate - according to gpgcheck)
Definition: ZConfig.cc:1101
void set_download_media_prefer_download(bool yesno_r)
Set download_media_prefer_download to a specific value.
Definition: ZConfig.cc:1071
std::string updateMessagesNotify() const
Command definition for sending update messages.
Definition: ZConfig.cc:1172
void addMultiversionSpec(const std::string &name_r)
Definition: ZConfig.cc:1148
Pathname builtinRepoCachePath() const
The builtin config file value.
Definition: ZConfig.cc:989
Pathname builtinRepoPackagesPath() const
The builtin config file value.
Definition: ZConfig.cc:998
Pathname solver_checkSystemFile() const
File in which dependencies described which has to be fulfilled for a running system.
Definition: ZConfig.cc:1128
Pathname builtinRepoMetadataPath() const
The builtin config file value.
Definition: ZConfig.cc:992
void set_default_download_media_prefer_download()
Set download_media_prefer_download to the configfiles default.
Definition: ZConfig.cc:1074
Pathname solver_checkSystemFileDir() const
Directory, which may or may not contain files in which dependencies described which has to be fulfill...
Definition: ZConfig.cc:1132
void resetGpgCheck()
Reset to the zconfig default.
Definition: ZConfig.cc:1108
void setSolverUpgradeRemoveDroppedPackages(bool val_r)
Set solverUpgradeRemoveDroppedPackages to val_r.
Definition: ZConfig.cc:1124
Pathname configPath() const
Path where the configfiles are kept (/etc/zypp).
Definition: ZConfig.cc:1003
static Arch defaultSystemArchitecture()
The autodetected system architecture.
Definition: ZConfig.cc:869
ZConfig()
Default ctor.
Definition: ZConfig.cc:834
Pathname pubkeyCachePath() const
Path where the pubkey caches.
Definition: ZConfig.cc:946
long download_max_concurrent_connections() const
Maximum number of concurrent connections for a single transfer.
Definition: ZConfig.cc:1077
void resetPkgGpgCheck()
Reset to the zconfig default.
Definition: ZConfig.cc:1110
bool solver_onlyRequires() const
Solver regards required packages,patterns,...
Definition: ZConfig.cc:1114
Pathname varsPath() const
Path containing custom repo variable definitions (configPath()/vars.d).
Definition: ZConfig.cc:1027
bool solver_dupAllowNameChange() const
DUP tune: Whether to follow package renames upon DUP.
Definition: ZConfig.cc:1117
bool repoLabelIsAlias() const
Whether to use repository alias or name in user messages (progress, exceptions, .....
Definition: ZConfig.cc:1056
void clearMultiversionSpec()
Definition: ZConfig.cc:1147
LocaleSet repoRefreshLocales() const
List of locales for which translated package descriptions should be downloaded.
Definition: ZConfig.cc:1053
long download_max_download_speed() const
Maximum download speed (bytes per second)
Definition: ZConfig.cc:1083
void setRepoMetadataPath(const Pathname &path_r)
Set a new path as the default repo cache path.
Definition: ZConfig.cc:962
bool solver_dupAllowDowngrade() const
DUP tune: Whether to allow version downgrades upon DUP.
Definition: ZConfig.cc:1116
std::string multiversionKernels() const
Definition: ZConfig.cc:1213
std::string distroverpkg() const
Package telling the "product version" on systems not using /etc/product.d/baseproduct.
Definition: ZConfig.cc:1205
bool download_use_deltarpm_always() const
Whether to consider using a deltarpm even when rpm is local.
Definition: ZConfig.cc:1065
void setRepoCachePath(const Pathname &path_r)
Set a new path as the default repo cache path.
Definition: ZConfig.cc:951
void setRepoGpgCheck(TriBool val_r)
Change the value.
Definition: ZConfig.cc:1105
Pathname credentialsGlobalDir() const
Defaults to /etc/zypp/credentials.d.
Definition: ZConfig.cc:1193
bool download_media_prefer_download() const
Hint which media to prefer when installing packages (download vs.
Definition: ZConfig.cc:1068
Pathname credentialsGlobalFile() const
Defaults to /etc/zypp/credentials.cat.
Definition: ZConfig.cc:1198
Wrapper class for ::stat/::lstat.
Definition: PathInfo.h:221
bool empty() const
Test for an empty path.
Definition: Pathname.h:114
static Pathname assertprefix(const Pathname &root_r, const Pathname &path_r)
Return path_r prefixed with root_r, unless it is already prefixed.
Definition: Pathname.cc:235
Parses a INI file and offers its structure as a dictionary.
Definition: inidict.h:42
section_const_iterator sectionsEnd() const
Definition: inidict.cc:113
EntrySet::const_iterator entry_const_iterator
Definition: inidict.h:48
MapKVIteratorTraits< SectionSet >::Key_const_iterator section_const_iterator
Definition: inidict.h:47
entry_const_iterator entriesBegin(const std::string &section) const
Definition: inidict.cc:75
Iterable< entry_const_iterator > entries(const std::string &section) const
Definition: inidict.cc:97
section_const_iterator sectionsBegin() const
Definition: inidict.cc:108
entry_const_iterator entriesEnd(const std::string &section) const
Definition: inidict.cc:86
void setTextLocale(const Locale &locale_r)
Set the default language for retrieving translated texts.
Definition: Pool.cc:233
static Pool instance()
Singleton ctor.
Definition: Pool.h:55
Regular expression.
Definition: Regex.h:95
Regular expression match result.
Definition: Regex.h:168
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition: String.h:30
Definition: Arch.h:352
String related utilities and Regular expression matching.
Types and functions for filesystem operations.
Definition: Glob.cc:24
int dirForEach(const Pathname &dir_r, const StrMatcher &matcher_r, function< bool(const Pathname &, const char *const)> fnc_r)
Definition: PathInfo.cc:32
int simpleParseFile(std::istream &str_r, ParseFlags flags_r, function< bool(int, std::string)> consume_r)
Simple lineparser optionally trimming and skipping comments.
Definition: IOStream.cc:124
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
Definition: String.h:1027
TriBool strToTriBool(const C_Str &str)
Parse str into a bool if it's a legal true or false string; else indeterminate.
Definition: String.cc:93
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
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
Definition: String.h:429
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:531
TInt strtonum(const C_Str &str)
Parsing numbers from string.
Definition: String.h:388
unsigned splitEscaped(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \t", bool withEmpty=false)
Split line_r into words with respect to escape delimeters.
Definition: String.h:595
int compareCI(const C_Str &lhs, const C_Str &rhs)
Definition: String.h:984
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
bool fromString(const std::string &val_r, ResolverFocus &ret_r)
ResolverFocus
The resolver's general attitude.
Definition: ResolverFocus.h:22
@ Default
Request the standard behavior (as defined in zypp.conf or 'Job')
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:27
DownloadMode
Supported commit download policies.
Definition: DownloadMode.h:23
@ DownloadDefault
libzypp will decide what to do.
Definition: DownloadMode.h:24
Mutable option with initial value also remembering a config value.
Definition: ZConfig.cc:274
DefaultOption(value_type initial_r)
Definition: ZConfig.cc:278
DefaultOption & operator=(value_type newval_r)
Definition: ZConfig.cc:283
option_type _default
Definition: ZConfig.cc:303
void setDefault(value_type newval_r)
Set a new default value.
Definition: ZConfig.cc:299
void restoreToDefault(value_type newval_r)
Reset value to a new default.
Definition: ZConfig.cc:291
const value_type & getDefault() const
Get the current default value.
Definition: ZConfig.cc:295
Option< Tp > option_type
Definition: ZConfig.cc:276
void restoreToDefault()
Reset value to the current default.
Definition: ZConfig.cc:287
Mutable option.
Definition: ZConfig.cc:244
void set(value_type newval_r)
Set a new value.
Definition: ZConfig.cc:264
Option(value_type initial_r)
No default ctor, explicit initialisation!
Definition: ZConfig.cc:248
value_type _val
Definition: ZConfig.cc:268
Option & operator=(value_type newval_r)
Definition: ZConfig.cc:252
const value_type & get() const
Get the value.
Definition: ZConfig.cc:256
MultiversionSpec & getDefaultSpec()
Definition: ZConfig.cc:763
void scanDirAt(const Pathname root_r, MultiversionSpec &spec_r, const Impl &zConfImpl_r)
Definition: ZConfig.cc:783
std::map< Pathname, MultiversionSpec > SpecMap
Definition: ZConfig.cc:734
MultiversionSpec & getSpec(Pathname root_r, const Impl &zConfImpl_r)
Definition: ZConfig.cc:736
int scanConfAt(const Pathname root_r, MultiversionSpec &spec_r, const Impl &zConfImpl_r)
Definition: ZConfig.cc:767
Settings that follow a changed Target.
Definition: ZConfig.cc:321
Option< bool > solver_dupAllowVendorChange
Definition: ZConfig.cc:389
DefaultOption< bool > solverUpgradeRemoveDroppedPackages
Definition: ZConfig.cc:392
Option< unsigned > solver_upgradeTestcasesToKeep
Definition: ZConfig.cc:391
Option< bool > solver_dupAllowDowngrade
Definition: ZConfig.cc:386
Option< bool > solver_dupAllowArchChange
Definition: ZConfig.cc:388
bool consume(const std::string &entry, const std::string &value)
Definition: ZConfig.cc:335
Option< bool > solver_cleandepsOnRemove
Definition: ZConfig.cc:390
Option< bool > solver_allowVendorChange
Definition: ZConfig.cc:385
Option< bool > solver_dupAllowNameChange
Definition: ZConfig.cc:387
static PoolImpl & myPool()
Definition: PoolImpl.cc:184
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:28
#define DBG
Definition: Logger.h:95
#define MIL
Definition: Logger.h:96
#define ERR
Definition: Logger.h:98
#define WAR
Definition: Logger.h:97