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 * Returns an empty path if no target is set.
72 Pathname systemRoot() const;
76 /** The autodetected system architecture. */
77 static Arch defaultSystemArchitecture();
79 /** The system architecture zypp uses. */
80 Arch systemArchitecture() const;
82 /** Override the zypp system architecture.
83 * This is useful for test scenarious. <b>But be warned</b>, zypp does
84 * not expect the system architecture to change at runtime. So
85 * set it at the verry beginning before you acess any other
88 void setSystemArchitecture( const Arch & arch_r );
90 /** Reset the zypp system architecture to the default. */
91 void resetSystemArchitecture()
92 { setSystemArchitecture( defaultSystemArchitecture() ); }
95 /** The autodetected prefered locale for translated texts.
97 static Locale defaultTextLocale();
99 /** The locale for translated texts zypp uses.
101 Locale textLocale() const;
103 /** Set the prefered locale for translated texts. */
104 void setTextLocale( const Locale & locale_r );
106 /** Reset the locale for translated texts to the default. */
107 void resetTextLocale()
108 { setTextLocale( defaultTextLocale() ); }
112 * Path where the caches are kept (/var/cache/zypp)
113 * \ingroup g_ZC_REPOCACHE
115 Pathname repoCachePath() const;
118 * Path where the repo metadata is downloaded and kept (repoCachePath()/raw).
119 * \ingroup g_ZC_REPOCACHE
121 Pathname repoMetadataPath() const;
124 * Path where the repo solv files are created and kept (repoCachePath()/solv).
125 * \ingroup g_ZC_REPOCACHE
127 Pathname repoSolvfilesPath() const;
130 * Path where the repo packages are downloaded and kept (repoCachePath()/packages).
131 * \ingroup g_ZC_REPOCACHE
133 Pathname repoPackagesPath() const;
136 * Path where the configfiles are kept (/etc/zypp).
137 * \ingroup g_ZC_CONFIGFILES
139 Pathname configPath() const;
142 * Path where the known repositories .repo files are kept (configPath()/repos.d).
143 * \ingroup g_ZC_CONFIGFILES
145 Pathname knownReposPath() const;
148 * Path where the known services .service files are kept (configPath()/services.d).
149 * \ingroup g_ZC_CONFIGFILES
151 Pathname knownServicesPath() const;
154 * Path where plugin services are installed
155 * plugin services are scripts returning a repository
157 * \ingroup g_ZC_CONFIGFILES
159 Pathname pluginServicesPath() const;
162 * Whether repository urls should be probed.
166 bool repo_add_probe() const;
169 * Amount of time in minutes that must pass before another refresh.
171 unsigned repo_refresh_delay() const;
174 * Whether to use repository alias or name in user messages (progress,
176 * True: use alias, false: use name.
178 bool repoLabelIsAlias() const;
181 * Whether to use repository alias or name in user messages (progress,
182 * exceptions, ...). Console applications might prefer to use and display
183 * the shorter alias instead of full repository name.
185 * Default: false; i.e. repo label is 'name'
187 void repoLabelIsAlias( bool yesno_r );
190 * Maximum number of concurrent connections for a single transfer
192 long download_max_concurrent_connections() const;
195 * Minimum download speed (bytes per second)
196 * until the connection is dropped
198 long download_min_download_speed() const;
201 * Maximum download speed (bytes per second)
203 long download_max_download_speed() const;
206 * Maximum silent tries
208 long download_max_silent_tries() const;
211 /** Whether to consider using a deltarpm when downloading a package.
212 * Config option <tt>download.use_deltarpm (true)</tt>
214 bool download_use_deltarpm() const;
216 /** Whether to consider using a deltarpm even when rpm is local.
217 * This requires \ref download_use_deltarpm being \c true.
218 * Config option <tt>download.use_deltarpm.always (false)</tt>
220 bool download_use_deltarpm_always() const;
223 * Hint which media to prefer when installing packages (download vs. CD).
224 * \see class \ref media::MediaPriority
226 bool download_media_prefer_download() const;
228 bool download_media_prefer_volatile() const
229 { return ! download_media_prefer_download(); }
231 * Set \ref download_media_prefer_download to a specific value.
233 void set_download_media_prefer_download( bool yesno_r );
235 * Set \ref download_media_prefer_download to the configfiles default.
237 void set_default_download_media_prefer_download();
240 * Commit download policy to use as default.
242 DownloadMode commit_downloadMode() const;
245 * Directory for equivalent vendor definitions (configPath()/vendors.d)
246 * \ingroup g_ZC_CONFIGFILES
248 Pathname vendorPath() const;
251 * Solver regards required packages,patterns,... only
253 bool solver_onlyRequires() const;
256 * File in which dependencies described which has to be
257 * fulfilled for a running system.
259 Pathname solver_checkSystemFile() const;
262 * Whether vendor check is by default enabled.
264 bool solver_allowVendorChange() const;
267 * Whether removing a package should also remove no longer needed requirements.
269 bool solver_cleandepsOnRemove() const;
272 * When committing a dist upgrade (e.g. <tt>zypper dup</tt>)
273 * a solver testcase is written. It is needed in bugreports,
274 * in case something went wrong. This returns the number of
275 * testcases to keep on the system. Old cases will be deleted,
276 * as new ones are created. Use \c 0 to write no testcase at all.
278 unsigned solver_upgradeTestcasesToKeep() const;
280 /** Whether dist upgrade should remove a products dropped packages (true).
282 * A new product may suggest a list of old and no longer supported
283 * packages (dropped packages). Performing a dist upgrade the solver
284 * may try to delete them, even if they do not cause any dependency
287 * Turning this option off, the solver will not try to remove those
288 * packages unless they actually do cause dependency trouble. At any
289 * time you may use zypper to detect orphaned packages, and do the
290 * cleanup manually. Or simply leave them installed as long as you don't
291 * need the disk space.
293 bool solverUpgradeRemoveDroppedPackages() const;
294 /** Set \ref solverUpgradeRemoveDroppedPackages to \a val_r. */
295 void setSolverUpgradeRemoveDroppedPackages( bool val_r );
296 /** Reset \ref solverUpgradeRemoveDroppedPackages to the \c zypp.conf default. */
297 void resetSolverUpgradeRemoveDroppedPackages();
299 /** \name Packages which can be installed in different versions at the same time.
300 * This returns the config file values (\c names or \c provides:...). For the corresponding
301 * packages use e.g \ref sat::Pool::multiversionBegin, or \ref sat::Solbale::multiversionInstall
302 * (\ref ui::Selectable::multiversionInstall).
305 const std::set<std::string> & multiversionSpec() const;
306 void addMultiversionSpec( const std::string & name_r );
307 void removeMultiversionSpec( const std::string & name_r );
311 * Path where zypp can find or create lock file (configPath()/locks)
312 * \ingroup g_ZC_CONFIGFILES
314 Pathname locksFile() const;
317 * Whether locks file should be read and applied after start (true)
319 bool apply_locks_file() const;
322 * Path where the update items are kept (/var/adm)
324 Pathname update_dataPath() const;
327 * Path where the repo metadata is downloaded and kept (update_dataPath()/).
328 * \ingroup g_ZC_REPOCACHE
330 Pathname update_scriptsPath() const;
333 * Path where the repo solv files are created and kept (update_dataPath()/solv).
334 * \ingroup g_ZC_REPOCACHE
336 Pathname update_messagesPath() const;
338 /** \name Command to be invoked to send update messages. */
340 /** Command definition for sending update messages.*/
341 std::string updateMessagesNotify() const;
342 /** Set a new command definition (see update.messages.notify in zypp.conf). */
343 void setUpdateMessagesNotify( const std::string & val_r );
344 /** Reset to the zypp.conf default. */
345 void resetUpdateMessagesNotify();
348 /** \name Options for package installation */
350 /** The default \ref target::rpm::RpmInstFlags for \ref ZYppCommitPolicy.
351 * Or-combination of \ref target::rpm::RpmInstFlag.
353 * ZConfig.instance().rpmInstallFlags().testFlag( target::rpm::RPMINST_EXCLUDEDOCS );
356 target::rpm::RpmInstFlags rpmInstallFlags() const;
360 * Path where ZYpp install history is logged. Defaults to
361 * /var/log/zypp/history.
363 * \see http://en.opensuse.org/Libzypp/Package_History
365 Pathname historyLogFile() const;
368 * Defaults to /etc/zypp/credentials.d
370 Pathname credentialsGlobalDir() const;
373 * Defaults to /etc/zypp/credentials.cat
375 Pathname credentialsGlobalFile() const;
377 /** Package telling the "product version" on systems not using /etc/product.d/baseproduct.
379 * On RHEL, Fedora and others the "product version" is determined by the first package
380 * providing 'redhat-release'. This value is not hardcoded in YUM and can be configured
381 * with the $distroverpkg variable.
383 * Defaults to 'redhat-release'.
385 std::string distroverpkg() const;
390 * Defaults to \c /usr/lib/zypp/plugins
392 Pathname pluginsDir() const;
395 * Defaults to \ref pluginsDir()/media
397 Pathname mediaPluginsDir() const;
400 * Defaults to \ref pluginsDir()/services
402 Pathname servicePluginsDir() const;
412 /** Pointer to implementation */
413 RW_pointer<Impl, rw_pointer::Scoped<Impl> > _pimpl;
415 ///////////////////////////////////////////////////////////////////
417 /////////////////////////////////////////////////////////////////
419 ///////////////////////////////////////////////////////////////////
420 #endif // ZYPP_ZCONFIG_H