libzypp 17.37.17
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 ( APIConfig(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 == "lock_timeout" ) {
533 }
534 else if ( entry == "arch" )
535 {
536 Arch carch( value );
537 if ( carch != cfg_arch )
538 {
539 WAR << "Overriding system architecture (" << cfg_arch << "): " << carch << endl;
540 cfg_arch = carch;
541 }
542 }
543 else if ( entry == "cachedir" )
544 {
545 cfg_cache_path.restoreToDefault( value );
546 }
547 else if ( entry == "metadatadir" )
548 {
549 cfg_metadata_path.restoreToDefault( value );
550 }
551 else if ( entry == "solvfilesdir" )
552 {
553 cfg_solvfiles_path.restoreToDefault( value );
554 }
555 else if ( entry == "packagesdir" )
556 {
557 cfg_packages_path.restoreToDefault( value );
558 }
559 else if ( entry == "configdir" )
560 {
561 cfg_config_path = Pathname(value);
562 }
563 else if ( entry == "reposdir" )
564 {
566 }
567 else if ( entry == "servicesdir" )
568 {
570 }
571 else if ( entry == "varsdir" )
572 {
573 cfg_vars_path = Pathname(value);
574 }
575 else if ( entry == "repo.add.probe" )
576 {
578 }
579 else if ( entry == "repo.refresh.delay" )
580 {
582 }
583 else if ( entry == "repo.refresh.locales" )
584 {
585 std::vector<std::string> tmp;
586 str::split( value, back_inserter( tmp ), ", \t" );
587
588 boost::function<Locale(const std::string &)> transform(
589 [](const std::string & str_r)->Locale{ return Locale(str_r); }
590 );
591 repoRefreshLocales.insert( make_transform_iterator( tmp.begin(), transform ),
592 make_transform_iterator( tmp.end(), transform ) );
593 }
594 else if ( entry == "download.use_deltarpm" )
595 {
597 }
598 else if ( entry == "download.use_deltarpm.always" )
599 {
601 }
602 else if ( entry == "download.media_preference" )
603 {
604 download_media_prefer_download.restoreToDefault( str::compareCI( value, "volatile" ) != 0 );
605 }
606 else if ( entry == "download.media_mountdir" )
607 {
608 download_mediaMountdir.restoreToDefault( Pathname(value) );
609 }
610 else if ( entry == "download.use_geoip_mirror") {
612 }
613 else if ( entry == "commit.downloadMode" )
614 {
615 commit_downloadMode.set( deserializeDownloadMode( value ) );
616 }
617 else if ( entry == "gpgcheck" )
618 {
619 gpgCheck.restoreToDefault( str::strToBool( value, gpgCheck ) );
620 }
621 else if ( entry == "repo_gpgcheck" )
622 {
623 repoGpgCheck.restoreToDefault( str::strToTriBool( value ) );
624 }
625 else if ( entry == "pkg_gpgcheck" )
626 {
627 pkgGpgCheck.restoreToDefault( str::strToTriBool( value ) );
628 }
629 else if ( entry == "vendordir" )
630 {
631 cfg_vendor_path = Pathname(value);
632 }
633 else if ( entry == "multiversiondir" )
634 {
636 }
637 else if ( entry == "multiversion.kernels" )
638 {
639 cfg_kernel_keep_spec = value;
640 }
641 else if ( entry == "solver.checkSystemFile" )
642 {
644 }
645 else if ( entry == "solver.checkSystemFileDir" )
646 {
648 }
649 else if ( entry == "multiversion" )
650 {
651 MultiversionSpec & defSpec( _multiversionMap.getDefaultSpec() );
652 str::splitEscaped( value, std::inserter( defSpec, defSpec.end() ), ", \t" );
653 }
654 else if ( entry == "locksfile.path" )
655 {
656 locks_file = Pathname(value);
657 }
658 else if ( entry == "locksfile.apply" )
659 {
661 }
662 else if ( entry == "update.datadir" )
663 {
664 // ignore, this is a constant anyway and should not be user configurabe
665 // update_data_path = Pathname(value);
666 }
667 else if ( entry == "update.scriptsdir" )
668 {
669 // ignore, this is a constant anyway and should not be user configurabe
670 // update_scripts_path = Pathname(value);
671 }
672 else if ( entry == "update.messagessdir" )
673 {
674 // ignore, this is a constant anyway and should not be user configurabe
675 // update_messages_path = Pathname(value);
676 }
677 else if ( entry == "update.messages.notify" )
678 {
679 updateMessagesNotify.set( value );
680 }
681 else if ( entry == "rpm.install.excludedocs" )
682 {
684 str::strToBool( value, false ) );
685 }
686 else if ( entry == "history.logfile" )
687 {
688 history_log_path = Pathname(value);
689 }
690 else if ( entry == "ZYPP_SINGLE_RPMTRANS" || entry == "techpreview.ZYPP_SINGLE_RPMTRANS" )
691 {
692 DBG << "ZYPP_SINGLE_RPMTRANS=" << value << endl;
693 ::setenv( "ZYPP_SINGLE_RPMTRANS", value.c_str(), 0 );
694 }
695 else if ( entry == "techpreview.ZYPP_MEDIANETWORK" )
696 {
697 DBG << "techpreview.ZYPP_MEDIANETWORK=" << value << endl;
698 ::setenv( "ZYPP_MEDIANETWORK", value.c_str(), 1 );
699 }
700 }
701 }
702 }
703 }
704 else
705 {
706 MIL << _parsedZyppConf << " not found, using defaults instead." << endl;
707 _parsedZyppConf = _parsedZyppConf.extend( " (NOT FOUND)" );
708 }
709
710 // legacy:
711 if ( getenv( "ZYPP_TESTSUITE_FAKE_ARCH" ) )
712 {
713 Arch carch( getenv( "ZYPP_TESTSUITE_FAKE_ARCH" ) );
714 if ( carch != cfg_arch )
715 {
716 WAR << "ZYPP_TESTSUITE_FAKE_ARCH: Overriding system architecture (" << cfg_arch << "): " << carch << endl;
717 cfg_arch = carch;
718 }
719 }
720 MIL << "ZConfig singleton created." << endl;
721 }
722
723 Impl(const Impl &) = delete;
724 Impl(Impl &&) = delete;
725 Impl &operator=(const Impl &) = delete;
726 Impl &operator=(Impl &&) = delete;
727 ~Impl() {}
728
737 {
738 Target_Ptr target( getZYpp()->getTarget() );
739 return target ? target->root() : _announced_root_path;
740 }
741
743 {
744 _announced_root_path = Pathname(); // first of all reset any previously _announced_root_path
745
746 Pathname newRoot { _autodetectSystemRoot() };
747 MIL << "notifyTargetChanged (" << newRoot << ")" << endl;
748
749 if ( newRoot.emptyOrRoot() ) {
750 _currentTargetDefaults.reset(); // to initial settigns from /
751 }
752 else {
754
755 Pathname newConf { newRoot/_autodetectZyppConfPath() };
756 if ( PathInfo(newConf).isExist() ) {
757 parser::IniDict dict( newConf );
758 for ( const auto & [entry,value] : dict.entries( "main" ) ) {
759 (*_currentTargetDefaults).consume( entry, value );
760 }
761 }
762 else {
763 MIL << _parsedZyppConf << " not found, using defaults." << endl;
764 }
765 }
766 }
767
768 public:
772
773 long cfg_lockTimeout = 0; // signed!
774
777
778 DefaultOption<Pathname> cfg_cache_path; // Settings from the config file are also remembered
779 DefaultOption<Pathname> cfg_metadata_path; // 'default'. Cleanup in RepoManager e.g needs to tell
780 DefaultOption<Pathname> cfg_solvfiles_path; // whether settings in effect are config values or
781 DefaultOption<Pathname> cfg_packages_path; // custom settings applied vie set...Path().
782
788
793
795
800
805
807
811
814
816 const MultiversionSpec & multiversion() const { return getMultiversion(); }
817
819
820 target::rpm::RpmInstFlags rpmInstallFlags;
821
823
824 std::string userData;
825
827
829
830 std::vector<std::string> geoipHosts;
831
832 /* Other config singleton instances */
834
835
836 public:
839 private:
841 std::optional<TargetDefaults> _currentTargetDefaults;
842
843 private:
844 // HACK for bnc#906096: let pool re-evaluate multiversion spec
845 // if target root changes. ZConfig returns data sensitive to
846 // current target root.
847 // TODO Actually we'd need to scan the target systems zypp.conf and
848 // overlay all system specific values.
850 {
851 using SpecMap = std::map<Pathname, MultiversionSpec>;
852
853 MultiversionSpec & getSpec( Pathname root_r, const Impl & zConfImpl_r ) // from system at root
854 {
855 // _specMap[] - the plain zypp.conf value
856 // _specMap[/] - combine [] and multiversion.d scan
857 // _specMap[root] - scan root/zypp.conf and root/multiversion.d
858
859 if ( root_r.empty() )
860 root_r = "/";
861 bool cacheHit = _specMap.count( root_r );
862 MultiversionSpec & ret( _specMap[root_r] ); // creates new entry on the fly
863
864 if ( ! cacheHit )
865 {
866 // bsc#1193488: If no (/root)/.../zypp.conf exists use the default zypp.conf
867 // multiversion settings. It is a legacy that the packaged multiversion setting
868 // in zypp.conf (the kernel) may differ from the builtin default (empty).
869 // But we want a missing config to behave similar to the default one, otherwise
870 // a bare metal install easily runs into trouble.
871 if ( root_r == "/" || scanConfAt( root_r, ret, zConfImpl_r ) == 0 )
872 ret = _specMap[Pathname()];
873 scanDirAt( root_r, ret, zConfImpl_r ); // add multiversion.d at root_r
874 using zypp::operator<<;
875 MIL << "MultiversionSpec '" << root_r << "' = " << ret << endl;
876 }
877 return ret;
878 }
879
880 MultiversionSpec & getDefaultSpec() // Spec from zypp.conf parsing; called before any getSpec
881 { return _specMap[Pathname()]; }
882
883 private:
884 int scanConfAt( const Pathname& root_r, MultiversionSpec & spec_r, const Impl & zConfImpl_r )
885 {
886 static const str::regex rx( "^multiversion *= *(.*)" );
887 str::smatch what;
888 return iostr::simpleParseFile( InputStream( Pathname::assertprefix( root_r, _autodetectZyppConfPath() ) ),
889 [&]( int num_r, std::string line_r )->bool
890 {
891 if ( line_r[0] == 'm' && str::regex_match( line_r, what, rx ) )
892 {
893 str::splitEscaped( what[1], std::inserter( spec_r, spec_r.end() ), ", \t" );
894 return false; // stop after match
895 }
896 return true;
897 } );
898 }
899
900 void scanDirAt( const Pathname& root_r, MultiversionSpec & spec_r, const Impl & zConfImpl_r )
901 {
902 // NOTE: Actually we'd need to scan and use the root_r! zypp.conf values.
903 Pathname multiversionDir( zConfImpl_r.cfg_multiversion_path );
904 if ( multiversionDir.empty() )
905 multiversionDir = ( zConfImpl_r.cfg_config_path.empty()
906 ? Pathname("/etc/zypp")
907 : zConfImpl_r.cfg_config_path ) / "multiversion.d";
908
909 filesystem::dirForEach( Pathname::assertprefix( root_r, multiversionDir ),
910 [&spec_r]( const Pathname & dir_r, const char *const & name_r )->bool
911 {
912 MIL << "Parsing " << dir_r/name_r << endl;
913 iostr::simpleParseFile( InputStream( dir_r/name_r ),
914 [&spec_r]( int num_r, std::string line_r )->bool
915 {
916 DBG << " found " << line_r << endl;
917 spec_r.insert( std::move(line_r) );
918 return true;
919 } );
920 return true;
921 } );
922 }
923
924 private:
926 };
927
929 { return _multiversionMap.getSpec( _autodetectSystemRoot(), *this ); }
930
932 };
933
934
936 //
937 // METHOD NAME : ZConfig::instance
938 // METHOD TYPE : ZConfig &
939 //
941 {
942 static ZConfig _instance; // The singleton
943 return _instance;
944 }
945
947 //
948 // METHOD NAME : ZConfig::ZConfig
949 // METHOD TYPE : Ctor
950 //
952 : _pimpl( new Impl )
953 {
954 about( MIL );
955 }
956
958 //
959 // METHOD NAME : ZConfig::~ZConfig
960 // METHOD TYPE : Dtor
961 //
964
966 {
967 const char * env = getenv("ZYPP_LOCK_TIMEOUT");
968 if ( env ) {
969 return str::strtonum<long>( env );
970 }
971 return _pimpl->cfg_lockTimeout;
972 }
973
975 { return _pimpl->notifyTargetChanged(); }
976
978 { return _pimpl->_autodetectSystemRoot(); }
979
981 {
982 return ( _pimpl->cfg_repo_mgr_root_path.empty()
983 ? systemRoot() : _pimpl->cfg_repo_mgr_root_path );
984 }
985
987 { _pimpl->cfg_repo_mgr_root_path = root; }
988
990 { _pimpl->_announced_root_path = root_r; }
991
993 //
994 // system architecture
995 //
997
999 {
1000 static Arch _val( _autodetectSystemArchitecture() );
1001 return _val;
1002 }
1003
1005 { return _pimpl->cfg_arch; }
1006
1008 {
1009 if ( arch_r != _pimpl->cfg_arch )
1010 {
1011 WAR << "Overriding system architecture (" << _pimpl->cfg_arch << "): " << arch_r << endl;
1012 _pimpl->cfg_arch = arch_r;
1013 }
1014 }
1015
1017 //
1018 // text locale
1019 //
1021
1023 {
1024 static Locale _val( _autodetectTextLocale() );
1025 return _val;
1026 }
1027
1029 { return _pimpl->cfg_textLocale; }
1030
1031 void ZConfig::setTextLocale( const Locale & locale_r )
1032 {
1033 if ( locale_r != _pimpl->cfg_textLocale )
1034 {
1035 WAR << "Overriding text locale (" << _pimpl->cfg_textLocale << "): " << locale_r << endl;
1036 _pimpl->cfg_textLocale = locale_r;
1037 // Propagate changes
1038 sat::Pool::instance().setTextLocale( locale_r );
1039 }
1040 }
1041
1043 // user data
1045
1047 { return !_pimpl->userData.empty(); }
1048
1049 std::string ZConfig::userData() const
1050 { return _pimpl->userData; }
1051
1052 bool ZConfig::setUserData( const std::string & str_r )
1053 {
1054 for_( ch, str_r.begin(), str_r.end() )
1055 {
1056 if ( *ch < ' ' && *ch != '\t' )
1057 {
1058 ERR << "New user data string rejectded: char " << (int)*ch << " at position " << (ch - str_r.begin()) << endl;
1059 return false;
1060 }
1061 }
1062 MIL << "Set user data string to '" << str_r << "'" << endl;
1063 _pimpl->userData = str_r;
1064 return true;
1065 }
1066
1068
1070 {
1071 return ( _pimpl->cfg_cache_path.get().empty()
1072 ? Pathname("/var/cache/zypp") : _pimpl->cfg_cache_path.get() );
1073 }
1074
1076 {
1077 return repoCachePath()/"pubkeys";
1078 }
1079
1081 {
1082 _pimpl->cfg_cache_path = path_r;
1083 }
1084
1086 {
1087 return ( _pimpl->cfg_metadata_path.get().empty()
1088 ? (repoCachePath()/"raw") : _pimpl->cfg_metadata_path.get() );
1089 }
1090
1092 {
1093 _pimpl->cfg_metadata_path = path_r;
1094 }
1095
1097 {
1098 return ( _pimpl->cfg_solvfiles_path.get().empty()
1099 ? (repoCachePath()/"solv") : _pimpl->cfg_solvfiles_path.get() );
1100 }
1101
1103 {
1104 _pimpl->cfg_solvfiles_path = path_r;
1105 }
1106
1108 {
1109 return ( _pimpl->cfg_packages_path.get().empty()
1110 ? (repoCachePath()/"packages") : _pimpl->cfg_packages_path.get() );
1111 }
1112
1114 {
1115 _pimpl->cfg_packages_path = path_r;
1116 }
1117
1119 { return _pimpl->cfg_cache_path.getDefault().empty() ? Pathname("/var/cache/zypp") : _pimpl->cfg_cache_path.getDefault(); }
1120
1122 { return _pimpl->cfg_metadata_path.getDefault().empty() ? (builtinRepoCachePath()/"raw") : _pimpl->cfg_metadata_path.getDefault(); }
1123
1125 { return _pimpl->cfg_solvfiles_path.getDefault().empty() ? (builtinRepoCachePath()/"solv") : _pimpl->cfg_solvfiles_path.getDefault(); }
1126
1128 { return _pimpl->cfg_packages_path.getDefault().empty() ? (builtinRepoCachePath()/"packages") : _pimpl->cfg_packages_path.getDefault(); }
1129
1131
1133 {
1134 return ( _pimpl->cfg_config_path.empty()
1135 ? Pathname("/etc/zypp") : _pimpl->cfg_config_path );
1136 }
1137
1139 {
1140 return ( _pimpl->cfg_known_repos_path.empty()
1141 ? (configPath()/"repos.d") : _pimpl->cfg_known_repos_path );
1142 }
1143
1145 {
1146 return ( _pimpl->cfg_known_services_path.empty()
1147 ? (configPath()/"services.d") : _pimpl->cfg_known_services_path );
1148 }
1149
1151 { return configPath()/"needreboot"; }
1152
1154 { return configPath()/"needreboot.d"; }
1155
1156 void ZConfig::setGeoipEnabled( bool enable )
1157 { _pimpl->geoipEnabled = enable; }
1158
1160 { return _pimpl->geoipEnabled; }
1161
1163 { return builtinRepoCachePath()/"geoip.d"; }
1164
1165 const std::vector<std::string> ZConfig::geoipHostnames () const
1166 { return _pimpl->geoipHosts; }
1167
1169 {
1170 return ( _pimpl->cfg_vars_path.empty()
1171 ? (configPath()/"vars.d") : _pimpl->cfg_vars_path );
1172 }
1173
1175 {
1176 return ( _pimpl->cfg_vendor_path.empty()
1177 ? (configPath()/"vendors.d") : _pimpl->cfg_vendor_path );
1178 }
1179
1181 {
1182 return ( _pimpl->locks_file.empty()
1183 ? (configPath()/"locks") : _pimpl->locks_file );
1184 }
1185
1187
1189 { return _pimpl->repo_add_probe; }
1190
1192 { return _pimpl->repo_refresh_delay; }
1193
1195 { return _pimpl->repoRefreshLocales.empty() ? Target::requestedLocales("") :_pimpl->repoRefreshLocales; }
1196
1198 { return _pimpl->repoLabelIsAlias; }
1199
1200 void ZConfig::repoLabelIsAlias( bool yesno_r )
1201 { _pimpl->repoLabelIsAlias = yesno_r; }
1202
1204 { return _pimpl->download_use_deltarpm; }
1205
1207 { return download_use_deltarpm() && _pimpl->download_use_deltarpm_always; }
1208
1210 { return _pimpl->download_media_prefer_download; }
1211
1213 { _pimpl->download_media_prefer_download.set( yesno_r ); }
1214
1216 { _pimpl->download_media_prefer_download.restoreToDefault(); }
1217
1219 { return _pimpl->_mediaConf.download_max_concurrent_connections(); }
1220
1222 { return _pimpl->_mediaConf.download_min_download_speed(); }
1223
1225 { return _pimpl->_mediaConf.download_max_download_speed(); }
1226
1228 { return _pimpl->_mediaConf.download_max_silent_tries(); }
1229
1231 { return _pimpl->_mediaConf.download_transfer_timeout(); }
1232
1233 Pathname ZConfig::download_mediaMountdir() const { return _pimpl->download_mediaMountdir; }
1234 void ZConfig::set_download_mediaMountdir( Pathname newval_r ) { _pimpl->download_mediaMountdir.set( std::move(newval_r) ); }
1235 void ZConfig::set_default_download_mediaMountdir() { _pimpl->download_mediaMountdir.restoreToDefault(); }
1236
1238 { return _pimpl->commit_downloadMode; }
1239
1240
1241 bool ZConfig::gpgCheck() const { return _pimpl->gpgCheck; }
1242 TriBool ZConfig::repoGpgCheck() const { return _pimpl->repoGpgCheck; }
1243 TriBool ZConfig::pkgGpgCheck() const { return _pimpl->pkgGpgCheck; }
1244
1245 void ZConfig::setGpgCheck( bool val_r ) { _pimpl->gpgCheck.set( val_r ); }
1246 void ZConfig::setRepoGpgCheck( TriBool val_r ) { _pimpl->repoGpgCheck.set( val_r ); }
1247 void ZConfig::setPkgGpgCheck( TriBool val_r ) { _pimpl->pkgGpgCheck.set( val_r ); }
1248
1249 void ZConfig::resetGpgCheck() { _pimpl->gpgCheck.restoreToDefault(); }
1250 void ZConfig::resetRepoGpgCheck() { _pimpl->repoGpgCheck.restoreToDefault(); }
1251 void ZConfig::resetPkgGpgCheck() { _pimpl->pkgGpgCheck.restoreToDefault(); }
1252
1253
1254 ResolverFocus ZConfig::solver_focus() const { return _pimpl->targetDefaults().solver_focus; }
1255 bool ZConfig::solver_onlyRequires() const { return _pimpl->targetDefaults().solver_onlyRequires; }
1256 bool ZConfig::solver_allowVendorChange() const { return _pimpl->targetDefaults().solver_allowVendorChange; }
1257 bool ZConfig::solver_dupAllowDowngrade() const { return _pimpl->targetDefaults().solver_dupAllowDowngrade; }
1258 bool ZConfig::solver_dupAllowNameChange() const { return _pimpl->targetDefaults().solver_dupAllowNameChange; }
1259 bool ZConfig::solver_dupAllowArchChange() const { return _pimpl->targetDefaults().solver_dupAllowArchChange; }
1260 bool ZConfig::solver_dupAllowVendorChange() const { return _pimpl->targetDefaults().solver_dupAllowVendorChange; }
1261 bool ZConfig::solver_cleandepsOnRemove() const { return _pimpl->targetDefaults().solver_cleandepsOnRemove; }
1262 unsigned ZConfig::solver_upgradeTestcasesToKeep() const { return _pimpl->targetDefaults().solver_upgradeTestcasesToKeep; }
1263
1264 bool ZConfig::solverUpgradeRemoveDroppedPackages() const { return _pimpl->targetDefaults().solverUpgradeRemoveDroppedPackages; }
1265 void ZConfig::setSolverUpgradeRemoveDroppedPackages( bool val_r ) { _pimpl->targetDefaults().solverUpgradeRemoveDroppedPackages.set( val_r ); }
1266 void ZConfig::resetSolverUpgradeRemoveDroppedPackages() { _pimpl->targetDefaults().solverUpgradeRemoveDroppedPackages.restoreToDefault(); }
1267
1268
1270 { return ( _pimpl->solver_checkSystemFile.empty()
1271 ? (configPath()/"systemCheck") : _pimpl->solver_checkSystemFile ); }
1272
1274 { return ( _pimpl->solver_checkSystemFileDir.empty()
1275 ? (configPath()/"systemCheck.d") : _pimpl->solver_checkSystemFileDir ); }
1276
1277
1278 namespace
1279 {
1280 inline void sigMultiversionSpecChanged()
1281 {
1283 }
1284 }
1285
1286 const std::set<std::string> & ZConfig::multiversionSpec() const { return _pimpl->multiversion(); }
1287 void ZConfig::multiversionSpec( std::set<std::string> new_r ) { _pimpl->multiversion().swap( new_r ); sigMultiversionSpecChanged(); }
1288 void ZConfig::clearMultiversionSpec() { _pimpl->multiversion().clear(); sigMultiversionSpecChanged(); }
1289 void ZConfig::addMultiversionSpec( const std::string & name_r ) { _pimpl->multiversion().insert( name_r ); sigMultiversionSpecChanged(); }
1290 void ZConfig::removeMultiversionSpec( const std::string & name_r ) { _pimpl->multiversion().erase( name_r ); sigMultiversionSpecChanged(); }
1291
1293 { return _pimpl->apply_locks_file; }
1294
1296#if LEGACY(1735)
1297 const
1298#endif
1299 {
1300 return Pathname("/var/adm");
1301 }
1302
1304#if LEGACY(1735)
1305 const
1306#endif
1307 {
1308 return Pathname(update_dataPath()/"update-messages");
1309 }
1310
1312#if LEGACY(1735)
1313 const
1314#endif
1315 {
1316 return Pathname(update_dataPath()/"update-scripts");
1317 }
1318
1320 { return _pimpl->updateMessagesNotify; }
1321
1322 void ZConfig::setUpdateMessagesNotify( const std::string & val_r )
1323 { _pimpl->updateMessagesNotify.set( val_r ); }
1324
1326 { _pimpl->updateMessagesNotify.restoreToDefault(); }
1327
1329
1330 target::rpm::RpmInstFlags ZConfig::rpmInstallFlags() const
1331 { return _pimpl->rpmInstallFlags; }
1332
1333
1335 {
1336 return ( _pimpl->history_log_path.empty() ?
1337 Pathname("/var/log/zypp/history") : _pimpl->history_log_path );
1338 }
1339
1341 {
1342 return _pimpl->_mediaConf.credentialsGlobalDir();
1343 }
1344
1346 {
1347 return _pimpl->_mediaConf.credentialsGlobalFile();
1348 }
1349
1351
1352 std::string ZConfig::distroverpkg() const
1353 { return "system-release"; }
1354
1356
1358 { return _pimpl->pluginsPath.get(); }
1359
1361 {
1362 return _pimpl->cfg_kernel_keep_spec;
1363 }
1364
1366
1367 std::ostream & ZConfig::about( std::ostream & str ) const
1368 {
1369 str << "libzypp: " LIBZYPP_VERSION_STRING << " (" << LIBZYPP_CODESTREAM << ")" << endl;
1370
1371 str << "libsolv: " << solv_version;
1372 if ( ::strcmp( solv_version, LIBSOLV_VERSION_STRING ) )
1373 str << " (built against " << LIBSOLV_VERSION_STRING << ")";
1374 str << endl;
1375
1376 str << "zypp.conf: '" << _pimpl->_parsedZyppConf << "'" << endl;
1377 str << "TextLocale: '" << textLocale() << "' (" << defaultTextLocale() << ")" << endl;
1378 str << "SystemArchitecture: '" << systemArchitecture() << "' (" << defaultSystemArchitecture() << ")" << endl;
1379 return str;
1380 }
1381
1383} // 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:790
DefaultOption< Pathname > download_mediaMountdir
Definition ZConfig.cc:804
MediaConfig & _mediaConf
Definition ZConfig.cc:833
DefaultOption< Pathname > cfg_metadata_path
Definition ZConfig.cc:779
Pathname cfg_known_repos_path
Definition ZConfig.cc:784
Pathname cfg_known_services_path
Definition ZConfig.cc:785
Pathname _autodetectSystemRoot() const
bsc#1237044: Provide announceSystemRoot to allow commands using –root without launching a Target.
Definition ZConfig.cc:736
Pathname cfg_vars_path
Definition ZConfig.cc:786
Impl & operator=(const Impl &)=delete
Impl & operator=(Impl &&)=delete
DefaultOption< Pathname > cfg_packages_path
Definition ZConfig.cc:781
bool download_use_deltarpm_always
Definition ZConfig.cc:802
Pathname _parsedZyppConf
Remember any parsed zypp.conf.
Definition ZConfig.cc:770
void notifyTargetChanged()
Definition ZConfig.cc:742
Pathname solver_checkSystemFile
Definition ZConfig.cc:812
Impl(const Impl &)=delete
MultiversionMap _multiversionMap
Definition ZConfig.cc:931
Pathname history_log_path
Definition ZConfig.cc:822
Pathname locks_file
Definition ZConfig.cc:792
const TargetDefaults & targetDefaults() const
Definition ZConfig.cc:837
MultiversionSpec & getMultiversion() const
Definition ZConfig.cc:928
Impl(Impl &&)=delete
LocaleSet repoRefreshLocales
Definition ZConfig.cc:798
DefaultOption< Pathname > cfg_cache_path
Definition ZConfig.cc:778
std::vector< std::string > geoipHosts
Definition ZConfig.cc:830
TargetDefaults & targetDefaults()
Definition ZConfig.cc:838
Pathname _announced_root_path
Definition ZConfig.cc:771
Option< Pathname > pluginsPath
Definition ZConfig.cc:826
std::string userData
Definition ZConfig.cc:824
std::string cfg_kernel_keep_spec
Definition ZConfig.cc:791
DefaultOption< TriBool > repoGpgCheck
Definition ZConfig.cc:809
unsigned repo_refresh_delay
Definition ZConfig.cc:797
Option< DownloadMode > commit_downloadMode
Definition ZConfig.cc:806
std::optional< TargetDefaults > _currentTargetDefaults
TargetDefaults while –root.
Definition ZConfig.cc:841
MultiversionSpec & multiversion()
Definition ZConfig.cc:815
DefaultOption< bool > download_media_prefer_download
Definition ZConfig.cc:803
std::set< std::string > MultiversionSpec
Definition ZConfig.cc:401
Pathname solver_checkSystemFileDir
Definition ZConfig.cc:813
Pathname cfg_config_path
Definition ZConfig.cc:783
TargetDefaults _initialTargetDefaults
Initial TargetDefaults from /.
Definition ZConfig.cc:840
target::rpm::RpmInstFlags rpmInstallFlags
Definition ZConfig.cc:820
const MultiversionSpec & multiversion() const
Definition ZConfig.cc:816
Pathname cfg_repo_mgr_root_path
Definition ZConfig.cc:787
DefaultOption< TriBool > pkgGpgCheck
Definition ZConfig.cc:810
DefaultOption< std::string > updateMessagesNotify
Definition ZConfig.cc:794
Pathname cfg_vendor_path
Definition ZConfig.cc:789
DefaultOption< Pathname > cfg_solvfiles_path
Definition ZConfig.cc:780
DefaultOption< bool > gpgCheck
Definition ZConfig.cc:808
bool hasUserData() const
Whether a (non empty) user data sting is defined.
Definition ZConfig.cc:1046
bool solver_cleandepsOnRemove() const
Whether removing a package should also remove no longer needed requirements.
Definition ZConfig.cc:1261
std::string userData() const
User defined string value to be passed to log, history, plugins...
Definition ZConfig.cc:1049
Pathname knownServicesPath() const
Path where the known services .service files are kept (configPath()/services.d).
Definition ZConfig.cc:1144
void removeMultiversionSpec(const std::string &name_r)
Definition ZConfig.cc:1290
Pathname repoPackagesPath() const
Path where the repo packages are downloaded and kept (repoCachePath()/packages).
Definition ZConfig.cc:1107
unsigned repo_refresh_delay() const
Amount of time in minutes that must pass before another refresh.
Definition ZConfig.cc:1191
Arch systemArchitecture() const
The system architecture zypp uses.
Definition ZConfig.cc:1004
Locale textLocale() const
The locale for translated texts zypp uses.
Definition ZConfig.cc:1028
const std::vector< std::string > geoipHostnames() const
All hostnames we want to rewrite using the geoip feature.
Definition ZConfig.cc:1165
ZConfig(const ZConfig &)=delete
static Pathname update_dataPath()
Path where the update items are kept (/var/adm)
Definition ZConfig.cc:1295
ResolverFocus solver_focus() const
The resolver's general attitude when resolving jobs.
Definition ZConfig.cc:1254
Pathname builtinRepoSolvfilesPath() const
The builtin config file value.
Definition ZConfig.cc:1124
Pathname pluginsPath() const
Defaults to /usr/lib/zypp/plugins.
Definition ZConfig.cc:1357
Pathname repoManagerRoot() const
The RepoManager root directory.
Definition ZConfig.cc:980
void resetRepoGpgCheck()
Reset to the zconfig default.
Definition ZConfig.cc:1250
bool gpgCheck() const
Turn signature checking on/off (on)
Definition ZConfig.cc:1241
Pathname knownReposPath() const
Path where the known repositories .repo files are kept (configPath()/repos.d).
Definition ZConfig.cc:1138
long download_transfer_timeout() const
Maximum time in seconds that you allow a transfer operation to take.
Definition ZConfig.cc:1230
void setRepoManagerRoot(const Pathname &root)
Sets the RepoManager root directory.
Definition ZConfig.cc:986
bool solver_dupAllowArchChange() const
DUP tune: Whether to allow package arch changes upon DUP.
Definition ZConfig.cc:1259
void setTextLocale(const Locale &locale_r)
Set the preferred locale for translated texts.
Definition ZConfig.cc:1031
bool solverUpgradeRemoveDroppedPackages() const
Whether dist upgrade should remove a products dropped packages (true).
Definition ZConfig.cc:1264
void notifyTargetChanged()
internal
Definition ZConfig.cc:974
static Locale defaultTextLocale()
The autodetected preferred locale for translated texts.
Definition ZConfig.cc:1022
Pathname download_mediaMountdir() const
Path where media are preferably mounted or downloaded.
Definition ZConfig.cc:1233
static Pathname update_scriptsPath()
Path where the update scripts are stored ( /var/adm/update-scripts )
Definition ZConfig.cc:1311
void resetSolverUpgradeRemoveDroppedPackages()
Reset solverUpgradeRemoveDroppedPackages to the zypp.conf default.
Definition ZConfig.cc:1266
bool apply_locks_file() const
Whether locks file should be read and applied after start (true)
Definition ZConfig.cc:1292
bool solver_allowVendorChange() const
Whether vendor check is by default enabled.
Definition ZConfig.cc:1256
void set_default_download_mediaMountdir()
Reset to zypp.cong default.
Definition ZConfig.cc:1235
Pathname repoCachePath() const
Path where the caches are kept (/var/cache/zypp)
Definition ZConfig.cc:1069
void setPkgGpgCheck(TriBool val_r)
Change the value.
Definition ZConfig.cc:1247
Pathname needrebootPath() const
Path where the custom needreboot config files are kept (configPath()/needreboot.d).
Definition ZConfig.cc:1153
bool setUserData(const std::string &str_r)
Set a new userData string.
Definition ZConfig.cc:1052
Pathname systemRoot() const
The target root directory.
Definition ZConfig.cc:977
long download_max_silent_tries() const
Maximum silent tries.
Definition ZConfig.cc:1227
bool repo_add_probe() const
Whether repository urls should be probed.
Definition ZConfig.cc:1188
target::rpm::RpmInstFlags rpmInstallFlags() const
The default target::rpm::RpmInstFlags for ZYppCommitPolicy.
Definition ZConfig.cc:1330
void setUpdateMessagesNotify(const std::string &val_r)
Set a new command definition (see update.messages.notify in zypp.conf).
Definition ZConfig.cc:1322
unsigned solver_upgradeTestcasesToKeep() const
When committing a dist upgrade (e.g.
Definition ZConfig.cc:1262
Pathname repoMetadataPath() const
Path where the repo metadata is downloaded and kept (repoCachePath()/raw).
Definition ZConfig.cc:1085
Pathname geoipCachePath() const
Path where the geoip caches are kept (/var/cache/zypp/geoip)
Definition ZConfig.cc:1162
Pathname vendorPath() const
Directory for equivalent vendor definitions (configPath()/vendors.d)
Definition ZConfig.cc:1174
long download_min_download_speed() const
Minimum download speed (bytes per second) until the connection is dropped.
Definition ZConfig.cc:1221
DownloadMode commit_downloadMode() const
Commit download policy to use as default.
Definition ZConfig.cc:1237
Pathname needrebootFile() const
Path of the default needreboot config file (configPath()/needreboot).
Definition ZConfig.cc:1150
void setGpgCheck(bool val_r)
Change the value.
Definition ZConfig.cc:1245
bool solver_dupAllowVendorChange() const
DUP tune: Whether to allow package vendor changes upon DUP.
Definition ZConfig.cc:1260
~ZConfig()
Dtor.
Definition ZConfig.cc:962
void setGeoipEnabled(bool enable=true)
Enables or disables the use of the geoip feature of download.opensuse.org.
Definition ZConfig.cc:1156
Pathname locksFile() const
Path where zypp can find or create lock file (configPath()/locks)
Definition ZConfig.cc:1180
RW_pointer< Impl, rw_pointer::Scoped< Impl > > _pimpl
Pointer to implementation.
Definition ZConfig.h:631
Pathname repoSolvfilesPath() const
Path where the repo solv files are created and kept (repoCachePath()/solv).
Definition ZConfig.cc:1096
bool geoipEnabled() const
Returns true if zypp should use the geoip feature of download.opensuse.org.
Definition ZConfig.cc:1159
static Pathname update_messagesPath()
Path where the update messages are stored ( /var/adm/update-messages )
Definition ZConfig.cc:1303
Pathname historyLogFile() const
Path where ZYpp install history is logged.
Definition ZConfig.cc:1334
void setSystemArchitecture(const Arch &arch_r)
Override the zypp system architecture.
Definition ZConfig.cc:1007
TriBool pkgGpgCheck() const
Check rpm package signatures (indeterminate - according to gpgcheck)
Definition ZConfig.cc:1243
static ZConfig & instance()
Singleton ctor.
Definition ZConfig.cc:940
void setRepoPackagesPath(const Pathname &path_r)
Set a new path as the default repo cache path.
Definition ZConfig.cc:1113
void setRepoSolvfilesPath(const Pathname &path_r)
Set a new path as the default repo cache path.
Definition ZConfig.cc:1102
void resetUpdateMessagesNotify()
Reset to the zypp.conf default.
Definition ZConfig.cc:1325
std::ostream & about(std::ostream &str) const
Print some detail about the current libzypp version.
Definition ZConfig.cc:1367
const std::set< std::string > & multiversionSpec() const
Definition ZConfig.cc:1286
void set_download_mediaMountdir(Pathname newval_r)
Set alternate value.
Definition ZConfig.cc:1234
bool download_use_deltarpm() const
Whether to consider using a deltarpm when downloading a package.
Definition ZConfig.cc:1203
TriBool repoGpgCheck() const
Check repo matadata signatures (indeterminate - according to gpgcheck)
Definition ZConfig.cc:1242
void set_download_media_prefer_download(bool yesno_r)
Set download_media_prefer_download to a specific value.
Definition ZConfig.cc:1212
std::string updateMessagesNotify() const
Command definition for sending update messages.
Definition ZConfig.cc:1319
void addMultiversionSpec(const std::string &name_r)
Definition ZConfig.cc:1289
Pathname builtinRepoCachePath() const
The builtin config file value.
Definition ZConfig.cc:1118
Pathname builtinRepoPackagesPath() const
The builtin config file value.
Definition ZConfig.cc:1127
Pathname solver_checkSystemFile() const
File in which dependencies described which has to be fulfilled for a running system.
Definition ZConfig.cc:1269
Pathname builtinRepoMetadataPath() const
The builtin config file value.
Definition ZConfig.cc:1121
void set_default_download_media_prefer_download()
Set download_media_prefer_download to the configfiles default.
Definition ZConfig.cc:1215
long lockTimeout() const
The number of seconds to wait for the zypp lock to become available.
Definition ZConfig.cc:965
Pathname solver_checkSystemFileDir() const
Directory, which may or may not contain files in which dependencies described which has to be fulfill...
Definition ZConfig.cc:1273
void resetGpgCheck()
Reset to the zconfig default.
Definition ZConfig.cc:1249
void setSolverUpgradeRemoveDroppedPackages(bool val_r)
Set solverUpgradeRemoveDroppedPackages to val_r.
Definition ZConfig.cc:1265
Pathname configPath() const
Path where the configfiles are kept (/etc/zypp).
Definition ZConfig.cc:1132
static Arch defaultSystemArchitecture()
The autodetected system architecture.
Definition ZConfig.cc:998
ZConfig()
Default ctor.
Definition ZConfig.cc:951
Pathname pubkeyCachePath() const
Path where the pubkey caches.
Definition ZConfig.cc:1075
long download_max_concurrent_connections() const
Maximum number of concurrent connections for a single transfer.
Definition ZConfig.cc:1218
void resetPkgGpgCheck()
Reset to the zconfig default.
Definition ZConfig.cc:1251
void announceSystemRoot(const Pathname &root_r)
Announce a target root directory without launching the Target.
Definition ZConfig.cc:989
bool solver_onlyRequires() const
Solver regards required packages,patterns,... only.
Definition ZConfig.cc:1255
Pathname varsPath() const
Path containing custom repo variable definitions (configPath()/vars.d).
Definition ZConfig.cc:1168
bool solver_dupAllowNameChange() const
DUP tune: Whether to follow package renames upon DUP.
Definition ZConfig.cc:1258
bool repoLabelIsAlias() const
Whether to use repository alias or name in user messages (progress, exceptions, .....
Definition ZConfig.cc:1197
void clearMultiversionSpec()
Definition ZConfig.cc:1288
LocaleSet repoRefreshLocales() const
List of locales for which translated package descriptions should be downloaded.
Definition ZConfig.cc:1194
long download_max_download_speed() const
Maximum download speed (bytes per second)
Definition ZConfig.cc:1224
void setRepoMetadataPath(const Pathname &path_r)
Set a new path as the default repo cache path.
Definition ZConfig.cc:1091
bool solver_dupAllowDowngrade() const
DUP tune: Whether to allow version downgrades upon DUP.
Definition ZConfig.cc:1257
std::string multiversionKernels() const
Definition ZConfig.cc:1360
std::string distroverpkg() const
Package telling the "product version" on systems not using /etc/product.d/baseproduct.
Definition ZConfig.cc:1352
bool download_use_deltarpm_always() const
Whether to consider using a deltarpm even when rpm is local.
Definition ZConfig.cc:1206
void setRepoCachePath(const Pathname &path_r)
Set a new path as the default repo cache path.
Definition ZConfig.cc:1080
void setRepoGpgCheck(TriBool val_r)
Change the value.
Definition ZConfig.cc:1246
Pathname credentialsGlobalDir() const
Defaults to /etc/zypp/credentials.d.
Definition ZConfig.cc:1340
bool download_media_prefer_download() const
Hint which media to prefer when installing packages (download vs.
Definition ZConfig.cc:1209
Pathname credentialsGlobalFile() const
Defaults to /etc/zypp/credentials.cat.
Definition ZConfig.cc:1345
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 emptyOrRoot() const
Test for "" or "/".
Definition Pathname.h:123
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
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
Definition String.h:31
Definition Arch.h:364
String related utilities and Regular expression matching.
Namespace intended to collect all environment variables we use.
Definition Env.h:25
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:96
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 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:500
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:602
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:665
int compareCI(const C_Str &lhs, const C_Str &rhs)
Definition String.h:1054
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')
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:884
MultiversionSpec & getSpec(Pathname root_r, const Impl &zConfImpl_r)
Definition ZConfig.cc:853
MultiversionSpec & getDefaultSpec()
Definition ZConfig.cc:880
void scanDirAt(const Pathname &root_r, MultiversionSpec &spec_r, const Impl &zConfImpl_r)
Definition ZConfig.cc:900
std::map< Pathname, MultiversionSpec > SpecMap
Definition ZConfig.cc:851
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:185
#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