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