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