libzypp
10.5.0
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 extern "C" 00013 { 00014 #include <sys/utsname.h> 00015 #include <unistd.h> 00016 #include <solv/solvversion.h> 00017 } 00018 #include <iostream> 00019 #include <fstream> 00020 #include "zypp/base/Logger.h" 00021 #include "zypp/base/IOStream.h" 00022 #include "zypp/base/InputStream.h" 00023 #include "zypp/base/String.h" 00024 00025 #include "zypp/ZConfig.h" 00026 #include "zypp/ZYppFactory.h" 00027 #include "zypp/PathInfo.h" 00028 #include "zypp/parser/IniDict.h" 00029 00030 #include "zypp/sat/Pool.h" 00031 00032 using namespace std; 00033 using namespace zypp::filesystem; 00034 using namespace zypp::parser; 00035 00036 #undef ZYPP_BASE_LOGGER_LOGGROUP 00037 #define ZYPP_BASE_LOGGER_LOGGROUP "zconfig" 00038 00040 namespace zypp 00041 { 00042 00051 00052 namespace 00053 { 00054 00057 Arch _autodetectSystemArchitecture() 00058 { 00059 struct ::utsname buf; 00060 if ( ::uname( &buf ) < 0 ) 00061 { 00062 ERR << "Can't determine system architecture" << endl; 00063 return Arch_noarch; 00064 } 00065 00066 Arch architecture( buf.machine ); 00067 MIL << "Uname architecture is '" << buf.machine << "'" << endl; 00068 00069 if ( architecture == Arch_i686 ) 00070 { 00071 // some CPUs report i686 but dont implement cx8 and cmov 00072 // check for both flags in /proc/cpuinfo and downgrade 00073 // to i586 if either is missing (cf bug #18885) 00074 std::ifstream cpuinfo( "/proc/cpuinfo" ); 00075 if ( cpuinfo ) 00076 { 00077 for( iostr::EachLine in( cpuinfo ); in; in.next() ) 00078 { 00079 if ( str::hasPrefix( *in, "flags" ) ) 00080 { 00081 if ( in->find( "cx8" ) == std::string::npos 00082 || in->find( "cmov" ) == std::string::npos ) 00083 { 00084 architecture = Arch_i586; 00085 WAR << "CPU lacks 'cx8' or 'cmov': architecture downgraded to '" << architecture << "'" << endl; 00086 } 00087 break; 00088 } 00089 } 00090 } 00091 else 00092 { 00093 ERR << "Cant open " << PathInfo("/proc/cpuinfo") << endl; 00094 } 00095 } 00096 else if ( architecture == Arch_sparc || architecture == Arch_sparc64 ) 00097 { 00098 // Check for sun4[vum] to get the real arch. (bug #566291) 00099 std::ifstream cpuinfo( "/proc/cpuinfo" ); 00100 if ( cpuinfo ) 00101 { 00102 for( iostr::EachLine in( cpuinfo ); in; in.next() ) 00103 { 00104 if ( str::hasPrefix( *in, "type" ) ) 00105 { 00106 if ( in->find( "sun4v" ) != std::string::npos ) 00107 { 00108 architecture = ( architecture == Arch_sparc64 ? Arch_sparc64v : Arch_sparcv9v ); 00109 WAR << "CPU has 'sun4v': architecture upgraded to '" << architecture << "'" << endl; 00110 } 00111 else if ( in->find( "sun4u" ) != std::string::npos ) 00112 { 00113 architecture = ( architecture == Arch_sparc64 ? Arch_sparc64 : Arch_sparcv9 ); 00114 WAR << "CPU has 'sun4u': architecture upgraded to '" << architecture << "'" << endl; 00115 } 00116 else if ( in->find( "sun4m" ) != std::string::npos ) 00117 { 00118 architecture = Arch_sparcv8; 00119 WAR << "CPU has 'sun4m': architecture upgraded to '" << architecture << "'" << endl; 00120 } 00121 break; 00122 } 00123 } 00124 } 00125 else 00126 { 00127 ERR << "Cant open " << PathInfo("/proc/cpuinfo") << endl; 00128 } 00129 } 00130 return architecture; 00131 } 00132 00150 Locale _autodetectTextLocale() 00151 { 00152 Locale ret( "en" ); 00153 const char * envlist[] = { "LC_ALL", "LC_MESSAGES", "LANG", NULL }; 00154 for ( const char ** envvar = envlist; *envvar; ++envvar ) 00155 { 00156 const char * envlang = getenv( *envvar ); 00157 if ( envlang ) 00158 { 00159 std::string envstr( envlang ); 00160 if ( envstr != "POSIX" && envstr != "C" ) 00161 { 00162 Locale lang( envstr ); 00163 if ( ! lang.code().empty() ) 00164 { 00165 MIL << "Found " << *envvar << "=" << envstr << endl; 00166 ret = lang; 00167 break; 00168 } 00169 } 00170 } 00171 } 00172 MIL << "Default text locale is '" << ret << "'" << endl; 00173 #warning HACK AROUND BOOST_TEST_CATCH_SYSTEM_ERRORS 00174 setenv( "BOOST_TEST_CATCH_SYSTEM_ERRORS", "no", 1 ); 00175 return ret; 00176 } 00177 00179 } // namespace zypp 00181 00183 template<class _Tp> 00184 struct Option 00185 { 00186 typedef _Tp value_type; 00187 00189 Option( const value_type & initial_r ) 00190 : _val( initial_r ) 00191 {} 00192 00194 const value_type & get() const 00195 { return _val; } 00196 00198 operator const value_type &() const 00199 { return _val; } 00200 00202 void set( const value_type & newval_r ) 00203 { _val = newval_r; } 00204 00206 value_type & ref() 00207 { return _val; } 00208 00209 private: 00210 value_type _val; 00211 }; 00212 00214 template<class _Tp> 00215 struct DefaultOption : public Option<_Tp> 00216 { 00217 typedef _Tp value_type; 00218 typedef Option<_Tp> option_type; 00219 00220 DefaultOption( const value_type & initial_r ) 00221 : Option<_Tp>( initial_r ), _default( initial_r ) 00222 {} 00223 00225 void restoreToDefault() 00226 { this->set( _default.get() ); } 00227 00229 void restoreToDefault( const value_type & newval_r ) 00230 { setDefault( newval_r ); restoreToDefault(); } 00231 00233 const value_type & getDefault() const 00234 { return _default.get(); } 00235 00237 void setDefault( const value_type & newval_r ) 00238 { _default.set( newval_r ); } 00239 00240 private: 00241 option_type _default; 00242 }; 00243 00245 // 00246 // CLASS NAME : ZConfig::Impl 00247 // 00253 class ZConfig::Impl 00254 { 00255 public: 00256 Impl( const Pathname & override_r = Pathname() ) 00257 : _parsedZyppConf ( override_r ) 00258 , cfg_arch ( defaultSystemArchitecture() ) 00259 , cfg_textLocale ( defaultTextLocale() ) 00260 , updateMessagesNotify ( "single | /usr/lib/zypp/notify-message -p %p" ) 00261 , repo_add_probe ( false ) 00262 , repo_refresh_delay ( 10 ) 00263 , repoLabelIsAlias ( false ) 00264 , download_use_deltarpm ( true ) 00265 , download_use_deltarpm_always ( false ) 00266 , download_media_prefer_download( true ) 00267 , download_max_concurrent_connections( 5 ) 00268 , download_min_download_speed ( 0 ) 00269 , download_max_download_speed ( 0 ) 00270 , download_max_silent_tries ( 5 ) 00271 , download_transfer_timeout ( 180 ) 00272 , commit_downloadMode ( DownloadDefault ) 00273 , solver_onlyRequires ( false ) 00274 , solver_allowVendorChange ( false ) 00275 , solver_cleandepsOnRemove ( false ) 00276 , solver_upgradeTestcasesToKeep ( 2 ) 00277 , solverUpgradeRemoveDroppedPackages( true ) 00278 , apply_locks_file ( true ) 00279 , pluginsPath ( "/usr/lib/zypp/plugins" ) 00280 { 00281 MIL << "libzypp: " << VERSION << " built " << __DATE__ << " " << __TIME__ << endl; 00282 // override_r has higest prio 00283 // ZYPP_CONF might override /etc/zypp/zypp.conf 00284 if ( _parsedZyppConf.empty() ) 00285 { 00286 const char *env_confpath = getenv( "ZYPP_CONF" ); 00287 _parsedZyppConf = env_confpath ? env_confpath : "/etc/zypp/zypp.conf"; 00288 } 00289 else 00290 { 00291 // Inject this into ZConfig. Be shure this is 00292 // allocated via new. See: reconfigureZConfig 00293 INT << "Reconfigure to " << _parsedZyppConf << endl; 00294 ZConfig::instance()._pimpl.reset( this ); 00295 } 00296 if ( PathInfo(_parsedZyppConf).isExist() ) 00297 { 00298 parser::IniDict dict( _parsedZyppConf ); 00299 for ( IniDict::section_const_iterator sit = dict.sectionsBegin(); 00300 sit != dict.sectionsEnd(); 00301 ++sit ) 00302 { 00303 string section(*sit); 00304 //MIL << section << endl; 00305 for ( IniDict::entry_const_iterator it = dict.entriesBegin(*sit); 00306 it != dict.entriesEnd(*sit); 00307 ++it ) 00308 { 00309 string entry(it->first); 00310 string value(it->second); 00311 //DBG << (*it).first << "=" << (*it).second << endl; 00312 if ( section == "main" ) 00313 { 00314 if ( entry == "arch" ) 00315 { 00316 Arch carch( value ); 00317 if ( carch != cfg_arch ) 00318 { 00319 WAR << "Overriding system architecture (" << cfg_arch << "): " << carch << endl; 00320 cfg_arch = carch; 00321 } 00322 } 00323 else if ( entry == "cachedir" ) 00324 { 00325 cfg_cache_path = Pathname(value); 00326 } 00327 else if ( entry == "metadatadir" ) 00328 { 00329 cfg_metadata_path = Pathname(value); 00330 } 00331 else if ( entry == "solvfilesdir" ) 00332 { 00333 cfg_solvfiles_path = Pathname(value); 00334 } 00335 else if ( entry == "packagesdir" ) 00336 { 00337 cfg_packages_path = Pathname(value); 00338 } 00339 else if ( entry == "configdir" ) 00340 { 00341 cfg_config_path = Pathname(value); 00342 } 00343 else if ( entry == "reposdir" ) 00344 { 00345 cfg_known_repos_path = Pathname(value); 00346 } 00347 else if ( entry == "servicesdir" ) 00348 { 00349 cfg_known_services_path = Pathname(value); 00350 } 00351 else if ( entry == "repo.add.probe" ) 00352 { 00353 repo_add_probe = str::strToBool( value, repo_add_probe ); 00354 } 00355 else if ( entry == "repo.refresh.delay" ) 00356 { 00357 str::strtonum(value, repo_refresh_delay); 00358 } 00359 else if ( entry == "repo.refresh.locales" ) 00360 { 00361 std::vector<std::string> tmp; 00362 str::split( value, back_inserter( tmp ), ", \t" ); 00363 00364 boost::function<Locale(const std::string &)> transform( 00365 [](const std::string & str_r)->Locale{ return Locale(str_r); } 00366 ); 00367 repoRefreshLocales.insert( make_transform_iterator( tmp.begin(), transform ), 00368 make_transform_iterator( tmp.end(), transform ) ); 00369 } 00370 else if ( entry == "download.use_deltarpm" ) 00371 { 00372 download_use_deltarpm = str::strToBool( value, download_use_deltarpm ); 00373 } 00374 else if ( entry == "download.use_deltarpm.always" ) 00375 { 00376 download_use_deltarpm_always = str::strToBool( value, download_use_deltarpm_always ); 00377 } 00378 else if ( entry == "download.media_preference" ) 00379 { 00380 download_media_prefer_download.restoreToDefault( str::compareCI( value, "volatile" ) != 0 ); 00381 } 00382 else if ( entry == "download.max_concurrent_connections" ) 00383 { 00384 str::strtonum(value, download_max_concurrent_connections); 00385 } 00386 else if ( entry == "download.min_download_speed" ) 00387 { 00388 str::strtonum(value, download_min_download_speed); 00389 } 00390 else if ( entry == "download.max_download_speed" ) 00391 { 00392 str::strtonum(value, download_max_download_speed); 00393 } 00394 else if ( entry == "download.max_silent_tries" ) 00395 { 00396 str::strtonum(value, download_max_silent_tries); 00397 } 00398 else if ( entry == "download.transfer_timeout" ) 00399 { 00400 str::strtonum(value, download_transfer_timeout); 00401 if ( download_transfer_timeout < 0 ) download_transfer_timeout = 0; 00402 else if ( download_transfer_timeout > 3600 ) download_transfer_timeout = 3600; 00403 } 00404 else if ( entry == "commit.downloadMode" ) 00405 { 00406 commit_downloadMode.set( deserializeDownloadMode( value ) ); 00407 } 00408 else if ( entry == "vendordir" ) 00409 { 00410 cfg_vendor_path = Pathname(value); 00411 } 00412 else if ( entry == "solver.onlyRequires" ) 00413 { 00414 solver_onlyRequires.set( str::strToBool( value, solver_onlyRequires ) ); 00415 } 00416 else if ( entry == "solver.allowVendorChange" ) 00417 { 00418 solver_allowVendorChange.set( str::strToBool( value, solver_allowVendorChange ) ); 00419 } 00420 else if ( entry == "solver.cleandepsOnRemove" ) 00421 { 00422 solver_cleandepsOnRemove.set( str::strToBool( value, solver_cleandepsOnRemove ) ); 00423 } 00424 else if ( entry == "solver.upgradeTestcasesToKeep" ) 00425 { 00426 solver_upgradeTestcasesToKeep.set( str::strtonum<unsigned>( value ) ); 00427 } 00428 else if ( entry == "solver.upgradeRemoveDroppedPackages" ) 00429 { 00430 solverUpgradeRemoveDroppedPackages.restoreToDefault( str::strToBool( value, solverUpgradeRemoveDroppedPackages.getDefault() ) ); 00431 } 00432 else if ( entry == "solver.checkSystemFile" ) 00433 { 00434 solver_checkSystemFile = Pathname(value); 00435 } 00436 else if ( entry == "multiversion" ) 00437 { 00438 str::split( value, inserter( multiversion, multiversion.end() ), ", \t" ); 00439 } 00440 else if ( entry == "locksfile.path" ) 00441 { 00442 locks_file = Pathname(value); 00443 } 00444 else if ( entry == "locksfile.apply" ) 00445 { 00446 apply_locks_file = str::strToBool( value, apply_locks_file ); 00447 } 00448 else if ( entry == "update.datadir" ) 00449 { 00450 update_data_path = Pathname(value); 00451 } 00452 else if ( entry == "update.scriptsdir" ) 00453 { 00454 update_scripts_path = Pathname(value); 00455 } 00456 else if ( entry == "update.messagessdir" ) 00457 { 00458 update_messages_path = Pathname(value); 00459 } 00460 else if ( entry == "update.messages.notify" ) 00461 { 00462 updateMessagesNotify.set( value ); 00463 } 00464 else if ( entry == "rpm.install.excludedocs" ) 00465 { 00466 rpmInstallFlags.setFlag( target::rpm::RPMINST_EXCLUDEDOCS, 00467 str::strToBool( value, false ) ); 00468 } 00469 else if ( entry == "history.logfile" ) 00470 { 00471 history_log_path = Pathname(value); 00472 } 00473 else if ( entry == "credentials.global.dir" ) 00474 { 00475 credentials_global_dir_path = Pathname(value); 00476 } 00477 else if ( entry == "credentials.global.file" ) 00478 { 00479 credentials_global_file_path = Pathname(value); 00480 } 00481 } 00482 } 00483 } 00484 } 00485 else 00486 { 00487 MIL << _parsedZyppConf << " not found, using defaults instead." << endl; 00488 _parsedZyppConf = _parsedZyppConf.extend( " (NOT FOUND)" ); 00489 } 00490 00491 // legacy: 00492 if ( getenv( "ZYPP_TESTSUITE_FAKE_ARCH" ) ) 00493 { 00494 Arch carch( getenv( "ZYPP_TESTSUITE_FAKE_ARCH" ) ); 00495 if ( carch != cfg_arch ) 00496 { 00497 WAR << "ZYPP_TESTSUITE_FAKE_ARCH: Overriding system architecture (" << cfg_arch << "): " << carch << endl; 00498 cfg_arch = carch; 00499 } 00500 } 00501 MIL << "ZConfig singleton created." << endl; 00502 } 00503 00504 ~Impl() 00505 {} 00506 00507 public: 00509 Pathname _parsedZyppConf; 00510 00511 Arch cfg_arch; 00512 Locale cfg_textLocale; 00513 00514 Pathname cfg_cache_path; 00515 Pathname cfg_metadata_path; 00516 Pathname cfg_solvfiles_path; 00517 Pathname cfg_packages_path; 00518 00519 Pathname cfg_config_path; 00520 Pathname cfg_known_repos_path; 00521 Pathname cfg_known_services_path; 00522 00523 Pathname cfg_vendor_path; 00524 Pathname locks_file; 00525 00526 Pathname update_data_path; 00527 Pathname update_scripts_path; 00528 Pathname update_messages_path; 00529 DefaultOption<std::string> updateMessagesNotify; 00530 00531 bool repo_add_probe; 00532 unsigned repo_refresh_delay; 00533 LocaleSet repoRefreshLocales; 00534 bool repoLabelIsAlias; 00535 00536 bool download_use_deltarpm; 00537 bool download_use_deltarpm_always; 00538 DefaultOption<bool> download_media_prefer_download; 00539 00540 int download_max_concurrent_connections; 00541 int download_min_download_speed; 00542 int download_max_download_speed; 00543 int download_max_silent_tries; 00544 int download_transfer_timeout; 00545 00546 Option<DownloadMode> commit_downloadMode; 00547 00548 Option<bool> solver_onlyRequires; 00549 Option<bool> solver_allowVendorChange; 00550 Option<bool> solver_cleandepsOnRemove; 00551 Option<unsigned> solver_upgradeTestcasesToKeep; 00552 DefaultOption<bool> solverUpgradeRemoveDroppedPackages; 00553 00554 Pathname solver_checkSystemFile; 00555 00556 std::set<std::string> multiversion; 00557 00558 bool apply_locks_file; 00559 00560 target::rpm::RpmInstFlags rpmInstallFlags; 00561 00562 Pathname history_log_path; 00563 Pathname credentials_global_dir_path; 00564 Pathname credentials_global_file_path; 00565 00566 Option<Pathname> pluginsPath; 00567 }; 00569 00570 // Backdoor to redirect ZConfig from within the running 00571 // TEST-application. HANDLE WITH CARE! 00572 void reconfigureZConfig( const Pathname & override_r ) 00573 { 00574 // ctor puts itself unter smart pointer control. 00575 new ZConfig::Impl( override_r ); 00576 } 00577 00579 // 00580 // METHOD NAME : ZConfig::instance 00581 // METHOD TYPE : ZConfig & 00582 // 00583 ZConfig & ZConfig::instance() 00584 { 00585 static ZConfig _instance; // The singleton 00586 return _instance; 00587 } 00588 00590 // 00591 // METHOD NAME : ZConfig::ZConfig 00592 // METHOD TYPE : Ctor 00593 // 00594 ZConfig::ZConfig() 00595 : _pimpl( new Impl ) 00596 { 00597 about( MIL ); 00598 } 00599 00601 // 00602 // METHOD NAME : ZConfig::~ZConfig 00603 // METHOD TYPE : Dtor 00604 // 00605 ZConfig::~ZConfig( ) 00606 {} 00607 00608 Pathname ZConfig::systemRoot() const 00609 { 00610 Target_Ptr target( getZYpp()->getTarget() ); 00611 return target ? target->root() : Pathname(); 00612 } 00613 00615 // 00616 // system architecture 00617 // 00619 00620 Arch ZConfig::defaultSystemArchitecture() 00621 { 00622 static Arch _val( _autodetectSystemArchitecture() ); 00623 return _val; 00624 } 00625 00626 Arch ZConfig::systemArchitecture() const 00627 { return _pimpl->cfg_arch; } 00628 00629 void ZConfig::setSystemArchitecture( const Arch & arch_r ) 00630 { 00631 if ( arch_r != _pimpl->cfg_arch ) 00632 { 00633 WAR << "Overriding system architecture (" << _pimpl->cfg_arch << "): " << arch_r << endl; 00634 _pimpl->cfg_arch = arch_r; 00635 } 00636 } 00637 00639 // 00640 // text locale 00641 // 00643 00644 Locale ZConfig::defaultTextLocale() 00645 { 00646 static Locale _val( _autodetectTextLocale() ); 00647 return _val; 00648 } 00649 00650 Locale ZConfig::textLocale() const 00651 { return _pimpl->cfg_textLocale; } 00652 00653 void ZConfig::setTextLocale( const Locale & locale_r ) 00654 { 00655 if ( locale_r != _pimpl->cfg_textLocale ) 00656 { 00657 WAR << "Overriding text locale (" << _pimpl->cfg_textLocale << "): " << locale_r << endl; 00658 _pimpl->cfg_textLocale = locale_r; 00659 #warning prefer signal 00660 sat::Pool::instance().setTextLocale( locale_r ); 00661 } 00662 } 00663 00665 00666 Pathname ZConfig::repoCachePath() const 00667 { 00668 return ( _pimpl->cfg_cache_path.empty() 00669 ? Pathname("/var/cache/zypp") : _pimpl->cfg_cache_path ); 00670 } 00671 00672 Pathname ZConfig::repoMetadataPath() const 00673 { 00674 return ( _pimpl->cfg_metadata_path.empty() 00675 ? (repoCachePath()/"raw") : _pimpl->cfg_metadata_path ); 00676 } 00677 00678 Pathname ZConfig::repoSolvfilesPath() const 00679 { 00680 return ( _pimpl->cfg_solvfiles_path.empty() 00681 ? (repoCachePath()/"solv") : _pimpl->cfg_solvfiles_path ); 00682 } 00683 00684 Pathname ZConfig::repoPackagesPath() const 00685 { 00686 return ( _pimpl->cfg_packages_path.empty() 00687 ? (repoCachePath()/"packages") : _pimpl->cfg_packages_path ); 00688 } 00689 00691 00692 Pathname ZConfig::configPath() const 00693 { 00694 return ( _pimpl->cfg_config_path.empty() 00695 ? Pathname("/etc/zypp") : _pimpl->cfg_config_path ); 00696 } 00697 00698 Pathname ZConfig::knownReposPath() const 00699 { 00700 return ( _pimpl->cfg_known_repos_path.empty() 00701 ? (configPath()/"repos.d") : _pimpl->cfg_known_repos_path ); 00702 } 00703 00704 Pathname ZConfig::knownServicesPath() const 00705 { 00706 return ( _pimpl->cfg_known_services_path.empty() 00707 ? (configPath()/"services.d") : _pimpl->cfg_known_repos_path ); 00708 } 00709 00710 Pathname ZConfig::vendorPath() const 00711 { 00712 return ( _pimpl->cfg_vendor_path.empty() 00713 ? (configPath()/"vendors.d") : _pimpl->cfg_vendor_path ); 00714 } 00715 00716 Pathname ZConfig::locksFile() const 00717 { 00718 return ( _pimpl->locks_file.empty() 00719 ? (configPath()/"locks") : _pimpl->locks_file ); 00720 } 00721 00723 00724 bool ZConfig::repo_add_probe() const 00725 { return _pimpl->repo_add_probe; } 00726 00727 unsigned ZConfig::repo_refresh_delay() const 00728 { return _pimpl->repo_refresh_delay; } 00729 00730 LocaleSet ZConfig::repoRefreshLocales() const 00731 { return _pimpl->repoRefreshLocales.empty() ? Target::requestedLocales("") :_pimpl->repoRefreshLocales; } 00732 00733 bool ZConfig::repoLabelIsAlias() const 00734 { return _pimpl->repoLabelIsAlias; } 00735 00736 void ZConfig::repoLabelIsAlias( bool yesno_r ) 00737 { _pimpl->repoLabelIsAlias = yesno_r; } 00738 00739 bool ZConfig::download_use_deltarpm() const 00740 { return _pimpl->download_use_deltarpm; } 00741 00742 bool ZConfig::download_use_deltarpm_always() const 00743 { return download_use_deltarpm() && _pimpl->download_use_deltarpm_always; } 00744 00745 bool ZConfig::download_media_prefer_download() const 00746 { return _pimpl->download_media_prefer_download; } 00747 00748 void ZConfig::set_download_media_prefer_download( bool yesno_r ) 00749 { _pimpl->download_media_prefer_download.set( yesno_r ); } 00750 00751 void ZConfig::set_default_download_media_prefer_download() 00752 { _pimpl->download_media_prefer_download.restoreToDefault(); } 00753 00754 long ZConfig::download_max_concurrent_connections() const 00755 { return _pimpl->download_max_concurrent_connections; } 00756 00757 long ZConfig::download_min_download_speed() const 00758 { return _pimpl->download_min_download_speed; } 00759 00760 long ZConfig::download_max_download_speed() const 00761 { return _pimpl->download_max_download_speed; } 00762 00763 long ZConfig::download_max_silent_tries() const 00764 { return _pimpl->download_max_silent_tries; } 00765 00766 long ZConfig::download_transfer_timeout() const 00767 { return _pimpl->download_transfer_timeout; } 00768 00769 DownloadMode ZConfig::commit_downloadMode() const 00770 { return _pimpl->commit_downloadMode; } 00771 00772 bool ZConfig::solver_onlyRequires() const 00773 { return _pimpl->solver_onlyRequires; } 00774 00775 bool ZConfig::solver_allowVendorChange() const 00776 { return _pimpl->solver_allowVendorChange; } 00777 00778 bool ZConfig::solver_cleandepsOnRemove() const 00779 { return _pimpl->solver_cleandepsOnRemove; } 00780 00781 Pathname ZConfig::solver_checkSystemFile() const 00782 { return ( _pimpl->solver_checkSystemFile.empty() 00783 ? (configPath()/"systemCheck") : _pimpl->solver_checkSystemFile ); } 00784 00785 unsigned ZConfig::solver_upgradeTestcasesToKeep() const 00786 { return _pimpl->solver_upgradeTestcasesToKeep; } 00787 00788 bool ZConfig::solverUpgradeRemoveDroppedPackages() const { return _pimpl->solverUpgradeRemoveDroppedPackages; } 00789 void ZConfig::setSolverUpgradeRemoveDroppedPackages( bool val_r ) { _pimpl->solverUpgradeRemoveDroppedPackages.set( val_r ); } 00790 void ZConfig::resetSolverUpgradeRemoveDroppedPackages() { _pimpl->solverUpgradeRemoveDroppedPackages.restoreToDefault(); } 00791 00792 const std::set<std::string> & ZConfig::multiversionSpec() const { return _pimpl->multiversion; } 00793 void ZConfig::addMultiversionSpec( const std::string & name_r ) { _pimpl->multiversion.insert( name_r ); } 00794 void ZConfig::removeMultiversionSpec( const std::string & name_r ) { _pimpl->multiversion.erase( name_r ); } 00795 00796 bool ZConfig::apply_locks_file() const 00797 { return _pimpl->apply_locks_file; } 00798 00799 Pathname ZConfig::update_dataPath() const 00800 { 00801 return ( _pimpl->update_data_path.empty() 00802 ? Pathname("/var/adm") : _pimpl->update_data_path ); 00803 } 00804 00805 Pathname ZConfig::update_messagesPath() const 00806 { 00807 return ( _pimpl->update_messages_path.empty() 00808 ? Pathname(update_dataPath()/"update-messages") : _pimpl->update_messages_path ); 00809 } 00810 00811 Pathname ZConfig::update_scriptsPath() const 00812 { 00813 return ( _pimpl->update_scripts_path.empty() 00814 ? Pathname(update_dataPath()/"update-scripts") : _pimpl->update_scripts_path ); 00815 } 00816 00817 std::string ZConfig::updateMessagesNotify() const 00818 { return _pimpl->updateMessagesNotify; } 00819 00820 void ZConfig::setUpdateMessagesNotify( const std::string & val_r ) 00821 { _pimpl->updateMessagesNotify.set( val_r ); } 00822 00823 void ZConfig::resetUpdateMessagesNotify() 00824 { _pimpl->updateMessagesNotify.restoreToDefault(); } 00825 00827 00828 target::rpm::RpmInstFlags ZConfig::rpmInstallFlags() const 00829 { return _pimpl->rpmInstallFlags; } 00830 00831 00832 Pathname ZConfig::historyLogFile() const 00833 { 00834 return ( _pimpl->history_log_path.empty() ? 00835 Pathname("/var/log/zypp/history") : _pimpl->history_log_path ); 00836 } 00837 00838 00839 Pathname ZConfig::credentialsGlobalDir() const 00840 { 00841 return ( _pimpl->credentials_global_dir_path.empty() ? 00842 Pathname("/etc/zypp/credentials.d") : _pimpl->credentials_global_dir_path ); 00843 } 00844 00845 Pathname ZConfig::credentialsGlobalFile() const 00846 { 00847 return ( _pimpl->credentials_global_file_path.empty() ? 00848 Pathname("/etc/zypp/credentials.cat") : _pimpl->credentials_global_file_path ); 00849 } 00850 00852 00853 std::string ZConfig::distroverpkg() const 00854 { return "redhat-release"; } 00855 00857 00858 Pathname ZConfig::pluginsPath() const 00859 { return _pimpl->pluginsPath.get(); } 00860 00862 00863 std::ostream & ZConfig::about( std::ostream & str ) const 00864 { 00865 str << "libzypp: " << VERSION << " built " << __DATE__ << " " << __TIME__ << endl; 00866 00867 str << "libsolv: " << solv_version; 00868 if ( ::strcmp( solv_version, LIBSOLV_VERSION_STRING ) ) 00869 str << " (built against " << LIBSOLV_VERSION_STRING << ")"; 00870 str << endl; 00871 00872 str << "zypp.conf: '" << _pimpl->_parsedZyppConf << "'" << endl; 00873 str << "TextLocale: '" << textLocale() << "' (" << defaultTextLocale() << ")" << endl; 00874 str << "SystemArchitecture: '" << systemArchitecture() << "' (" << defaultSystemArchitecture() << ")" << endl; 00875 return str; 00876 } 00877 00879 } // namespace zypp