libzypp 17.38.3
ZConfig.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12extern "C"
13{
14#include <features.h>
15#include <sys/utsname.h>
16#if __GLIBC_PREREQ (2,16)
17#include <sys/auxv.h> // getauxval for PPC64P7 detection
18#endif
19#include <unistd.h>
20#include <solv/solvversion.h>
21}
22#include <iostream>
23#include <fstream>
24#include <optional>
25#include <zypp-core/APIConfig.h>
28#include <zypp-core/base/InputStream>
31
32#include <zypp/ZConfig.h>
33#include <zypp/ZYppFactory.h>
34#include <zypp/PathInfo.h>
35#include <zypp-core/parser/EconfDict>
36
37#include <zypp/sat/Pool.h>
39
40#include <zypp-media/MediaConfig>
41
42using std::endl;
43using namespace zypp::filesystem;
44using namespace zypp::parser;
45
46#undef ZYPP_BASE_LOGGER_LOGGROUP
47#define ZYPP_BASE_LOGGER_LOGGROUP "zconfig"
48
50namespace zypp
51{
52
53 namespace env {
54 inline std::optional<Pathname> ZYPP_CONF()
55 {
56 const char *env_confpath = getenv( "ZYPP_CONF" );
57 if ( env_confpath )
58 return env_confpath;
59 return std::nullopt;
60 }
61 } // namespace env
62
63
64
75 namespace
76 {
77
79 // From rpm's lib/rpmrc.c
80# if defined(__linux__) && defined(__x86_64__)
81 static inline void cpuid(uint32_t op, uint32_t op2, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
82 {
83 asm volatile (
84 "cpuid\n"
85 : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
86 : "a" (op), "c" (op2));
87 }
88
89 /* From gcc's gcc/config/i386/cpuid.h */
90 /* Features (%eax == 1) */
91 /* %ecx */
92 #define bit_SSE3 (1 << 0)
93 #define bit_SSSE3 (1 << 9)
94 #define bit_FMA (1 << 12)
95 #define bit_CMPXCHG16B (1 << 13)
96 #define bit_SSE4_1 (1 << 19)
97 #define bit_SSE4_2 (1 << 20)
98 #define bit_MOVBE (1 << 22)
99 #define bit_POPCNT (1 << 23)
100 #define bit_OSXSAVE (1 << 27)
101 #define bit_AVX (1 << 28)
102 #define bit_F16C (1 << 29)
103
104 /* Extended Features (%eax == 0x80000001) */
105 /* %ecx */
106 #define bit_LAHF_LM (1 << 0)
107 #define bit_LZCNT (1 << 5)
108
109 /* Extended Features (%eax == 7) */
110 /* %ebx */
111 #define bit_BMI (1 << 3)
112 #define bit_AVX2 (1 << 5)
113 #define bit_BMI2 (1 << 8)
114 #define bit_AVX512F (1 << 16)
115 #define bit_AVX512DQ (1 << 17)
116 #define bit_AVX512CD (1 << 28)
117 #define bit_AVX512BW (1 << 30)
118 #define bit_AVX512VL (1u << 31)
119
120 static int get_x86_64_level(void)
121 {
122 int level = 1;
123
124 unsigned int op_1_ecx = 0, op_80000001_ecx = 0, op_7_ebx = 0, unused = 0;
125 cpuid(1, 0, &unused, &unused, &op_1_ecx, &unused);
126 cpuid(0x80000001, 0, &unused, &unused, &op_80000001_ecx, &unused);
127 cpuid(7, 0, &unused, &op_7_ebx, &unused, &unused);
128
129 const unsigned int op_1_ecx_lv2 = bit_SSE3 | bit_SSSE3 | bit_CMPXCHG16B | bit_SSE4_1 | bit_SSE4_2 | bit_POPCNT;
130 if ((op_1_ecx & op_1_ecx_lv2) == op_1_ecx_lv2 && (op_80000001_ecx & bit_LAHF_LM))
131 level = 2;
132
133 const unsigned int op_1_ecx_lv3 = bit_FMA | bit_MOVBE | bit_OSXSAVE | bit_AVX | bit_F16C;
134 const unsigned int op_7_ebx_lv3 = bit_BMI | bit_AVX2 | bit_BMI2;
135 if (level == 2 && (op_1_ecx & op_1_ecx_lv3) == op_1_ecx_lv3 && (op_7_ebx & op_7_ebx_lv3) == op_7_ebx_lv3
136 && (op_80000001_ecx & bit_LZCNT))
137 level = 3;
138
139 const unsigned int op_7_ebx_lv4 = bit_AVX512F | bit_AVX512DQ | bit_AVX512CD | bit_AVX512BW | bit_AVX512VL;
140 if (level == 3 && (op_7_ebx & op_7_ebx_lv4) == op_7_ebx_lv4)
141 level = 4;
142
143 return level;
144 }
145# endif
147
150 Arch _autodetectSystemArchitecture()
151 {
152 struct ::utsname buf;
153 if ( ::uname( &buf ) < 0 )
154 {
155 ERR << "Can't determine system architecture" << endl;
156 return Arch_noarch;
157 }
158
159 Arch architecture( buf.machine );
160 MIL << "Uname architecture is '" << buf.machine << "'" << endl;
161
162 if ( architecture == Arch_x86_64 )
163 {
164#if defined(__linux__) && defined(__x86_64__)
165 switch ( get_x86_64_level() )
166 {
167 case 2:
168 architecture = Arch_x86_64_v2;
169 WAR << "CPU has 'x86_64': architecture upgraded to '" << architecture << "'" << endl;
170 break;
171 case 3:
172 architecture = Arch_x86_64_v3;
173 WAR << "CPU has 'x86_64': architecture upgraded to '" << architecture << "'" << endl;
174 break;
175 case 4:
176 architecture = Arch_x86_64_v4;
177 WAR << "CPU has 'x86_64': architecture upgraded to '" << architecture << "'" << endl;
178 break;
179 }
180# endif
181 }
182 else if ( architecture == Arch_i686 )
183 {
184 // some CPUs report i686 but dont implement cx8 and cmov
185 // check for both flags in /proc/cpuinfo and downgrade
186 // to i586 if either is missing (cf bug #18885)
187 std::ifstream cpuinfo( "/proc/cpuinfo" );
188 if ( cpuinfo )
189 {
190 for( iostr::EachLine in( cpuinfo ); in; in.next() )
191 {
192 if ( str::hasPrefix( *in, "flags" ) )
193 {
194 if ( in->find( "cx8" ) == std::string::npos
195 || in->find( "cmov" ) == std::string::npos )
196 {
197 architecture = Arch_i586;
198 WAR << "CPU lacks 'cx8' or 'cmov': architecture downgraded to '" << architecture << "'" << endl;
199 }
200 break;
201 }
202 }
203 }
204 else
205 {
206 ERR << "Cant open " << PathInfo("/proc/cpuinfo") << endl;
207 }
208 }
209 else if ( architecture == Arch_sparc || architecture == Arch_sparc64 )
210 {
211 // Check for sun4[vum] to get the real arch. (bug #566291)
212 std::ifstream cpuinfo( "/proc/cpuinfo" );
213 if ( cpuinfo )
214 {
215 for( iostr::EachLine in( cpuinfo ); in; in.next() )
216 {
217 if ( str::hasPrefix( *in, "type" ) )
218 {
219 if ( in->find( "sun4v" ) != std::string::npos )
220 {
221 architecture = ( architecture == Arch_sparc64 ? Arch_sparc64v : Arch_sparcv9v );
222 WAR << "CPU has 'sun4v': architecture upgraded to '" << architecture << "'" << endl;
223 }
224 else if ( in->find( "sun4u" ) != std::string::npos )
225 {
226 architecture = ( architecture == Arch_sparc64 ? Arch_sparc64 : Arch_sparcv9 );
227 WAR << "CPU has 'sun4u': architecture upgraded to '" << architecture << "'" << endl;
228 }
229 else if ( in->find( "sun4m" ) != std::string::npos )
230 {
231 architecture = Arch_sparcv8;
232 WAR << "CPU has 'sun4m': architecture upgraded to '" << architecture << "'" << endl;
233 }
234 break;
235 }
236 }
237 }
238 else
239 {
240 ERR << "Cant open " << PathInfo("/proc/cpuinfo") << endl;
241 }
242 }
243 else if ( architecture == Arch_armv8l || architecture == Arch_armv7l || architecture == Arch_armv6l )
244 {
245 std::ifstream platform( "/etc/rpm/platform" );
246 if (platform)
247 {
248 for( iostr::EachLine in( platform ); in; in.next() )
249 {
250 if ( str::hasPrefix( *in, "armv8hl-" ) )
251 {
252 architecture = Arch_armv8hl;
253 WAR << "/etc/rpm/platform contains armv8hl-: architecture upgraded to '" << architecture << "'" << endl;
254 break;
255 }
256 if ( str::hasPrefix( *in, "armv7hl-" ) )
257 {
258 architecture = Arch_armv7hl;
259 WAR << "/etc/rpm/platform contains armv7hl-: architecture upgraded to '" << architecture << "'" << endl;
260 break;
261 }
262 if ( str::hasPrefix( *in, "armv6hl-" ) )
263 {
264 architecture = Arch_armv6hl;
265 WAR << "/etc/rpm/platform contains armv6hl-: architecture upgraded to '" << architecture << "'" << endl;
266 break;
267 }
268 }
269 }
270 }
271#if __GLIBC_PREREQ (2,16)
272 else if ( architecture == Arch_ppc64 )
273 {
274 const char * platform = (const char *)getauxval( AT_PLATFORM );
275 int powerlvl = 0;
276 if ( platform && sscanf( platform, "power%d", &powerlvl ) == 1 && powerlvl > 6 )
277 architecture = Arch_ppc64p7;
278 }
279#endif
280 return architecture;
281 }
282
300 Locale _autodetectTextLocale()
301 {
302 Locale ret( Locale::enCode );
303 const char * envlist[] = { "LC_ALL", "LC_MESSAGES", "LANG", NULL };
304 for ( const char ** envvar = envlist; *envvar; ++envvar )
305 {
306 const char * envlang = getenv( *envvar );
307 if ( envlang )
308 {
309 std::string envstr( envlang );
310 if ( envstr != "POSIX" && envstr != "C" )
311 {
312 Locale lang( envstr );
313 if ( lang )
314 {
315 MIL << "Found " << *envvar << "=" << envstr << endl;
316 ret = lang;
317 break;
318 }
319 }
320 }
321 }
322 MIL << "Default text locale is '" << ret << "'" << endl;
323#warning HACK AROUND BOOST_TEST_CATCH_SYSTEM_ERRORS
324 setenv( "BOOST_TEST_CATCH_SYSTEM_ERRORS", "no", 1 );
325 return ret;
326 }
327
338 struct ZyppConfIniMap : public IniDict {
339 ZyppConfIniMap( Pathname root_r = "/" )
340 : IniDict { iniMapReadFrom(root_r) }
341 {
342 pMIL( str::sconcat("zypp.conf(", root_r, "):"), *this );
343 pDBG( dump(*this) );
344 }
345
346 private:
348 IniDict iniMapReadFrom( const Pathname & root_r )
349 {
350 pMIL( "Reading zypp.conf for root", root_r );
351 std::optional<Pathname> ZYPP_CONF { env::ZYPP_CONF() };
352 if ( ZYPP_CONF ) {
353 // Read the plain file requested by $ZYPP_CONF
354 pMIL( "$ZYPP_CONF is set to", str::sconcat("'",*ZYPP_CONF,"'") );
355 PathInfo conf { root_r / *ZYPP_CONF };
356 if ( conf.isFile() ) {
357 pMIL( "$ZYPP_CONF requests reading file", conf );
358 return parser::IniDict( conf.path() );
359 } else {
360 pMIL( "$ZYPP_CONF denotes no file below root. Using builtin defaults." );
361 return parser::IniDict();
362 }
363 } else {
364 // Econf mode reading the systems settings
365 return parser::EconfDict( "/zypp/zypp.conf", root_r );
366 }
367 }
368 };
369
371 } // namespace zypp
373
375 template<class Tp>
376 struct Option
377 {
378 using value_type = Tp;
379
381 Option( value_type initial_r )
382 : _val( std::move(initial_r) )
383 {}
384
386 { set( std::move(newval_r) ); return *this; }
387
389 const value_type & get() const
390 { return _val; }
391
393 operator const value_type &() const
394 { return _val; }
395
397 void set( value_type newval_r )
398 { _val = std::move(newval_r); }
399
400 private:
402 };
403
405 template<class Tp>
406 struct DefaultOption : public Option<Tp>
407 {
408 using value_type = Tp;
410
411 explicit DefaultOption( value_type initial_r )
412 : Option<Tp>( initial_r )
413 , _default( std::move(initial_r) )
414 {}
415
417 { this->set( std::move(newval_r) ); return *this; }
418
421 { this->set( _default.get() ); }
422
425 { setDefault( std::move(newval_r) ); restoreToDefault(); }
426
428 const value_type & getDefault() const
429 { return _default.get(); }
430
432 void setDefault( value_type newval_r )
433 { _default.set( std::move(newval_r) ); }
434
435 private:
437 };
438
440 //
441 // CLASS NAME : ZConfig::Impl
442 //
449 {
450 using MultiversionSpec = std::set<std::string>;
451
454 {
467
468 bool consume( const std::string & section, const std::string & entry, const std::string & value )
469 {
470 if ( section != "main" )
471 return false;
472
473 if ( entry == "solver.focus" )
474 {
475 fromString( value, solver_focus );
476 }
477 else if ( entry == "solver.onlyRequires" )
478 {
480 }
481 else if ( entry == "solver.allowVendorChange" )
482 {
484 }
485 else if ( entry == "solver.dupAllowDowngrade" )
486 {
488 }
489 else if ( entry == "solver.dupAllowNameChange" )
490 {
492 }
493 else if ( entry == "solver.dupAllowArchChange" )
494 {
496 }
497 else if ( entry == "solver.dupAllowVendorChange" )
498 {
500 }
501 else if ( entry == "solver.cleandepsOnRemove" )
502 {
504 }
505 else if ( entry == "solver.upgradeTestcasesToKeep" )
506 {
508 }
509 else if ( entry == "solver.upgradeRemoveDroppedPackages" )
510 {
512 }
513 else
514 return false;
515
516 return true;
517 }
518
529 };
530
531 public:
535 , cfg_cache_path { "/var/cache/zypp" }
536 , cfg_metadata_path { "" } // empty - follows cfg_cache_path
537 , cfg_solvfiles_path { "" } // empty - follows cfg_cache_path
538 , cfg_packages_path { "" } // empty - follows cfg_cache_path
539 , updateMessagesNotify ( "" )
540 , repo_add_probe ( false )
541 , repo_refresh_delay ( 10 )
542 , repoLabelIsAlias ( false )
543 , download_use_deltarpm ( APIConfig(LIBZYPP_CONFIG_USE_DELTARPM_BY_DEFAULT) )
546 , download_mediaMountdir ( "/var/adm/mount" )
548 , gpgCheck ( true )
549 , repoGpgCheck ( indeterminate )
550 , pkgGpgCheck ( indeterminate )
551 , apply_locks_file ( true )
552 , pluginsPath ( "/usr/lib/zypp/plugins" )
553 , geoipEnabled ( true )
554 , geoipHosts { "download.opensuse.org" }
555 {
556 MIL << "libzypp: " LIBZYPP_VERSION_STRING << " (" << LIBZYPP_CODESTREAM << ")" << endl;
557
558 ZyppConfIniMap iniMap; // Scan the default zypp.conf settings
559 for ( const auto & section : iniMap.sections() ) {
560 for ( const auto & [entry,value] : iniMap.entries( section ) ) {
561
562 if ( _initialTargetDefaults.consume( section, entry, value ) )
563 continue;
564
565 if ( _mediaConf.setConfigValue( section, entry, value ) )
566 continue;
567
568 if ( section == "main" )
569 {
570 if ( entry == "lock_timeout" )
571 {
572 str::strtonum( value, cfg_lockTimeout );
573 }
574 else if ( entry == "arch" )
575 {
576 Arch carch( value );
577 if ( carch != cfg_arch ) {
578 WAR << "Overriding system architecture (" << cfg_arch << "): " << carch << endl;
579 cfg_arch = carch;
580 }
581 }
582 else if ( entry == "cachedir" )
583 {
584 cfg_cache_path.restoreToDefault( value );
585 }
586 else if ( entry == "metadatadir" )
587 {
588 cfg_metadata_path.restoreToDefault( value );
589 }
590 else if ( entry == "solvfilesdir" )
591 {
592 cfg_solvfiles_path.restoreToDefault( value );
593 }
594 else if ( entry == "packagesdir" )
595 {
596 cfg_packages_path.restoreToDefault( value );
597 }
598 else if ( entry == "configdir" )
599 {
600 cfg_config_path = Pathname(value);
601 }
602 else if ( entry == "reposdir" )
603 {
604 cfg_known_repos_path = Pathname(value);
605 }
606 else if ( entry == "servicesdir" )
607 {
608 cfg_known_services_path = Pathname(value);
609 }
610 else if ( entry == "varsdir" )
611 {
612 cfg_vars_path = Pathname(value);
613 }
614 else if ( entry == "repo.add.probe" )
615 {
616 repo_add_probe = str::strToBool( value, repo_add_probe );
617 }
618 else if ( entry == "repo.refresh.delay" )
619 {
620 str::strtonum(value, repo_refresh_delay);
621 }
622 else if ( entry == "repo.refresh.locales" )
623 {
624 std::vector<std::string> tmp;
625 str::split( value, back_inserter( tmp ), ", \t" );
626
627 boost::function<Locale(const std::string &)> transform(
628 [](const std::string & str_r)->Locale{ return Locale(str_r); }
629 );
630 repoRefreshLocales.insert( make_transform_iterator( tmp.begin(), transform ),
631 make_transform_iterator( tmp.end(), transform ) );
632 }
633 else if ( entry == "download.use_deltarpm" )
634 {
635 download_use_deltarpm = str::strToBool( value, download_use_deltarpm );
636 }
637 else if ( entry == "download.use_deltarpm.always" )
638 {
639 download_use_deltarpm_always = str::strToBool( value, download_use_deltarpm_always );
640 }
641 else if ( entry == "download.media_preference" )
642 {
643 download_media_prefer_download.restoreToDefault( str::compareCI( value, "volatile" ) != 0 );
644 }
645 else if ( entry == "download.media_mountdir" )
646 {
647 download_mediaMountdir.restoreToDefault( Pathname(value) );
648 }
649 else if ( entry == "download.use_geoip_mirror") {
650 geoipEnabled = str::strToBool( value, geoipEnabled );
651 }
652 else if ( entry == "commit.downloadMode" )
653 {
654 commit_downloadMode.set( deserializeDownloadMode( value ) );
655 }
656 else if ( entry == "gpgcheck" )
657 {
658 gpgCheck.restoreToDefault( str::strToBool( value, gpgCheck ) );
659 }
660 else if ( entry == "repo_gpgcheck" )
661 {
662 repoGpgCheck.restoreToDefault( str::strToTriBool( value ) );
663 }
664 else if ( entry == "pkg_gpgcheck" )
665 {
666 pkgGpgCheck.restoreToDefault( str::strToTriBool( value ) );
667 }
668 else if ( entry == "vendordir" )
669 {
670 cfg_vendor_path = Pathname(value);
671 }
672 else if ( entry == "multiversiondir" )
673 {
674 cfg_multiversion_path = Pathname(value);
675 }
676 else if ( entry == "multiversion.kernels" )
677 {
678 cfg_kernel_keep_spec = value;
679 }
680 else if ( entry == "solver.checkSystemFile" )
681 {
682 solver_checkSystemFile = Pathname(value);
683 }
684 else if ( entry == "solver.checkSystemFileDir" )
685 {
686 solver_checkSystemFileDir = Pathname(value);
687 }
688 else if ( entry == "multiversion" )
689 {
690 MultiversionSpec & defSpec( _multiversionMap.getDefaultSpec() );
691 str::splitEscaped( value, std::inserter( defSpec, defSpec.end() ), ", \t" );
692 }
693 else if ( entry == "locksfile.path" )
694 {
695 locks_file = Pathname(value);
696 }
697 else if ( entry == "locksfile.apply" )
698 {
699 apply_locks_file = str::strToBool( value, apply_locks_file );
700 }
701 else if ( entry == "update.datadir" )
702 {
703 // ignore, this is a constant anyway and should not be user configurabe
704 // update_data_path = Pathname(value);
705 }
706 else if ( entry == "update.scriptsdir" )
707 {
708 // ignore, this is a constant anyway and should not be user configurabe
709 // update_scripts_path = Pathname(value);
710 }
711 else if ( entry == "update.messagessdir" )
712 {
713 // ignore, this is a constant anyway and should not be user configurabe
714 // update_messages_path = Pathname(value);
715 }
716 else if ( entry == "update.messages.notify" )
717 {
718 updateMessagesNotify.set( value );
719 }
720 else if ( entry == "rpm.install.excludedocs" )
721 {
722 rpmInstallFlags.setFlag( target::rpm::RPMINST_EXCLUDEDOCS,
723 str::strToBool( value, false ) );
724 }
725 else if ( entry == "history.logfile" )
726 {
727 history_log_path = Pathname(value);
728 }
729 else if ( entry == "ZYPP_SINGLE_RPMTRANS" || entry == "techpreview.ZYPP_SINGLE_RPMTRANS" )
730 {
731 DBG << "ZYPP_SINGLE_RPMTRANS=" << value << endl;
732 ::setenv( "ZYPP_SINGLE_RPMTRANS", value.c_str(), 0 );
733 }
734 else if ( entry == "techpreview.ZYPP_MEDIANETWORK" )
735 {
736 DBG << "techpreview.ZYPP_MEDIANETWORK=" << value << endl;
737 ::setenv( "ZYPP_MEDIANETWORK", value.c_str(), 1 );
738 }
739 else { // unknown entry
740 pWAR( "zypp.conf: Unknown entry in [main]:", entry, "=", value );
741 }
742 }
743 else { // unknown section {
744 pWAR( "zypp.conf: Unknown section:", str::sconcat("[",section,"]"), entry, "=", value );
745 }
746 }
747 }
748
749 // legacy:
750 if ( getenv( "ZYPP_TESTSUITE_FAKE_ARCH" ) )
751 {
752 Arch carch( getenv( "ZYPP_TESTSUITE_FAKE_ARCH" ) );
753 if ( carch != cfg_arch )
754 {
755 WAR << "ZYPP_TESTSUITE_FAKE_ARCH: Overriding system architecture (" << cfg_arch << "): " << carch << endl;
756 cfg_arch = carch;
757 }
758 }
759 MIL << "ZConfig singleton created." << endl;
760 }
761
762 Impl(const Impl &) = delete;
763 Impl(Impl &&) = delete;
764 Impl &operator=(const Impl &) = delete;
765 Impl &operator=(Impl &&) = delete;
766 ~Impl() {}
767
776 {
777 Target_Ptr target( getZYpp()->getTarget() );
778 return target ? target->root() : _announced_root_path;
779 }
780
782 {
783 _announced_root_path = Pathname(); // first of all reset any previously _announced_root_path
784
785 Pathname newRoot { _autodetectSystemRoot() };
786 MIL << "notifyTargetChanged (" << newRoot << ")" << endl;
787
788 if ( newRoot.emptyOrRoot() ) {
789 _currentTargetDefaults.reset(); // to initial settigns from /
790 }
791 else {
793 ZyppConfIniMap iniMap { newRoot }; // Scan the zypp.conf settings for newRoot
794 for ( const auto & section : iniMap.sections() ) {
795 for ( const auto & [entry,value] : iniMap.entries( section ) ) {
796 (*_currentTargetDefaults).consume( section, entry, value );
797 }
798 }
799 }
800 }
801
802 public:
804
805 long cfg_lockTimeout = 0; // signed!
806
809
810 DefaultOption<Pathname> cfg_cache_path; // Settings from the config file are also remembered
811 DefaultOption<Pathname> cfg_metadata_path; // 'default'. Cleanup in RepoManager e.g needs to tell
812 DefaultOption<Pathname> cfg_solvfiles_path; // whether settings in effect are config values or
813 DefaultOption<Pathname> cfg_packages_path; // custom settings applied vie set...Path().
814
820
825
827
832
837
839
843
846
848 const MultiversionSpec & multiversion() const { return getMultiversion(); }
849
851
852 target::rpm::RpmInstFlags rpmInstallFlags;
853
855
856 std::string userData;
857
859
861
862 std::vector<std::string> geoipHosts;
863
864 /* Other config singleton instances */
866
867
868 public:
871 private:
873 std::optional<TargetDefaults> _currentTargetDefaults;
874
875 private:
876 // HACK for bnc#906096: let pool re-evaluate multiversion spec
877 // if target root changes. ZConfig returns data sensitive to
878 // current target root.
879 // TODO Actually we'd need to scan the target systems zypp.conf and
880 // overlay all system specific values.
882 {
883 using SpecMap = std::map<Pathname, MultiversionSpec>;
884
885 MultiversionSpec & getSpec( Pathname root_r, const Impl & zConfImpl_r ) // from system at root
886 {
887 // _specMap[] - the plain zypp.conf value
888 // _specMap[/] - combine [] and multiversion.d scan
889 // _specMap[root] - scan root/zypp.conf and root/multiversion.d
890
891 if ( root_r.empty() )
892 root_r = "/";
893 bool cacheHit = _specMap.count( root_r );
894 MultiversionSpec & ret( _specMap[root_r] ); // creates new entry on the fly
895
896 if ( ! cacheHit )
897 {
898 // bsc#1193488: If no (/root)/.../zypp.conf exists use the default zypp.conf
899 // multiversion settings. It is a legacy that the packaged multiversion setting
900 // in zypp.conf (the kernel) may differ from the builtin default (empty).
901 // But we want a missing config to behave similar to the default one, otherwise
902 // a bare metal install easily runs into trouble.
903 if ( root_r == "/" || not scanConfAt( root_r, ret, zConfImpl_r ) )
904 ret = _specMap[Pathname()];
905 scanDirAt( root_r, ret, zConfImpl_r ); // add multiversion.d at root_r
906 using zypp::operator<<;
907 MIL << "MultiversionSpec '" << root_r << "' = " << ret << endl;
908 }
909 return ret;
910 }
911
912 MultiversionSpec & getDefaultSpec() // Spec from zypp.conf parsing; called before any getSpec
913 { return _specMap[Pathname()]; }
914
915 private:
916 bool scanConfAt( const Pathname& root_r, MultiversionSpec & spec_r, const Impl & zConfImpl_r )
917 {
918 ZyppConfIniMap iniMap { root_r }; // Scan the zypp.conf settings for root
919 // TODO: iniDict lacks direct value access :(
920 for ( const auto & section : iniMap.sections() ) {
921 for ( const auto & [entry,value] : iniMap.entries( section ) ) {
922 if ( entry == "multiversion" ) {
923 str::splitEscaped( value, std::inserter( spec_r, spec_r.end() ), ", \t" );
924 return true;
925 }
926 }
927 }
928 return false;
929 }
930
931 void scanDirAt( const Pathname& root_r, MultiversionSpec & spec_r, const Impl & zConfImpl_r )
932 {
933 // NOTE: Actually we'd need to scan and use the root_r! zypp.conf values.
934 Pathname multiversionDir( zConfImpl_r.cfg_multiversion_path );
935 if ( multiversionDir.empty() )
936 multiversionDir = ( zConfImpl_r.cfg_config_path.empty()
937 ? Pathname("/etc/zypp")
938 : zConfImpl_r.cfg_config_path ) / "multiversion.d";
939
940 filesystem::dirForEach( Pathname::assertprefix( root_r, multiversionDir ),
941 [&spec_r]( const Pathname & dir_r, const char *const & name_r )->bool
942 {
943 MIL << "Parsing " << dir_r/name_r << endl;
944 iostr::simpleParseFile( InputStream( dir_r/name_r ),
945 [&spec_r]( int num_r, std::string line_r )->bool
946 {
947 DBG << " found " << line_r << endl;
948 spec_r.insert( std::move(line_r) );
949 return true;
950 } );
951 return true;
952 } );
953 }
954
955 private:
957 };
958
960 { return _multiversionMap.getSpec( _autodetectSystemRoot(), *this ); }
961
963 };
964
965
967 //
968 // METHOD NAME : ZConfig::instance
969 // METHOD TYPE : ZConfig &
970 //
972 {
973 static ZConfig _instance; // The singleton
974 return _instance;
975 }
976
978 //
979 // METHOD NAME : ZConfig::ZConfig
980 // METHOD TYPE : Ctor
981 //
983 : _pimpl( new Impl )
984 {
985 about( MIL );
986 }
987
989 //
990 // METHOD NAME : ZConfig::~ZConfig
991 // METHOD TYPE : Dtor
992 //
995
997 {
998 const char * env = getenv("ZYPP_LOCK_TIMEOUT");
999 if ( env ) {
1000 return str::strtonum<long>( env );
1001 }
1002 return _pimpl->cfg_lockTimeout;
1003 }
1004
1006 { return _pimpl->notifyTargetChanged(); }
1007
1009 { return _pimpl->_autodetectSystemRoot(); }
1010
1012 {
1013 return ( _pimpl->cfg_repo_mgr_root_path.empty()
1014 ? systemRoot() : _pimpl->cfg_repo_mgr_root_path );
1015 }
1016
1018 { _pimpl->cfg_repo_mgr_root_path = root; }
1019
1021 { _pimpl->_announced_root_path = root_r; }
1022
1024 //
1025 // system architecture
1026 //
1028
1030 {
1031 static Arch _val( _autodetectSystemArchitecture() );
1032 return _val;
1033 }
1034
1036 { return _pimpl->cfg_arch; }
1037
1039 {
1040 if ( arch_r != _pimpl->cfg_arch )
1041 {
1042 WAR << "Overriding system architecture (" << _pimpl->cfg_arch << "): " << arch_r << endl;
1043 _pimpl->cfg_arch = arch_r;
1044 }
1045 }
1046
1048 //
1049 // text locale
1050 //
1052
1054 {
1055 static Locale _val( _autodetectTextLocale() );
1056 return _val;
1057 }
1058
1060 { return _pimpl->cfg_textLocale; }
1061
1062 void ZConfig::setTextLocale( const Locale & locale_r )
1063 {
1064 if ( locale_r != _pimpl->cfg_textLocale )
1065 {
1066 WAR << "Overriding text locale (" << _pimpl->cfg_textLocale << "): " << locale_r << endl;
1067 _pimpl->cfg_textLocale = locale_r;
1068 // Propagate changes
1069 sat::Pool::instance().setTextLocale( locale_r );
1070 }
1071 }
1072
1074 // user data
1076
1078 { return !_pimpl->userData.empty(); }
1079
1080 std::string ZConfig::userData() const
1081 { return _pimpl->userData; }
1082
1083 bool ZConfig::setUserData( const std::string & str_r )
1084 {
1085 for_( ch, str_r.begin(), str_r.end() )
1086 {
1087 if ( *ch < ' ' && *ch != '\t' )
1088 {
1089 ERR << "New user data string rejectded: char " << (int)*ch << " at position " << (ch - str_r.begin()) << endl;
1090 return false;
1091 }
1092 }
1093 MIL << "Set user data string to '" << str_r << "'" << endl;
1094 _pimpl->userData = str_r;
1095 return true;
1096 }
1097
1099
1101 {
1102 return ( _pimpl->cfg_cache_path.get().empty()
1103 ? Pathname("/var/cache/zypp") : _pimpl->cfg_cache_path.get() );
1104 }
1105
1107 {
1108 return repoCachePath()/"pubkeys";
1109 }
1110
1112 {
1113 _pimpl->cfg_cache_path = path_r;
1114 }
1115
1117 {
1118 return ( _pimpl->cfg_metadata_path.get().empty()
1119 ? (repoCachePath()/"raw") : _pimpl->cfg_metadata_path.get() );
1120 }
1121
1123 {
1124 _pimpl->cfg_metadata_path = path_r;
1125 }
1126
1128 {
1129 return ( _pimpl->cfg_solvfiles_path.get().empty()
1130 ? (repoCachePath()/"solv") : _pimpl->cfg_solvfiles_path.get() );
1131 }
1132
1134 {
1135 _pimpl->cfg_solvfiles_path = path_r;
1136 }
1137
1139 {
1140 return ( _pimpl->cfg_packages_path.get().empty()
1141 ? (repoCachePath()/"packages") : _pimpl->cfg_packages_path.get() );
1142 }
1143
1145 {
1146 _pimpl->cfg_packages_path = path_r;
1147 }
1148
1150 { return _pimpl->cfg_cache_path.getDefault().empty() ? Pathname("/var/cache/zypp") : _pimpl->cfg_cache_path.getDefault(); }
1151
1153 { return _pimpl->cfg_metadata_path.getDefault().empty() ? (builtinRepoCachePath()/"raw") : _pimpl->cfg_metadata_path.getDefault(); }
1154
1156 { return _pimpl->cfg_solvfiles_path.getDefault().empty() ? (builtinRepoCachePath()/"solv") : _pimpl->cfg_solvfiles_path.getDefault(); }
1157
1159 { return _pimpl->cfg_packages_path.getDefault().empty() ? (builtinRepoCachePath()/"packages") : _pimpl->cfg_packages_path.getDefault(); }
1160
1162
1164 {
1165 return ( _pimpl->cfg_config_path.empty()
1166 ? Pathname("/etc/zypp") : _pimpl->cfg_config_path );
1167 }
1168
1170 {
1171 return ( _pimpl->cfg_known_repos_path.empty()
1172 ? (configPath()/"repos.d") : _pimpl->cfg_known_repos_path );
1173 }
1174
1176 {
1177 return ( _pimpl->cfg_known_services_path.empty()
1178 ? (configPath()/"services.d") : _pimpl->cfg_known_services_path );
1179 }
1180
1182 { return configPath()/"needreboot"; }
1183
1185 { return configPath()/"needreboot.d"; }
1186
1187 void ZConfig::setGeoipEnabled( bool enable )
1188 { _pimpl->geoipEnabled = enable; }
1189
1191 { return _pimpl->geoipEnabled; }
1192
1194 { return builtinRepoCachePath()/"geoip.d"; }
1195
1196 const std::vector<std::string> ZConfig::geoipHostnames () const
1197 { return _pimpl->geoipHosts; }
1198
1200 {
1201 return ( _pimpl->cfg_vars_path.empty()
1202 ? (configPath()/"vars.d") : _pimpl->cfg_vars_path );
1203 }
1204
1206 {
1207 return ( _pimpl->cfg_vendor_path.empty()
1208 ? (configPath()/"vendors.d") : _pimpl->cfg_vendor_path );
1209 }
1210
1212 {
1213 return ( _pimpl->locks_file.empty()
1214 ? (configPath()/"locks") : _pimpl->locks_file );
1215 }
1216
1218
1220 { return _pimpl->repo_add_probe; }
1221
1223 { return _pimpl->repo_refresh_delay; }
1224
1226 { return _pimpl->repoRefreshLocales.empty() ? Target::requestedLocales("") :_pimpl->repoRefreshLocales; }
1227
1229 { return _pimpl->repoLabelIsAlias; }
1230
1231 void ZConfig::repoLabelIsAlias( bool yesno_r )
1232 { _pimpl->repoLabelIsAlias = yesno_r; }
1233
1235 { return _pimpl->download_use_deltarpm; }
1236
1238 { return download_use_deltarpm() && _pimpl->download_use_deltarpm_always; }
1239
1241 { return _pimpl->download_media_prefer_download; }
1242
1244 { _pimpl->download_media_prefer_download.set( yesno_r ); }
1245
1247 { _pimpl->download_media_prefer_download.restoreToDefault(); }
1248
1250 { return _pimpl->_mediaConf.download_max_concurrent_connections(); }
1251
1253 { return _pimpl->_mediaConf.download_min_download_speed(); }
1254
1256 { return _pimpl->_mediaConf.download_max_download_speed(); }
1257
1259 { return _pimpl->_mediaConf.download_max_silent_tries(); }
1260
1262 { return _pimpl->_mediaConf.download_transfer_timeout(); }
1263
1264 Pathname ZConfig::download_mediaMountdir() const { return _pimpl->download_mediaMountdir; }
1265 void ZConfig::set_download_mediaMountdir( Pathname newval_r ) { _pimpl->download_mediaMountdir.set( std::move(newval_r) ); }
1266 void ZConfig::set_default_download_mediaMountdir() { _pimpl->download_mediaMountdir.restoreToDefault(); }
1267
1269 { return _pimpl->commit_downloadMode; }
1270
1271
1272 bool ZConfig::gpgCheck() const { return _pimpl->gpgCheck; }
1273 TriBool ZConfig::repoGpgCheck() const { return _pimpl->repoGpgCheck; }
1274 TriBool ZConfig::pkgGpgCheck() const { return _pimpl->pkgGpgCheck; }
1275
1276 void ZConfig::setGpgCheck( bool val_r ) { _pimpl->gpgCheck.set( val_r ); }
1277 void ZConfig::setRepoGpgCheck( TriBool val_r ) { _pimpl->repoGpgCheck.set( val_r ); }
1278 void ZConfig::setPkgGpgCheck( TriBool val_r ) { _pimpl->pkgGpgCheck.set( val_r ); }
1279
1280 void ZConfig::resetGpgCheck() { _pimpl->gpgCheck.restoreToDefault(); }
1281 void ZConfig::resetRepoGpgCheck() { _pimpl->repoGpgCheck.restoreToDefault(); }
1282 void ZConfig::resetPkgGpgCheck() { _pimpl->pkgGpgCheck.restoreToDefault(); }
1283
1284
1285 ResolverFocus ZConfig::solver_focus() const { return _pimpl->targetDefaults().solver_focus; }
1286 bool ZConfig::solver_onlyRequires() const { return _pimpl->targetDefaults().solver_onlyRequires; }
1287 bool ZConfig::solver_allowVendorChange() const { return _pimpl->targetDefaults().solver_allowVendorChange; }
1288 bool ZConfig::solver_dupAllowDowngrade() const { return _pimpl->targetDefaults().solver_dupAllowDowngrade; }
1289 bool ZConfig::solver_dupAllowNameChange() const { return _pimpl->targetDefaults().solver_dupAllowNameChange; }
1290 bool ZConfig::solver_dupAllowArchChange() const { return _pimpl->targetDefaults().solver_dupAllowArchChange; }
1291 bool ZConfig::solver_dupAllowVendorChange() const { return _pimpl->targetDefaults().solver_dupAllowVendorChange; }
1292 bool ZConfig::solver_cleandepsOnRemove() const { return _pimpl->targetDefaults().solver_cleandepsOnRemove; }
1293 unsigned ZConfig::solver_upgradeTestcasesToKeep() const { return _pimpl->targetDefaults().solver_upgradeTestcasesToKeep; }
1294
1295 bool ZConfig::solverUpgradeRemoveDroppedPackages() const { return _pimpl->targetDefaults().solverUpgradeRemoveDroppedPackages; }
1296 void ZConfig::setSolverUpgradeRemoveDroppedPackages( bool val_r ) { _pimpl->targetDefaults().solverUpgradeRemoveDroppedPackages.set( val_r ); }
1297 void ZConfig::resetSolverUpgradeRemoveDroppedPackages() { _pimpl->targetDefaults().solverUpgradeRemoveDroppedPackages.restoreToDefault(); }
1298
1299
1301 { return ( _pimpl->solver_checkSystemFile.empty()
1302 ? (configPath()/"systemCheck") : _pimpl->solver_checkSystemFile ); }
1303
1305 { return ( _pimpl->solver_checkSystemFileDir.empty()
1306 ? (configPath()/"systemCheck.d") : _pimpl->solver_checkSystemFileDir ); }
1307
1308
1309 namespace
1310 {
1311 inline void sigMultiversionSpecChanged()
1312 {
1314 }
1315 }
1316
1317 const std::set<std::string> & ZConfig::multiversionSpec() const { return _pimpl->multiversion(); }
1318 void ZConfig::multiversionSpec( std::set<std::string> new_r ) { _pimpl->multiversion().swap( new_r ); sigMultiversionSpecChanged(); }
1319 void ZConfig::clearMultiversionSpec() { _pimpl->multiversion().clear(); sigMultiversionSpecChanged(); }
1320 void ZConfig::addMultiversionSpec( const std::string & name_r ) { _pimpl->multiversion().insert( name_r ); sigMultiversionSpecChanged(); }
1321 void ZConfig::removeMultiversionSpec( const std::string & name_r ) { _pimpl->multiversion().erase( name_r ); sigMultiversionSpecChanged(); }
1322
1324 { return _pimpl->apply_locks_file; }
1325
1327#if LEGACY(1735)
1328 const
1329#endif
1330 {
1331 return Pathname("/var/adm");
1332 }
1333
1335#if LEGACY(1735)
1336 const
1337#endif
1338 {
1339 return Pathname(update_dataPath()/"update-messages");
1340 }
1341
1343#if LEGACY(1735)
1344 const
1345#endif
1346 {
1347 return Pathname(update_dataPath()/"update-scripts");
1348 }
1349
1351 { return _pimpl->updateMessagesNotify; }
1352
1353 void ZConfig::setUpdateMessagesNotify( const std::string & val_r )
1354 { _pimpl->updateMessagesNotify.set( val_r ); }
1355
1357 { _pimpl->updateMessagesNotify.restoreToDefault(); }
1358
1360
1361 target::rpm::RpmInstFlags ZConfig::rpmInstallFlags() const
1362 { return _pimpl->rpmInstallFlags; }
1363
1364
1366 {
1367 return ( _pimpl->history_log_path.empty() ?
1368 Pathname("/var/log/zypp/history") : _pimpl->history_log_path );
1369 }
1370
1372 {
1373 return _pimpl->_mediaConf.credentialsGlobalDir();
1374 }
1375
1377 {
1378 return _pimpl->_mediaConf.credentialsGlobalFile();
1379 }
1380
1382
1383 std::string ZConfig::distroverpkg() const
1384 { return "system-release"; }
1385
1387
1389 { return _pimpl->pluginsPath.get(); }
1390
1392 {
1393 return _pimpl->cfg_kernel_keep_spec;
1394 }
1395
1397
1398 std::ostream & ZConfig::about( std::ostream & str ) const
1399 {
1400 str << "libzypp: " LIBZYPP_VERSION_STRING << " (" << LIBZYPP_CODESTREAM << ")" << endl;
1401
1402 str << "libsolv: " << solv_version;
1403 if ( ::strcmp( solv_version, LIBSOLV_VERSION_STRING ) )
1404 str << " (built against " << LIBSOLV_VERSION_STRING << ")";
1405 str << endl;
1406
1407 str << "TextLocale: '" << textLocale() << "' (" << defaultTextLocale() << ")" << endl;
1408 str << "SystemArchitecture: '" << systemArchitecture() << "' (" << defaultSystemArchitecture() << ")" << endl;
1409 return str;
1410 }
1411
1413} // namespace zypp
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition Easy.h:27
#define pMIL
Definition LogTools.h:305
#define pDBG
Definition LogTools.h:304
#define DBG
Definition Logger.h:99
#define MIL
Definition Logger.h:100
#define ERR
Definition Logger.h:102
#define WAR
Definition Logger.h:101
Architecture.
Definition Arch.h:37
Helper to create and pass std::istream.
Definition inputstream.h:57
'Language[_Country]' codes.
Definition Locale.h:51
static const Locale enCode
Last resort "en".
Definition Locale.h:78
static MediaConfig & instance()
static Pathname assertprefix(const Pathname &root_r, const Pathname &path_r)
Return path_r prefixed with root_r, unless it is already prefixed.
Definition Pathname.cc:272
LocaleSet requestedLocales() const
Languages to be supported by the system.
Definition Target.cc:94
ZConfig implementation.
Definition ZConfig.cc:449
Pathname cfg_multiversion_path
Definition ZConfig.cc:822
DefaultOption< Pathname > download_mediaMountdir
Definition ZConfig.cc:836
MediaConfig & _mediaConf
Definition ZConfig.cc:865
DefaultOption< Pathname > cfg_metadata_path
Definition ZConfig.cc:811
Pathname cfg_known_repos_path
Definition ZConfig.cc:816
Pathname cfg_known_services_path
Definition ZConfig.cc:817
Pathname _autodetectSystemRoot() const
bsc#1237044: Provide announceSystemRoot to allow commands using –root without launching a Target.
Definition ZConfig.cc:775
Pathname cfg_vars_path
Definition ZConfig.cc:818
Impl & operator=(const Impl &)=delete
Impl & operator=(Impl &&)=delete
DefaultOption< Pathname > cfg_packages_path
Definition ZConfig.cc:813
bool download_use_deltarpm_always
Definition ZConfig.cc:834
void notifyTargetChanged()
Definition ZConfig.cc:781
Pathname solver_checkSystemFile
Definition ZConfig.cc:844
Impl(const Impl &)=delete
MultiversionMap _multiversionMap
Definition ZConfig.cc:962
Pathname history_log_path
Definition ZConfig.cc:854
Pathname locks_file
Definition ZConfig.cc:824
const TargetDefaults & targetDefaults() const
Definition ZConfig.cc:869
MultiversionSpec & getMultiversion() const
Definition ZConfig.cc:959
Impl(Impl &&)=delete
LocaleSet repoRefreshLocales
Definition ZConfig.cc:830
DefaultOption< Pathname > cfg_cache_path
Definition ZConfig.cc:810
std::vector< std::string > geoipHosts
Definition ZConfig.cc:862
TargetDefaults & targetDefaults()
Definition ZConfig.cc:870
Pathname _announced_root_path
Definition ZConfig.cc:803
Option< Pathname > pluginsPath
Definition ZConfig.cc:858
std::string userData
Definition ZConfig.cc:856
std::string cfg_kernel_keep_spec
Definition ZConfig.cc:823
DefaultOption< TriBool > repoGpgCheck
Definition ZConfig.cc:841
unsigned repo_refresh_delay
Definition ZConfig.cc:829
Option< DownloadMode > commit_downloadMode
Definition ZConfig.cc:838
std::optional< TargetDefaults > _currentTargetDefaults
TargetDefaults while –root.
Definition ZConfig.cc:873
MultiversionSpec & multiversion()
Definition ZConfig.cc:847
DefaultOption< bool > download_media_prefer_download
Definition ZConfig.cc:835
std::set< std::string > MultiversionSpec
Definition ZConfig.cc:450
Pathname solver_checkSystemFileDir
Definition ZConfig.cc:845
Pathname cfg_config_path
Definition ZConfig.cc:815
TargetDefaults _initialTargetDefaults
Initial TargetDefaults from /.
Definition ZConfig.cc:872
target::rpm::RpmInstFlags rpmInstallFlags
Definition ZConfig.cc:852
const MultiversionSpec & multiversion() const
Definition ZConfig.cc:848
Pathname cfg_repo_mgr_root_path
Definition ZConfig.cc:819
DefaultOption< TriBool > pkgGpgCheck
Definition ZConfig.cc:842
DefaultOption< std::string > updateMessagesNotify
Definition ZConfig.cc:826
Pathname cfg_vendor_path
Definition ZConfig.cc:821
DefaultOption< Pathname > cfg_solvfiles_path
Definition ZConfig.cc:812
DefaultOption< bool > gpgCheck
Definition ZConfig.cc:840
bool hasUserData() const
Whether a (non empty) user data sting is defined.
Definition ZConfig.cc:1077
bool solver_cleandepsOnRemove() const
Whether removing a package should also remove no longer needed requirements.
Definition ZConfig.cc:1292
std::string userData() const
User defined string value to be passed to log, history, plugins...
Definition ZConfig.cc:1080
Pathname knownServicesPath() const
Path where the known services .service files are kept (configPath()/services.d).
Definition ZConfig.cc:1175
void removeMultiversionSpec(const std::string &name_r)
Definition ZConfig.cc:1321
Pathname repoPackagesPath() const
Path where the repo packages are downloaded and kept (repoCachePath()/packages).
Definition ZConfig.cc:1138
unsigned repo_refresh_delay() const
Amount of time in minutes that must pass before another refresh.
Definition ZConfig.cc:1222
Arch systemArchitecture() const
The system architecture zypp uses.
Definition ZConfig.cc:1035
Locale textLocale() const
The locale for translated texts zypp uses.
Definition ZConfig.cc:1059
const std::vector< std::string > geoipHostnames() const
All hostnames we want to rewrite using the geoip feature.
Definition ZConfig.cc:1196
ZConfig(const ZConfig &)=delete
static Pathname update_dataPath()
Path where the update items are kept (/var/adm).
Definition ZConfig.cc:1326
ResolverFocus solver_focus() const
The resolver's general attitude when resolving jobs.
Definition ZConfig.cc:1285
Pathname builtinRepoSolvfilesPath() const
The builtin config file value.
Definition ZConfig.cc:1155
Pathname pluginsPath() const
Defaults to /usr/lib/zypp/plugins.
Definition ZConfig.cc:1388
Pathname repoManagerRoot() const
The RepoManager root directory.
Definition ZConfig.cc:1011
void resetRepoGpgCheck()
Reset to the zconfig default.
Definition ZConfig.cc:1281
bool gpgCheck() const
Turn signature checking on/off (on).
Definition ZConfig.cc:1272
Pathname knownReposPath() const
Path where the known repositories .repo files are kept (configPath()/repos.d).
Definition ZConfig.cc:1169
long download_transfer_timeout() const
Maximum time in seconds that you allow a transfer operation to take.
Definition ZConfig.cc:1261
void setRepoManagerRoot(const Pathname &root)
Sets the RepoManager root directory.
Definition ZConfig.cc:1017
bool solver_dupAllowArchChange() const
DUP tune: Whether to allow package arch changes upon DUP.
Definition ZConfig.cc:1290
void setTextLocale(const Locale &locale_r)
Set the preferred locale for translated texts.
Definition ZConfig.cc:1062
bool solverUpgradeRemoveDroppedPackages() const
Whether dist upgrade should remove a products dropped packages (true).
Definition ZConfig.cc:1295
void notifyTargetChanged()
internal
Definition ZConfig.cc:1005
static Locale defaultTextLocale()
The autodetected preferred locale for translated texts.
Definition ZConfig.cc:1053
Pathname download_mediaMountdir() const
Path where media are preferably mounted or downloaded.
Definition ZConfig.cc:1264
static Pathname update_scriptsPath()
Path where the update scripts are stored ( /var/adm/update-scripts ).
Definition ZConfig.cc:1342
void resetSolverUpgradeRemoveDroppedPackages()
Reset solverUpgradeRemoveDroppedPackages to the zypp.conf default.
Definition ZConfig.cc:1297
bool apply_locks_file() const
Whether locks file should be read and applied after start (true).
Definition ZConfig.cc:1323
bool solver_allowVendorChange() const
Whether vendor check is by default enabled.
Definition ZConfig.cc:1287
void set_default_download_mediaMountdir()
Reset to zypp.cong default.
Definition ZConfig.cc:1266
Pathname repoCachePath() const
Path where the caches are kept (/var/cache/zypp).
Definition ZConfig.cc:1100
void setPkgGpgCheck(TriBool val_r)
Change the value.
Definition ZConfig.cc:1278
Pathname needrebootPath() const
Path where the custom needreboot config files are kept (configPath()/needreboot.d).
Definition ZConfig.cc:1184
bool setUserData(const std::string &str_r)
Set a new userData string.
Definition ZConfig.cc:1083
Pathname systemRoot() const
The target root directory.
Definition ZConfig.cc:1008
long download_max_silent_tries() const
Maximum silent tries.
Definition ZConfig.cc:1258
bool repo_add_probe() const
Whether repository urls should be probed.
Definition ZConfig.cc:1219
target::rpm::RpmInstFlags rpmInstallFlags() const
The default target::rpm::RpmInstFlags for ZYppCommitPolicy.
Definition ZConfig.cc:1361
void setUpdateMessagesNotify(const std::string &val_r)
Set a new command definition (see update.messages.notify in zypp.conf).
Definition ZConfig.cc:1353
unsigned solver_upgradeTestcasesToKeep() const
When committing a dist upgrade (e.g.
Definition ZConfig.cc:1293
Pathname repoMetadataPath() const
Path where the repo metadata is downloaded and kept (repoCachePath()/raw).
Definition ZConfig.cc:1116
Pathname geoipCachePath() const
Path where the geoip caches are kept (/var/cache/zypp/geoip).
Definition ZConfig.cc:1193
Pathname vendorPath() const
Directory for equivalent vendor definitions (configPath()/vendors.d).
Definition ZConfig.cc:1205
long download_min_download_speed() const
Minimum download speed (bytes per second) until the connection is dropped.
Definition ZConfig.cc:1252
DownloadMode commit_downloadMode() const
Commit download policy to use as default.
Definition ZConfig.cc:1268
Pathname needrebootFile() const
Path of the default needreboot config file (configPath()/needreboot).
Definition ZConfig.cc:1181
void setGpgCheck(bool val_r)
Change the value.
Definition ZConfig.cc:1276
bool solver_dupAllowVendorChange() const
DUP tune: Whether to allow package vendor changes upon DUP.
Definition ZConfig.cc:1291
~ZConfig()
Dtor.
Definition ZConfig.cc:993
void setGeoipEnabled(bool enable=true)
Enables or disables the use of the geoip feature of download.opensuse.org.
Definition ZConfig.cc:1187
Pathname locksFile() const
Path where zypp can find or create lock file (configPath()/locks).
Definition ZConfig.cc:1211
RW_pointer< Impl, rw_pointer::Scoped< Impl > > _pimpl
Pointer to implementation.
Definition ZConfig.h:644
Pathname repoSolvfilesPath() const
Path where the repo solv files are created and kept (repoCachePath()/solv).
Definition ZConfig.cc:1127
bool geoipEnabled() const
Returns true if zypp should use the geoip feature of download.opensuse.org.
Definition ZConfig.cc:1190
static Pathname update_messagesPath()
Path where the update messages are stored ( /var/adm/update-messages ).
Definition ZConfig.cc:1334
Pathname historyLogFile() const
Path where ZYpp install history is logged.
Definition ZConfig.cc:1365
void setSystemArchitecture(const Arch &arch_r)
Override the zypp system architecture.
Definition ZConfig.cc:1038
TriBool pkgGpgCheck() const
Check rpm package signatures (indeterminate - according to gpgcheck).
Definition ZConfig.cc:1274
static ZConfig & instance()
Singleton ctor.
Definition ZConfig.cc:971
void setRepoPackagesPath(const Pathname &path_r)
Set a new path as the default repo cache path.
Definition ZConfig.cc:1144
void setRepoSolvfilesPath(const Pathname &path_r)
Set a new path as the default repo cache path.
Definition ZConfig.cc:1133
void resetUpdateMessagesNotify()
Reset to the zypp.conf default.
Definition ZConfig.cc:1356
std::ostream & about(std::ostream &str) const
Print some detail about the current libzypp version.
Definition ZConfig.cc:1398
const std::set< std::string > & multiversionSpec() const
Definition ZConfig.cc:1317
void set_download_mediaMountdir(Pathname newval_r)
Set alternate value.
Definition ZConfig.cc:1265
bool download_use_deltarpm() const
Whether to consider using a deltarpm when downloading a package.
Definition ZConfig.cc:1234
TriBool repoGpgCheck() const
Check repo matadata signatures (indeterminate - according to gpgcheck).
Definition ZConfig.cc:1273
void set_download_media_prefer_download(bool yesno_r)
Set download_media_prefer_download to a specific value.
Definition ZConfig.cc:1243
std::string updateMessagesNotify() const
Command definition for sending update messages.
Definition ZConfig.cc:1350
void addMultiversionSpec(const std::string &name_r)
Definition ZConfig.cc:1320
Pathname builtinRepoCachePath() const
The builtin config file value.
Definition ZConfig.cc:1149
Pathname builtinRepoPackagesPath() const
The builtin config file value.
Definition ZConfig.cc:1158
Pathname solver_checkSystemFile() const
File in which dependencies described which has to be fulfilled for a running system.
Definition ZConfig.cc:1300
Pathname builtinRepoMetadataPath() const
The builtin config file value.
Definition ZConfig.cc:1152
void set_default_download_media_prefer_download()
Set download_media_prefer_download to the configfiles default.
Definition ZConfig.cc:1246
long lockTimeout() const
The number of seconds to wait for the zypp lock to become available.
Definition ZConfig.cc:996
Pathname solver_checkSystemFileDir() const
Directory, which may or may not contain files in which dependencies described which has to be fulfill...
Definition ZConfig.cc:1304
void resetGpgCheck()
Reset to the zconfig default.
Definition ZConfig.cc:1280
void setSolverUpgradeRemoveDroppedPackages(bool val_r)
Set solverUpgradeRemoveDroppedPackages to val_r.
Definition ZConfig.cc:1296
Pathname configPath() const
Path where the configfiles are kept (/etc/zypp).
Definition ZConfig.cc:1163
static Arch defaultSystemArchitecture()
The autodetected system architecture.
Definition ZConfig.cc:1029
Pathname pubkeyCachePath() const
Path where the pubkey caches.
Definition ZConfig.cc:1106
long download_max_concurrent_connections() const
Maximum number of concurrent connections for a single transfer.
Definition ZConfig.cc:1249
void resetPkgGpgCheck()
Reset to the zconfig default.
Definition ZConfig.cc:1282
void announceSystemRoot(const Pathname &root_r)
Announce a target root directory without launching the Target.
Definition ZConfig.cc:1020
bool solver_onlyRequires() const
Solver regards required packages,patterns,... only.
Definition ZConfig.cc:1286
Pathname varsPath() const
Path containing custom repo variable definitions (configPath()/vars.d).
Definition ZConfig.cc:1199
bool solver_dupAllowNameChange() const
DUP tune: Whether to follow package renames upon DUP.
Definition ZConfig.cc:1289
bool repoLabelIsAlias() const
Whether to use repository alias or name in user messages (progress, exceptions, .....
Definition ZConfig.cc:1228
void clearMultiversionSpec()
Definition ZConfig.cc:1319
LocaleSet repoRefreshLocales() const
List of locales for which translated package descriptions should be downloaded.
Definition ZConfig.cc:1225
long download_max_download_speed() const
Maximum download speed (bytes per second).
Definition ZConfig.cc:1255
void setRepoMetadataPath(const Pathname &path_r)
Set a new path as the default repo cache path.
Definition ZConfig.cc:1122
bool solver_dupAllowDowngrade() const
DUP tune: Whether to allow version downgrades upon DUP.
Definition ZConfig.cc:1288
std::string multiversionKernels() const
Definition ZConfig.cc:1391
std::string distroverpkg() const
Package telling the "product version" on systems not using /etc/product.d/baseproduct.
Definition ZConfig.cc:1383
bool download_use_deltarpm_always() const
Whether to consider using a deltarpm even when rpm is local.
Definition ZConfig.cc:1237
void setRepoCachePath(const Pathname &path_r)
Set a new path as the default repo cache path.
Definition ZConfig.cc:1111
void setRepoGpgCheck(TriBool val_r)
Change the value.
Definition ZConfig.cc:1277
Pathname credentialsGlobalDir() const
Defaults to /etc/zypp/credentials.d.
Definition ZConfig.cc:1371
bool download_media_prefer_download() const
Hint which media to prefer when installing packages (download vs.
Definition ZConfig.cc:1240
Pathname credentialsGlobalFile() const
Defaults to /etc/zypp/credentials.cat.
Definition ZConfig.cc:1376
ZYpp::Ptr getZYpp()
Convenience to get the Pointer to the ZYpp instance.
Definition ZYppFactory.h:77
Wrapper class for stat/lstat.
Definition PathInfo.h:226
const Pathname & path() const
Return current Pathname.
Definition PathInfo.h:251
bool emptyOrRoot() const
Test for "" or "/".
Definition Pathname.h:127
bool empty() const
Test for an empty path.
Definition Pathname.h:117
Simple lineparser: Traverse each line in a file.
Definition IOStream.h:113
bool next()
Advance to next line.
Definition IOStream.cc:72
void setTextLocale(const Locale &locale_r)
Set the default language for retrieving translated texts.
Definition Pool.cc:233
static Pool instance()
Singleton ctor.
Definition Pool.h:55
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition String.h:31
Definition ansi.h:855
String related utilities and Regular expression matching.
Namespace intended to collect all environment variables we use.
std::optional< Pathname > ZYPP_CONF()
Definition ZConfig.cc:54
Types and functions for filesystem operations.
Definition Glob.cc:24
int dirForEach(const Pathname &dir_r, const StrMatcher &matcher_r, function< bool(const Pathname &, const char *const)> fnc_r)
Definition PathInfo.cc:32
int simpleParseFile(std::istream &str_r, ParseFlags flags_r, function< bool(int, std::string)> consume_r)
Simple lineparser optionally trimming and skipping comments.
Definition IOStream.cc:124
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
Definition String.h:1097
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
Definition String.h:500
TInt strtonum(const C_Str &str)
Parsing numbers from string.
std::string sconcat(Args &&... args)
Concat words as string.
Definition LogTools.h:276
unsigned splitEscaped(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \t", bool withEmpty=false)
Split line_r into words with respect to escape delimeters.
Definition String.h:665
Easy-to use interface to the ZYPP dependency resolver.
bool fromString(const std::string &val_r, ResolverFocus &ret_r)
std::unordered_set< Locale > LocaleSet
Definition Locale.h:29
ResolverFocus
The resolver's general attitude.
@ Default
Request the standard behavior (as defined in zypp.conf or 'Job').
detail::Dump< Tp > dump(const Tp &obj_r)
Definition LogTools.h:757
DownloadMode
Supported commit download policies.
@ DownloadDefault
libzypp will decide what to do.
Mutable option with initial value also remembering a config value.
Definition ZConfig.cc:407
DefaultOption(value_type initial_r)
Definition ZConfig.cc:411
option_type _default
Definition ZConfig.cc:436
void setDefault(value_type newval_r)
Set a new default value.
Definition ZConfig.cc:432
void restoreToDefault(value_type newval_r)
Reset value to a new default.
Definition ZConfig.cc:424
DefaultOption & operator=(value_type newval_r)
Definition ZConfig.cc:416
void restoreToDefault()
Reset value to the current default.
Definition ZConfig.cc:420
Option< Tp > option_type
Definition ZConfig.cc:409
const value_type & getDefault() const
Get the current default value.
Definition ZConfig.cc:428
Mutable option.
Definition ZConfig.cc:377
const value_type & get() const
Get the value.
Definition ZConfig.cc:389
Option & operator=(value_type newval_r)
Definition ZConfig.cc:385
void set(value_type newval_r)
Set a new value.
Definition ZConfig.cc:397
Option(value_type initial_r)
No default ctor, explicit initialisation!
Definition ZConfig.cc:381
value_type _val
Definition ZConfig.cc:401
MultiversionSpec & getSpec(Pathname root_r, const Impl &zConfImpl_r)
Definition ZConfig.cc:885
MultiversionSpec & getDefaultSpec()
Definition ZConfig.cc:912
void scanDirAt(const Pathname &root_r, MultiversionSpec &spec_r, const Impl &zConfImpl_r)
Definition ZConfig.cc:931
bool scanConfAt(const Pathname &root_r, MultiversionSpec &spec_r, const Impl &zConfImpl_r)
Definition ZConfig.cc:916
std::map< Pathname, MultiversionSpec > SpecMap
Definition ZConfig.cc:883
Settings that follow a changed Target.
Definition ZConfig.cc:454
Option< bool > solver_dupAllowVendorChange
Definition ZConfig.cc:525
DefaultOption< bool > solverUpgradeRemoveDroppedPackages
Definition ZConfig.cc:528
Option< unsigned > solver_upgradeTestcasesToKeep
Definition ZConfig.cc:527
Option< bool > solver_dupAllowDowngrade
Definition ZConfig.cc:522
bool consume(const std::string &section, const std::string &entry, const std::string &value)
Definition ZConfig.cc:468
Option< bool > solver_dupAllowArchChange
Definition ZConfig.cc:524
Option< bool > solver_cleandepsOnRemove
Definition ZConfig.cc:526
Option< bool > solver_allowVendorChange
Definition ZConfig.cc:521
Option< bool > solver_dupAllowNameChange
Definition ZConfig.cc:523
static PoolImpl & myPool()
Definition PoolImpl.cc:185