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 ( "single | /usr/lib/zypp/notify-message -p %p" )
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_max_concurrent_connections( 5 )
320 , download_min_download_speed ( 0 )
321 , download_max_download_speed ( 0 )
322 , download_max_silent_tries ( 5 )
323 , download_transfer_timeout ( 180 )
324 , commit_downloadMode ( DownloadDefault )
326 , repoGpgCheck ( indeterminate )
327 , pkgGpgCheck ( indeterminate )
328 , solver_onlyRequires ( false )
329 , solver_allowVendorChange ( false )
330 , solver_dupAllowDowngrade ( true )
331 , solver_dupAllowNameChange ( true )
332 , solver_dupAllowArchChange ( true )
333 , solver_dupAllowVendorChange ( true )
334 , solver_cleandepsOnRemove ( false )
335 , solver_upgradeTestcasesToKeep ( 2 )
336 , solverUpgradeRemoveDroppedPackages( true )
337 , apply_locks_file ( true )
338 , pluginsPath ( "/usr/lib/zypp/plugins" )
340 MIL << "libzypp: " << VERSION << " built " << __DATE__ << " " << __TIME__ << endl;
341 // override_r has higest prio
342 // ZYPP_CONF might override /etc/zypp/zypp.conf
343 if ( _parsedZyppConf.empty() )
345 _parsedZyppConf = _autodetectZyppConfPath();
349 // Inject this into ZConfig. Be shure this is
350 // allocated via new. See: reconfigureZConfig
351 INT << "Reconfigure to " << _parsedZyppConf << endl;
352 ZConfig::instance()._pimpl.reset( this );
354 if ( PathInfo(_parsedZyppConf).isExist() )
356 parser::IniDict dict( _parsedZyppConf );
357 for ( IniDict::section_const_iterator sit = dict.sectionsBegin();
358 sit != dict.sectionsEnd();
361 string section(*sit);
362 //MIL << section << endl;
363 for ( IniDict::entry_const_iterator it = dict.entriesBegin(*sit);
364 it != dict.entriesEnd(*sit);
367 string entry(it->first);
368 string value(it->second);
369 //DBG << (*it).first << "=" << (*it).second << endl;
370 if ( section == "main" )
372 if ( entry == "arch" )
375 if ( carch != cfg_arch )
377 WAR << "Overriding system architecture (" << cfg_arch << "): " << carch << endl;
381 else if ( entry == "cachedir" )
383 cfg_cache_path = Pathname(value);
385 else if ( entry == "metadatadir" )
387 cfg_metadata_path = Pathname(value);
389 else if ( entry == "solvfilesdir" )
391 cfg_solvfiles_path = Pathname(value);
393 else if ( entry == "packagesdir" )
395 cfg_packages_path = Pathname(value);
397 else if ( entry == "configdir" )
399 cfg_config_path = Pathname(value);
401 else if ( entry == "reposdir" )
403 cfg_known_repos_path = Pathname(value);
405 else if ( entry == "servicesdir" )
407 cfg_known_services_path = Pathname(value);
409 else if ( entry == "repo.add.probe" )
411 repo_add_probe = str::strToBool( value, repo_add_probe );
413 else if ( entry == "repo.refresh.delay" )
415 str::strtonum(value, repo_refresh_delay);
417 else if ( entry == "repo.refresh.locales" )
419 std::vector<std::string> tmp;
420 str::split( value, back_inserter( tmp ), ", \t" );
422 boost::function<Locale(const std::string &)> transform(
423 [](const std::string & str_r)->Locale{ return Locale(str_r); }
425 repoRefreshLocales.insert( make_transform_iterator( tmp.begin(), transform ),
426 make_transform_iterator( tmp.end(), transform ) );
428 else if ( entry == "download.use_deltarpm" )
430 download_use_deltarpm = str::strToBool( value, download_use_deltarpm );
432 else if ( entry == "download.use_deltarpm.always" )
434 download_use_deltarpm_always = str::strToBool( value, download_use_deltarpm_always );
436 else if ( entry == "download.media_preference" )
438 download_media_prefer_download.restoreToDefault( str::compareCI( value, "volatile" ) != 0 );
440 else if ( entry == "download.max_concurrent_connections" )
442 str::strtonum(value, download_max_concurrent_connections);
444 else if ( entry == "download.min_download_speed" )
446 str::strtonum(value, download_min_download_speed);
448 else if ( entry == "download.max_download_speed" )
450 str::strtonum(value, download_max_download_speed);
452 else if ( entry == "download.max_silent_tries" )
454 str::strtonum(value, download_max_silent_tries);
456 else if ( entry == "download.transfer_timeout" )
458 str::strtonum(value, download_transfer_timeout);
459 if ( download_transfer_timeout < 0 ) download_transfer_timeout = 0;
460 else if ( download_transfer_timeout > 3600 ) download_transfer_timeout = 3600;
462 else if ( entry == "commit.downloadMode" )
464 commit_downloadMode.set( deserializeDownloadMode( value ) );
466 else if ( entry == "gpgcheck" )
468 gpgCheck.set( str::strToBool( value, gpgCheck ) );
470 else if ( entry == "repo_gpgcheck" )
472 repoGpgCheck.set( str::strToTriBool( value ) );
474 else if ( entry == "pkg_gpgcheck" )
476 pkgGpgCheck.set( str::strToTriBool( value ) );
478 else if ( entry == "vendordir" )
480 cfg_vendor_path = Pathname(value);
482 else if ( entry == "multiversiondir" )
484 cfg_multiversion_path = Pathname(value);
486 else if ( entry == "solver.onlyRequires" )
488 solver_onlyRequires.set( str::strToBool( value, solver_onlyRequires ) );
490 else if ( entry == "solver.allowVendorChange" )
492 solver_allowVendorChange.set( str::strToBool( value, solver_allowVendorChange ) );
494 else if ( entry == "solver.dupAllowDowngrade" )
496 solver_dupAllowDowngrade.set( str::strToBool( value, solver_dupAllowDowngrade ) );
498 else if ( entry == "solver.dupAllowNameChange" )
500 solver_dupAllowNameChange.set( str::strToBool( value, solver_dupAllowNameChange ) );
502 else if ( entry == "solver.dupAllowArchChange" )
504 solver_dupAllowArchChange.set( str::strToBool( value, solver_dupAllowArchChange ) );
506 else if ( entry == "solver.dupAllowVendorChange" )
508 solver_dupAllowVendorChange.set( str::strToBool( value, solver_dupAllowVendorChange ) );
510 else if ( entry == "solver.cleandepsOnRemove" )
512 solver_cleandepsOnRemove.set( str::strToBool( value, solver_cleandepsOnRemove ) );
514 else if ( entry == "solver.upgradeTestcasesToKeep" )
516 solver_upgradeTestcasesToKeep.set( str::strtonum<unsigned>( value ) );
518 else if ( entry == "solver.upgradeRemoveDroppedPackages" )
520 solverUpgradeRemoveDroppedPackages.restoreToDefault( str::strToBool( value, solverUpgradeRemoveDroppedPackages.getDefault() ) );
522 else if ( entry == "solver.checkSystemFile" )
524 solver_checkSystemFile = Pathname(value);
526 else if ( entry == "solver.checkSystemFileDir" )
528 solver_checkSystemFileDir = Pathname(value);
530 else if ( entry == "multiversion" )
532 MultiversionSpec & defSpec( _multiversionMap.getDefaultSpec() );
533 str::splitEscaped( value, std::inserter( defSpec, defSpec.end() ), ", \t" );
535 else if ( entry == "locksfile.path" )
537 locks_file = Pathname(value);
539 else if ( entry == "locksfile.apply" )
541 apply_locks_file = str::strToBool( value, apply_locks_file );
543 else if ( entry == "update.datadir" )
545 update_data_path = Pathname(value);
547 else if ( entry == "update.scriptsdir" )
549 update_scripts_path = Pathname(value);
551 else if ( entry == "update.messagessdir" )
553 update_messages_path = Pathname(value);
555 else if ( entry == "update.messages.notify" )
557 updateMessagesNotify.set( value );
559 else if ( entry == "rpm.install.excludedocs" )
561 rpmInstallFlags.setFlag( target::rpm::RPMINST_EXCLUDEDOCS,
562 str::strToBool( value, false ) );
564 else if ( entry == "history.logfile" )
566 history_log_path = Pathname(value);
568 else if ( entry == "credentials.global.dir" )
570 credentials_global_dir_path = Pathname(value);
572 else if ( entry == "credentials.global.file" )
574 credentials_global_file_path = Pathname(value);
584 MIL << _parsedZyppConf << " not found, using defaults instead." << endl;
585 _parsedZyppConf = _parsedZyppConf.extend( " (NOT FOUND)" );
589 if ( getenv( "ZYPP_TESTSUITE_FAKE_ARCH" ) )
591 Arch carch( getenv( "ZYPP_TESTSUITE_FAKE_ARCH" ) );
592 if ( carch != cfg_arch )
594 WAR << "ZYPP_TESTSUITE_FAKE_ARCH: Overriding system architecture (" << cfg_arch << "): " << carch << endl;
598 MIL << "ZConfig singleton created." << endl;
605 /** Remember any parsed zypp.conf. */
606 Pathname _parsedZyppConf;
609 Locale cfg_textLocale;
611 Pathname cfg_cache_path;
612 Pathname cfg_metadata_path;
613 Pathname cfg_solvfiles_path;
614 Pathname cfg_packages_path;
616 Pathname cfg_config_path;
617 Pathname cfg_known_repos_path;
618 Pathname cfg_known_services_path;
620 Pathname cfg_vendor_path;
621 Pathname cfg_multiversion_path;
624 Pathname update_data_path;
625 Pathname update_scripts_path;
626 Pathname update_messages_path;
627 DefaultOption<std::string> updateMessagesNotify;
630 unsigned repo_refresh_delay;
631 LocaleSet repoRefreshLocales;
632 bool repoLabelIsAlias;
634 bool download_use_deltarpm;
635 bool download_use_deltarpm_always;
636 DefaultOption<bool> download_media_prefer_download;
638 int download_max_concurrent_connections;
639 int download_min_download_speed;
640 int download_max_download_speed;
641 int download_max_silent_tries;
642 int download_transfer_timeout;
644 Option<DownloadMode> commit_downloadMode;
646 Option<bool> gpgCheck;
647 Option<TriBool> repoGpgCheck;
648 Option<TriBool> pkgGpgCheck;
650 Option<bool> solver_onlyRequires;
651 Option<bool> solver_allowVendorChange;
652 Option<bool> solver_dupAllowDowngrade;
653 Option<bool> solver_dupAllowNameChange;
654 Option<bool> solver_dupAllowArchChange;
655 Option<bool> solver_dupAllowVendorChange;
656 Option<bool> solver_cleandepsOnRemove;
657 Option<unsigned> solver_upgradeTestcasesToKeep;
658 DefaultOption<bool> solverUpgradeRemoveDroppedPackages;
660 Pathname solver_checkSystemFile;
661 Pathname solver_checkSystemFileDir;
663 MultiversionSpec & multiversion() { return getMultiversion(); }
664 const MultiversionSpec & multiversion() const { return getMultiversion(); }
666 bool apply_locks_file;
668 target::rpm::RpmInstFlags rpmInstallFlags;
670 Pathname history_log_path;
671 Pathname credentials_global_dir_path;
672 Pathname credentials_global_file_path;
674 std::string userData;
676 Option<Pathname> pluginsPath;
679 // HACK for bnc#906096: let pool re-evaluate multiversion spec
680 // if target root changes. ZConfig returns data sensitive to
681 // current target root.
682 // TODO Actually we'd need to scan the target systems zypp.conf and
683 // overlay all system specific values.
684 struct MultiversionMap
686 typedef std::map<Pathname,MultiversionSpec> SpecMap;
688 MultiversionSpec & getSpec( Pathname root_r, const Impl & zConfImpl_r ) // from system at root
690 // _specMap[] - the plain zypp.conf value
691 // _specMap[/] - combine [] and multiversion.d scan
692 // _specMap[root] - scan root/zypp.conf and root/multiversion.d
694 if ( root_r.empty() )
696 bool cacheHit = _specMap.count( root_r );
697 MultiversionSpec & ret( _specMap[root_r] ); // creates new entry on the fly
702 ret.swap( _specMap[Pathname()] ); // original zypp.conf
704 scanConfAt( root_r, ret, zConfImpl_r ); // scan zypp.conf at root_r
705 scanDirAt( root_r, ret, zConfImpl_r ); // add multiversion.d at root_r
706 using zypp::operator<<;
707 MIL << "MultiversionSpec '" << root_r << "' = " << ret << endl;
712 MultiversionSpec & getDefaultSpec() // Spec from zypp.conf parsing; called before any getSpec
713 { return _specMap[Pathname()]; }
716 void scanConfAt( const Pathname root_r, MultiversionSpec & spec_r, const Impl & zConfImpl_r )
718 static const str::regex rx( "^multiversion *= *(.*)" );
720 iostr::simpleParseFile( InputStream( Pathname::assertprefix( root_r, _autodetectZyppConfPath() ) ),
721 [&]( int num_r, std::string line_r )->bool
723 if ( line_r[0] == 'm' && str::regex_match( line_r, what, rx ) )
725 str::splitEscaped( what[1], std::inserter( spec_r, spec_r.end() ), ", \t" );
726 return false; // stop after match
732 void scanDirAt( const Pathname root_r, MultiversionSpec & spec_r, const Impl & zConfImpl_r )
734 // NOTE: Actually we'd need to scan and use the root_r! zypp.conf values.
735 Pathname multiversionDir( zConfImpl_r.cfg_multiversion_path );
736 if ( multiversionDir.empty() )
737 multiversionDir = ( zConfImpl_r.cfg_config_path.empty()
738 ? Pathname("/etc/zypp")
739 : zConfImpl_r.cfg_config_path ) / "multiversion.d";
741 filesystem::dirForEach( Pathname::assertprefix( root_r, multiversionDir ),
742 [&spec_r]( const Pathname & dir_r, const char *const & name_r )->bool
744 MIL << "Parsing " << dir_r/name_r << endl;
745 iostr::simpleParseFile( InputStream( dir_r/name_r ),
746 [&spec_r]( int num_r, std::string line_r )->bool
748 DBG << " found " << line_r << endl;
749 spec_r.insert( std::move(line_r) );
760 MultiversionSpec & getMultiversion() const
761 { return _multiversionMap.getSpec( _autodetectSystemRoot(), *this ); }
763 mutable MultiversionMap _multiversionMap;
765 ///////////////////////////////////////////////////////////////////
767 // Backdoor to redirect ZConfig from within the running
768 // TEST-application. HANDLE WITH CARE!
769 void reconfigureZConfig( const Pathname & override_r )
771 // ctor puts itself unter smart pointer control.
772 new ZConfig::Impl( override_r );
775 ///////////////////////////////////////////////////////////////////
777 // METHOD NAME : ZConfig::instance
778 // METHOD TYPE : ZConfig &
780 ZConfig & ZConfig::instance()
782 static ZConfig _instance; // The singleton
786 ///////////////////////////////////////////////////////////////////
788 // METHOD NAME : ZConfig::ZConfig
789 // METHOD TYPE : Ctor
797 ///////////////////////////////////////////////////////////////////
799 // METHOD NAME : ZConfig::~ZConfig
800 // METHOD TYPE : Dtor
805 Pathname ZConfig::systemRoot() const
806 { return _autodetectSystemRoot(); }
808 ///////////////////////////////////////////////////////////////////
810 // system architecture
812 ///////////////////////////////////////////////////////////////////
814 Arch ZConfig::defaultSystemArchitecture()
816 static Arch _val( _autodetectSystemArchitecture() );
820 Arch ZConfig::systemArchitecture() const
821 { return _pimpl->cfg_arch; }
823 void ZConfig::setSystemArchitecture( const Arch & arch_r )
825 if ( arch_r != _pimpl->cfg_arch )
827 WAR << "Overriding system architecture (" << _pimpl->cfg_arch << "): " << arch_r << endl;
828 _pimpl->cfg_arch = arch_r;
832 ///////////////////////////////////////////////////////////////////
836 ///////////////////////////////////////////////////////////////////
838 Locale ZConfig::defaultTextLocale()
840 static Locale _val( _autodetectTextLocale() );
844 Locale ZConfig::textLocale() const
845 { return _pimpl->cfg_textLocale; }
847 void ZConfig::setTextLocale( const Locale & locale_r )
849 if ( locale_r != _pimpl->cfg_textLocale )
851 WAR << "Overriding text locale (" << _pimpl->cfg_textLocale << "): " << locale_r << endl;
852 _pimpl->cfg_textLocale = locale_r;
853 #warning prefer signal
854 sat::Pool::instance().setTextLocale( locale_r );
858 ///////////////////////////////////////////////////////////////////
860 ///////////////////////////////////////////////////////////////////
862 bool ZConfig::hasUserData() const
863 { return !_pimpl->userData.empty(); }
865 std::string ZConfig::userData() const
866 { return _pimpl->userData; }
868 bool ZConfig::setUserData( const std::string & str_r )
870 for_( ch, str_r.begin(), str_r.end() )
872 if ( *ch < ' ' && *ch != '\t' )
874 ERR << "New user data string rejectded: char " << (int)*ch << " at position " << (ch - str_r.begin()) << endl;
878 MIL << "Set user data string to '" << str_r << "'" << endl;
879 _pimpl->userData = str_r;
883 ///////////////////////////////////////////////////////////////////
885 Pathname ZConfig::repoCachePath() const
887 return ( _pimpl->cfg_cache_path.empty()
888 ? Pathname("/var/cache/zypp") : _pimpl->cfg_cache_path );
891 Pathname ZConfig::repoMetadataPath() const
893 return ( _pimpl->cfg_metadata_path.empty()
894 ? (repoCachePath()/"raw") : _pimpl->cfg_metadata_path );
897 Pathname ZConfig::repoSolvfilesPath() const
899 return ( _pimpl->cfg_solvfiles_path.empty()
900 ? (repoCachePath()/"solv") : _pimpl->cfg_solvfiles_path );
903 Pathname ZConfig::repoPackagesPath() const
905 return ( _pimpl->cfg_packages_path.empty()
906 ? (repoCachePath()/"packages") : _pimpl->cfg_packages_path );
909 ///////////////////////////////////////////////////////////////////
911 Pathname ZConfig::configPath() const
913 return ( _pimpl->cfg_config_path.empty()
914 ? Pathname("/etc/zypp") : _pimpl->cfg_config_path );
917 Pathname ZConfig::knownReposPath() const
919 return ( _pimpl->cfg_known_repos_path.empty()
920 ? (configPath()/"repos.d") : _pimpl->cfg_known_repos_path );
923 Pathname ZConfig::knownServicesPath() const
925 return ( _pimpl->cfg_known_services_path.empty()
926 ? (configPath()/"services.d") : _pimpl->cfg_known_services_path );
929 Pathname ZConfig::vendorPath() const
931 return ( _pimpl->cfg_vendor_path.empty()
932 ? (configPath()/"vendors.d") : _pimpl->cfg_vendor_path );
935 Pathname ZConfig::locksFile() const
937 return ( _pimpl->locks_file.empty()
938 ? (configPath()/"locks") : _pimpl->locks_file );
941 ///////////////////////////////////////////////////////////////////
943 bool ZConfig::repo_add_probe() const
944 { return _pimpl->repo_add_probe; }
946 unsigned ZConfig::repo_refresh_delay() const
947 { return _pimpl->repo_refresh_delay; }
949 LocaleSet ZConfig::repoRefreshLocales() const
950 { return _pimpl->repoRefreshLocales.empty() ? Target::requestedLocales("") :_pimpl->repoRefreshLocales; }
952 bool ZConfig::repoLabelIsAlias() const
953 { return _pimpl->repoLabelIsAlias; }
955 void ZConfig::repoLabelIsAlias( bool yesno_r )
956 { _pimpl->repoLabelIsAlias = yesno_r; }
958 bool ZConfig::download_use_deltarpm() const
959 { return _pimpl->download_use_deltarpm; }
961 bool ZConfig::download_use_deltarpm_always() const
962 { return download_use_deltarpm() && _pimpl->download_use_deltarpm_always; }
964 bool ZConfig::download_media_prefer_download() const
965 { return _pimpl->download_media_prefer_download; }
967 void ZConfig::set_download_media_prefer_download( bool yesno_r )
968 { _pimpl->download_media_prefer_download.set( yesno_r ); }
970 void ZConfig::set_default_download_media_prefer_download()
971 { _pimpl->download_media_prefer_download.restoreToDefault(); }
973 long ZConfig::download_max_concurrent_connections() const
974 { return _pimpl->download_max_concurrent_connections; }
976 long ZConfig::download_min_download_speed() const
977 { return _pimpl->download_min_download_speed; }
979 long ZConfig::download_max_download_speed() const
980 { return _pimpl->download_max_download_speed; }
982 long ZConfig::download_max_silent_tries() const
983 { return _pimpl->download_max_silent_tries; }
985 long ZConfig::download_transfer_timeout() const
986 { return _pimpl->download_transfer_timeout; }
988 DownloadMode ZConfig::commit_downloadMode() const
989 { return _pimpl->commit_downloadMode; }
991 bool ZConfig::gpgCheck() const
992 { return _pimpl->gpgCheck; }
994 TriBool ZConfig::repoGpgCheck() const
995 { return _pimpl->repoGpgCheck; }
997 TriBool ZConfig::pkgGpgCheck() const
998 { return _pimpl->pkgGpgCheck; }
1000 bool ZConfig::solver_onlyRequires() const
1001 { return _pimpl->solver_onlyRequires; }
1003 bool ZConfig::solver_allowVendorChange() const
1004 { return _pimpl->solver_allowVendorChange; }
1006 bool ZConfig::solver_dupAllowDowngrade() const { return _pimpl->solver_dupAllowDowngrade; }
1007 bool ZConfig::solver_dupAllowNameChange() const { return _pimpl->solver_dupAllowNameChange; }
1008 bool ZConfig::solver_dupAllowArchChange() const { return _pimpl->solver_dupAllowArchChange; }
1009 bool ZConfig::solver_dupAllowVendorChange() const { return _pimpl->solver_dupAllowVendorChange; }
1011 bool ZConfig::solver_cleandepsOnRemove() const
1012 { return _pimpl->solver_cleandepsOnRemove; }
1014 Pathname ZConfig::solver_checkSystemFile() const
1015 { return ( _pimpl->solver_checkSystemFile.empty()
1016 ? (configPath()/"systemCheck") : _pimpl->solver_checkSystemFile ); }
1018 Pathname ZConfig::solver_checkSystemFileDir() const
1019 { return ( _pimpl->solver_checkSystemFileDir.empty()
1020 ? (configPath()/"systemCheck.d") : _pimpl->solver_checkSystemFileDir ); }
1022 unsigned ZConfig::solver_upgradeTestcasesToKeep() const
1023 { return _pimpl->solver_upgradeTestcasesToKeep; }
1025 bool ZConfig::solverUpgradeRemoveDroppedPackages() const { return _pimpl->solverUpgradeRemoveDroppedPackages; }
1026 void ZConfig::setSolverUpgradeRemoveDroppedPackages( bool val_r ) { _pimpl->solverUpgradeRemoveDroppedPackages.set( val_r ); }
1027 void ZConfig::resetSolverUpgradeRemoveDroppedPackages() { _pimpl->solverUpgradeRemoveDroppedPackages.restoreToDefault(); }
1031 inline void sigMultiversionSpecChanged()
1033 sat::detail::PoolMember::myPool().multiversionSpecChanged();
1037 const std::set<std::string> & ZConfig::multiversionSpec() const { return _pimpl->multiversion(); }
1038 void ZConfig::multiversionSpec( std::set<std::string> new_r ) { _pimpl->multiversion().swap( new_r ); sigMultiversionSpecChanged(); }
1039 void ZConfig::clearMultiversionSpec() { _pimpl->multiversion().clear(); sigMultiversionSpecChanged(); }
1040 void ZConfig::addMultiversionSpec( const std::string & name_r ) { _pimpl->multiversion().insert( name_r ); sigMultiversionSpecChanged(); }
1041 void ZConfig::removeMultiversionSpec( const std::string & name_r ) { _pimpl->multiversion().erase( name_r ); sigMultiversionSpecChanged(); }
1043 bool ZConfig::apply_locks_file() const
1044 { return _pimpl->apply_locks_file; }
1046 Pathname ZConfig::update_dataPath() const
1048 return ( _pimpl->update_data_path.empty()
1049 ? Pathname("/var/adm") : _pimpl->update_data_path );
1052 Pathname ZConfig::update_messagesPath() const
1054 return ( _pimpl->update_messages_path.empty()
1055 ? Pathname(update_dataPath()/"update-messages") : _pimpl->update_messages_path );
1058 Pathname ZConfig::update_scriptsPath() const
1060 return ( _pimpl->update_scripts_path.empty()
1061 ? Pathname(update_dataPath()/"update-scripts") : _pimpl->update_scripts_path );
1064 std::string ZConfig::updateMessagesNotify() const
1065 { return _pimpl->updateMessagesNotify; }
1067 void ZConfig::setUpdateMessagesNotify( const std::string & val_r )
1068 { _pimpl->updateMessagesNotify.set( val_r ); }
1070 void ZConfig::resetUpdateMessagesNotify()
1071 { _pimpl->updateMessagesNotify.restoreToDefault(); }
1073 ///////////////////////////////////////////////////////////////////
1075 target::rpm::RpmInstFlags ZConfig::rpmInstallFlags() const
1076 { return _pimpl->rpmInstallFlags; }
1079 Pathname ZConfig::historyLogFile() const
1081 return ( _pimpl->history_log_path.empty() ?
1082 Pathname("/var/log/zypp/history") : _pimpl->history_log_path );
1085 Pathname ZConfig::credentialsGlobalDir() const
1087 return ( _pimpl->credentials_global_dir_path.empty() ?
1088 Pathname("/etc/zypp/credentials.d") : _pimpl->credentials_global_dir_path );
1091 Pathname ZConfig::credentialsGlobalFile() const
1093 return ( _pimpl->credentials_global_file_path.empty() ?
1094 Pathname("/etc/zypp/credentials.cat") : _pimpl->credentials_global_file_path );
1097 ///////////////////////////////////////////////////////////////////
1099 std::string ZConfig::distroverpkg() const
1100 { return "redhat-release"; }
1102 ///////////////////////////////////////////////////////////////////
1104 Pathname ZConfig::pluginsPath() const
1105 { return _pimpl->pluginsPath.get(); }
1107 ///////////////////////////////////////////////////////////////////
1109 std::ostream & ZConfig::about( std::ostream & str ) const
1111 str << "libzypp: " << VERSION << " built " << __DATE__ << " " << __TIME__ << endl;
1113 str << "libsolv: " << solv_version;
1114 if ( ::strcmp( solv_version, LIBSOLV_VERSION_STRING ) )
1115 str << " (built against " << LIBSOLV_VERSION_STRING << ")";
1118 str << "zypp.conf: '" << _pimpl->_parsedZyppConf << "'" << endl;
1119 str << "TextLocale: '" << textLocale() << "' (" << defaultTextLocale() << ")" << endl;
1120 str << "SystemArchitecture: '" << systemArchitecture() << "' (" << defaultSystemArchitecture() << ")" << endl;
1124 /////////////////////////////////////////////////////////////////
1126 ///////////////////////////////////////////////////////////////////