1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/ZConfig.h
12 #ifndef ZYPP_ZCONFIG_H
13 #define ZYPP_ZCONFIG_H
19 #include "zypp/APIConfig.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()
58 class ZConfig : private base::NonCopyable
63 static ZConfig & instance();
65 /** Print some detail about the current libzypp version.*/
66 std::ostream & about( std::ostream & str ) const;
70 /** The target root directory.
71 * Returns an empty path if no target is set.
73 Pathname systemRoot() const;
77 /** The autodetected system architecture. */
78 static Arch defaultSystemArchitecture();
80 /** The system architecture zypp uses. */
81 Arch systemArchitecture() const;
83 /** Override the zypp system architecture.
84 * This is useful for test scenarious. <b>But be warned</b>, zypp does
85 * not expect the system architecture to change at runtime. So
86 * set it at the verry beginning before you acess any other
89 void setSystemArchitecture( const Arch & arch_r );
91 /** Reset the zypp system architecture to the default. */
92 void resetSystemArchitecture()
93 { setSystemArchitecture( defaultSystemArchitecture() ); }
96 /** The autodetected prefered locale for translated texts.
98 static Locale defaultTextLocale();
100 /** The locale for translated texts zypp uses.
102 Locale textLocale() const;
104 /** Set the prefered locale for translated texts. */
105 void setTextLocale( const Locale & locale_r );
107 /** Reset the locale for translated texts to the default. */
108 void resetTextLocale()
109 { setTextLocale( defaultTextLocale() ); }
112 /** \name Maintain user data
113 * \see \ref zypp-userdata
116 /** Whether a (non empty) user data sting is defined. */
117 bool hasUserData() const;
119 /** User defined string value to be passed to log, history, plugins... */
120 std::string userData() const;
122 /** Set a new \ref userData string.
123 * \returns \c TRUE if the string was accepted; \c FALSE if the
124 * string was rejected due to nonprintable characters or newlines.
126 bool setUserData( const std::string & str_r );
131 * Path where the caches are kept (/var/cache/zypp)
132 * \ingroup g_ZC_REPOCACHE
134 Pathname repoCachePath() const;
137 * Path where the repo metadata is downloaded and kept (repoCachePath()/raw).
138 * \ingroup g_ZC_REPOCACHE
140 Pathname repoMetadataPath() const;
143 * Path where the repo solv files are created and kept (repoCachePath()/solv).
144 * \ingroup g_ZC_REPOCACHE
146 Pathname repoSolvfilesPath() const;
149 * Path where the repo packages are downloaded and kept (repoCachePath()/packages).
150 * \ingroup g_ZC_REPOCACHE
152 Pathname repoPackagesPath() const;
155 * Path where the configfiles are kept (/etc/zypp).
156 * \ingroup g_ZC_CONFIGFILES
158 Pathname configPath() const;
161 * Path where the known repositories .repo files are kept (configPath()/repos.d).
162 * \ingroup g_ZC_CONFIGFILES
164 Pathname knownReposPath() const;
167 * Path where the known services .service files are kept (configPath()/services.d).
168 * \ingroup g_ZC_CONFIGFILES
170 Pathname knownServicesPath() const;
173 * Whether repository urls should be probed.
177 bool repo_add_probe() const;
180 * Amount of time in minutes that must pass before another refresh.
182 unsigned repo_refresh_delay() const;
185 * List of locales for which translated package descriptions should be downloaded.
187 LocaleSet repoRefreshLocales() const;
190 * Whether to use repository alias or name in user messages (progress,
192 * True: use alias, false: use name.
194 bool repoLabelIsAlias() const;
197 * Whether to use repository alias or name in user messages (progress,
198 * exceptions, ...). Console applications might prefer to use and display
199 * the shorter alias instead of full repository name.
201 * Default: false; i.e. repo label is 'name'
203 void repoLabelIsAlias( bool yesno_r );
206 * Maximum number of concurrent connections for a single transfer
208 long download_max_concurrent_connections() const;
211 * Minimum download speed (bytes per second)
212 * until the connection is dropped
214 long download_min_download_speed() const;
217 * Maximum download speed (bytes per second)
219 long download_max_download_speed() const;
222 * Maximum silent tries
224 long download_max_silent_tries() const;
227 /** Whether to consider using a deltarpm when downloading a package.
228 * Config option <tt>download.use_deltarpm (true)</tt>
230 bool download_use_deltarpm() const;
232 /** Whether to consider using a deltarpm even when rpm is local.
233 * This requires \ref download_use_deltarpm being \c true.
234 * Config option <tt>download.use_deltarpm.always (false)</tt>
236 bool download_use_deltarpm_always() const;
239 * Hint which media to prefer when installing packages (download vs. CD).
240 * \see class \ref media::MediaPriority
242 bool download_media_prefer_download() const;
244 bool download_media_prefer_volatile() const
245 { return ! download_media_prefer_download(); }
247 * Set \ref download_media_prefer_download to a specific value.
249 void set_download_media_prefer_download( bool yesno_r );
251 * Set \ref download_media_prefer_download to the configfiles default.
253 void set_default_download_media_prefer_download();
256 * Commit download policy to use as default.
258 DownloadMode commit_downloadMode() const;
261 * Directory for equivalent vendor definitions (configPath()/vendors.d)
262 * \ingroup g_ZC_CONFIGFILES
264 Pathname vendorPath() const;
267 * Solver regards required packages,patterns,... only
269 bool solver_onlyRequires() const;
272 * File in which dependencies described which has to be
273 * fulfilled for a running system.
275 Pathname solver_checkSystemFile() const;
278 * Whether vendor check is by default enabled.
280 bool solver_allowVendorChange() const;
283 * Whether removing a package should also remove no longer needed requirements.
285 bool solver_cleandepsOnRemove() const;
288 * When committing a dist upgrade (e.g. <tt>zypper dup</tt>)
289 * a solver testcase is written. It is needed in bugreports,
290 * in case something went wrong. This returns the number of
291 * testcases to keep on the system. Old cases will be deleted,
292 * as new ones are created. Use \c 0 to write no testcase at all.
294 unsigned solver_upgradeTestcasesToKeep() const;
296 /** Whether dist upgrade should remove a products dropped packages (true).
298 * A new product may suggest a list of old and no longer supported
299 * packages (dropped packages). Performing a dist upgrade the solver
300 * may try to delete them, even if they do not cause any dependency
303 * Turning this option off, the solver will not try to remove those
304 * packages unless they actually do cause dependency trouble. At any
305 * time you may use zypper to detect orphaned packages, and do the
306 * cleanup manually. Or simply leave them installed as long as you don't
307 * need the disk space.
309 bool solverUpgradeRemoveDroppedPackages() const;
310 /** Set \ref solverUpgradeRemoveDroppedPackages to \a val_r. */
311 void setSolverUpgradeRemoveDroppedPackages( bool val_r );
312 /** Reset \ref solverUpgradeRemoveDroppedPackages to the \c zypp.conf default. */
313 void resetSolverUpgradeRemoveDroppedPackages();
315 /** \name Packages which can be installed in different versions at the same time.
316 * This returns the config file values (\c names or \c provides:...). For the corresponding
317 * packages use e.g \ref sat::Pool::multiversionBegin, or \ref sat::Solbale::multiversionInstall
318 * (\ref ui::Selectable::multiversionInstall).
321 const std::set<std::string> & multiversionSpec() const;
322 void addMultiversionSpec( const std::string & name_r );
323 void removeMultiversionSpec( const std::string & name_r );
327 * Path where zypp can find or create lock file (configPath()/locks)
328 * \ingroup g_ZC_CONFIGFILES
330 Pathname locksFile() const;
333 * Whether locks file should be read and applied after start (true)
335 bool apply_locks_file() const;
338 * Path where the update items are kept (/var/adm)
340 Pathname update_dataPath() const;
343 * Path where the repo metadata is downloaded and kept (update_dataPath()/).
344 * \ingroup g_ZC_REPOCACHE
346 Pathname update_scriptsPath() const;
349 * Path where the repo solv files are created and kept (update_dataPath()/solv).
350 * \ingroup g_ZC_REPOCACHE
352 Pathname update_messagesPath() const;
354 /** \name Command to be invoked to send update messages. */
356 /** Command definition for sending update messages.*/
357 std::string updateMessagesNotify() const;
358 /** Set a new command definition (see update.messages.notify in zypp.conf). */
359 void setUpdateMessagesNotify( const std::string & val_r );
360 /** Reset to the zypp.conf default. */
361 void resetUpdateMessagesNotify();
364 /** \name Options for package installation */
366 /** The default \ref target::rpm::RpmInstFlags for \ref ZYppCommitPolicy.
367 * Or-combination of \ref target::rpm::RpmInstFlag.
369 * ZConfig.instance().rpmInstallFlags().testFlag( target::rpm::RPMINST_EXCLUDEDOCS );
372 target::rpm::RpmInstFlags rpmInstallFlags() const;
376 * Path where ZYpp install history is logged. Defaults to
377 * /var/log/zypp/history.
379 * \see http://en.opensuse.org/Libzypp/Package_History
381 Pathname historyLogFile() const;
384 * Defaults to /etc/zypp/credentials.d
386 Pathname credentialsGlobalDir() const;
389 * Defaults to /etc/zypp/credentials.cat
391 Pathname credentialsGlobalFile() const;
393 /** Package telling the "product version" on systems not using /etc/product.d/baseproduct.
395 * On RHEL, Fedora and others the "product version" is determined by the first package
396 * providing 'redhat-release'. This value is not hardcoded in YUM and can be configured
397 * with the $distroverpkg variable.
399 * Defaults to 'redhat-release'.
401 std::string distroverpkg() const;
406 * Defaults to \c /usr/lib/zypp/plugins
408 Pathname pluginsPath() const;
419 /** Pointer to implementation */
420 RW_pointer<Impl, rw_pointer::Scoped<Impl> > _pimpl;
422 ///////////////////////////////////////////////////////////////////
424 /////////////////////////////////////////////////////////////////
426 ///////////////////////////////////////////////////////////////////
427 #endif // ZYPP_ZCONFIG_H