Merge branch 'master' of git@git.opensuse.org:projects/zypp/libzypp
[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
60       /** Singleton ctor */
61       static ZConfig & instance();
62
63       /** Print some detail about the current libzypp version.*/
64       std::ostream & about( std::ostream & str ) const;
65
66     public:
67
68       /** The autodetected system architecture. */
69       static Arch defaultSystemArchitecture();
70
71       /** The system architecture zypp uses. */
72       Arch systemArchitecture() const;
73
74       /** Override the zypp system architecture.
75        * This is useful for test scenarious. <b>But be warned</b>, zypp does
76        * not expect the system architecture to change at runtime. So
77        * set it at the verry beginning before you acess any other
78        * zypp component.
79       */
80       void setSystemArchitecture( const Arch & arch_r );
81
82       /** Reset the zypp system architecture to the default. */
83       void resetSystemArchitecture()
84       { setSystemArchitecture( defaultSystemArchitecture() ); }
85
86     public:
87       /** The autodetected prefered locale for translated texts.
88        */
89       static Locale defaultTextLocale();
90
91       /** The locale for translated texts zypp uses.
92        */
93       Locale textLocale() const;
94
95       /** Set the prefered locale for translated texts. */
96       void setTextLocale( const Locale & locale_r );
97
98       /** Reset the locale for translated texts to the default. */
99       void resetTextLocale()
100       { setTextLocale( defaultTextLocale() ); }
101
102     public:
103       /**
104        * Path where the caches are kept (/var/cache/zypp)
105        * \ingroup g_ZC_REPOCACHE
106        */
107       Pathname repoCachePath() const;
108
109      /**
110        * Path where the repo metadata is downloaded and kept (repoCachePath()/raw).
111         * \ingroup g_ZC_REPOCACHE
112       */
113       Pathname repoMetadataPath() const;
114
115      /**
116        * Path where the repo solv files are created and kept (repoCachePath()/solv).
117         * \ingroup g_ZC_REPOCACHE
118       */
119       Pathname repoSolvfilesPath() const;
120
121       /**
122        * Path where the repo packages are downloaded and kept (repoCachePath()/packages).
123         * \ingroup g_ZC_REPOCACHE
124       */
125       Pathname repoPackagesPath() const;
126
127       /**
128        * Path where the configfiles are kept (/etc/zypp).
129        * \ingroup g_ZC_CONFIGFILES
130        */
131       Pathname configPath() const;
132
133       /**
134        * Path where the known repositories .repo files are kept (configPath()/repos.d).
135        * \ingroup g_ZC_CONFIGFILES
136        */
137       Pathname knownReposPath() const;
138
139       /**
140        * Path where the known services .service files are kept (configPath()/services.d).
141        * \ingroup g_ZC_CONFIGFILES
142        */
143       Pathname knownServicesPath() const;
144
145       /**
146        * Whether repository urls should be probed.
147        / config option
148        * repo.add.probe
149        */
150       bool repo_add_probe() const;
151
152       /**
153        * Amount of time in minutes that must pass before another refresh.
154        */
155       unsigned repo_refresh_delay() const;
156
157       /**
158        * Maximum number of concurrent connections for a single transfer
159        */
160       long download_max_concurrent_connections() const;
161
162       /**
163        * Minimum download speed (bytes per second)
164        * until the connection is dropped
165        */
166       long download_min_download_speed() const;
167
168       /**
169        * Maximum download speed (bytes per second)
170        */
171       long download_max_download_speed() const;
172
173       /**
174        * Maximum silent tries
175        */
176       long download_max_silent_tries() const;
177
178
179       /** Whether to consider using a deltarpm when downloading a package.
180        * Config option <tt>download.use_deltarpm (true)</tt>
181        */
182       bool download_use_deltarpm() const;
183
184       /** Whether to consider using a deltarpm even when rpm is local.
185        * This requires \ref download_use_deltarpm being \c true.
186        * Config option <tt>download.use_deltarpm.always (false)</tt>
187        */
188       bool download_use_deltarpm_always() const;
189
190       /**
191        * Hint which media to prefer when installing packages (download vs. CD).
192        * \see class \ref media::MediaPriority
193        */
194       bool download_media_prefer_download() const;
195       /** \overload */
196       bool download_media_prefer_volatile() const
197       { return ! download_media_prefer_download(); }
198       /**
199        * Set \ref download_media_prefer_download to a specific value.
200        */
201       void set_download_media_prefer_download( bool yesno_r );
202       /**
203        * Set \ref download_media_prefer_download to the configfiles default.
204        */
205       void set_default_download_media_prefer_download();
206
207       /**
208        * Directory for equivalent vendor definitions  (configPath()/vendors.d)
209        * \ingroup g_ZC_CONFIGFILES
210        */
211       Pathname vendorPath() const;
212
213       /**
214        * Directory for additional product information  (configPath()/products.d)
215        * \ingroup g_ZC_CONFIGFILES
216        * \deprecated This locations is no longer used or supported.
217        */
218       Pathname productsPath() const ZYPP_DEPRECATED;
219
220       /**
221        * Solver regards required packages,patterns,... only
222        */
223       bool solver_onlyRequires() const;
224
225       /**
226        * File in which dependencies described which has to be
227        * fulfilled for a running system.
228        */
229       Pathname solver_checkSystemFile() const;
230
231       /**
232        * Packages which can be installed parallel with different versions
233        * Returning a set of package names (IdString)
234        */
235       std::set<IdString> multiversion() const;
236       void addMultiversion(std::string &name);
237       bool removeMultiversion(std::string &name);
238
239       /**
240        * Path where zypp can find or create lock file (configPath()/locks)
241        * \ingroup g_ZC_CONFIGFILES
242        */
243       Pathname locksFile() const;
244
245       /**
246        * Whether locks file should be read and applied after start (true)
247        */
248       bool apply_locks_file() const;
249
250       /**
251        * Path where the update items are kept (/var/adm)
252        */
253       Pathname update_dataPath() const;
254
255      /**
256       * Path where the repo metadata is downloaded and kept (update_dataPath()/).
257       * \ingroup g_ZC_REPOCACHE
258       */
259       Pathname update_scriptsPath() const;
260
261      /**
262       * Path where the repo solv files are created and kept (update_dataPath()/solv).
263       * \ingroup g_ZC_REPOCACHE
264       */
265       Pathname update_messagesPath() const;
266
267       /** \name Options for package installation */
268       //@{
269       /** The default \ref target::rpm::RpmInstFlags for \ref ZYppCommitPolicy.
270        * Or-combination of \ref target::rpm::RpmInstFlag.
271        * \code
272        * ZConfig.instance().rpmInstallFlags().testFlag( target::rpm::RPMINST_EXCLUDEDOCS );
273        * \endcode
274        */
275       target::rpm::RpmInstFlags rpmInstallFlags() const;
276       //@}
277
278       /**
279        * Path where ZYpp install history is logged. Defaults to
280        * /var/log/zypp/history.
281        *
282        * \see http://en.opensuse.org/Libzypp/Package_History
283        */
284       Pathname historyLogFile() const;
285
286       /**
287        * Defaults to /etc/zypp/credentials.d
288        */
289       Pathname credentialsGlobalDir() const;
290
291       /**
292        * Defaults to /etc/zypp/credentials.cat
293        */
294       Pathname credentialsGlobalFile() const;
295
296     public:
297       class Impl;
298       /** Dtor */
299       ~ZConfig();
300     private:
301       friend class Impl;
302       /** Default ctor. */
303       ZConfig();
304       /** Pointer to implementation */
305       RW_pointer<Impl, rw_pointer::Scoped<Impl> > _pimpl;
306   };
307   ///////////////////////////////////////////////////////////////////
308
309   /////////////////////////////////////////////////////////////////
310 } // namespace zypp
311 ///////////////////////////////////////////////////////////////////
312 #endif // ZYPP_ZCONFIG_H