Add sample zypp.conf to documentation
[platform/upstream/libzypp.git] / zypp / ZConfig.cc
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/ZConfig.cc
10  *
11 */
12 extern "C"
13 {
14 #include <sys/utsname.h>
15 #include <unistd.h>
16 #include <solv/solvversion.h>
17 }
18 #include <iostream>
19 #include <fstream>
20 #include "zypp/base/Logger.h"
21 #include "zypp/base/IOStream.h"
22 #include "zypp/base/InputStream.h"
23 #include "zypp/base/String.h"
24
25 #include "zypp/ZConfig.h"
26 #include "zypp/ZYppFactory.h"
27 #include "zypp/PathInfo.h"
28 #include "zypp/parser/IniDict.h"
29
30 #include "zypp/sat/Pool.h"
31
32 using namespace std;
33 using namespace zypp::filesystem;
34 using namespace zypp::parser;
35
36 #undef ZYPP_BASE_LOGGER_LOGGROUP
37 #define ZYPP_BASE_LOGGER_LOGGROUP "zconfig"
38
39 ///////////////////////////////////////////////////////////////////
40 namespace zypp
41 { /////////////////////////////////////////////////////////////////
42   /** \addtogroup ZyppConfig Zypp Configuration Options
43    *
44    * The global \c zypp.conf configuration file is per default located in \c /etc/zypp/.
45    * An alternate config file can be set using the environment varaible \c ZYPP_CONF=<PATH>
46    * (see \ref zypp-envars).
47    *
48    * \section ZyppConfig_ZyppConfSample Sample zypp.conf
49    * \include ../zypp.conf
50    */
51   ///////////////////////////////////////////////////////////////////
52   namespace
53   { /////////////////////////////////////////////////////////////////
54
55     /** Determine system architecture evaluating \c uname and \c /proc/cpuinfo.
56     */
57     Arch _autodetectSystemArchitecture()
58     {
59       struct ::utsname buf;
60       if ( ::uname( &buf ) < 0 )
61       {
62         ERR << "Can't determine system architecture" << endl;
63         return Arch_noarch;
64       }
65
66       Arch architecture( buf.machine );
67       MIL << "Uname architecture is '" << buf.machine << "'" << endl;
68
69       if ( architecture == Arch_i686 )
70       {
71         // some CPUs report i686 but dont implement cx8 and cmov
72         // check for both flags in /proc/cpuinfo and downgrade
73         // to i586 if either is missing (cf bug #18885)
74         std::ifstream cpuinfo( "/proc/cpuinfo" );
75         if ( cpuinfo )
76         {
77           for( iostr::EachLine in( cpuinfo ); in; in.next() )
78           {
79             if ( str::hasPrefix( *in, "flags" ) )
80             {
81               if (    in->find( "cx8" ) == std::string::npos
82                    || in->find( "cmov" ) == std::string::npos )
83               {
84                 architecture = Arch_i586;
85                 WAR << "CPU lacks 'cx8' or 'cmov': architecture downgraded to '" << architecture << "'" << endl;
86               }
87               break;
88             }
89           }
90         }
91         else
92         {
93           ERR << "Cant open " << PathInfo("/proc/cpuinfo") << endl;
94         }
95       }
96       else if ( architecture == Arch_sparc || architecture == Arch_sparc64 )
97       {
98         // Check for sun4[vum] to get the real arch. (bug #566291)
99         std::ifstream cpuinfo( "/proc/cpuinfo" );
100         if ( cpuinfo )
101         {
102           for( iostr::EachLine in( cpuinfo ); in; in.next() )
103           {
104             if ( str::hasPrefix( *in, "type" ) )
105             {
106               if ( in->find( "sun4v" ) != std::string::npos )
107               {
108                 architecture = ( architecture == Arch_sparc64 ? Arch_sparc64v : Arch_sparcv9v );
109                 WAR << "CPU has 'sun4v': architecture upgraded to '" << architecture << "'" << endl;
110               }
111               else if ( in->find( "sun4u" ) != std::string::npos )
112               {
113                 architecture = ( architecture == Arch_sparc64 ? Arch_sparc64 : Arch_sparcv9 );
114                 WAR << "CPU has 'sun4u': architecture upgraded to '" << architecture << "'" << endl;
115               }
116               else if ( in->find( "sun4m" ) != std::string::npos )
117               {
118                 architecture = Arch_sparcv8;
119                 WAR << "CPU has 'sun4m': architecture upgraded to '" << architecture << "'" << endl;
120               }
121               break;
122             }
123           }
124         }
125         else
126         {
127           ERR << "Cant open " << PathInfo("/proc/cpuinfo") << endl;
128         }
129       }
130       return architecture;
131     }
132
133      /** The locale to be used for texts and messages.
134      *
135      * For the encoding to be used the preference is
136      *
137      *    LC_ALL, LC_CTYPE, LANG
138      *
139      * For the language of the messages to be used, the preference is
140      *
141      *    LANGUAGE, LC_ALL, LC_MESSAGES, LANG
142      *
143      * Note that LANGUAGE can contain more than one locale name, it can be
144      * a list of locale names like for example
145      *
146      *    LANGUAGE=ja_JP.UTF-8:de_DE.UTF-8:fr_FR.UTF-8
147
148      * \todo Support dynamic fallbacklists defined by LANGUAGE
149      */
150     Locale _autodetectTextLocale()
151     {
152       Locale ret( "en" );
153       const char * envlist[] = { "LC_ALL", "LC_MESSAGES", "LANG", NULL };
154       for ( const char ** envvar = envlist; *envvar; ++envvar )
155       {
156         const char * envlang = getenv( *envvar );
157         if ( envlang )
158         {
159           std::string envstr( envlang );
160           if ( envstr != "POSIX" && envstr != "C" )
161           {
162             Locale lang( envstr );
163             if ( ! lang.code().empty() )
164             {
165               MIL << "Found " << *envvar << "=" << envstr << endl;
166               ret = lang;
167               break;
168             }
169           }
170         }
171       }
172       MIL << "Default text locale is '" << ret << "'" << endl;
173 #warning HACK AROUND BOOST_TEST_CATCH_SYSTEM_ERRORS
174       setenv( "BOOST_TEST_CATCH_SYSTEM_ERRORS", "no", 1 );
175       return ret;
176     }
177
178    /////////////////////////////////////////////////////////////////
179   } // namespace zypp
180   ///////////////////////////////////////////////////////////////////
181
182   /** Mutable option. */
183   template<class _Tp>
184       struct Option
185       {
186         typedef _Tp value_type;
187
188         /** No default ctor, explicit initialisation! */
189         Option( const value_type & initial_r )
190           : _val( initial_r )
191         {}
192
193         /** Get the value.  */
194         const value_type & get() const
195         { return _val; }
196
197         /** Autoconversion to value_type.  */
198         operator const value_type &() const
199         { return _val; }
200
201         /** Set a new value.  */
202         void set( const value_type & newval_r )
203         { _val = newval_r; }
204
205         /** Non-const reference to set a new value. */
206         value_type & ref()
207         { return _val; }
208
209         private:
210           value_type _val;
211       };
212
213   /** Mutable option with initial value also remembering a config value. */
214   template<class _Tp>
215       struct DefaultOption : public Option<_Tp>
216       {
217         typedef _Tp         value_type;
218         typedef Option<_Tp> option_type;
219
220         DefaultOption( const value_type & initial_r )
221           : Option<_Tp>( initial_r ), _default( initial_r )
222         {}
223
224         /** Reset value to the current default. */
225         void restoreToDefault()
226         { this->set( _default.get() ); }
227
228         /** Reset value to a new default. */
229         void restoreToDefault( const value_type & newval_r )
230         { setDefault( newval_r ); restoreToDefault(); }
231
232         /** Get the current default value. */
233         const value_type & getDefault() const
234         { return _default.get(); }
235
236         /** Set a new default value. */
237         void setDefault( const value_type & newval_r )
238         { _default.set( newval_r ); }
239
240         private:
241           option_type _default;
242       };
243
244   ///////////////////////////////////////////////////////////////////
245   //
246   //    CLASS NAME : ZConfig::Impl
247   //
248   /** ZConfig implementation.
249    * \todo Enrich section and entry definition by some comment
250    * (including the default setting and provide some method to
251    * write this into a sample zypp.conf.
252   */
253   class ZConfig::Impl
254   {
255     public:
256       Impl( const Pathname & override_r = Pathname() )
257         : _parsedZyppConf               ( override_r )
258         , cfg_arch                      ( defaultSystemArchitecture() )
259         , cfg_textLocale                ( defaultTextLocale() )
260         , updateMessagesNotify          ( "single | /usr/lib/zypp/notify-message -p %p" )
261         , repo_add_probe                ( false )
262         , repo_refresh_delay            ( 10 )
263         , repoLabelIsAlias              ( false )
264         , download_use_deltarpm         ( true )
265         , download_use_deltarpm_always  ( false )
266         , download_media_prefer_download( true )
267         , download_max_concurrent_connections( 5 )
268         , download_min_download_speed   ( 0 )
269         , download_max_download_speed   ( 0 )
270         , download_max_silent_tries     ( 5 )
271         , commit_downloadMode           ( DownloadDefault )
272         , solver_onlyRequires           ( false )
273         , solver_allowVendorChange      ( false )
274         , solver_cleandepsOnRemove      ( false )
275         , solver_upgradeTestcasesToKeep ( 2 )
276         , solverUpgradeRemoveDroppedPackages( true )
277         , apply_locks_file              ( true )
278         , pluginsPath                   ( "/usr/lib/zypp/plugins" )
279       {
280         MIL << "libzypp: " << VERSION << " built " << __DATE__ << " " <<  __TIME__ << endl;
281         // override_r has higest prio
282         // ZYPP_CONF might override /etc/zypp/zypp.conf
283         if ( _parsedZyppConf.empty() )
284         {
285           const char *env_confpath = getenv( "ZYPP_CONF" );
286           _parsedZyppConf = env_confpath ? env_confpath : "/etc/zypp/zypp.conf";
287         }
288         else
289         {
290           // Inject this into ZConfig. Be shure this is
291           // allocated via new. See: reconfigureZConfig
292           INT << "Reconfigure to " << _parsedZyppConf << endl;
293           ZConfig::instance()._pimpl.reset( this );
294         }
295         if ( PathInfo(_parsedZyppConf).isExist() )
296         {
297           parser::IniDict dict( _parsedZyppConf );
298           for ( IniDict::section_const_iterator sit = dict.sectionsBegin();
299                 sit != dict.sectionsEnd();
300                 ++sit )
301           {
302             string section(*sit);
303             //MIL << section << endl;
304             for ( IniDict::entry_const_iterator it = dict.entriesBegin(*sit);
305                   it != dict.entriesEnd(*sit);
306                   ++it )
307             {
308               string entry(it->first);
309               string value(it->second);
310               //DBG << (*it).first << "=" << (*it).second << endl;
311               if ( section == "main" )
312               {
313                 if ( entry == "arch" )
314                 {
315                   Arch carch( value );
316                   if ( carch != cfg_arch )
317                   {
318                     WAR << "Overriding system architecture (" << cfg_arch << "): " << carch << endl;
319                     cfg_arch = carch;
320                   }
321                 }
322                 else if ( entry == "cachedir" )
323                 {
324                   cfg_cache_path = Pathname(value);
325                 }
326                 else if ( entry == "metadatadir" )
327                 {
328                   cfg_metadata_path = Pathname(value);
329                 }
330                 else if ( entry == "solvfilesdir" )
331                 {
332                   cfg_solvfiles_path = Pathname(value);
333                 }
334                 else if ( entry == "packagesdir" )
335                 {
336                   cfg_packages_path = Pathname(value);
337                 }
338                 else if ( entry == "configdir" )
339                 {
340                   cfg_config_path = Pathname(value);
341                 }
342                 else if ( entry == "reposdir" )
343                 {
344                   cfg_known_repos_path = Pathname(value);
345                 }
346                 else if ( entry == "servicesdir" )
347                 {
348                   cfg_known_services_path = Pathname(value);
349                 }
350                 else if ( entry == "repo.add.probe" )
351                 {
352                   repo_add_probe = str::strToBool( value, repo_add_probe );
353                 }
354                 else if ( entry == "repo.refresh.delay" )
355                 {
356                   str::strtonum(value, repo_refresh_delay);
357                 }
358                 else if ( entry == "repo.refresh.locales" )
359                 {
360                   std::vector<std::string> tmp;
361                   str::split( value, back_inserter( tmp ), ", \t" );
362
363                   boost::function<Locale(const std::string &)> transform(
364                     [](const std::string & str_r)->Locale{ return Locale(str_r); }
365                   );
366                   repoRefreshLocales.insert( make_transform_iterator( tmp.begin(), transform ),
367                                              make_transform_iterator( tmp.end(), transform ) );
368                 }
369                 else if ( entry == "download.use_deltarpm" )
370                 {
371                   download_use_deltarpm = str::strToBool( value, download_use_deltarpm );
372                 }
373                 else if ( entry == "download.use_deltarpm.always" )
374                 {
375                   download_use_deltarpm_always = str::strToBool( value, download_use_deltarpm_always );
376                 }
377                 else if ( entry == "download.media_preference" )
378                 {
379                   download_media_prefer_download.restoreToDefault( str::compareCI( value, "volatile" ) != 0 );
380                 }
381                 else if ( entry == "download.max_concurrent_connections" )
382                 {
383                   str::strtonum(value, download_max_concurrent_connections);
384                 }
385                 else if ( entry == "download.min_download_speed" )
386                 {
387                   str::strtonum(value, download_min_download_speed);
388                 }
389                 else if ( entry == "download.max_download_speed" )
390                 {
391                   str::strtonum(value, download_max_download_speed);
392                 }
393                 else if ( entry == "download.max_silent_tries" )
394                 {
395                   str::strtonum(value, download_max_silent_tries);
396                 }
397                 else if ( entry == "commit.downloadMode" )
398                 {
399                   commit_downloadMode.set( deserializeDownloadMode( value ) );
400                 }
401                 else if ( entry == "vendordir" )
402                 {
403                   cfg_vendor_path = Pathname(value);
404                 }
405                 else if ( entry == "solver.onlyRequires" )
406                 {
407                   solver_onlyRequires.set( str::strToBool( value, solver_onlyRequires ) );
408                 }
409                 else if ( entry == "solver.allowVendorChange" )
410                 {
411                   solver_allowVendorChange.set( str::strToBool( value, solver_allowVendorChange ) );
412                 }
413                 else if ( entry == "solver.cleandepsOnRemove" )
414                 {
415                   solver_cleandepsOnRemove.set( str::strToBool( value, solver_cleandepsOnRemove ) );
416                 }
417                 else if ( entry == "solver.upgradeTestcasesToKeep" )
418                 {
419                   solver_upgradeTestcasesToKeep.set( str::strtonum<unsigned>( value ) );
420                 }
421                 else if ( entry == "solver.upgradeRemoveDroppedPackages" )
422                 {
423                   solverUpgradeRemoveDroppedPackages.restoreToDefault( str::strToBool( value, solverUpgradeRemoveDroppedPackages.getDefault() ) );
424                 }
425                 else if ( entry == "solver.checkSystemFile" )
426                 {
427                   solver_checkSystemFile = Pathname(value);
428                 }
429                 else if ( entry == "multiversion" )
430                 {
431                   str::split( value, inserter( multiversion, multiversion.end() ), ", \t" );
432                 }
433                 else if ( entry == "locksfile.path" )
434                 {
435                   locks_file = Pathname(value);
436                 }
437                 else if ( entry == "locksfile.apply" )
438                 {
439                   apply_locks_file = str::strToBool( value, apply_locks_file );
440                 }
441                 else if ( entry == "update.datadir" )
442                 {
443                   update_data_path = Pathname(value);
444                 }
445                 else if ( entry == "update.scriptsdir" )
446                 {
447                   update_scripts_path = Pathname(value);
448                 }
449                 else if ( entry == "update.messagessdir" )
450                 {
451                   update_messages_path = Pathname(value);
452                 }
453                 else if ( entry == "update.messages.notify" )
454                 {
455                   updateMessagesNotify.set( value );
456                 }
457                 else if ( entry == "rpm.install.excludedocs" )
458                 {
459                   rpmInstallFlags.setFlag( target::rpm::RPMINST_EXCLUDEDOCS,
460                                            str::strToBool( value, false ) );
461                 }
462                 else if ( entry == "history.logfile" )
463                 {
464                   history_log_path = Pathname(value);
465                 }
466                 else if ( entry == "credentials.global.dir" )
467                 {
468                   credentials_global_dir_path = Pathname(value);
469                 }
470                 else if ( entry == "credentials.global.file" )
471                 {
472                   credentials_global_file_path = Pathname(value);
473                 }
474               }
475             }
476           }
477         }
478         else
479         {
480           MIL << _parsedZyppConf << " not found, using defaults instead." << endl;
481           _parsedZyppConf = _parsedZyppConf.extend( " (NOT FOUND)" );
482         }
483
484         // legacy:
485         if ( getenv( "ZYPP_TESTSUITE_FAKE_ARCH" ) )
486         {
487           Arch carch( getenv( "ZYPP_TESTSUITE_FAKE_ARCH" ) );
488           if ( carch != cfg_arch )
489           {
490             WAR << "ZYPP_TESTSUITE_FAKE_ARCH: Overriding system architecture (" << cfg_arch << "): " << carch << endl;
491             cfg_arch = carch;
492           }
493         }
494         MIL << "ZConfig singleton created." << endl;
495       }
496
497       ~Impl()
498       {}
499
500     public:
501     /** Remember any parsed zypp.conf. */
502     Pathname _parsedZyppConf;
503
504     Arch     cfg_arch;
505     Locale   cfg_textLocale;
506
507     Pathname cfg_cache_path;
508     Pathname cfg_metadata_path;
509     Pathname cfg_solvfiles_path;
510     Pathname cfg_packages_path;
511
512     Pathname cfg_config_path;
513     Pathname cfg_known_repos_path;
514     Pathname cfg_known_services_path;
515
516     Pathname cfg_vendor_path;
517     Pathname locks_file;
518
519     Pathname update_data_path;
520     Pathname update_scripts_path;
521     Pathname update_messages_path;
522     DefaultOption<std::string> updateMessagesNotify;
523
524     bool        repo_add_probe;
525     unsigned    repo_refresh_delay;
526     LocaleSet   repoRefreshLocales;
527     bool        repoLabelIsAlias;
528
529     bool download_use_deltarpm;
530     bool download_use_deltarpm_always;
531     DefaultOption<bool> download_media_prefer_download;
532
533     int download_max_concurrent_connections;
534     int download_min_download_speed;
535     int download_max_download_speed;
536     int download_max_silent_tries;
537
538     Option<DownloadMode> commit_downloadMode;
539
540     Option<bool>        solver_onlyRequires;
541     Option<bool>        solver_allowVendorChange;
542     Option<bool>        solver_cleandepsOnRemove;
543     Option<unsigned>    solver_upgradeTestcasesToKeep;
544     DefaultOption<bool> solverUpgradeRemoveDroppedPackages;
545
546     Pathname solver_checkSystemFile;
547
548     std::set<std::string> multiversion;
549
550     bool apply_locks_file;
551
552     target::rpm::RpmInstFlags rpmInstallFlags;
553
554     Pathname history_log_path;
555     Pathname credentials_global_dir_path;
556     Pathname credentials_global_file_path;
557
558     Option<Pathname> pluginsPath;
559   };
560   ///////////////////////////////////////////////////////////////////
561
562   // Backdoor to redirect ZConfig from within the running
563   // TEST-application. HANDLE WITH CARE!
564   void reconfigureZConfig( const Pathname & override_r )
565   {
566     // ctor puts itself unter smart pointer control.
567     new ZConfig::Impl( override_r );
568   }
569
570   ///////////////////////////////////////////////////////////////////
571   //
572   //    METHOD NAME : ZConfig::instance
573   //    METHOD TYPE : ZConfig &
574   //
575   ZConfig & ZConfig::instance()
576   {
577     static ZConfig _instance; // The singleton
578     return _instance;
579   }
580
581   ///////////////////////////////////////////////////////////////////
582   //
583   //    METHOD NAME : ZConfig::ZConfig
584   //    METHOD TYPE : Ctor
585   //
586   ZConfig::ZConfig()
587   : _pimpl( new Impl )
588   {
589     about( MIL );
590   }
591
592   ///////////////////////////////////////////////////////////////////
593   //
594   //    METHOD NAME : ZConfig::~ZConfig
595   //    METHOD TYPE : Dtor
596   //
597   ZConfig::~ZConfig( )
598   {}
599
600   Pathname ZConfig::systemRoot() const
601   {
602     Target_Ptr target( getZYpp()->getTarget() );
603     return target ? target->root() : Pathname();
604   }
605
606   ///////////////////////////////////////////////////////////////////
607   //
608   // system architecture
609   //
610   ///////////////////////////////////////////////////////////////////
611
612   Arch ZConfig::defaultSystemArchitecture()
613   {
614     static Arch _val( _autodetectSystemArchitecture() );
615     return _val;
616   }
617
618   Arch ZConfig::systemArchitecture() const
619   { return _pimpl->cfg_arch; }
620
621   void ZConfig::setSystemArchitecture( const Arch & arch_r )
622   {
623     if ( arch_r != _pimpl->cfg_arch )
624     {
625       WAR << "Overriding system architecture (" << _pimpl->cfg_arch << "): " << arch_r << endl;
626       _pimpl->cfg_arch = arch_r;
627     }
628   }
629
630   ///////////////////////////////////////////////////////////////////
631   //
632   // text locale
633   //
634   ///////////////////////////////////////////////////////////////////
635
636   Locale ZConfig::defaultTextLocale()
637   {
638     static Locale _val( _autodetectTextLocale() );
639     return _val;
640   }
641
642   Locale ZConfig::textLocale() const
643   { return _pimpl->cfg_textLocale; }
644
645   void ZConfig::setTextLocale( const Locale & locale_r )
646   {
647     if ( locale_r != _pimpl->cfg_textLocale )
648     {
649       WAR << "Overriding text locale (" << _pimpl->cfg_textLocale << "): " << locale_r << endl;
650       _pimpl->cfg_textLocale = locale_r;
651 #warning prefer signal
652       sat::Pool::instance().setTextLocale( locale_r );
653     }
654   }
655
656   ///////////////////////////////////////////////////////////////////
657
658   Pathname ZConfig::repoCachePath() const
659   {
660     return ( _pimpl->cfg_cache_path.empty()
661         ? Pathname("/var/cache/zypp") : _pimpl->cfg_cache_path );
662   }
663
664   Pathname ZConfig::repoMetadataPath() const
665   {
666     return ( _pimpl->cfg_metadata_path.empty()
667         ? (repoCachePath()/"raw") : _pimpl->cfg_metadata_path );
668   }
669
670   Pathname ZConfig::repoSolvfilesPath() const
671   {
672     return ( _pimpl->cfg_solvfiles_path.empty()
673         ? (repoCachePath()/"solv") : _pimpl->cfg_solvfiles_path );
674   }
675
676   Pathname ZConfig::repoPackagesPath() const
677   {
678     return ( _pimpl->cfg_packages_path.empty()
679         ? (repoCachePath()/"packages") : _pimpl->cfg_packages_path );
680   }
681
682   ///////////////////////////////////////////////////////////////////
683
684   Pathname ZConfig::configPath() const
685   {
686     return ( _pimpl->cfg_config_path.empty()
687         ? Pathname("/etc/zypp") : _pimpl->cfg_config_path );
688   }
689
690   Pathname ZConfig::knownReposPath() const
691   {
692     return ( _pimpl->cfg_known_repos_path.empty()
693         ? (configPath()/"repos.d") : _pimpl->cfg_known_repos_path );
694   }
695
696   Pathname ZConfig::knownServicesPath() const
697   {
698     return ( _pimpl->cfg_known_services_path.empty()
699         ? (configPath()/"services.d") : _pimpl->cfg_known_repos_path );
700   }
701
702   Pathname ZConfig::vendorPath() const
703   {
704     return ( _pimpl->cfg_vendor_path.empty()
705         ? (configPath()/"vendors.d") : _pimpl->cfg_vendor_path );
706   }
707
708   Pathname ZConfig::locksFile() const
709   {
710     return ( _pimpl->locks_file.empty()
711         ? (configPath()/"locks") : _pimpl->locks_file );
712   }
713
714   ///////////////////////////////////////////////////////////////////
715
716   bool ZConfig::repo_add_probe() const
717   { return _pimpl->repo_add_probe; }
718
719   unsigned ZConfig::repo_refresh_delay() const
720   { return _pimpl->repo_refresh_delay; }
721
722   LocaleSet ZConfig::repoRefreshLocales() const
723   { return _pimpl->repoRefreshLocales.empty() ? Target::requestedLocales("") :_pimpl->repoRefreshLocales; }
724
725   bool ZConfig::repoLabelIsAlias() const
726   { return _pimpl->repoLabelIsAlias; }
727
728   void ZConfig::repoLabelIsAlias( bool yesno_r )
729   { _pimpl->repoLabelIsAlias = yesno_r; }
730
731   bool ZConfig::download_use_deltarpm() const
732   { return _pimpl->download_use_deltarpm; }
733
734   bool ZConfig::download_use_deltarpm_always() const
735   { return download_use_deltarpm() && _pimpl->download_use_deltarpm_always; }
736
737   bool ZConfig::download_media_prefer_download() const
738   { return _pimpl->download_media_prefer_download; }
739
740   void ZConfig::set_download_media_prefer_download( bool yesno_r )
741   { _pimpl->download_media_prefer_download.set( yesno_r ); }
742
743   void ZConfig::set_default_download_media_prefer_download()
744   { _pimpl->download_media_prefer_download.restoreToDefault(); }
745
746   long ZConfig::download_max_concurrent_connections() const
747   { return _pimpl->download_max_concurrent_connections; }
748
749   long ZConfig::download_min_download_speed() const
750   { return _pimpl->download_min_download_speed; }
751
752   long ZConfig::download_max_download_speed() const
753   { return _pimpl->download_max_download_speed; }
754
755   long ZConfig::download_max_silent_tries() const
756   { return _pimpl->download_max_silent_tries; }
757
758   DownloadMode ZConfig::commit_downloadMode() const
759   { return _pimpl->commit_downloadMode; }
760
761   bool ZConfig::solver_onlyRequires() const
762   { return _pimpl->solver_onlyRequires; }
763
764   bool ZConfig::solver_allowVendorChange() const
765   { return _pimpl->solver_allowVendorChange; }
766
767   bool ZConfig::solver_cleandepsOnRemove() const
768   { return _pimpl->solver_cleandepsOnRemove; }
769
770   Pathname ZConfig::solver_checkSystemFile() const
771   { return ( _pimpl->solver_checkSystemFile.empty()
772       ? (configPath()/"systemCheck") : _pimpl->solver_checkSystemFile ); }
773
774   unsigned ZConfig::solver_upgradeTestcasesToKeep() const
775   { return _pimpl->solver_upgradeTestcasesToKeep; }
776
777   bool ZConfig::solverUpgradeRemoveDroppedPackages() const              { return _pimpl->solverUpgradeRemoveDroppedPackages; }
778   void ZConfig::setSolverUpgradeRemoveDroppedPackages( bool val_r )     { _pimpl->solverUpgradeRemoveDroppedPackages.set( val_r ); }
779   void ZConfig::resetSolverUpgradeRemoveDroppedPackages()               { _pimpl->solverUpgradeRemoveDroppedPackages.restoreToDefault(); }
780
781   const std::set<std::string> & ZConfig::multiversionSpec() const       { return _pimpl->multiversion; }
782   void ZConfig::addMultiversionSpec( const std::string & name_r )       { _pimpl->multiversion.insert( name_r ); }
783   void ZConfig::removeMultiversionSpec( const std::string & name_r )    { _pimpl->multiversion.erase( name_r ); }
784
785   bool ZConfig::apply_locks_file() const
786   { return _pimpl->apply_locks_file; }
787
788   Pathname ZConfig::update_dataPath() const
789   {
790     return ( _pimpl->update_data_path.empty()
791         ? Pathname("/var/adm") : _pimpl->update_data_path );
792   }
793
794   Pathname ZConfig::update_messagesPath() const
795   {
796     return ( _pimpl->update_messages_path.empty()
797              ? Pathname(update_dataPath()/"update-messages") : _pimpl->update_messages_path );
798   }
799
800   Pathname ZConfig::update_scriptsPath() const
801   {
802     return ( _pimpl->update_scripts_path.empty()
803              ? Pathname(update_dataPath()/"update-scripts") : _pimpl->update_scripts_path );
804   }
805
806   std::string ZConfig::updateMessagesNotify() const
807   { return _pimpl->updateMessagesNotify; }
808
809   void ZConfig::setUpdateMessagesNotify( const std::string & val_r )
810   { _pimpl->updateMessagesNotify.set( val_r ); }
811
812   void ZConfig::resetUpdateMessagesNotify()
813   { _pimpl->updateMessagesNotify.restoreToDefault(); }
814
815   ///////////////////////////////////////////////////////////////////
816
817   target::rpm::RpmInstFlags ZConfig::rpmInstallFlags() const
818   { return _pimpl->rpmInstallFlags; }
819
820
821   Pathname ZConfig::historyLogFile() const
822   {
823     return ( _pimpl->history_log_path.empty() ?
824         Pathname("/var/log/zypp/history") : _pimpl->history_log_path );
825   }
826
827
828   Pathname ZConfig::credentialsGlobalDir() const
829   {
830     return ( _pimpl->credentials_global_dir_path.empty() ?
831         Pathname("/etc/zypp/credentials.d") : _pimpl->credentials_global_dir_path );
832   }
833
834   Pathname ZConfig::credentialsGlobalFile() const
835   {
836     return ( _pimpl->credentials_global_file_path.empty() ?
837         Pathname("/etc/zypp/credentials.cat") : _pimpl->credentials_global_file_path );
838   }
839
840   ///////////////////////////////////////////////////////////////////
841
842   std::string ZConfig::distroverpkg() const
843   { return "redhat-release"; }
844
845   ///////////////////////////////////////////////////////////////////
846
847   Pathname ZConfig::pluginsPath() const
848   { return _pimpl->pluginsPath.get(); }
849
850   ///////////////////////////////////////////////////////////////////
851
852   std::ostream & ZConfig::about( std::ostream & str ) const
853   {
854     str << "libzypp: " << VERSION << " built " << __DATE__ << " " <<  __TIME__ << endl;
855
856     str << "libsolv: " << solv_version;
857     if ( ::strcmp( solv_version, LIBSOLV_VERSION_STRING ) )
858       str << " (built against " << LIBSOLV_VERSION_STRING << ")";
859     str << endl;
860
861     str << "zypp.conf: '" << _pimpl->_parsedZyppConf << "'" << endl;
862     str << "TextLocale: '" << textLocale() << "' (" << defaultTextLocale() << ")" << endl;
863     str << "SystemArchitecture: '" << systemArchitecture() << "' (" << defaultSystemArchitecture() << ")" << endl;
864     return str;
865   }
866
867   /////////////////////////////////////////////////////////////////
868 } // namespace zypp
869 ///////////////////////////////////////////////////////////////////