Add zypp.conf option commit.downloadMode to set the default commit download policy.
[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/DownloadMode.h"
29 #include "zypp/target/rpm/RpmFlags.h"
30
31 ///////////////////////////////////////////////////////////////////
32 namespace zypp
33 { /////////////////////////////////////////////////////////////////
34
35   ///////////////////////////////////////////////////////////////////
36   //
37   //    CLASS NAME : ZConfig
38   //
39   /** Interim helper class to collect global options and settings.
40    * Use it to avoid hardcoded values and calls to getZYpp() just
41    * to retrieve some value like architecture, languages or tmppath.
42    *
43    * It reads /etc/zypp/zypp.conf, the filename can be overridden by
44    * setting the ZYPP_CONF environment variable to a different file.
45    *
46    * Note, if you add settings to this file, please follow the following
47    * convention:
48    *
49    * namespace.settingname
50    *
51    * should become
52    *
53    * namespace_settingName()
54    *
55    * \ingroup Singleton
56   */
57   class ZConfig : private base::NonCopyable
58   {
59     public:
60
61       /** Singleton ctor */
62       static ZConfig & instance();
63
64       /** Print some detail about the current libzypp version.*/
65       std::ostream & about( std::ostream & str ) const;
66
67     public:
68
69       /** The target root directory. */
70       Pathname systemRoot() const;
71
72     public:
73
74       /** The autodetected system architecture. */
75       static Arch defaultSystemArchitecture();
76
77       /** The system architecture zypp uses. */
78       Arch systemArchitecture() const;
79
80       /** Override the zypp system architecture.
81        * This is useful for test scenarious. <b>But be warned</b>, zypp does
82        * not expect the system architecture to change at runtime. So
83        * set it at the verry beginning before you acess any other
84        * zypp component.
85       */
86       void setSystemArchitecture( const Arch & arch_r );
87
88       /** Reset the zypp system architecture to the default. */
89       void resetSystemArchitecture()
90       { setSystemArchitecture( defaultSystemArchitecture() ); }
91
92     public:
93       /** The autodetected prefered locale for translated texts.
94        */
95       static Locale defaultTextLocale();
96
97       /** The locale for translated texts zypp uses.
98        */
99       Locale textLocale() const;
100
101       /** Set the prefered locale for translated texts. */
102       void setTextLocale( const Locale & locale_r );
103
104       /** Reset the locale for translated texts to the default. */
105       void resetTextLocale()
106       { setTextLocale( defaultTextLocale() ); }
107
108     public:
109       /**
110        * Path where the caches are kept (/var/cache/zypp)
111        * \ingroup g_ZC_REPOCACHE
112        */
113       Pathname repoCachePath() const;
114
115      /**
116        * Path where the repo metadata is downloaded and kept (repoCachePath()/raw).
117         * \ingroup g_ZC_REPOCACHE
118       */
119       Pathname repoMetadataPath() const;
120
121      /**
122        * Path where the repo solv files are created and kept (repoCachePath()/solv).
123         * \ingroup g_ZC_REPOCACHE
124       */
125       Pathname repoSolvfilesPath() const;
126
127       /**
128        * Path where the repo packages are downloaded and kept (repoCachePath()/packages).
129         * \ingroup g_ZC_REPOCACHE
130       */
131       Pathname repoPackagesPath() const;
132
133       /**
134        * Path where the configfiles are kept (/etc/zypp).
135        * \ingroup g_ZC_CONFIGFILES
136        */
137       Pathname configPath() const;
138
139       /**
140        * Path where the known repositories .repo files are kept (configPath()/repos.d).
141        * \ingroup g_ZC_CONFIGFILES
142        */
143       Pathname knownReposPath() const;
144
145       /**
146        * Path where the known services .service files are kept (configPath()/services.d).
147        * \ingroup g_ZC_CONFIGFILES
148        */
149       Pathname knownServicesPath() const;
150
151       /**
152        * Whether repository urls should be probed.
153        / config option
154        * repo.add.probe
155        */
156       bool repo_add_probe() const;
157
158       /**
159        * Amount of time in minutes that must pass before another refresh.
160        */
161       unsigned repo_refresh_delay() const;
162
163       /**
164        * Maximum number of concurrent connections for a single transfer
165        */
166       long download_max_concurrent_connections() const;
167
168       /**
169        * Minimum download speed (bytes per second)
170        * until the connection is dropped
171        */
172       long download_min_download_speed() const;
173
174       /**
175        * Maximum download speed (bytes per second)
176        */
177       long download_max_download_speed() const;
178
179       /**
180        * Maximum silent tries
181        */
182       long download_max_silent_tries() const;
183
184
185       /** Whether to consider using a deltarpm when downloading a package.
186        * Config option <tt>download.use_deltarpm (true)</tt>
187        */
188       bool download_use_deltarpm() const;
189
190       /** Whether to consider using a deltarpm even when rpm is local.
191        * This requires \ref download_use_deltarpm being \c true.
192        * Config option <tt>download.use_deltarpm.always (false)</tt>
193        */
194       bool download_use_deltarpm_always() const;
195
196       /**
197        * Hint which media to prefer when installing packages (download vs. CD).
198        * \see class \ref media::MediaPriority
199        */
200       bool download_media_prefer_download() const;
201       /** \overload */
202       bool download_media_prefer_volatile() const
203       { return ! download_media_prefer_download(); }
204       /**
205        * Set \ref download_media_prefer_download to a specific value.
206        */
207       void set_download_media_prefer_download( bool yesno_r );
208       /**
209        * Set \ref download_media_prefer_download to the configfiles default.
210        */
211       void set_default_download_media_prefer_download();
212
213       /**
214        * Commit download policy to use as default.
215        */
216       DownloadMode commit_downloadMode() const;
217
218       /**
219        * Directory for equivalent vendor definitions  (configPath()/vendors.d)
220        * \ingroup g_ZC_CONFIGFILES
221        */
222       Pathname vendorPath() const;
223
224       /**
225        * Solver regards required packages,patterns,... only
226        */
227       bool solver_onlyRequires() const;
228
229       /**
230        * File in which dependencies described which has to be
231        * fulfilled for a running system.
232        */
233       Pathname solver_checkSystemFile() const;
234
235       /**
236        * Whether vendor check is by default enabled.
237        */
238       bool solver_allowVendorChange() const;
239
240       /**
241        * When committing a dist upgrade (e.g. <tt>zypper dup</tt>)
242        * a solver testcase is written. It is needed in bugreports,
243        * in case something went wrong. This returns the number of
244        * testcases to keep on the system. Old cases will be deleted,
245        * as new ones are created. Use \c 0 to write no testcase at all.
246        */
247       unsigned solver_upgradeTestcasesToKeep() const;
248
249       /**
250        * Packages which can be installed parallel with different versions
251        * Returning a set of package names (IdString)
252        */
253       std::set<IdString> multiversion() const;
254       void addMultiversion(std::string &name);
255       bool removeMultiversion(std::string &name);
256
257       /**
258        * Path where zypp can find or create lock file (configPath()/locks)
259        * \ingroup g_ZC_CONFIGFILES
260        */
261       Pathname locksFile() const;
262
263       /**
264        * Whether locks file should be read and applied after start (true)
265        */
266       bool apply_locks_file() const;
267
268       /**
269        * Path where the update items are kept (/var/adm)
270        */
271       Pathname update_dataPath() const;
272
273      /**
274       * Path where the repo metadata is downloaded and kept (update_dataPath()/).
275       * \ingroup g_ZC_REPOCACHE
276       */
277       Pathname update_scriptsPath() const;
278
279      /**
280       * Path where the repo solv files are created and kept (update_dataPath()/solv).
281       * \ingroup g_ZC_REPOCACHE
282       */
283       Pathname update_messagesPath() const;
284
285       /** \name Options for package installation */
286       //@{
287       /** The default \ref target::rpm::RpmInstFlags for \ref ZYppCommitPolicy.
288        * Or-combination of \ref target::rpm::RpmInstFlag.
289        * \code
290        * ZConfig.instance().rpmInstallFlags().testFlag( target::rpm::RPMINST_EXCLUDEDOCS );
291        * \endcode
292        */
293       target::rpm::RpmInstFlags rpmInstallFlags() const;
294       //@}
295
296       /**
297        * Path where ZYpp install history is logged. Defaults to
298        * /var/log/zypp/history.
299        *
300        * \see http://en.opensuse.org/Libzypp/Package_History
301        */
302       Pathname historyLogFile() const;
303
304       /**
305        * Defaults to /etc/zypp/credentials.d
306        */
307       Pathname credentialsGlobalDir() const;
308
309       /**
310        * Defaults to /etc/zypp/credentials.cat
311        */
312       Pathname credentialsGlobalFile() const;
313
314
315       /** Package telling the "product version" on systems not using /etc/product.d/baseproduct.
316        *
317        * On RHEL, Fedora and others the "product version" is determined by the first package
318        * providing 'redhat-release'. This value is not hardcoded in YUM and can be configured
319        * with the $distroverpkg variable.
320        *
321        * Defaults to 'redhat-release'.
322        */
323       std::string distroverpkg() const;
324
325     public:
326       class Impl;
327       /** Dtor */
328       ~ZConfig();
329     private:
330       friend class Impl;
331       /** Default ctor. */
332       ZConfig();
333       /** Pointer to implementation */
334       RW_pointer<Impl, rw_pointer::Scoped<Impl> > _pimpl;
335   };
336   ///////////////////////////////////////////////////////////////////
337
338   /////////////////////////////////////////////////////////////////
339 } // namespace zypp
340 ///////////////////////////////////////////////////////////////////
341 #endif // ZYPP_ZCONFIG_H