1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/ZConfig.cc
15 #include <sys/utsname.h>
16 #if __GLIBC_PREREQ (2,16)
17 #include <sys/auxv.h> // getauxval for PPC64P7 detection
20 #include <solv/solvversion.h>
24 #include "zypp/base/LogTools.h"
25 #include "zypp/base/IOStream.h"
26 #include "zypp/base/InputStream.h"
27 #include "zypp/base/String.h"
28 #include "zypp/base/Regex.h"
30 #include "zypp/ZConfig.h"
31 #include "zypp/ZYppFactory.h"
32 #include "zypp/PathInfo.h"
33 #include "zypp/parser/IniDict.h"
35 #include "zypp/sat/Pool.h"
36 #include "zypp/sat/detail/PoolImpl.h"
39 using namespace zypp::filesystem;
40 using namespace zypp::parser;
42 #undef ZYPP_BASE_LOGGER_LOGGROUP
43 #define ZYPP_BASE_LOGGER_LOGGROUP "zconfig"
45 ///////////////////////////////////////////////////////////////////
47 { /////////////////////////////////////////////////////////////////
48 /** \addtogroup ZyppConfig Zypp Configuration Options
50 * The global \c zypp.conf configuration file is per default located in \c /etc/zypp/.
51 * An alternate config file can be set using the environment varaible \c ZYPP_CONF=<PATH>
52 * (see \ref zypp-envars).
54 * \section ZyppConfig_ZyppConfSample Sample zypp.conf
55 * \include ../zypp.conf
57 ///////////////////////////////////////////////////////////////////
59 { /////////////////////////////////////////////////////////////////
61 /** Determine system architecture evaluating \c uname and \c /proc/cpuinfo.
63 Arch _autodetectSystemArchitecture()
66 if ( ::uname( &buf ) < 0 )
68 ERR << "Can't determine system architecture" << endl;
72 Arch architecture( buf.machine );
73 MIL << "Uname architecture is '" << buf.machine << "'" << endl;
75 if ( architecture == Arch_i686 )
77 // some CPUs report i686 but dont implement cx8 and cmov
78 // check for both flags in /proc/cpuinfo and downgrade
79 // to i586 if either is missing (cf bug #18885)
80 std::ifstream cpuinfo( "/proc/cpuinfo" );
83 for( iostr::EachLine in( cpuinfo ); in; in.next() )
85 if ( str::hasPrefix( *in, "flags" ) )
87 if ( in->find( "cx8" ) == std::string::npos
88 || in->find( "cmov" ) == std::string::npos )
90 architecture = Arch_i586;
91 WAR << "CPU lacks 'cx8' or 'cmov': architecture downgraded to '" << architecture << "'" << endl;
99 ERR << "Cant open " << PathInfo("/proc/cpuinfo") << endl;
102 else if ( architecture == Arch_sparc || architecture == Arch_sparc64 )
104 // Check for sun4[vum] to get the real arch. (bug #566291)
105 std::ifstream cpuinfo( "/proc/cpuinfo" );
108 for( iostr::EachLine in( cpuinfo ); in; in.next() )
110 if ( str::hasPrefix( *in, "type" ) )
112 if ( in->find( "sun4v" ) != std::string::npos )
114 architecture = ( architecture == Arch_sparc64 ? Arch_sparc64v : Arch_sparcv9v );
115 WAR << "CPU has 'sun4v': architecture upgraded to '" << architecture << "'" << endl;
117 else if ( in->find( "sun4u" ) != std::string::npos )
119 architecture = ( architecture == Arch_sparc64 ? Arch_sparc64 : Arch_sparcv9 );
120 WAR << "CPU has 'sun4u': architecture upgraded to '" << architecture << "'" << endl;
122 else if ( in->find( "sun4m" ) != std::string::npos )
124 architecture = Arch_sparcv8;
125 WAR << "CPU has 'sun4m': architecture upgraded to '" << architecture << "'" << endl;
133 ERR << "Cant open " << PathInfo("/proc/cpuinfo") << endl;
136 else if ( architecture == Arch_armv7l || architecture == Arch_armv6l )
138 std::ifstream platform( "/etc/rpm/platform" );
141 for( iostr::EachLine in( platform ); in; in.next() )
143 if ( str::hasPrefix( *in, "armv7hl-" ) )
145 architecture = Arch_armv7hl;
146 WAR << "/etc/rpm/platform contains armv7hl-: architecture upgraded to '" << architecture << "'" << endl;
149 if ( str::hasPrefix( *in, "armv6hl-" ) )
151 architecture = Arch_armv6hl;
152 WAR << "/etc/rpm/platform contains armv6hl-: architecture upgraded to '" << architecture << "'" << endl;
158 #if __GLIBC_PREREQ (2,16)
159 else if ( architecture == Arch_ppc64 )
161 const char * platform = (const char *)getauxval( AT_PLATFORM );
163 if ( platform && sscanf( platform, "power%d", &powerlvl ) == 1 && powerlvl > 6 )
164 architecture = Arch_ppc64p7;
170 /** The locale to be used for texts and messages.
172 * For the encoding to be used the preference is
174 * LC_ALL, LC_CTYPE, LANG
176 * For the language of the messages to be used, the preference is
178 * LANGUAGE, LC_ALL, LC_MESSAGES, LANG
180 * Note that LANGUAGE can contain more than one locale name, it can be
181 * a list of locale names like for example
183 * LANGUAGE=ja_JP.UTF-8:de_DE.UTF-8:fr_FR.UTF-8
185 * \todo Support dynamic fallbacklists defined by LANGUAGE
187 Locale _autodetectTextLocale()
189 Locale ret( Locale::enCode );
190 const char * envlist[] = { "LC_ALL", "LC_MESSAGES", "LANG", NULL };
191 for ( const char ** envvar = envlist; *envvar; ++envvar )
193 const char * envlang = getenv( *envvar );
196 std::string envstr( envlang );
197 if ( envstr != "POSIX" && envstr != "C" )
199 Locale lang( envstr );
202 MIL << "Found " << *envvar << "=" << envstr << endl;
209 MIL << "Default text locale is '" << ret << "'" << endl;
210 #warning HACK AROUND BOOST_TEST_CATCH_SYSTEM_ERRORS
211 setenv( "BOOST_TEST_CATCH_SYSTEM_ERRORS", "no", 1 );
216 inline Pathname _autodetectSystemRoot()
218 Target_Ptr target( getZYpp()->getTarget() );
219 return target ? target->root() : Pathname();
222 inline Pathname _autodetectZyppConfPath()
224 const char *env_confpath = getenv( "ZYPP_CONF" );
225 return env_confpath ? env_confpath : "/etc/zypp/zypp.conf";
228 /////////////////////////////////////////////////////////////////
230 ///////////////////////////////////////////////////////////////////
232 /** Mutable option. */
236 typedef Tp value_type;
238 /** No default ctor, explicit initialisation! */
239 Option( const value_type & initial_r )
243 /** Get the value. */
244 const value_type & get() const
247 /** Autoconversion to value_type. */
248 operator const value_type &() const
251 /** Set a new value. */
252 void set( const value_type & newval_r )
255 /** Non-const reference to set a new value. */
263 /** Mutable option with initial value also remembering a config value. */
265 struct DefaultOption : public Option<Tp>
267 typedef Tp value_type;
268 typedef Option<Tp> option_type;
270 DefaultOption( const value_type & initial_r )
271 : Option<Tp>( initial_r ), _default( initial_r )
274 /** Reset value to the current default. */
275 void restoreToDefault()
276 { this->set( _default.get() ); }
278 /** Reset value to a new default. */
279 void restoreToDefault( const value_type & newval_r )
280 { setDefault( newval_r ); restoreToDefault(); }
282 /** Get the current default value. */
283 const value_type & getDefault() const
284 { return _default.get(); }
286 /** Set a new default value. */
287 void setDefault( const value_type & newval_r )
288 { _default.set( newval_r ); }
291 option_type _default;
294 ///////////////////////////////////////////////////////////////////
296 // CLASS NAME : ZConfig::Impl
298 /** ZConfig implementation.
299 * \todo Enrich section and entry definition by some comment
300 * (including the default setting and provide some method to
301 * write this into a sample zypp.conf.
305 typedef std::set<std::string> MultiversionSpec;
308 Impl( const Pathname & override_r = Pathname() )
309 : _parsedZyppConf ( override_r )
310 , cfg_arch ( defaultSystemArchitecture() )
311 , cfg_textLocale ( defaultTextLocale() )
312 , updateMessagesNotify ( "" )
313 , repo_add_probe ( false )
314 , repo_refresh_delay ( 10 )
315 , repoLabelIsAlias ( false )
316 , download_use_deltarpm ( true )
317 , download_use_deltarpm_always ( false )
318 , download_media_prefer_download( true )
319 , download_mediaMountdir ( "/var/adm/mount" )
320 , download_max_concurrent_connections( 5 )
321 , download_min_download_speed ( 0 )
322 , download_max_download_speed ( 0 )
323 , download_max_silent_tries ( 5 )
324 , download_transfer_timeout ( 180 )
325 , commit_downloadMode ( DownloadDefault )
327 , repoGpgCheck ( indeterminate )
328 , pkgGpgCheck ( indeterminate )
329 , solver_focus ( ResolverFocus::Default )
330 , solver_onlyRequires ( false )
331 , solver_allowVendorChange ( false )
332 , solver_dupAllowDowngrade ( true )
333 , solver_dupAllowNameChange ( true )
334 , solver_dupAllowArchChange ( true )
335 , solver_dupAllowVendorChange ( true )
336 , solver_cleandepsOnRemove ( false )
337 , solver_upgradeTestcasesToKeep ( 2 )
338 , solverUpgradeRemoveDroppedPackages( true )
339 , apply_locks_file ( true )
340 , pluginsPath ( "/usr/lib/zypp/plugins" )
342 MIL << "libzypp: " << VERSION << endl;
343 // override_r has higest prio
344 // ZYPP_CONF might override /etc/zypp/zypp.conf
345 if ( _parsedZyppConf.empty() )
347 _parsedZyppConf = _autodetectZyppConfPath();
351 // Inject this into ZConfig. Be shure this is
352 // allocated via new. See: reconfigureZConfig
353 INT << "Reconfigure to " << _parsedZyppConf << endl;
354 ZConfig::instance()._pimpl.reset( this );
356 if ( PathInfo(_parsedZyppConf).isExist() )
358 parser::IniDict dict( _parsedZyppConf );
359 for ( IniDict::section_const_iterator sit = dict.sectionsBegin();
360 sit != dict.sectionsEnd();
363 string section(*sit);
364 //MIL << section << endl;
365 for ( IniDict::entry_const_iterator it = dict.entriesBegin(*sit);
366 it != dict.entriesEnd(*sit);
369 string entry(it->first);
370 string value(it->second);
371 //DBG << (*it).first << "=" << (*it).second << endl;
372 if ( section == "main" )
374 if ( entry == "arch" )
377 if ( carch != cfg_arch )
379 WAR << "Overriding system architecture (" << cfg_arch << "): " << carch << endl;
383 else if ( entry == "cachedir" )
385 cfg_cache_path = Pathname(value);
387 else if ( entry == "metadatadir" )
389 cfg_metadata_path = Pathname(value);
391 else if ( entry == "solvfilesdir" )
393 cfg_solvfiles_path = Pathname(value);
395 else if ( entry == "packagesdir" )
397 cfg_packages_path = Pathname(value);
399 else if ( entry == "configdir" )
401 cfg_config_path = Pathname(value);
403 else if ( entry == "reposdir" )
405 cfg_known_repos_path = Pathname(value);
407 else if ( entry == "servicesdir" )
409 cfg_known_services_path = Pathname(value);
411 else if ( entry == "varsdir" )
413 cfg_vars_path = Pathname(value);
415 else if ( entry == "repo.add.probe" )
417 repo_add_probe = str::strToBool( value, repo_add_probe );
419 else if ( entry == "repo.refresh.delay" )
421 str::strtonum(value, repo_refresh_delay);
423 else if ( entry == "repo.refresh.locales" )
425 std::vector<std::string> tmp;
426 str::split( value, back_inserter( tmp ), ", \t" );
428 boost::function<Locale(const std::string &)> transform(
429 [](const std::string & str_r)->Locale{ return Locale(str_r); }
431 repoRefreshLocales.insert( make_transform_iterator( tmp.begin(), transform ),
432 make_transform_iterator( tmp.end(), transform ) );
434 else if ( entry == "download.use_deltarpm" )
436 download_use_deltarpm = str::strToBool( value, download_use_deltarpm );
438 else if ( entry == "download.use_deltarpm.always" )
440 download_use_deltarpm_always = str::strToBool( value, download_use_deltarpm_always );
442 else if ( entry == "download.media_preference" )
444 download_media_prefer_download.restoreToDefault( str::compareCI( value, "volatile" ) != 0 );
447 else if ( entry == "download.media_mountdir" )
449 download_mediaMountdir.restoreToDefault( Pathname(value) );
452 else if ( entry == "download.max_concurrent_connections" )
454 str::strtonum(value, download_max_concurrent_connections);
456 else if ( entry == "download.min_download_speed" )
458 str::strtonum(value, download_min_download_speed);
460 else if ( entry == "download.max_download_speed" )
462 str::strtonum(value, download_max_download_speed);
464 else if ( entry == "download.max_silent_tries" )
466 str::strtonum(value, download_max_silent_tries);
468 else if ( entry == "download.transfer_timeout" )
470 str::strtonum(value, download_transfer_timeout);
471 if ( download_transfer_timeout < 0 ) download_transfer_timeout = 0;
472 else if ( download_transfer_timeout > 3600 ) download_transfer_timeout = 3600;
474 else if ( entry == "commit.downloadMode" )
476 commit_downloadMode.set( deserializeDownloadMode( value ) );
478 else if ( entry == "gpgcheck" )
480 gpgCheck.restoreToDefault( str::strToBool( value, gpgCheck ) );
482 else if ( entry == "repo_gpgcheck" )
484 repoGpgCheck.restoreToDefault( str::strToTriBool( value ) );
486 else if ( entry == "pkg_gpgcheck" )
488 pkgGpgCheck.restoreToDefault( str::strToTriBool( value ) );
490 else if ( entry == "vendordir" )
492 cfg_vendor_path = Pathname(value);
494 else if ( entry == "multiversiondir" )
496 cfg_multiversion_path = Pathname(value);
498 else if ( entry == "multiversion.kernels" )
500 cfg_kernel_keep_spec = value;
502 else if ( entry == "solver.focus" )
504 fromString( value, solver_focus );
506 else if ( entry == "solver.onlyRequires" )
508 solver_onlyRequires.set( str::strToBool( value, solver_onlyRequires ) );
510 else if ( entry == "solver.allowVendorChange" )
512 solver_allowVendorChange.set( str::strToBool( value, solver_allowVendorChange ) );
514 else if ( entry == "solver.dupAllowDowngrade" )
516 solver_dupAllowDowngrade.set( str::strToBool( value, solver_dupAllowDowngrade ) );
518 else if ( entry == "solver.dupAllowNameChange" )
520 solver_dupAllowNameChange.set( str::strToBool( value, solver_dupAllowNameChange ) );
522 else if ( entry == "solver.dupAllowArchChange" )
524 solver_dupAllowArchChange.set( str::strToBool( value, solver_dupAllowArchChange ) );
526 else if ( entry == "solver.dupAllowVendorChange" )
528 solver_dupAllowVendorChange.set( str::strToBool( value, solver_dupAllowVendorChange ) );
530 else if ( entry == "solver.cleandepsOnRemove" )
532 solver_cleandepsOnRemove.set( str::strToBool( value, solver_cleandepsOnRemove ) );
534 else if ( entry == "solver.upgradeTestcasesToKeep" )
536 solver_upgradeTestcasesToKeep.set( str::strtonum<unsigned>( value ) );
538 else if ( entry == "solver.upgradeRemoveDroppedPackages" )
540 solverUpgradeRemoveDroppedPackages.restoreToDefault( str::strToBool( value, solverUpgradeRemoveDroppedPackages.getDefault() ) );
542 else if ( entry == "solver.checkSystemFile" )
544 solver_checkSystemFile = Pathname(value);
546 else if ( entry == "solver.checkSystemFileDir" )
548 solver_checkSystemFileDir = Pathname(value);
550 else if ( entry == "multiversion" )
552 MultiversionSpec & defSpec( _multiversionMap.getDefaultSpec() );
553 str::splitEscaped( value, std::inserter( defSpec, defSpec.end() ), ", \t" );
555 else if ( entry == "locksfile.path" )
557 locks_file = Pathname(value);
559 else if ( entry == "locksfile.apply" )
561 apply_locks_file = str::strToBool( value, apply_locks_file );
563 else if ( entry == "update.datadir" )
565 update_data_path = Pathname(value);
567 else if ( entry == "update.scriptsdir" )
569 update_scripts_path = Pathname(value);
571 else if ( entry == "update.messagessdir" )
573 update_messages_path = Pathname(value);
575 else if ( entry == "update.messages.notify" )
577 updateMessagesNotify.set( value );
579 else if ( entry == "rpm.install.excludedocs" )
581 rpmInstallFlags.setFlag( target::rpm::RPMINST_EXCLUDEDOCS,
582 str::strToBool( value, false ) );
584 else if ( entry == "history.logfile" )
586 history_log_path = Pathname(value);
588 else if ( entry == "credentials.global.dir" )
590 credentials_global_dir_path = Pathname(value);
592 else if ( entry == "credentials.global.file" )
594 credentials_global_file_path = Pathname(value);
604 MIL << _parsedZyppConf << " not found, using defaults instead." << endl;
605 _parsedZyppConf = _parsedZyppConf.extend( " (NOT FOUND)" );
609 if ( getenv( "ZYPP_TESTSUITE_FAKE_ARCH" ) )
611 Arch carch( getenv( "ZYPP_TESTSUITE_FAKE_ARCH" ) );
612 if ( carch != cfg_arch )
614 WAR << "ZYPP_TESTSUITE_FAKE_ARCH: Overriding system architecture (" << cfg_arch << "): " << carch << endl;
618 MIL << "ZConfig singleton created." << endl;
625 /** Remember any parsed zypp.conf. */
626 Pathname _parsedZyppConf;
629 Locale cfg_textLocale;
631 Pathname cfg_cache_path;
632 Pathname cfg_metadata_path;
633 Pathname cfg_solvfiles_path;
634 Pathname cfg_packages_path;
636 Pathname cfg_config_path;
637 Pathname cfg_known_repos_path;
638 Pathname cfg_known_services_path;
639 Pathname cfg_vars_path;
640 Pathname cfg_repo_mgr_root_path;
642 Pathname cfg_vendor_path;
643 Pathname cfg_multiversion_path;
644 std::string cfg_kernel_keep_spec;
647 Pathname update_data_path;
648 Pathname update_scripts_path;
649 Pathname update_messages_path;
650 DefaultOption<std::string> updateMessagesNotify;
653 unsigned repo_refresh_delay;
654 LocaleSet repoRefreshLocales;
655 bool repoLabelIsAlias;
657 bool download_use_deltarpm;
658 bool download_use_deltarpm_always;
659 DefaultOption<bool> download_media_prefer_download;
660 DefaultOption<Pathname> download_mediaMountdir;
662 int download_max_concurrent_connections;
663 int download_min_download_speed;
664 int download_max_download_speed;
665 int download_max_silent_tries;
666 int download_transfer_timeout;
668 Option<DownloadMode> commit_downloadMode;
670 DefaultOption<bool> gpgCheck;
671 DefaultOption<TriBool> repoGpgCheck;
672 DefaultOption<TriBool> pkgGpgCheck;
674 ResolverFocus solver_focus;
675 Option<bool> solver_onlyRequires;
676 Option<bool> solver_allowVendorChange;
677 Option<bool> solver_dupAllowDowngrade;
678 Option<bool> solver_dupAllowNameChange;
679 Option<bool> solver_dupAllowArchChange;
680 Option<bool> solver_dupAllowVendorChange;
681 Option<bool> solver_cleandepsOnRemove;
682 Option<unsigned> solver_upgradeTestcasesToKeep;
683 DefaultOption<bool> solverUpgradeRemoveDroppedPackages;
685 Pathname solver_checkSystemFile;
686 Pathname solver_checkSystemFileDir;
688 MultiversionSpec & multiversion() { return getMultiversion(); }
689 const MultiversionSpec & multiversion() const { return getMultiversion(); }
691 bool apply_locks_file;
693 target::rpm::RpmInstFlags rpmInstallFlags;
695 Pathname history_log_path;
696 Pathname credentials_global_dir_path;
697 Pathname credentials_global_file_path;
699 std::string userData;
701 Option<Pathname> pluginsPath;
704 // HACK for bnc#906096: let pool re-evaluate multiversion spec
705 // if target root changes. ZConfig returns data sensitive to
706 // current target root.
707 // TODO Actually we'd need to scan the target systems zypp.conf and
708 // overlay all system specific values.
709 struct MultiversionMap
711 typedef std::map<Pathname,MultiversionSpec> SpecMap;
713 MultiversionSpec & getSpec( Pathname root_r, const Impl & zConfImpl_r ) // from system at root
715 // _specMap[] - the plain zypp.conf value
716 // _specMap[/] - combine [] and multiversion.d scan
717 // _specMap[root] - scan root/zypp.conf and root/multiversion.d
719 if ( root_r.empty() )
721 bool cacheHit = _specMap.count( root_r );
722 MultiversionSpec & ret( _specMap[root_r] ); // creates new entry on the fly
727 ret.swap( _specMap[Pathname()] ); // original zypp.conf
729 scanConfAt( root_r, ret, zConfImpl_r ); // scan zypp.conf at root_r
730 scanDirAt( root_r, ret, zConfImpl_r ); // add multiversion.d at root_r
731 using zypp::operator<<;
732 MIL << "MultiversionSpec '" << root_r << "' = " << ret << endl;
737 MultiversionSpec & getDefaultSpec() // Spec from zypp.conf parsing; called before any getSpec
738 { return _specMap[Pathname()]; }
741 void scanConfAt( const Pathname root_r, MultiversionSpec & spec_r, const Impl & zConfImpl_r )
743 static const str::regex rx( "^multiversion *= *(.*)" );
745 iostr::simpleParseFile( InputStream( Pathname::assertprefix( root_r, _autodetectZyppConfPath() ) ),
746 [&]( int num_r, std::string line_r )->bool
748 if ( line_r[0] == 'm' && str::regex_match( line_r, what, rx ) )
750 str::splitEscaped( what[1], std::inserter( spec_r, spec_r.end() ), ", \t" );
751 return false; // stop after match
757 void scanDirAt( const Pathname root_r, MultiversionSpec & spec_r, const Impl & zConfImpl_r )
759 // NOTE: Actually we'd need to scan and use the root_r! zypp.conf values.
760 Pathname multiversionDir( zConfImpl_r.cfg_multiversion_path );
761 if ( multiversionDir.empty() )
762 multiversionDir = ( zConfImpl_r.cfg_config_path.empty()
763 ? Pathname("/etc/zypp")
764 : zConfImpl_r.cfg_config_path ) / "multiversion.d";
766 filesystem::dirForEach( Pathname::assertprefix( root_r, multiversionDir ),
767 [&spec_r]( const Pathname & dir_r, const char *const & name_r )->bool
769 MIL << "Parsing " << dir_r/name_r << endl;
770 iostr::simpleParseFile( InputStream( dir_r/name_r ),
771 [&spec_r]( int num_r, std::string line_r )->bool
773 DBG << " found " << line_r << endl;
774 spec_r.insert( std::move(line_r) );
785 MultiversionSpec & getMultiversion() const
786 { return _multiversionMap.getSpec( _autodetectSystemRoot(), *this ); }
788 mutable MultiversionMap _multiversionMap;
790 ///////////////////////////////////////////////////////////////////
792 // Backdoor to redirect ZConfig from within the running
793 // TEST-application. HANDLE WITH CARE!
794 void reconfigureZConfig( const Pathname & override_r )
796 // ctor puts itself unter smart pointer control.
797 new ZConfig::Impl( override_r );
800 ///////////////////////////////////////////////////////////////////
802 // METHOD NAME : ZConfig::instance
803 // METHOD TYPE : ZConfig &
805 ZConfig & ZConfig::instance()
807 static ZConfig _instance; // The singleton
811 ///////////////////////////////////////////////////////////////////
813 // METHOD NAME : ZConfig::ZConfig
814 // METHOD TYPE : Ctor
822 ///////////////////////////////////////////////////////////////////
824 // METHOD NAME : ZConfig::~ZConfig
825 // METHOD TYPE : Dtor
830 Pathname ZConfig::systemRoot() const
831 { return _autodetectSystemRoot(); }
834 Pathname ZConfig::repoManagerRoot() const
836 return ( _pimpl->cfg_repo_mgr_root_path.empty()
837 ? systemRoot() : _pimpl->cfg_repo_mgr_root_path );
840 void ZConfig::setRepoManagerRoot(const zypp::filesystem::Pathname &root)
841 { _pimpl->cfg_repo_mgr_root_path = root; }
843 ///////////////////////////////////////////////////////////////////
845 // system architecture
847 ///////////////////////////////////////////////////////////////////
849 Arch ZConfig::defaultSystemArchitecture()
851 static Arch _val( _autodetectSystemArchitecture() );
855 Arch ZConfig::systemArchitecture() const
856 { return _pimpl->cfg_arch; }
858 void ZConfig::setSystemArchitecture( const Arch & arch_r )
860 if ( arch_r != _pimpl->cfg_arch )
862 WAR << "Overriding system architecture (" << _pimpl->cfg_arch << "): " << arch_r << endl;
863 _pimpl->cfg_arch = arch_r;
867 ///////////////////////////////////////////////////////////////////
871 ///////////////////////////////////////////////////////////////////
873 Locale ZConfig::defaultTextLocale()
875 static Locale _val( _autodetectTextLocale() );
879 Locale ZConfig::textLocale() const
880 { return _pimpl->cfg_textLocale; }
882 void ZConfig::setTextLocale( const Locale & locale_r )
884 if ( locale_r != _pimpl->cfg_textLocale )
886 WAR << "Overriding text locale (" << _pimpl->cfg_textLocale << "): " << locale_r << endl;
887 _pimpl->cfg_textLocale = locale_r;
888 #warning prefer signal
889 sat::Pool::instance().setTextLocale( locale_r );
893 ///////////////////////////////////////////////////////////////////
895 ///////////////////////////////////////////////////////////////////
897 bool ZConfig::hasUserData() const
898 { return !_pimpl->userData.empty(); }
900 std::string ZConfig::userData() const
901 { return _pimpl->userData; }
903 bool ZConfig::setUserData( const std::string & str_r )
905 for_( ch, str_r.begin(), str_r.end() )
907 if ( *ch < ' ' && *ch != '\t' )
909 ERR << "New user data string rejectded: char " << (int)*ch << " at position " << (ch - str_r.begin()) << endl;
913 MIL << "Set user data string to '" << str_r << "'" << endl;
914 _pimpl->userData = str_r;
918 ///////////////////////////////////////////////////////////////////
920 Pathname ZConfig::repoCachePath() const
922 return ( _pimpl->cfg_cache_path.empty()
923 ? Pathname("/var/cache/zypp") : _pimpl->cfg_cache_path );
926 Pathname ZConfig::pubkeyCachePath() const
928 return ( _pimpl->cfg_cache_path.empty()
929 ? Pathname("/var/cache/zypp/pubkeys") : _pimpl->cfg_cache_path/"pubkeys" );
932 void ZConfig::setRepoCachePath(const zypp::filesystem::Pathname &path_r)
934 _pimpl->cfg_cache_path = path_r;
937 Pathname ZConfig::repoMetadataPath() const
939 return ( _pimpl->cfg_metadata_path.empty()
940 ? (repoCachePath()/"raw") : _pimpl->cfg_metadata_path );
943 void ZConfig::setRepoMetadataPath(const zypp::filesystem::Pathname &path_r)
945 _pimpl->cfg_metadata_path = path_r;
948 Pathname ZConfig::repoSolvfilesPath() const
950 return ( _pimpl->cfg_solvfiles_path.empty()
951 ? (repoCachePath()/"solv") : _pimpl->cfg_solvfiles_path );
954 void ZConfig::setRepoSolvfilesPath(const zypp::filesystem::Pathname &path_r)
956 _pimpl->cfg_solvfiles_path = path_r;
959 Pathname ZConfig::repoPackagesPath() const
961 return ( _pimpl->cfg_packages_path.empty()
962 ? (repoCachePath()/"packages") : _pimpl->cfg_packages_path );
965 void ZConfig::setRepoPackagesPath(const zypp::filesystem::Pathname &path_r)
967 _pimpl->cfg_packages_path = path_r;
970 ///////////////////////////////////////////////////////////////////
972 Pathname ZConfig::configPath() const
974 return ( _pimpl->cfg_config_path.empty()
975 ? Pathname("/etc/zypp") : _pimpl->cfg_config_path );
978 Pathname ZConfig::knownReposPath() const
980 return ( _pimpl->cfg_known_repos_path.empty()
981 ? (configPath()/"repos.d") : _pimpl->cfg_known_repos_path );
984 Pathname ZConfig::knownServicesPath() const
986 return ( _pimpl->cfg_known_services_path.empty()
987 ? (configPath()/"services.d") : _pimpl->cfg_known_services_path );
990 Pathname ZConfig::needrebootFile() const
991 { return configPath()/"needreboot"; }
993 Pathname ZConfig::needrebootPath() const
994 { return configPath()/"needreboot.d"; }
996 Pathname ZConfig::varsPath() const
998 return ( _pimpl->cfg_vars_path.empty()
999 ? (configPath()/"vars.d") : _pimpl->cfg_vars_path );
1002 Pathname ZConfig::vendorPath() const
1004 return ( _pimpl->cfg_vendor_path.empty()
1005 ? (configPath()/"vendors.d") : _pimpl->cfg_vendor_path );
1008 Pathname ZConfig::locksFile() const
1010 return ( _pimpl->locks_file.empty()
1011 ? (configPath()/"locks") : _pimpl->locks_file );
1014 ///////////////////////////////////////////////////////////////////
1016 bool ZConfig::repo_add_probe() const
1017 { return _pimpl->repo_add_probe; }
1019 unsigned ZConfig::repo_refresh_delay() const
1020 { return _pimpl->repo_refresh_delay; }
1022 LocaleSet ZConfig::repoRefreshLocales() const
1023 { return _pimpl->repoRefreshLocales.empty() ? Target::requestedLocales("") :_pimpl->repoRefreshLocales; }
1025 bool ZConfig::repoLabelIsAlias() const
1026 { return _pimpl->repoLabelIsAlias; }
1028 void ZConfig::repoLabelIsAlias( bool yesno_r )
1029 { _pimpl->repoLabelIsAlias = yesno_r; }
1031 bool ZConfig::download_use_deltarpm() const
1032 { return _pimpl->download_use_deltarpm; }
1034 bool ZConfig::download_use_deltarpm_always() const
1035 { return download_use_deltarpm() && _pimpl->download_use_deltarpm_always; }
1037 bool ZConfig::download_media_prefer_download() const
1038 { return _pimpl->download_media_prefer_download; }
1040 void ZConfig::set_download_media_prefer_download( bool yesno_r )
1041 { _pimpl->download_media_prefer_download.set( yesno_r ); }
1043 void ZConfig::set_default_download_media_prefer_download()
1044 { _pimpl->download_media_prefer_download.restoreToDefault(); }
1046 long ZConfig::download_max_concurrent_connections() const
1047 { return _pimpl->download_max_concurrent_connections; }
1049 long ZConfig::download_min_download_speed() const
1050 { return _pimpl->download_min_download_speed; }
1052 long ZConfig::download_max_download_speed() const
1053 { return _pimpl->download_max_download_speed; }
1055 long ZConfig::download_max_silent_tries() const
1056 { return _pimpl->download_max_silent_tries; }
1058 long ZConfig::download_transfer_timeout() const
1059 { return _pimpl->download_transfer_timeout; }
1061 Pathname ZConfig::download_mediaMountdir() const { return _pimpl->download_mediaMountdir; }
1062 void ZConfig::set_download_mediaMountdir( Pathname newval_r ) { _pimpl->download_mediaMountdir.set( std::move(newval_r) ); }
1063 void ZConfig::set_default_download_mediaMountdir() { _pimpl->download_mediaMountdir.restoreToDefault(); }
1065 DownloadMode ZConfig::commit_downloadMode() const
1066 { return _pimpl->commit_downloadMode; }
1069 bool ZConfig::gpgCheck() const { return _pimpl->gpgCheck; }
1070 TriBool ZConfig::repoGpgCheck() const { return _pimpl->repoGpgCheck; }
1071 TriBool ZConfig::pkgGpgCheck() const { return _pimpl->pkgGpgCheck; }
1073 void ZConfig::setGpgCheck( bool val_r ) { _pimpl->gpgCheck.set( val_r ); }
1074 void ZConfig::setRepoGpgCheck( TriBool val_r ) { _pimpl->repoGpgCheck.set( val_r ); }
1075 void ZConfig::setPkgGpgCheck( TriBool val_r ) { _pimpl->pkgGpgCheck.set( val_r ); }
1077 void ZConfig::resetGpgCheck() { _pimpl->gpgCheck.restoreToDefault(); }
1078 void ZConfig::resetRepoGpgCheck() { _pimpl->repoGpgCheck.restoreToDefault(); }
1079 void ZConfig::resetPkgGpgCheck() { _pimpl->pkgGpgCheck.restoreToDefault(); }
1081 ResolverFocus ZConfig::solver_focus() const { return _pimpl->solver_focus; }
1083 bool ZConfig::solver_onlyRequires() const
1084 { return _pimpl->solver_onlyRequires; }
1086 bool ZConfig::solver_allowVendorChange() const
1087 { return _pimpl->solver_allowVendorChange; }
1089 bool ZConfig::solver_dupAllowDowngrade() const { return _pimpl->solver_dupAllowDowngrade; }
1090 bool ZConfig::solver_dupAllowNameChange() const { return _pimpl->solver_dupAllowNameChange; }
1091 bool ZConfig::solver_dupAllowArchChange() const { return _pimpl->solver_dupAllowArchChange; }
1092 bool ZConfig::solver_dupAllowVendorChange() const { return _pimpl->solver_dupAllowVendorChange; }
1094 bool ZConfig::solver_cleandepsOnRemove() const
1095 { return _pimpl->solver_cleandepsOnRemove; }
1097 Pathname ZConfig::solver_checkSystemFile() const
1098 { return ( _pimpl->solver_checkSystemFile.empty()
1099 ? (configPath()/"systemCheck") : _pimpl->solver_checkSystemFile ); }
1101 Pathname ZConfig::solver_checkSystemFileDir() const
1102 { return ( _pimpl->solver_checkSystemFileDir.empty()
1103 ? (configPath()/"systemCheck.d") : _pimpl->solver_checkSystemFileDir ); }
1105 unsigned ZConfig::solver_upgradeTestcasesToKeep() const
1106 { return _pimpl->solver_upgradeTestcasesToKeep; }
1108 bool ZConfig::solverUpgradeRemoveDroppedPackages() const { return _pimpl->solverUpgradeRemoveDroppedPackages; }
1109 void ZConfig::setSolverUpgradeRemoveDroppedPackages( bool val_r ) { _pimpl->solverUpgradeRemoveDroppedPackages.set( val_r ); }
1110 void ZConfig::resetSolverUpgradeRemoveDroppedPackages() { _pimpl->solverUpgradeRemoveDroppedPackages.restoreToDefault(); }
1114 inline void sigMultiversionSpecChanged()
1116 sat::detail::PoolMember::myPool().multiversionSpecChanged();
1120 const std::set<std::string> & ZConfig::multiversionSpec() const { return _pimpl->multiversion(); }
1121 void ZConfig::multiversionSpec( std::set<std::string> new_r ) { _pimpl->multiversion().swap( new_r ); sigMultiversionSpecChanged(); }
1122 void ZConfig::clearMultiversionSpec() { _pimpl->multiversion().clear(); sigMultiversionSpecChanged(); }
1123 void ZConfig::addMultiversionSpec( const std::string & name_r ) { _pimpl->multiversion().insert( name_r ); sigMultiversionSpecChanged(); }
1124 void ZConfig::removeMultiversionSpec( const std::string & name_r ) { _pimpl->multiversion().erase( name_r ); sigMultiversionSpecChanged(); }
1126 bool ZConfig::apply_locks_file() const
1127 { return _pimpl->apply_locks_file; }
1129 Pathname ZConfig::update_dataPath() const
1131 return ( _pimpl->update_data_path.empty()
1132 ? Pathname("/var/adm") : _pimpl->update_data_path );
1135 Pathname ZConfig::update_messagesPath() const
1137 return ( _pimpl->update_messages_path.empty()
1138 ? Pathname(update_dataPath()/"update-messages") : _pimpl->update_messages_path );
1141 Pathname ZConfig::update_scriptsPath() const
1143 return ( _pimpl->update_scripts_path.empty()
1144 ? Pathname(update_dataPath()/"update-scripts") : _pimpl->update_scripts_path );
1147 std::string ZConfig::updateMessagesNotify() const
1148 { return _pimpl->updateMessagesNotify; }
1150 void ZConfig::setUpdateMessagesNotify( const std::string & val_r )
1151 { _pimpl->updateMessagesNotify.set( val_r ); }
1153 void ZConfig::resetUpdateMessagesNotify()
1154 { _pimpl->updateMessagesNotify.restoreToDefault(); }
1156 ///////////////////////////////////////////////////////////////////
1158 target::rpm::RpmInstFlags ZConfig::rpmInstallFlags() const
1159 { return _pimpl->rpmInstallFlags; }
1162 Pathname ZConfig::historyLogFile() const
1164 return ( _pimpl->history_log_path.empty() ?
1165 Pathname("/var/log/zypp/history") : _pimpl->history_log_path );
1168 Pathname ZConfig::credentialsGlobalDir() const
1170 return ( _pimpl->credentials_global_dir_path.empty() ?
1171 Pathname("/etc/zypp/credentials.d") : _pimpl->credentials_global_dir_path );
1174 Pathname ZConfig::credentialsGlobalFile() const
1176 return ( _pimpl->credentials_global_file_path.empty() ?
1177 Pathname("/etc/zypp/credentials.cat") : _pimpl->credentials_global_file_path );
1180 ///////////////////////////////////////////////////////////////////
1182 std::string ZConfig::distroverpkg() const
1183 { return "system-release"; }
1185 ///////////////////////////////////////////////////////////////////
1187 Pathname ZConfig::pluginsPath() const
1188 { return _pimpl->pluginsPath.get(); }
1190 string ZConfig::multiversionKernels() const
1192 return _pimpl->cfg_kernel_keep_spec;
1195 ///////////////////////////////////////////////////////////////////
1197 std::ostream & ZConfig::about( std::ostream & str ) const
1199 str << "libzypp: " << VERSION << endl;
1201 str << "libsolv: " << solv_version;
1202 if ( ::strcmp( solv_version, LIBSOLV_VERSION_STRING ) )
1203 str << " (built against " << LIBSOLV_VERSION_STRING << ")";
1206 str << "zypp.conf: '" << _pimpl->_parsedZyppConf << "'" << endl;
1207 str << "TextLocale: '" << textLocale() << "' (" << defaultTextLocale() << ")" << endl;
1208 str << "SystemArchitecture: '" << systemArchitecture() << "' (" << defaultSystemArchitecture() << ")" << endl;
1212 /////////////////////////////////////////////////////////////////
1214 ///////////////////////////////////////////////////////////////////