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