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/DownloadMode.h"
29 #include "zypp/target/rpm/RpmFlags.h"
31 ///////////////////////////////////////////////////////////////////
33 { /////////////////////////////////////////////////////////////////
35 ///////////////////////////////////////////////////////////////////
37 // CLASS NAME : ZConfig
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.
43 * It reads /etc/zypp/zypp.conf, the filename can be overridden by
44 * setting the ZYPP_CONF environment variable to a different file.
46 * Note, if you add settings to this file, please follow the following
49 * namespace.settingname
53 * namespace_settingName()
57 class ZConfig : private base::NonCopyable
62 static ZConfig & instance();
64 /** Print some detail about the current libzypp version.*/
65 std::ostream & about( std::ostream & str ) const;
69 /** The target root directory. */
70 Pathname systemRoot() const;
74 /** The autodetected system architecture. */
75 static Arch defaultSystemArchitecture();
77 /** The system architecture zypp uses. */
78 Arch systemArchitecture() const;
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
86 void setSystemArchitecture( const Arch & arch_r );
88 /** Reset the zypp system architecture to the default. */
89 void resetSystemArchitecture()
90 { setSystemArchitecture( defaultSystemArchitecture() ); }
93 /** The autodetected prefered locale for translated texts.
95 static Locale defaultTextLocale();
97 /** The locale for translated texts zypp uses.
99 Locale textLocale() const;
101 /** Set the prefered locale for translated texts. */
102 void setTextLocale( const Locale & locale_r );
104 /** Reset the locale for translated texts to the default. */
105 void resetTextLocale()
106 { setTextLocale( defaultTextLocale() ); }
110 * Path where the caches are kept (/var/cache/zypp)
111 * \ingroup g_ZC_REPOCACHE
113 Pathname repoCachePath() const;
116 * Path where the repo metadata is downloaded and kept (repoCachePath()/raw).
117 * \ingroup g_ZC_REPOCACHE
119 Pathname repoMetadataPath() const;
122 * Path where the repo solv files are created and kept (repoCachePath()/solv).
123 * \ingroup g_ZC_REPOCACHE
125 Pathname repoSolvfilesPath() const;
128 * Path where the repo packages are downloaded and kept (repoCachePath()/packages).
129 * \ingroup g_ZC_REPOCACHE
131 Pathname repoPackagesPath() const;
134 * Path where the configfiles are kept (/etc/zypp).
135 * \ingroup g_ZC_CONFIGFILES
137 Pathname configPath() const;
140 * Path where the known repositories .repo files are kept (configPath()/repos.d).
141 * \ingroup g_ZC_CONFIGFILES
143 Pathname knownReposPath() const;
146 * Path where the known services .service files are kept (configPath()/services.d).
147 * \ingroup g_ZC_CONFIGFILES
149 Pathname knownServicesPath() const;
152 * Whether repository urls should be probed.
156 bool repo_add_probe() const;
159 * Amount of time in minutes that must pass before another refresh.
161 unsigned repo_refresh_delay() const;
164 * Maximum number of concurrent connections for a single transfer
166 long download_max_concurrent_connections() const;
169 * Minimum download speed (bytes per second)
170 * until the connection is dropped
172 long download_min_download_speed() const;
175 * Maximum download speed (bytes per second)
177 long download_max_download_speed() const;
180 * Maximum silent tries
182 long download_max_silent_tries() const;
185 /** Whether to consider using a deltarpm when downloading a package.
186 * Config option <tt>download.use_deltarpm (true)</tt>
188 bool download_use_deltarpm() const;
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>
194 bool download_use_deltarpm_always() const;
197 * Hint which media to prefer when installing packages (download vs. CD).
198 * \see class \ref media::MediaPriority
200 bool download_media_prefer_download() const;
202 bool download_media_prefer_volatile() const
203 { return ! download_media_prefer_download(); }
205 * Set \ref download_media_prefer_download to a specific value.
207 void set_download_media_prefer_download( bool yesno_r );
209 * Set \ref download_media_prefer_download to the configfiles default.
211 void set_default_download_media_prefer_download();
214 * Commit download policy to use as default.
216 DownloadMode commit_downloadMode() const;
219 * Directory for equivalent vendor definitions (configPath()/vendors.d)
220 * \ingroup g_ZC_CONFIGFILES
222 Pathname vendorPath() const;
225 * Solver regards required packages,patterns,... only
227 bool solver_onlyRequires() const;
230 * File in which dependencies described which has to be
231 * fulfilled for a running system.
233 Pathname solver_checkSystemFile() const;
236 * Whether vendor check is by default enabled.
238 bool solver_allowVendorChange() const;
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.
247 unsigned solver_upgradeTestcasesToKeep() const;
249 /** Whether dist upgrade should remove a products dropped packages (true).
251 * A new product may suggest a list of old and no longer supported
252 * packages (dropped packages). Performing a dist upgrade the solver
253 * may try to delete them, even if they do not cause any dependency
256 * Turning this option off, the solver will not try to remove those
257 * packages unless they actually do cause dependency trouble. At any
258 * time you may use zypper to detect orphaned packages, and do the
259 * cleanup manually. Or simply leave them installed as long as you don't
260 * need the disk space.
262 bool solverUpgradeRemoveDropedPackages() const;
263 /** Set \ref solverUpgradeRemoveDropedPackages to \a val_r. */
264 void setSolverUpgradeRemoveDropedPackages( bool val_r );
265 /** Reset \ref solverUpgradeRemoveDropedPackages to the \c zypp.conf default. */
266 void resetSolverUpgradeRemoveDropedPackages();
269 * Packages which can be installed parallel with different versions
270 * Returning a set of package names (IdString)
272 std::set<IdString> multiversion() const;
273 void addMultiversion(std::string &name);
274 bool removeMultiversion(std::string &name);
277 * Path where zypp can find or create lock file (configPath()/locks)
278 * \ingroup g_ZC_CONFIGFILES
280 Pathname locksFile() const;
283 * Whether locks file should be read and applied after start (true)
285 bool apply_locks_file() const;
288 * Path where the update items are kept (/var/adm)
290 Pathname update_dataPath() const;
293 * Path where the repo metadata is downloaded and kept (update_dataPath()/).
294 * \ingroup g_ZC_REPOCACHE
296 Pathname update_scriptsPath() const;
299 * Path where the repo solv files are created and kept (update_dataPath()/solv).
300 * \ingroup g_ZC_REPOCACHE
302 Pathname update_messagesPath() const;
304 /** \name Command to be invoked to send update messages. */
306 /** Command definition for sending update messages.*/
307 std::string updateMessagesNotify() const;
308 /** Set a new command definition (see update.messages.notify in zypp.conf). */
309 void setUpdateMessagesNotify( const std::string & val_r );
310 /** Reset to the zypp.conf default. */
311 void resetUpdateMessagesNotify();
314 /** \name Options for package installation */
316 /** The default \ref target::rpm::RpmInstFlags for \ref ZYppCommitPolicy.
317 * Or-combination of \ref target::rpm::RpmInstFlag.
319 * ZConfig.instance().rpmInstallFlags().testFlag( target::rpm::RPMINST_EXCLUDEDOCS );
322 target::rpm::RpmInstFlags rpmInstallFlags() const;
326 * Path where ZYpp install history is logged. Defaults to
327 * /var/log/zypp/history.
329 * \see http://en.opensuse.org/Libzypp/Package_History
331 Pathname historyLogFile() const;
334 * Defaults to /etc/zypp/credentials.d
336 Pathname credentialsGlobalDir() const;
339 * Defaults to /etc/zypp/credentials.cat
341 Pathname credentialsGlobalFile() const;
344 /** Package telling the "product version" on systems not using /etc/product.d/baseproduct.
346 * On RHEL, Fedora and others the "product version" is determined by the first package
347 * providing 'redhat-release'. This value is not hardcoded in YUM and can be configured
348 * with the $distroverpkg variable.
350 * Defaults to 'redhat-release'.
352 std::string distroverpkg() const;
362 /** Pointer to implementation */
363 RW_pointer<Impl, rw_pointer::Scoped<Impl> > _pimpl;
365 ///////////////////////////////////////////////////////////////////
367 /////////////////////////////////////////////////////////////////
369 ///////////////////////////////////////////////////////////////////
370 #endif // ZYPP_ZCONFIG_H