- Propagate default rpm install flags from zypp.conf via ZConfig and
[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        * Separator string for storing/reading sets of strings to/from
143        * metadata cache DB.
144        */
145       const std::string & cacheDBSplitJoinSeparator() const;
146
147       /**
148        * Whether repository urls should be probed.
149        / config option
150        * repo.add.probe
151        */
152       bool repo_add_probe() const;
153
154       /**
155        * Amount of time in minutes that must pass before another refresh.
156        */
157       unsigned repo_refresh_delay() const;
158
159       /** Whether to consider using a deltarpm when downloading a package.
160        * Config option <tt>download.use_deltarpm (true)</tt>
161        */
162       bool download_use_deltarpm() const;
163
164       /**
165        * Directory for equivalent vendor definitions  (configPath()/vendors.d)
166        * \ingroup g_ZC_CONFIGFILES
167        */
168       Pathname vendorPath() const;
169
170       /**
171        * Directory for additional product information  (configPath()/products.d)
172        * \ingroup g_ZC_CONFIGFILES
173        */
174       Pathname productsPath() const;
175
176       /**
177        * Solver regards required packages,patterns,... only
178        */
179       bool solver_onlyRequires() const;
180
181       /**
182        * File in which dependencies described which has to be
183        * fulfilled for a running system.
184        */
185       Pathname solver_checkSystemFile() const;
186
187       /**
188        * Packages which can be installed parallel with different versions
189        * Returning a set of package names (IdString)
190        */
191       std::set<IdString> multiversion() const;
192       void addMultiversion(std::string &name);
193       bool removeMultiversion(std::string &name);
194
195       /**
196        * Path where zypp can find or create lock file (configPath()/locks)
197        * \ingroup g_ZC_CONFIGFILES
198        */
199       Pathname locksFile() const;
200
201       /**
202        * Whether locks file should be read and applied after start (true)
203        */
204       bool apply_locks_file() const;
205
206       /**
207        * Path where the update items are kept (/var/adm)
208        */
209       Pathname update_dataPath() const;
210
211      /**
212       * Path where the repo metadata is downloaded and kept (update_dataPath()/).
213       * \ingroup g_ZC_REPOCACHE
214       */
215       Pathname update_scriptsPath() const;
216
217      /**
218       * Path where the repo solv files are created and kept (update_dataPath()/solv).
219       * \ingroup g_ZC_REPOCACHE
220       */
221       Pathname update_messagesPath() const;
222
223     public:
224       /** \name Options for package installation */
225       //@{
226       /** The default \ref target::rpm::RpmInstFlags for \ref ZYppCommitPolicy.
227        * Or-combination of \ref target::rpm::RpmInstFlag.
228        * \code
229        * ZConfig.instance().rpmInstallFlags().testFlag( target::rpm::RPMINST_EXCLUDEDOCS );
230        * \endcode
231        */
232       target::rpm::RpmInstFlags rpmInstallFlags() const;
233       //@}
234
235     public:
236       class Impl;
237       /** Dtor */
238       ~ZConfig();
239     private:
240       friend class Impl;
241       /** Default ctor. */
242       ZConfig();
243       /** Pointer to implementation */
244       RW_pointer<Impl, rw_pointer::Scoped<Impl> > _pimpl;
245   };
246   ///////////////////////////////////////////////////////////////////
247
248   /////////////////////////////////////////////////////////////////
249 } // namespace zypp
250 ///////////////////////////////////////////////////////////////////
251 #endif // ZYPP_ZCONFIG_H