- new History Log, first version (fate #110205)
[platform/upstream/libzypp.git] / zypp / ZConfig.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/ZConfig.h
10  *
11 */
12 #ifndef ZYPP_ZCONFIG_H
13 #define ZYPP_ZCONFIG_H
14
15 #include <iosfwd>
16 #include <set>
17 #include <string>
18
19 #include "zypp/base/Deprecated.h"
20 #include "zypp/base/NonCopyable.h"
21 #include "zypp/base/PtrTypes.h"
22
23 #include "zypp/Arch.h"
24 #include "zypp/Locale.h"
25 #include "zypp/Pathname.h"
26 #include "zypp/IdString.h"
27
28 #include "zypp/target/rpm/RpmFlags.h"
29
30 ///////////////////////////////////////////////////////////////////
31 namespace zypp
32 { /////////////////////////////////////////////////////////////////
33
34   ///////////////////////////////////////////////////////////////////
35   //
36   //    CLASS NAME : ZConfig
37   //
38   /** Interim helper class to collect global options and settings.
39    * Use it to avoid hardcoded values and calls to getZYpp() just
40    * to retrieve some value like architecture, languages or tmppath.
41    *
42    * It reads /etc/zypp/zypp.conf, the filename can be overridden by
43    * setting the ZYPP_CONF environment variable to a different file.
44    *
45    * Note, if you add settings to this file, please follow the following
46    * convention:
47    *
48    * namespace.settingname
49    *
50    * should become
51    *
52    * namespace_settingName()
53    *
54    * \ingroup Singleton
55   */
56   class ZConfig : private base::NonCopyable
57   {
58     public:
59       /** Singleton ctor */
60       static ZConfig & instance();
61
62     public:
63
64       /** The autodetected system architecture. */
65       static Arch defaultSystemArchitecture();
66
67       /** The system architecture zypp uses. */
68       Arch systemArchitecture() const;
69
70       /** Override the zypp system architecture.
71        * This is useful for test scenarious. <b>But be warned</b>, zypp does
72        * not expect the system architecture to change at runtime. So
73        * set it at the verry beginning before you acess any other
74        * zypp component.
75       */
76       void setSystemArchitecture( const Arch & arch_r );
77
78       /** Reset the zypp system architecture to the default. */
79       void resetSystemArchitecture()
80       { setSystemArchitecture( defaultSystemArchitecture() ); }
81
82     public:
83       /** The autodetected prefered locale for translated texts.
84        */
85       static Locale defaultTextLocale();
86
87       /** The locale for translated texts zypp uses.
88        */
89       Locale textLocale() const;
90
91       /** Set the prefered locale for translated texts. */
92       void setTextLocale( const Locale & locale_r );
93
94       /** Reset the locale for translated texts to the default. */
95       void resetTextLocale()
96       { setTextLocale( defaultTextLocale() ); }
97
98     public:
99       /**
100        * Path where the caches are kept (/var/cache/zypp)
101        * \ingroup g_ZC_REPOCACHE
102        */
103       Pathname repoCachePath() const;
104
105      /**
106        * Path where the repo metadata is downloaded and kept (repoCachePath()/raw).
107         * \ingroup g_ZC_REPOCACHE
108       */
109       Pathname repoMetadataPath() const;
110
111      /**
112        * Path where the repo solv files are created and kept (repoCachePath()/solv).
113         * \ingroup g_ZC_REPOCACHE
114       */
115       Pathname repoSolvfilesPath() const;
116
117       /**
118        * Path where the repo packages are downloaded and kept (repoCachePath()/packages).
119         * \ingroup g_ZC_REPOCACHE
120       */
121       Pathname repoPackagesPath() const;
122
123       /**
124        * Path where the configfiles are kept (/etc/zypp).
125        * \ingroup g_ZC_CONFIGFILES
126        */
127       Pathname configPath() const;
128
129       /**
130        * Path where the known repositories .repo files are kept (configPath()/repos.d).
131        * \ingroup g_ZC_CONFIGFILES
132        */
133       Pathname knownReposPath() const;
134
135       /**
136        * Path where the known services .service files are kept (configPath()/services.d).
137        * \ingroup g_ZC_CONFIGFILES
138        */
139       Pathname knownServicesPath() const;
140
141       /**
142        * Whether repository urls should be probed.
143        / config option
144        * repo.add.probe
145        */
146       bool repo_add_probe() const;
147
148       /**
149        * Amount of time in minutes that must pass before another refresh.
150        */
151       unsigned repo_refresh_delay() const;
152
153       /** Whether to consider using a deltarpm when downloading a package.
154        * Config option <tt>download.use_deltarpm (true)</tt>
155        */
156       bool download_use_deltarpm() const;
157
158       /**
159        * Directory for equivalent vendor definitions  (configPath()/vendors.d)
160        * \ingroup g_ZC_CONFIGFILES
161        */
162       Pathname vendorPath() const;
163
164       /**
165        * Directory for additional product information  (configPath()/products.d)
166        * \ingroup g_ZC_CONFIGFILES
167        */
168       Pathname productsPath() const;
169
170       /**
171        * Solver regards required packages,patterns,... only
172        */
173       bool solver_onlyRequires() const;
174
175       /**
176        * File in which dependencies described which has to be
177        * fulfilled for a running system.
178        */
179       Pathname solver_checkSystemFile() const;
180
181       /**
182        * Packages which can be installed parallel with different versions
183        * Returning a set of package names (IdString)
184        */
185       std::set<IdString> multiversion() const;
186       void addMultiversion(std::string &name);
187       bool removeMultiversion(std::string &name);
188
189       /**
190        * Path where zypp can find or create lock file (configPath()/locks)
191        * \ingroup g_ZC_CONFIGFILES
192        */
193       Pathname locksFile() const;
194
195       /**
196        * Whether locks file should be read and applied after start (true)
197        */
198       bool apply_locks_file() const;
199
200       /**
201        * Path where the update items are kept (/var/adm)
202        */
203       Pathname update_dataPath() const;
204
205      /**
206       * Path where the repo metadata is downloaded and kept (update_dataPath()/).
207       * \ingroup g_ZC_REPOCACHE
208       */
209       Pathname update_scriptsPath() const;
210
211      /**
212       * Path where the repo solv files are created and kept (update_dataPath()/solv).
213       * \ingroup g_ZC_REPOCACHE
214       */
215       Pathname update_messagesPath() const;
216
217       /** \name Options for package installation */
218       //@{
219       /** The default \ref target::rpm::RpmInstFlags for \ref ZYppCommitPolicy.
220        * Or-combination of \ref target::rpm::RpmInstFlag.
221        * \code
222        * ZConfig.instance().rpmInstallFlags().testFlag( target::rpm::RPMINST_EXCLUDEDOCS );
223        * \endcode
224        */
225       target::rpm::RpmInstFlags rpmInstallFlags() const;
226       //@}
227
228       Pathname historyLogFile() const;
229
230     public:
231       class Impl;
232       /** Dtor */
233       ~ZConfig();
234     private:
235       friend class Impl;
236       /** Default ctor. */
237       ZConfig();
238       /** Pointer to implementation */
239       RW_pointer<Impl, rw_pointer::Scoped<Impl> > _pimpl;
240   };
241   ///////////////////////////////////////////////////////////////////
242
243   /////////////////////////////////////////////////////////////////
244 } // namespace zypp
245 ///////////////////////////////////////////////////////////////////
246 #endif // ZYPP_ZCONFIG_H