1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/ZConfig.h
12 #ifndef ZYPP_ZCONFIG_H
13 #define ZYPP_ZCONFIG_H
19 #include "zypp/base/Deprecated.h"
20 #include "zypp/base/NonCopyable.h"
21 #include "zypp/base/PtrTypes.h"
23 #include "zypp/Arch.h"
24 #include "zypp/Locale.h"
25 #include "zypp/Pathname.h"
26 #include "zypp/IdString.h"
28 #include "zypp/target/rpm/RpmFlags.h"
30 ///////////////////////////////////////////////////////////////////
32 { /////////////////////////////////////////////////////////////////
34 ///////////////////////////////////////////////////////////////////
36 // CLASS NAME : ZConfig
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.
42 * It reads /etc/zypp/zypp.conf, the filename can be overridden by
43 * setting the ZYPP_CONF environment variable to a different file.
45 * Note, if you add settings to this file, please follow the following
48 * namespace.settingname
52 * namespace_settingName()
56 class ZConfig : private base::NonCopyable
61 static ZConfig & instance();
63 /** Print some detail about the current libzypp version.*/
64 std::ostream & about( std::ostream & str ) const;
68 /** The target root directory. */
69 Pathname systemRoot() const;
73 /** The autodetected system architecture. */
74 static Arch defaultSystemArchitecture();
76 /** The system architecture zypp uses. */
77 Arch systemArchitecture() const;
79 /** Override the zypp system architecture.
80 * This is useful for test scenarious. <b>But be warned</b>, zypp does
81 * not expect the system architecture to change at runtime. So
82 * set it at the verry beginning before you acess any other
85 void setSystemArchitecture( const Arch & arch_r );
87 /** Reset the zypp system architecture to the default. */
88 void resetSystemArchitecture()
89 { setSystemArchitecture( defaultSystemArchitecture() ); }
92 /** The autodetected prefered locale for translated texts.
94 static Locale defaultTextLocale();
96 /** The locale for translated texts zypp uses.
98 Locale textLocale() const;
100 /** Set the prefered locale for translated texts. */
101 void setTextLocale( const Locale & locale_r );
103 /** Reset the locale for translated texts to the default. */
104 void resetTextLocale()
105 { setTextLocale( defaultTextLocale() ); }
109 * Path where the caches are kept (/var/cache/zypp)
110 * \ingroup g_ZC_REPOCACHE
112 Pathname repoCachePath() const;
115 * Path where the repo metadata is downloaded and kept (repoCachePath()/raw).
116 * \ingroup g_ZC_REPOCACHE
118 Pathname repoMetadataPath() const;
121 * Path where the repo solv files are created and kept (repoCachePath()/solv).
122 * \ingroup g_ZC_REPOCACHE
124 Pathname repoSolvfilesPath() const;
127 * Path where the repo packages are downloaded and kept (repoCachePath()/packages).
128 * \ingroup g_ZC_REPOCACHE
130 Pathname repoPackagesPath() const;
133 * Path where the configfiles are kept (/etc/zypp).
134 * \ingroup g_ZC_CONFIGFILES
136 Pathname configPath() const;
139 * Path where the known repositories .repo files are kept (configPath()/repos.d).
140 * \ingroup g_ZC_CONFIGFILES
142 Pathname knownReposPath() const;
145 * Path where the known services .service files are kept (configPath()/services.d).
146 * \ingroup g_ZC_CONFIGFILES
148 Pathname knownServicesPath() const;
151 * Whether repository urls should be probed.
155 bool repo_add_probe() const;
158 * Amount of time in minutes that must pass before another refresh.
160 unsigned repo_refresh_delay() const;
163 * Maximum number of concurrent connections for a single transfer
165 long download_max_concurrent_connections() const;
168 * Minimum download speed (bytes per second)
169 * until the connection is dropped
171 long download_min_download_speed() const;
174 * Maximum download speed (bytes per second)
176 long download_max_download_speed() const;
179 * Maximum silent tries
181 long download_max_silent_tries() const;
184 /** Whether to consider using a deltarpm when downloading a package.
185 * Config option <tt>download.use_deltarpm (true)</tt>
187 bool download_use_deltarpm() const;
189 /** Whether to consider using a deltarpm even when rpm is local.
190 * This requires \ref download_use_deltarpm being \c true.
191 * Config option <tt>download.use_deltarpm.always (false)</tt>
193 bool download_use_deltarpm_always() const;
196 * Hint which media to prefer when installing packages (download vs. CD).
197 * \see class \ref media::MediaPriority
199 bool download_media_prefer_download() const;
201 bool download_media_prefer_volatile() const
202 { return ! download_media_prefer_download(); }
204 * Set \ref download_media_prefer_download to a specific value.
206 void set_download_media_prefer_download( bool yesno_r );
208 * Set \ref download_media_prefer_download to the configfiles default.
210 void set_default_download_media_prefer_download();
213 * Directory for equivalent vendor definitions (configPath()/vendors.d)
214 * \ingroup g_ZC_CONFIGFILES
216 Pathname vendorPath() const;
219 * Solver regards required packages,patterns,... only
221 bool solver_onlyRequires() const;
224 * File in which dependencies described which has to be
225 * fulfilled for a running system.
227 Pathname solver_checkSystemFile() const;
230 * Whether vendor check is by default enabled.
232 bool solver_allowVendorChange() const;
235 * When committing a dist upgrade (e.g. <tt>zypper dup</tt>)
236 * a solver testcase is written. It is needed in bugreports,
237 * in case something went wrong. This returns the number of
238 * testcases to keep on the system. Old cases will be deleted,
239 * as new ones are created. Use \c 0 to write no testcase at all.
241 unsigned solver_upgradeTestcasesToKeep() const;
244 * Packages which can be installed parallel with different versions
245 * Returning a set of package names (IdString)
247 std::set<IdString> multiversion() const;
248 void addMultiversion(std::string &name);
249 bool removeMultiversion(std::string &name);
252 * Path where zypp can find or create lock file (configPath()/locks)
253 * \ingroup g_ZC_CONFIGFILES
255 Pathname locksFile() const;
258 * Whether locks file should be read and applied after start (true)
260 bool apply_locks_file() const;
263 * Path where the update items are kept (/var/adm)
265 Pathname update_dataPath() const;
268 * Path where the repo metadata is downloaded and kept (update_dataPath()/).
269 * \ingroup g_ZC_REPOCACHE
271 Pathname update_scriptsPath() const;
274 * Path where the repo solv files are created and kept (update_dataPath()/solv).
275 * \ingroup g_ZC_REPOCACHE
277 Pathname update_messagesPath() const;
279 /** \name Options for package installation */
281 /** The default \ref target::rpm::RpmInstFlags for \ref ZYppCommitPolicy.
282 * Or-combination of \ref target::rpm::RpmInstFlag.
284 * ZConfig.instance().rpmInstallFlags().testFlag( target::rpm::RPMINST_EXCLUDEDOCS );
287 target::rpm::RpmInstFlags rpmInstallFlags() const;
291 * Path where ZYpp install history is logged. Defaults to
292 * /var/log/zypp/history.
294 * \see http://en.opensuse.org/Libzypp/Package_History
296 Pathname historyLogFile() const;
299 * Defaults to /etc/zypp/credentials.d
301 Pathname credentialsGlobalDir() const;
304 * Defaults to /etc/zypp/credentials.cat
306 Pathname credentialsGlobalFile() const;
309 /** Package telling the "product version" on systems not using /etc/product.d/baseproduct.
311 * On RHEL, Fedora and others the "product version" is determined by the first package
312 * providing 'redhat-release'. This value is not hardcoded in YUM and can be configured
313 * with the $distroverpkg variable.
315 * Defaults to 'redhat-release'.
317 std::string distroverpkg() const;
327 /** Pointer to implementation */
328 RW_pointer<Impl, rw_pointer::Scoped<Impl> > _pimpl;
330 ///////////////////////////////////////////////////////////////////
332 /////////////////////////////////////////////////////////////////
334 ///////////////////////////////////////////////////////////////////
335 #endif // ZYPP_ZCONFIG_H