libzypp  13.10.6
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 "zypp/base/Logger.h"
25 #include "zypp/base/IOStream.h"
26 #include "zypp/base/InputStream.h"
27 #include "zypp/base/String.h"
28 
29 #include "zypp/ZConfig.h"
30 #include "zypp/ZYppFactory.h"
31 #include "zypp/PathInfo.h"
32 #include "zypp/parser/IniDict.h"
33 
34 #include "zypp/sat/Pool.h"
35 
36 using namespace std;
37 using namespace zypp::filesystem;
38 using namespace zypp::parser;
39 
40 #undef ZYPP_BASE_LOGGER_LOGGROUP
41 #define ZYPP_BASE_LOGGER_LOGGROUP "zconfig"
42 
44 namespace zypp
45 {
46 
55  namespace
57  {
58 
61  Arch _autodetectSystemArchitecture()
62  {
63  struct ::utsname buf;
64  if ( ::uname( &buf ) < 0 )
65  {
66  ERR << "Can't determine system architecture" << endl;
67  return Arch_noarch;
68  }
69 
70  Arch architecture( buf.machine );
71  MIL << "Uname architecture is '" << buf.machine << "'" << endl;
72 
73  if ( architecture == Arch_i686 )
74  {
75  // some CPUs report i686 but dont implement cx8 and cmov
76  // check for both flags in /proc/cpuinfo and downgrade
77  // to i586 if either is missing (cf bug #18885)
78  std::ifstream cpuinfo( "/proc/cpuinfo" );
79  if ( cpuinfo )
80  {
81  for( iostr::EachLine in( cpuinfo ); in; in.next() )
82  {
83  if ( str::hasPrefix( *in, "flags" ) )
84  {
85  if ( in->find( "cx8" ) == std::string::npos
86  || in->find( "cmov" ) == std::string::npos )
87  {
88  architecture = Arch_i586;
89  WAR << "CPU lacks 'cx8' or 'cmov': architecture downgraded to '" << architecture << "'" << endl;
90  }
91  break;
92  }
93  }
94  }
95  else
96  {
97  ERR << "Cant open " << PathInfo("/proc/cpuinfo") << endl;
98  }
99  }
100  else if ( architecture == Arch_sparc || architecture == Arch_sparc64 )
101  {
102  // Check for sun4[vum] to get the real arch. (bug #566291)
103  std::ifstream cpuinfo( "/proc/cpuinfo" );
104  if ( cpuinfo )
105  {
106  for( iostr::EachLine in( cpuinfo ); in; in.next() )
107  {
108  if ( str::hasPrefix( *in, "type" ) )
109  {
110  if ( in->find( "sun4v" ) != std::string::npos )
111  {
112  architecture = ( architecture == Arch_sparc64 ? Arch_sparc64v : Arch_sparcv9v );
113  WAR << "CPU has 'sun4v': architecture upgraded to '" << architecture << "'" << endl;
114  }
115  else if ( in->find( "sun4u" ) != std::string::npos )
116  {
117  architecture = ( architecture == Arch_sparc64 ? Arch_sparc64 : Arch_sparcv9 );
118  WAR << "CPU has 'sun4u': architecture upgraded to '" << architecture << "'" << endl;
119  }
120  else if ( in->find( "sun4m" ) != std::string::npos )
121  {
122  architecture = Arch_sparcv8;
123  WAR << "CPU has 'sun4m': architecture upgraded to '" << architecture << "'" << endl;
124  }
125  break;
126  }
127  }
128  }
129  else
130  {
131  ERR << "Cant open " << PathInfo("/proc/cpuinfo") << endl;
132  }
133  }
134  else if ( architecture == Arch_armv7l || architecture == Arch_armv6l )
135  {
136  std::ifstream platform( "/etc/rpm/platform" );
137  if (platform)
138  {
139  for( iostr::EachLine in( platform ); in; in.next() )
140  {
141  if ( str::hasPrefix( *in, "armv7hl-" ) )
142  {
143  architecture = Arch_armv7hl;
144  WAR << "/etc/rpm/platform contains armv7hl-: architecture upgraded to '" << architecture << "'" << endl;
145  break;
146  }
147  if ( str::hasPrefix( *in, "armv6hl-" ) )
148  {
149  architecture = Arch_armv6hl;
150  WAR << "/etc/rpm/platform contains armv6hl-: architecture upgraded to '" << architecture << "'" << endl;
151  break;
152  }
153  }
154  }
155  }
156 #if __GLIBC_PREREQ (2,16)
157  else if ( architecture == Arch_ppc64 )
158  {
159  const char * platform = (const char *)getauxval( AT_PLATFORM );
160  int powerlvl;
161  if ( platform && sscanf( platform, "power%d", &powerlvl ) == 1 && powerlvl > 6 )
162  architecture = Arch_ppc64p7;
163  }
164 #endif
165  return architecture;
166  }
167 
185  Locale _autodetectTextLocale()
186  {
187  Locale ret( "en" );
188  const char * envlist[] = { "LC_ALL", "LC_MESSAGES", "LANG", NULL };
189  for ( const char ** envvar = envlist; *envvar; ++envvar )
190  {
191  const char * envlang = getenv( *envvar );
192  if ( envlang )
193  {
194  std::string envstr( envlang );
195  if ( envstr != "POSIX" && envstr != "C" )
196  {
197  Locale lang( envstr );
198  if ( ! lang.code().empty() )
199  {
200  MIL << "Found " << *envvar << "=" << envstr << endl;
201  ret = lang;
202  break;
203  }
204  }
205  }
206  }
207  MIL << "Default text locale is '" << ret << "'" << endl;
208 #warning HACK AROUND BOOST_TEST_CATCH_SYSTEM_ERRORS
209  setenv( "BOOST_TEST_CATCH_SYSTEM_ERRORS", "no", 1 );
210  return ret;
211  }
212 
214  } // namespace zypp
216 
218  template<class _Tp>
219  struct Option
220  {
221  typedef _Tp value_type;
222 
224  Option( const value_type & initial_r )
225  : _val( initial_r )
226  {}
227 
229  const value_type & get() const
230  { return _val; }
231 
233  operator const value_type &() const
234  { return _val; }
235 
237  void set( const value_type & newval_r )
238  { _val = newval_r; }
239 
242  { return _val; }
243 
244  private:
246  };
247 
249  template<class _Tp>
250  struct DefaultOption : public Option<_Tp>
251  {
252  typedef _Tp value_type;
254 
255  DefaultOption( const value_type & initial_r )
256  : Option<_Tp>( initial_r ), _default( initial_r )
257  {}
258 
261  { this->set( _default.get() ); }
262 
264  void restoreToDefault( const value_type & newval_r )
265  { setDefault( newval_r ); restoreToDefault(); }
266 
268  const value_type & getDefault() const
269  { return _default.get(); }
270 
272  void setDefault( const value_type & newval_r )
273  { _default.set( newval_r ); }
274 
275  private:
277  };
278 
280  //
281  // CLASS NAME : ZConfig::Impl
282  //
289  {
290  public:
291  Impl( const Pathname & override_r = Pathname() )
292  : _parsedZyppConf ( override_r )
293  , cfg_arch ( defaultSystemArchitecture() )
294  , cfg_textLocale ( defaultTextLocale() )
295  , updateMessagesNotify ( "single | /usr/lib/zypp/notify-message -p %p" )
296  , repo_add_probe ( false )
297  , repo_refresh_delay ( 10 )
298  , repoLabelIsAlias ( false )
299  , download_use_deltarpm ( true )
300  , download_use_deltarpm_always ( false )
301  , download_media_prefer_download( true )
302  , download_max_concurrent_connections( 5 )
303  , download_min_download_speed ( 0 )
304  , download_max_download_speed ( 0 )
305  , download_max_silent_tries ( 5 )
306  , download_transfer_timeout ( 180 )
307  , commit_downloadMode ( DownloadDefault )
308  , solver_onlyRequires ( false )
309  , solver_allowVendorChange ( false )
310  , solver_cleandepsOnRemove ( false )
311  , solver_upgradeTestcasesToKeep ( 2 )
312  , solverUpgradeRemoveDroppedPackages( true )
313  , apply_locks_file ( true )
314  , pluginsPath ( "/usr/lib/zypp/plugins" )
315  {
316  MIL << "libzypp: " << VERSION << " built " << __DATE__ << " " << __TIME__ << endl;
317  // override_r has higest prio
318  // ZYPP_CONF might override /etc/zypp/zypp.conf
319  if ( _parsedZyppConf.empty() )
320  {
321  const char *env_confpath = getenv( "ZYPP_CONF" );
322  _parsedZyppConf = env_confpath ? env_confpath : "/etc/zypp/zypp.conf";
323  }
324  else
325  {
326  // Inject this into ZConfig. Be shure this is
327  // allocated via new. See: reconfigureZConfig
328  INT << "Reconfigure to " << _parsedZyppConf << endl;
329  ZConfig::instance()._pimpl.reset( this );
330  }
331  if ( PathInfo(_parsedZyppConf).isExist() )
332  {
333  parser::IniDict dict( _parsedZyppConf );
335  sit != dict.sectionsEnd();
336  ++sit )
337  {
338  string section(*sit);
339  //MIL << section << endl;
340  for ( IniDict::entry_const_iterator it = dict.entriesBegin(*sit);
341  it != dict.entriesEnd(*sit);
342  ++it )
343  {
344  string entry(it->first);
345  string value(it->second);
346  //DBG << (*it).first << "=" << (*it).second << endl;
347  if ( section == "main" )
348  {
349  if ( entry == "arch" )
350  {
351  Arch carch( value );
352  if ( carch != cfg_arch )
353  {
354  WAR << "Overriding system architecture (" << cfg_arch << "): " << carch << endl;
355  cfg_arch = carch;
356  }
357  }
358  else if ( entry == "cachedir" )
359  {
360  cfg_cache_path = Pathname(value);
361  }
362  else if ( entry == "metadatadir" )
363  {
364  cfg_metadata_path = Pathname(value);
365  }
366  else if ( entry == "solvfilesdir" )
367  {
368  cfg_solvfiles_path = Pathname(value);
369  }
370  else if ( entry == "packagesdir" )
371  {
372  cfg_packages_path = Pathname(value);
373  }
374  else if ( entry == "configdir" )
375  {
376  cfg_config_path = Pathname(value);
377  }
378  else if ( entry == "reposdir" )
379  {
380  cfg_known_repos_path = Pathname(value);
381  }
382  else if ( entry == "servicesdir" )
383  {
384  cfg_known_services_path = Pathname(value);
385  }
386  else if ( entry == "repo.add.probe" )
387  {
388  repo_add_probe = str::strToBool( value, repo_add_probe );
389  }
390  else if ( entry == "repo.refresh.delay" )
391  {
392  str::strtonum(value, repo_refresh_delay);
393  }
394  else if ( entry == "repo.refresh.locales" )
395  {
396  std::vector<std::string> tmp;
397  str::split( value, back_inserter( tmp ), ", \t" );
398 
399  boost::function<Locale(const std::string &)> transform(
400  [](const std::string & str_r)->Locale{ return Locale(str_r); }
401  );
402  repoRefreshLocales.insert( make_transform_iterator( tmp.begin(), transform ),
403  make_transform_iterator( tmp.end(), transform ) );
404  }
405  else if ( entry == "download.use_deltarpm" )
406  {
407  download_use_deltarpm = str::strToBool( value, download_use_deltarpm );
408  }
409  else if ( entry == "download.use_deltarpm.always" )
410  {
411  download_use_deltarpm_always = str::strToBool( value, download_use_deltarpm_always );
412  }
413  else if ( entry == "download.media_preference" )
414  {
415  download_media_prefer_download.restoreToDefault( str::compareCI( value, "volatile" ) != 0 );
416  }
417  else if ( entry == "download.max_concurrent_connections" )
418  {
419  str::strtonum(value, download_max_concurrent_connections);
420  }
421  else if ( entry == "download.min_download_speed" )
422  {
423  str::strtonum(value, download_min_download_speed);
424  }
425  else if ( entry == "download.max_download_speed" )
426  {
427  str::strtonum(value, download_max_download_speed);
428  }
429  else if ( entry == "download.max_silent_tries" )
430  {
431  str::strtonum(value, download_max_silent_tries);
432  }
433  else if ( entry == "download.transfer_timeout" )
434  {
435  str::strtonum(value, download_transfer_timeout);
436  if ( download_transfer_timeout < 0 ) download_transfer_timeout = 0;
437  else if ( download_transfer_timeout > 3600 ) download_transfer_timeout = 3600;
438  }
439  else if ( entry == "commit.downloadMode" )
440  {
441  commit_downloadMode.set( deserializeDownloadMode( value ) );
442  }
443  else if ( entry == "vendordir" )
444  {
445  cfg_vendor_path = Pathname(value);
446  }
447  else if ( entry == "multiversiondir" )
448  {
449  cfg_multiversion_path = Pathname(value);
450  }
451  else if ( entry == "solver.onlyRequires" )
452  {
453  solver_onlyRequires.set( str::strToBool( value, solver_onlyRequires ) );
454  }
455  else if ( entry == "solver.allowVendorChange" )
456  {
457  solver_allowVendorChange.set( str::strToBool( value, solver_allowVendorChange ) );
458  }
459  else if ( entry == "solver.cleandepsOnRemove" )
460  {
461  solver_cleandepsOnRemove.set( str::strToBool( value, solver_cleandepsOnRemove ) );
462  }
463  else if ( entry == "solver.upgradeTestcasesToKeep" )
464  {
465  solver_upgradeTestcasesToKeep.set( str::strtonum<unsigned>( value ) );
466  }
467  else if ( entry == "solver.upgradeRemoveDroppedPackages" )
468  {
469  solverUpgradeRemoveDroppedPackages.restoreToDefault( str::strToBool( value, solverUpgradeRemoveDroppedPackages.getDefault() ) );
470  }
471  else if ( entry == "solver.checkSystemFile" )
472  {
473  solver_checkSystemFile = Pathname(value);
474  }
475  else if ( entry == "multiversion" )
476  {
477  str::split( value, inserter( _multiversion, _multiversion.end() ), ", \t" );
478  }
479  else if ( entry == "locksfile.path" )
480  {
481  locks_file = Pathname(value);
482  }
483  else if ( entry == "locksfile.apply" )
484  {
485  apply_locks_file = str::strToBool( value, apply_locks_file );
486  }
487  else if ( entry == "update.datadir" )
488  {
489  update_data_path = Pathname(value);
490  }
491  else if ( entry == "update.scriptsdir" )
492  {
493  update_scripts_path = Pathname(value);
494  }
495  else if ( entry == "update.messagessdir" )
496  {
497  update_messages_path = Pathname(value);
498  }
499  else if ( entry == "update.messages.notify" )
500  {
501  updateMessagesNotify.set( value );
502  }
503  else if ( entry == "rpm.install.excludedocs" )
504  {
505  rpmInstallFlags.setFlag( target::rpm::RPMINST_EXCLUDEDOCS,
506  str::strToBool( value, false ) );
507  }
508  else if ( entry == "history.logfile" )
509  {
510  history_log_path = Pathname(value);
511  }
512  else if ( entry == "credentials.global.dir" )
513  {
514  credentials_global_dir_path = Pathname(value);
515  }
516  else if ( entry == "credentials.global.file" )
517  {
518  credentials_global_file_path = Pathname(value);
519  }
520  }
521  }
522  }
523  }
524  else
525  {
526  MIL << _parsedZyppConf << " not found, using defaults instead." << endl;
527  _parsedZyppConf = _parsedZyppConf.extend( " (NOT FOUND)" );
528  }
529 
530  // legacy:
531  if ( getenv( "ZYPP_TESTSUITE_FAKE_ARCH" ) )
532  {
533  Arch carch( getenv( "ZYPP_TESTSUITE_FAKE_ARCH" ) );
534  if ( carch != cfg_arch )
535  {
536  WAR << "ZYPP_TESTSUITE_FAKE_ARCH: Overriding system architecture (" << cfg_arch << "): " << carch << endl;
537  cfg_arch = carch;
538  }
539  }
540  MIL << "ZConfig singleton created." << endl;
541  }
542 
544  {}
545 
546  public:
548  Pathname _parsedZyppConf;
549 
552 
553  Pathname cfg_cache_path;
557 
558  Pathname cfg_config_path;
561 
562  Pathname cfg_vendor_path;
564  Pathname locks_file;
565 
570 
575 
579 
585 
587 
593 
595 
596  std::set<std::string> & multiversion() { return getMultiversion(); }
597  const std::set<std::string> & multiversion() const { return getMultiversion(); }
598 
600 
601  target::rpm::RpmInstFlags rpmInstallFlags;
602 
606 
607  std::string userData;
608 
610 
611  private:
612  std::set<std::string> & getMultiversion() const
613  {
614  if ( ! _multiversionInitialized )
615  {
616  Pathname multiversionDir( cfg_multiversion_path );
617  if ( multiversionDir.empty() )
618  multiversionDir = ( cfg_config_path.empty() ? Pathname("/etc/zypp") : cfg_config_path ) / "multiversion.d";
619 
620  filesystem::dirForEach( multiversionDir,
621  [this]( const Pathname & dir_r, const char *const & name_r )->bool
622  {
623  MIL << "Parsing " << dir_r/name_r << endl;
624  iostr::simpleParseFile( InputStream( dir_r/name_r ),
625  [this]( int num_r, std::string line_r )->bool
626  {
627  DBG << " found " << line_r << endl;
628  _multiversion.insert( line_r );
629  return true;
630  } );
631  return true;
632  } );
633  _multiversionInitialized = true;
634  }
635  return _multiversion;
636  }
637  mutable std::set<std::string> _multiversion;
639  };
641 
642  // Backdoor to redirect ZConfig from within the running
643  // TEST-application. HANDLE WITH CARE!
644  void reconfigureZConfig( const Pathname & override_r )
645  {
646  // ctor puts itself unter smart pointer control.
647  new ZConfig::Impl( override_r );
648  }
649 
651  //
652  // METHOD NAME : ZConfig::instance
653  // METHOD TYPE : ZConfig &
654  //
655  ZConfig & ZConfig::instance()
656  {
657  static ZConfig _instance; // The singleton
658  return _instance;
659  }
660 
662  //
663  // METHOD NAME : ZConfig::ZConfig
664  // METHOD TYPE : Ctor
665  //
666  ZConfig::ZConfig()
667  : _pimpl( new Impl )
668  {
669  about( MIL );
670  }
671 
673  //
674  // METHOD NAME : ZConfig::~ZConfig
675  // METHOD TYPE : Dtor
676  //
678  {}
679 
680  Pathname ZConfig::systemRoot() const
681  {
682  Target_Ptr target( getZYpp()->getTarget() );
683  return target ? target->root() : Pathname();
684  }
685 
687  //
688  // system architecture
689  //
691 
693  {
694  static Arch _val( _autodetectSystemArchitecture() );
695  return _val;
696  }
697 
699  { return _pimpl->cfg_arch; }
700 
701  void ZConfig::setSystemArchitecture( const Arch & arch_r )
702  {
703  if ( arch_r != _pimpl->cfg_arch )
704  {
705  WAR << "Overriding system architecture (" << _pimpl->cfg_arch << "): " << arch_r << endl;
706  _pimpl->cfg_arch = arch_r;
707  }
708  }
709 
711  //
712  // text locale
713  //
715 
717  {
718  static Locale _val( _autodetectTextLocale() );
719  return _val;
720  }
721 
723  { return _pimpl->cfg_textLocale; }
724 
725  void ZConfig::setTextLocale( const Locale & locale_r )
726  {
727  if ( locale_r != _pimpl->cfg_textLocale )
728  {
729  WAR << "Overriding text locale (" << _pimpl->cfg_textLocale << "): " << locale_r << endl;
730  _pimpl->cfg_textLocale = locale_r;
731 #warning prefer signal
732  sat::Pool::instance().setTextLocale( locale_r );
733  }
734  }
735 
737  // user data
739 
740  bool ZConfig::hasUserData() const
741  { return !_pimpl->userData.empty(); }
742 
743  std::string ZConfig::userData() const
744  { return _pimpl->userData; }
745 
746  bool ZConfig::setUserData( const std::string & str_r )
747  {
748  for_( ch, str_r.begin(), str_r.end() )
749  {
750  if ( *ch < ' ' && *ch != '\t' )
751  {
752  ERR << "New user data string rejectded: char " << (int)*ch << " at position " << (ch - str_r.begin()) << endl;
753  return false;
754  }
755  }
756  MIL << "Set user data string to '" << str_r << "'" << endl;
757  _pimpl->userData = str_r;
758  return true;
759  }
760 
762 
763  Pathname ZConfig::repoCachePath() const
764  {
765  return ( _pimpl->cfg_cache_path.empty()
766  ? Pathname("/var/cache/zypp") : _pimpl->cfg_cache_path );
767  }
768 
769  Pathname ZConfig::repoMetadataPath() const
770  {
771  return ( _pimpl->cfg_metadata_path.empty()
772  ? (repoCachePath()/"raw") : _pimpl->cfg_metadata_path );
773  }
774 
775  Pathname ZConfig::repoSolvfilesPath() const
776  {
777  return ( _pimpl->cfg_solvfiles_path.empty()
778  ? (repoCachePath()/"solv") : _pimpl->cfg_solvfiles_path );
779  }
780 
781  Pathname ZConfig::repoPackagesPath() const
782  {
783  return ( _pimpl->cfg_packages_path.empty()
784  ? (repoCachePath()/"packages") : _pimpl->cfg_packages_path );
785  }
786 
788 
789  Pathname ZConfig::configPath() const
790  {
791  return ( _pimpl->cfg_config_path.empty()
792  ? Pathname("/etc/zypp") : _pimpl->cfg_config_path );
793  }
794 
795  Pathname ZConfig::knownReposPath() const
796  {
797  return ( _pimpl->cfg_known_repos_path.empty()
798  ? (configPath()/"repos.d") : _pimpl->cfg_known_repos_path );
799  }
800 
801  Pathname ZConfig::knownServicesPath() const
802  {
803  return ( _pimpl->cfg_known_services_path.empty()
804  ? (configPath()/"services.d") : _pimpl->cfg_known_services_path );
805  }
806 
807  Pathname ZConfig::vendorPath() const
808  {
809  return ( _pimpl->cfg_vendor_path.empty()
810  ? (configPath()/"vendors.d") : _pimpl->cfg_vendor_path );
811  }
812 
813  Pathname ZConfig::locksFile() const
814  {
815  return ( _pimpl->locks_file.empty()
816  ? (configPath()/"locks") : _pimpl->locks_file );
817  }
818 
820 
822  { return _pimpl->repo_add_probe; }
823 
825  { return _pimpl->repo_refresh_delay; }
826 
828  { return _pimpl->repoRefreshLocales.empty() ? Target::requestedLocales("") :_pimpl->repoRefreshLocales; }
829 
831  { return _pimpl->repoLabelIsAlias; }
832 
833  void ZConfig::repoLabelIsAlias( bool yesno_r )
834  { _pimpl->repoLabelIsAlias = yesno_r; }
835 
837  { return _pimpl->download_use_deltarpm; }
838 
840  { return download_use_deltarpm() && _pimpl->download_use_deltarpm_always; }
841 
843  { return _pimpl->download_media_prefer_download; }
844 
846  { _pimpl->download_media_prefer_download.set( yesno_r ); }
847 
849  { _pimpl->download_media_prefer_download.restoreToDefault(); }
850 
852  { return _pimpl->download_max_concurrent_connections; }
853 
855  { return _pimpl->download_min_download_speed; }
856 
858  { return _pimpl->download_max_download_speed; }
859 
861  { return _pimpl->download_max_silent_tries; }
862 
864  { return _pimpl->download_transfer_timeout; }
865 
867  { return _pimpl->commit_downloadMode; }
868 
870  { return _pimpl->solver_onlyRequires; }
871 
873  { return _pimpl->solver_allowVendorChange; }
874 
876  { return _pimpl->solver_cleandepsOnRemove; }
877 
879  { return ( _pimpl->solver_checkSystemFile.empty()
880  ? (configPath()/"systemCheck") : _pimpl->solver_checkSystemFile ); }
881 
883  { return _pimpl->solver_upgradeTestcasesToKeep; }
884 
885  bool ZConfig::solverUpgradeRemoveDroppedPackages() const { return _pimpl->solverUpgradeRemoveDroppedPackages; }
886  void ZConfig::setSolverUpgradeRemoveDroppedPackages( bool val_r ) { _pimpl->solverUpgradeRemoveDroppedPackages.set( val_r ); }
887  void ZConfig::resetSolverUpgradeRemoveDroppedPackages() { _pimpl->solverUpgradeRemoveDroppedPackages.restoreToDefault(); }
888 
889  const std::set<std::string> & ZConfig::multiversionSpec() const { return _pimpl->multiversion(); }
890  void ZConfig::multiversionSpec( std::set<std::string> new_r ) { _pimpl->multiversion().swap( new_r ); }
891  void ZConfig::clearMultiversionSpec() { _pimpl->multiversion().clear(); }
892  void ZConfig::addMultiversionSpec( const std::string & name_r ) { _pimpl->multiversion().insert( name_r ); }
893  void ZConfig::removeMultiversionSpec( const std::string & name_r ) { _pimpl->multiversion().erase( name_r ); }
894 
896  { return _pimpl->apply_locks_file; }
897 
898  Pathname ZConfig::update_dataPath() const
899  {
900  return ( _pimpl->update_data_path.empty()
901  ? Pathname("/var/adm") : _pimpl->update_data_path );
902  }
903 
905  {
906  return ( _pimpl->update_messages_path.empty()
907  ? Pathname(update_dataPath()/"update-messages") : _pimpl->update_messages_path );
908  }
909 
911  {
912  return ( _pimpl->update_scripts_path.empty()
913  ? Pathname(update_dataPath()/"update-scripts") : _pimpl->update_scripts_path );
914  }
915 
916  std::string ZConfig::updateMessagesNotify() const
917  { return _pimpl->updateMessagesNotify; }
918 
919  void ZConfig::setUpdateMessagesNotify( const std::string & val_r )
920  { _pimpl->updateMessagesNotify.set( val_r ); }
921 
923  { _pimpl->updateMessagesNotify.restoreToDefault(); }
924 
926 
927  target::rpm::RpmInstFlags ZConfig::rpmInstallFlags() const
928  { return _pimpl->rpmInstallFlags; }
929 
930 
931  Pathname ZConfig::historyLogFile() const
932  {
933  return ( _pimpl->history_log_path.empty() ?
934  Pathname("/var/log/zypp/history") : _pimpl->history_log_path );
935  }
936 
938  {
939  return ( _pimpl->credentials_global_dir_path.empty() ?
940  Pathname("/etc/zypp/credentials.d") : _pimpl->credentials_global_dir_path );
941  }
942 
944  {
945  return ( _pimpl->credentials_global_file_path.empty() ?
946  Pathname("/etc/zypp/credentials.cat") : _pimpl->credentials_global_file_path );
947  }
948 
950 
951  std::string ZConfig::distroverpkg() const
952  { return "redhat-release"; }
953 
955 
956  Pathname ZConfig::pluginsPath() const
957  { return _pimpl->pluginsPath.get(); }
958 
960 
961  std::ostream & ZConfig::about( std::ostream & str ) const
962  {
963  str << "libzypp: " << VERSION << " built " << __DATE__ << " " << __TIME__ << endl;
964 
965  str << "libsolv: " << solv_version;
966  if ( ::strcmp( solv_version, LIBSOLV_VERSION_STRING ) )
967  str << " (built against " << LIBSOLV_VERSION_STRING << ")";
968  str << endl;
969 
970  str << "zypp.conf: '" << _pimpl->_parsedZyppConf << "'" << endl;
971  str << "TextLocale: '" << textLocale() << "' (" << defaultTextLocale() << ")" << endl;
972  str << "SystemArchitecture: '" << systemArchitecture() << "' (" << defaultSystemArchitecture() << ")" << endl;
973  return str;
974  }
975 
977 } // namespace zypp
~ZConfig()
Dtor.
Definition: ZConfig.cc:677
static Locale defaultTextLocale()
The autodetected prefered locale for translated texts.
Definition: ZConfig.cc:716
Mutable option.
Definition: ZConfig.cc:219
DefaultOption(const value_type &initial_r)
Definition: ZConfig.cc:255
#define MIL
Definition: Logger.h:47
const Arch Arch_sparcv9(_sparcv9())
Pathname update_scripts_path
Definition: ZConfig.cc:567
Pathname cfg_known_repos_path
Definition: ZConfig.cc:559
int download_transfer_timeout
Definition: ZConfig.cc:584
MapKVIteratorTraits< SectionSet >::Key_const_iterator section_const_iterator
Definition: IniDict.h:46
Option< unsigned > solver_upgradeTestcasesToKeep
Definition: ZConfig.cc:591
void setUpdateMessagesNotify(const std::string &val_r)
Set a new command definition (see update.messages.notify in zypp.conf).
Definition: ZConfig.cc:919
Option< bool > solver_cleandepsOnRemove
Definition: ZConfig.cc:590
Pathname cfg_known_services_path
Definition: ZConfig.cc:560
int download_max_concurrent_connections
Definition: ZConfig.cc:580
std::ostream & about(std::ostream &str) const
Print some detail about the current libzypp version.
Definition: ZConfig.cc:961
Pathname update_messages_path
Definition: ZConfig.cc:568
std::string distroverpkg() const
Package telling the &quot;product version&quot; on systems not using /etc/product.d/baseproduct.
Definition: ZConfig.cc:951
unsigned split(const C_Str &line_r, _OutputIterator result_r, const C_Str &sepchars_r=" \t")
Split line_r into words.
Definition: String.h:394
unsigned solver_upgradeTestcasesToKeep() const
When committing a dist upgrade (e.g.
Definition: ZConfig.cc:882
void setTextLocale(const Locale &locale_r)
Set the default language for retrieving translated texts.
Definition: Pool.cc:193
Architecture.
Definition: Arch.h:36
pluginsPath("/usr/lib/zypp/plugins")
Definition: ZConfig.cc:314
bool download_use_deltarpm
Definition: ZConfig.cc:576
const Arch Arch_i686(_i686())
Pathname knownServicesPath() const
Path where the known services .service files are kept (configPath()/services.d).
Definition: ZConfig.cc:801
Pathname vendorPath() const
Directory for equivalent vendor definitions (configPath()/vendors.d)
Definition: ZConfig.cc:807
Pathname repoCachePath() const
Path where the caches are kept (/var/cache/zypp)
Definition: ZConfig.cc:763
LocaleSet repoRefreshLocales
Definition: ZConfig.cc:573
#define INT
Definition: Logger.h:51
Pathname credentialsGlobalFile() const
Defaults to /etc/zypp/credentials.cat.
Definition: ZConfig.cc:943
Pathname cfg_metadata_path
Definition: ZConfig.cc:554
const Arch Arch_ppc64(_ppc64())
Option< _Tp > option_type
Definition: ZConfig.cc:253
const Arch Arch_sparcv8(_sparcv8())
void removeMultiversionSpec(const std::string &name_r)
Definition: ZConfig.cc:893
Pathname cfg_cache_path
Definition: ZConfig.cc:553
void setSystemArchitecture(const Arch &arch_r)
Override the zypp system architecture.
Definition: ZConfig.cc:701
bool apply_locks_file() const
Whether locks file should be read and applied after start (true)
Definition: ZConfig.cc:895
Pathname cfg_config_path
Definition: ZConfig.cc:558
target::rpm::RpmInstFlags rpmInstallFlags
Definition: ZConfig.cc:601
Helper to create and pass std::istream.
Definition: InputStream.h:56
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:27
void reconfigureZConfig(const Pathname &override_r)
Definition: ZConfig.cc:644
long download_max_download_speed() const
Maximum download speed (bytes per second)
Definition: ZConfig.cc:857
bool setUserData(const std::string &str_r)
Set a new userData string.
Definition: ZConfig.cc:746
const Arch Arch_armv7hl(_armv7hl())
bool solver_cleandepsOnRemove() const
Whether removing a package should also remove no longer needed requirements.
Definition: ZConfig.cc:875
bool repo_add_probe() const
Whether repository urls should be probed.
Definition: ZConfig.cc:821
const Arch Arch_noarch(_noarch())
const std::set< std::string > & multiversion() const
Definition: ZConfig.cc:597
void resetSolverUpgradeRemoveDroppedPackages()
Reset solverUpgradeRemoveDroppedPackages to the zypp.conf default.
Definition: ZConfig.cc:887
Pathname _parsedZyppConf
Remember any parsed zypp.conf.
Definition: ZConfig.cc:548
Pathname pluginsPath() const
Defaults to /usr/lib/zypp/plugins.
Definition: ZConfig.cc:956
const Arch Arch_sparc64v(_sparc64v())
RW_pointer< Impl, rw_pointer::Scoped< Impl > > _pimpl
Pointer to implementation.
Definition: ZConfig.h:427
#define ERR
Definition: Logger.h:49
bool solverUpgradeRemoveDroppedPackages() const
Whether dist upgrade should remove a products dropped packages (true).
Definition: ZConfig.cc:885
DownloadMode commit_downloadMode() const
Commit download policy to use as default.
Definition: ZConfig.cc:866
Option< bool > solver_allowVendorChange
Definition: ZConfig.cc:589
void addMultiversionSpec(const std::string &name_r)
Definition: ZConfig.cc:892
Pathname credentials_global_dir_path
Definition: ZConfig.cc:604
void set_download_media_prefer_download(bool yesno_r)
Set download_media_prefer_download to a specific value.
Definition: ZConfig.cc:845
const Arch Arch_sparcv9v(_sparcv9v())
DefaultOption< bool > download_media_prefer_download
Definition: ZConfig.cc:578
const value_type & getDefault() const
Get the current default value.
Definition: ZConfig.cc:268
Pathname configPath() const
Path where the configfiles are kept (/etc/zypp).
Definition: ZConfig.cc:789
const Arch Arch_i586(_i586())
Pathname historyLogFile() const
Path where ZYpp install history is logged.
Definition: ZConfig.cc:931
void setTextLocale(const Locale &locale_r)
Set the prefered locale for translated texts.
Definition: ZConfig.cc:725
const Arch Arch_armv6l(_armv6l())
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
Pathname knownReposPath() const
Path where the known repositories .repo files are kept (configPath()/repos.d).
Definition: ZConfig.cc:795
static Pool instance()
Singleton ctor.
Definition: Pool.h:51
Pathname update_data_path
Definition: ZConfig.cc:566
Pathname credentials_global_file_path
Definition: ZConfig.cc:605
LocaleSet repoRefreshLocales() const
List of locales for which translated package descriptions should be downloaded.
Definition: ZConfig.cc:827
const Arch Arch_sparc64(_sparc64())
void set_default_download_media_prefer_download()
Set download_media_prefer_download to the configfiles default.
Definition: ZConfig.cc:848
void restoreToDefault(const value_type &newval_r)
Reset value to a new default.
Definition: ZConfig.cc:264
ZConfig implementation.
Definition: ZConfig.cc:288
void setDefault(const value_type &newval_r)
Set a new default value.
Definition: ZConfig.cc:272
libzypp will decide what to do.
Definition: DownloadMode.h:24
void restoreToDefault()
Reset value to the current default.
Definition: ZConfig.cc:260
Interim helper class to collect global options and settings.
Definition: ZConfig.h:58
#define WAR
Definition: Logger.h:48
Pathname cfg_packages_path
Definition: ZConfig.cc:556
section_const_iterator sectionsBegin() const
Definition: IniDict.cc:94
Pathname update_scriptsPath() const
Path where the repo metadata is downloaded and kept (update_dataPath()/).
Definition: ZConfig.cc:910
Pathname locksFile() const
Path where zypp can find or create lock file (configPath()/locks)
Definition: ZConfig.cc:813
std::tr1::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
long download_min_download_speed() const
Minimum download speed (bytes per second) until the connection is dropped.
Definition: ZConfig.cc:854
void clearMultiversionSpec()
Definition: ZConfig.cc:891
entry_const_iterator entriesEnd(const std::string &section) const
Definition: IniDict.cc:82
bool hasUserData() const
Whether a (non empty) user data sting is defined.
Definition: ZConfig.cc:740
int download_max_silent_tries
Definition: ZConfig.cc:583
Pathname update_messagesPath() const
Path where the repo solv files are created and kept (update_dataPath()/solv).
Definition: ZConfig.cc:904
_It strtonum(const C_Str &str)
Parsing numbers from string.
Definition: String.h:304
Pathname locks_file
Definition: ZConfig.cc:564
Pathname repoSolvfilesPath() const
Path where the repo solv files are created and kept (repoCachePath()/solv).
Definition: ZConfig.cc:775
Pathname repoPackagesPath() const
Path where the repo packages are downloaded and kept (repoCachePath()/packages).
Definition: ZConfig.cc:781
bool download_use_deltarpm() const
Whether to consider using a deltarpm when downloading a package.
Definition: ZConfig.cc:836
Locale cfg_textLocale
Definition: ZConfig.cc:551
Mutable option with initial value also remembering a config value.
Definition: ZConfig.cc:250
Pathname repoMetadataPath() const
Path where the repo metadata is downloaded and kept (repoCachePath()/raw).
Definition: ZConfig.cc:769
value_type & ref()
Non-const reference to set a new value.
Definition: ZConfig.cc:241
long download_max_silent_tries() const
Maximum silent tries.
Definition: ZConfig.cc:860
bool download_use_deltarpm_always
Definition: ZConfig.cc:577
std::set< std::string > & getMultiversion() const
Definition: ZConfig.cc:612
int compareCI(const C_Str &lhs, const C_Str &rhs)
Definition: String.h:763
const Arch Arch_armv6hl(_armv6hl())
bool solver_allowVendorChange() const
Whether vendor check is by default enabled.
Definition: ZConfig.cc:872
bool solver_onlyRequires() const
Solver regards required packages,patterns,...
Definition: ZConfig.cc:869
Option< Pathname > pluginsPath
Definition: ZConfig.cc:609
Parses a INI file and offers its structure as a dictionary.
Definition: IniDict.h:40
std::set< std::string > & multiversion()
Definition: ZConfig.cc:596
static Arch defaultSystemArchitecture()
The autodetected system architecture.
Definition: ZConfig.cc:692
Pathname systemRoot() const
The target root directory.
Definition: ZConfig.cc:680
entry_const_iterator entriesBegin(const std::string &section) const
Definition: IniDict.cc:71
bool download_media_prefer_download() const
Hint which media to prefer when installing packages (download vs.
Definition: ZConfig.cc:842
DefaultOption< std::string > updateMessagesNotify
Definition: ZConfig.cc:569
const std::set< std::string > & multiversionSpec() const
Definition: ZConfig.cc:889
Pathname solver_checkSystemFile
Definition: ZConfig.cc:594
target::rpm::RpmInstFlags rpmInstallFlags() const
The default target::rpm::RpmInstFlags for ZYppCommitPolicy.
Definition: ZConfig.cc:927
const Arch Arch_armv7l(_armv7l())
_Tp value_type
Definition: ZConfig.cc:221
Option< bool > solver_onlyRequires
Definition: ZConfig.cc:588
Pathname history_log_path
Definition: ZConfig.cc:603
std::string userData
Definition: ZConfig.cc:607
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
Definition: String.h:345
Pathname update_dataPath() const
Path where the update items are kept (/var/adm)
Definition: ZConfig.cc:898
std::string userData() const
User defined string value to be passed to log, history, plugins...
Definition: ZConfig.cc:743
Option(const value_type &initial_r)
No default ctor, explicit initialisation!
Definition: ZConfig.cc:224
const Arch Arch_sparc(_sparc())
int download_max_download_speed
Definition: ZConfig.cc:582
Wrapper class for ::stat/::lstat.
Definition: PathInfo.h:220
void resetUpdateMessagesNotify()
Reset to the zypp.conf default.
Definition: ZConfig.cc:922
int dirForEach(const Pathname &dir_r, function< bool(const Pathname &, const char *const)> fnc_r)
Invoke callback function fnc_r for each entry in directory dir_r.
Definition: PathInfo.cc:552
DefaultIntegral< bool, false > _multiversionInitialized
Definition: ZConfig.cc:638
void setSolverUpgradeRemoveDroppedPackages(bool val_r)
Set solverUpgradeRemoveDroppedPackages to val_r.
Definition: ZConfig.cc:886
int download_min_download_speed
Definition: ZConfig.cc:581
void set(const value_type &newval_r)
Set a new value.
Definition: ZConfig.cc:237
Locale textLocale() const
The locale for translated texts zypp uses.
Definition: ZConfig.cc:722
std::string updateMessagesNotify() const
Command definition for sending update messages.
Definition: ZConfig.cc:916
EntrySet::const_iterator entry_const_iterator
Definition: IniDict.h:47
unsigned repo_refresh_delay() const
Amount of time in minutes that must pass before another refresh.
Definition: ZConfig.cc:824
Arch systemArchitecture() const
The system architecture zypp uses.
Definition: ZConfig.cc:698
bool repoLabelIsAlias() const
Whether to use repository alias or name in user messages (progress, exceptions, ...).
Definition: ZConfig.cc:830
Pathname cfg_vendor_path
Definition: ZConfig.cc:562
Pathname cfg_multiversion_path
Definition: ZConfig.cc:563
LocaleSet requestedLocales() const
Languages to be supported by the system.
Definition: Target.cc:109
DefaultOption< bool > solverUpgradeRemoveDroppedPackages
Definition: ZConfig.cc:592
section_const_iterator sectionsEnd() const
Definition: IniDict.cc:99
long download_max_concurrent_connections() const
Maximum number of concurrent connections for a single transfer.
Definition: ZConfig.cc:851
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
Definition: String.h:828
option_type _default
Definition: ZConfig.cc:276
value_type _val
Definition: ZConfig.cc:245
Pathname solver_checkSystemFile() const
File in which dependencies described which has to be fulfilled for a running system.
Definition: ZConfig.cc:878
Option< DownloadMode > commit_downloadMode
Definition: ZConfig.cc:586
unsigned repo_refresh_delay
Definition: ZConfig.cc:572
const Arch Arch_ppc64p7(_ppc64p7())
bool download_use_deltarpm_always() const
Whether to consider using a deltarpm even when rpm is local.
Definition: ZConfig.cc:839
#define DBG
Definition: Logger.h:46
long download_transfer_timeout() const
Maximum time in seconds that you allow a transfer operation to take.
Definition: ZConfig.cc:863
Pathname credentialsGlobalDir() const
Defaults to /etc/zypp/credentials.d.
Definition: ZConfig.cc:937
DownloadMode
Supported commit download policies.
Definition: DownloadMode.h:22
Pathname cfg_solvfiles_path
Definition: ZConfig.cc:555
std::set< std::string > _multiversion
Definition: ZConfig.cc:637