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"
27 #include "zypp/TriBool.h"
29 #include "zypp/DownloadMode.h"
30 #include "zypp/target/rpm/RpmFlags.h"
32 ///////////////////////////////////////////////////////////////////
34 { /////////////////////////////////////////////////////////////////
36 ///////////////////////////////////////////////////////////////////
38 // CLASS NAME : ZConfig
40 /** Interim helper class to collect global options and settings.
41 * Use it to avoid hardcoded values and calls to getZYpp() just
42 * to retrieve some value like architecture, languages or tmppath.
44 * It reads /etc/zypp/zypp.conf, the filename can be overridden by
45 * setting the ZYPP_CONF environment variable to a different file.
47 * Note, if you add settings to this file, please follow the following
50 * namespace.settingname
54 * namespace_settingName()
59 class ZConfig : private base::NonCopyable
64 static ZConfig & instance();
66 /** Print some detail about the current libzypp version.*/
67 std::ostream & about( std::ostream & str ) const;
71 /** The target root directory.
72 * Returns an empty path if no target is set.
74 Pathname systemRoot() const;
78 /** The autodetected system architecture. */
79 static Arch defaultSystemArchitecture();
81 /** The system architecture zypp uses. */
82 Arch systemArchitecture() const;
84 /** Override the zypp system architecture.
85 * This is useful for test scenarious. <b>But be warned</b>, zypp does
86 * not expect the system architecture to change at runtime. So
87 * set it at the verry beginning before you acess any other
90 void setSystemArchitecture( const Arch & arch_r );
92 /** Reset the zypp system architecture to the default. */
93 void resetSystemArchitecture()
94 { setSystemArchitecture( defaultSystemArchitecture() ); }
97 /** The autodetected prefered locale for translated texts.
99 static Locale defaultTextLocale();
101 /** The locale for translated texts zypp uses.
103 Locale textLocale() const;
105 /** Set the prefered locale for translated texts. */
106 void setTextLocale( const Locale & locale_r );
108 /** Reset the locale for translated texts to the default. */
109 void resetTextLocale()
110 { setTextLocale( defaultTextLocale() ); }
113 /** \name Maintain user data
114 * \see \ref zypp-userdata
117 /** Whether a (non empty) user data sting is defined. */
118 bool hasUserData() const;
120 /** User defined string value to be passed to log, history, plugins... */
121 std::string userData() const;
123 /** Set a new \ref userData string.
124 * \returns \c TRUE if the string was accepted; \c FALSE if the
125 * string was rejected due to nonprintable characters or newlines.
127 bool setUserData( const std::string & str_r );
132 * Path where the caches are kept (/var/cache/zypp)
133 * \ingroup g_ZC_REPOCACHE
135 Pathname repoCachePath() const;
138 * Path where the repo metadata is downloaded and kept (repoCachePath()/raw).
139 * \ingroup g_ZC_REPOCACHE
141 Pathname repoMetadataPath() const;
144 * Path where the repo solv files are created and kept (repoCachePath()/solv).
145 * \ingroup g_ZC_REPOCACHE
147 Pathname repoSolvfilesPath() const;
150 * Path where the repo packages are downloaded and kept (repoCachePath()/packages).
151 * \ingroup g_ZC_REPOCACHE
153 Pathname repoPackagesPath() const;
156 * Path where the configfiles are kept (/etc/zypp).
157 * \ingroup g_ZC_CONFIGFILES
159 Pathname configPath() const;
162 * Path where the known repositories .repo files are kept (configPath()/repos.d).
163 * \ingroup g_ZC_CONFIGFILES
165 Pathname knownReposPath() const;
168 * Path where the known services .service files are kept (configPath()/services.d).
169 * \ingroup g_ZC_CONFIGFILES
171 Pathname knownServicesPath() const;
174 * Whether repository urls should be probed.
178 bool repo_add_probe() const;
181 * Amount of time in minutes that must pass before another refresh.
183 unsigned repo_refresh_delay() const;
186 * List of locales for which translated package descriptions should be downloaded.
188 LocaleSet repoRefreshLocales() const;
191 * Whether to use repository alias or name in user messages (progress,
193 * True: use alias, false: use name.
195 bool repoLabelIsAlias() const;
198 * Whether to use repository alias or name in user messages (progress,
199 * exceptions, ...). Console applications might prefer to use and display
200 * the shorter alias instead of full repository name.
202 * Default: false; i.e. repo label is 'name'
204 void repoLabelIsAlias( bool yesno_r );
207 * Maximum number of concurrent connections for a single transfer
209 long download_max_concurrent_connections() const;
212 * Minimum download speed (bytes per second)
213 * until the connection is dropped
215 long download_min_download_speed() const;
218 * Maximum download speed (bytes per second)
220 long download_max_download_speed() const;
223 * Maximum silent tries
225 long download_max_silent_tries() const;
228 * Maximum time in seconds that you allow a transfer operation to take.
230 long download_transfer_timeout() const;
233 /** Whether to consider using a deltarpm when downloading a package.
234 * Config option <tt>download.use_deltarpm (true)</tt>
236 bool download_use_deltarpm() const;
238 /** Whether to consider using a deltarpm even when rpm is local.
239 * This requires \ref download_use_deltarpm being \c true.
240 * Config option <tt>download.use_deltarpm.always (false)</tt>
242 bool download_use_deltarpm_always() const;
245 * Hint which media to prefer when installing packages (download vs. CD).
246 * \see class \ref media::MediaPriority
248 bool download_media_prefer_download() const;
250 bool download_media_prefer_volatile() const
251 { return ! download_media_prefer_download(); }
253 * Set \ref download_media_prefer_download to a specific value.
255 void set_download_media_prefer_download( bool yesno_r );
257 * Set \ref download_media_prefer_download to the configfiles default.
259 void set_default_download_media_prefer_download();
261 /** Path where media are preferably mounted or downloaded.
262 * Config option <tt>download.media_mountdir (/var/adm/mount)</tt>
263 * Needs to be a (writable) directory, otherwise /var/tmp is fallback.
265 Pathname download_mediaMountdir() const;
266 /** Set alternate value. */
267 void set_download_mediaMountdir( Pathname newval_r );
268 /** Reset to zypp.cong default. */
269 void set_default_download_mediaMountdir();
272 * Commit download policy to use as default.
274 DownloadMode commit_downloadMode() const;
276 /** \name Signature checking (repodata and packages)
277 * If \ref gpgcheck is \c on (the default) we will either check the signature
278 * of repo metadata (packages are secured via checksum in the metadata), or the
279 * signature of an rpm package to install if it's repo metadata are not signed
280 * or not checked. If \ref gpgcheck is \c off, no checks are performed.
282 * The default behavior can be altered by explicitly setting \ref repo_gpgcheck and/or
283 * \ref pkg_gpgcheck to perform those checks always (\c on) or never (\c off).
285 * Explicitly setting \c gpgcheck, \c repo_gpgcheck or \c pkg_gpgcheck in a
286 * repositories \a .repo file will overwrite the defaults here.
289 bool gpgCheck() const; ///< Turn signature checking on/off (on)
290 TriBool repoGpgCheck() const; ///< Check repo matadata signatures (indeterminate - according to gpgcheck)
291 TriBool pkgGpgCheck() const; ///< Check rpm package signatures (indeterminate - according to gpgcheck)
295 * Directory for equivalent vendor definitions (configPath()/vendors.d)
296 * \ingroup g_ZC_CONFIGFILES
298 Pathname vendorPath() const;
301 * Solver regards required packages,patterns,... only
303 bool solver_onlyRequires() const;
306 * File in which dependencies described which has to be
307 * fulfilled for a running system.
309 Pathname solver_checkSystemFile() const;
312 * Directory, which may or may not contain files in which
313 * dependencies described which has to be fulfilled for a
316 Pathname solver_checkSystemFileDir() const;
319 * Whether vendor check is by default enabled.
321 bool solver_allowVendorChange() const;
323 /** DUP tune: Whether to allow version downgrades upon DUP. */
324 bool solver_dupAllowDowngrade() const;
326 /** DUP tune: Whether to follow package renames upon DUP. */
327 bool solver_dupAllowNameChange() const;
329 /** DUP tune: Whether to allow package arch changes upon DUP. */
330 bool solver_dupAllowArchChange() const;
332 /** DUP tune: Whether to allow package vendor changes upon DUP. */
333 bool solver_dupAllowVendorChange() const;
336 * Whether removing a package should also remove no longer needed requirements.
338 bool solver_cleandepsOnRemove() const;
341 * When committing a dist upgrade (e.g. <tt>zypper dup</tt>)
342 * a solver testcase is written. It is needed in bugreports,
343 * in case something went wrong. This returns the number of
344 * testcases to keep on the system. Old cases will be deleted,
345 * as new ones are created. Use \c 0 to write no testcase at all.
347 unsigned solver_upgradeTestcasesToKeep() const;
349 /** Whether dist upgrade should remove a products dropped packages (true).
351 * A new product may suggest a list of old and no longer supported
352 * packages (dropped packages). Performing a dist upgrade the solver
353 * may try to delete them, even if they do not cause any dependency
356 * Turning this option off, the solver will not try to remove those
357 * packages unless they actually do cause dependency trouble. At any
358 * time you may use zypper to detect orphaned packages, and do the
359 * cleanup manually. Or simply leave them installed as long as you don't
360 * need the disk space.
362 bool solverUpgradeRemoveDroppedPackages() const;
363 /** Set \ref solverUpgradeRemoveDroppedPackages to \a val_r. */
364 void setSolverUpgradeRemoveDroppedPackages( bool val_r );
365 /** Reset \ref solverUpgradeRemoveDroppedPackages to the \c zypp.conf default. */
366 void resetSolverUpgradeRemoveDroppedPackages();
368 /** \name Packages which can be installed in different versions at the same time.
370 * This returns the config file values (\c names or \c provides:...). The
371 * corresponding packages have the \c multiversionInstall property set. Those
372 * packages will be installed using 'rpm -i', so they will not implicitly obsolete
373 * other installed versions.
375 * \see \ref sat::SolvableType
378 const std::set<std::string> & multiversionSpec() const;
379 void multiversionSpec( std::set<std::string> new_r );
380 void clearMultiversionSpec();
381 void addMultiversionSpec( const std::string & name_r );
382 void removeMultiversionSpec( const std::string & name_r );
386 * Path where zypp can find or create lock file (configPath()/locks)
387 * \ingroup g_ZC_CONFIGFILES
389 Pathname locksFile() const;
392 * Whether locks file should be read and applied after start (true)
394 bool apply_locks_file() const;
397 * Path where the update items are kept (/var/adm)
399 Pathname update_dataPath() const;
402 * Path where the repo metadata is downloaded and kept (update_dataPath()/).
403 * \ingroup g_ZC_REPOCACHE
405 Pathname update_scriptsPath() const;
408 * Path where the repo solv files are created and kept (update_dataPath()/solv).
409 * \ingroup g_ZC_REPOCACHE
411 Pathname update_messagesPath() const;
413 /** \name Command to be invoked to send update messages. */
415 /** Command definition for sending update messages.*/
416 std::string updateMessagesNotify() const;
417 /** Set a new command definition (see update.messages.notify in zypp.conf). */
418 void setUpdateMessagesNotify( const std::string & val_r );
419 /** Reset to the zypp.conf default. */
420 void resetUpdateMessagesNotify();
423 /** \name Options for package installation */
425 /** The default \ref target::rpm::RpmInstFlags for \ref ZYppCommitPolicy.
426 * Or-combination of \ref target::rpm::RpmInstFlag.
428 * ZConfig.instance().rpmInstallFlags().testFlag( target::rpm::RPMINST_EXCLUDEDOCS );
431 target::rpm::RpmInstFlags rpmInstallFlags() const;
435 * Path where ZYpp install history is logged. Defaults to
436 * /var/log/zypp/history.
438 * \see http://en.opensuse.org/Libzypp/Package_History
440 Pathname historyLogFile() const;
443 * Defaults to /etc/zypp/credentials.d
445 Pathname credentialsGlobalDir() const;
448 * Defaults to /etc/zypp/credentials.cat
450 Pathname credentialsGlobalFile() const;
452 /** Package telling the "product version" on systems not using /etc/product.d/baseproduct.
454 * On RHEL, Fedora and others the "product version" is determined by the first package
455 * providing 'redhat-release'. This value is not hardcoded in YUM and can be configured
456 * with the $distroverpkg variable.
458 * Defaults to 'redhat-release'.
460 std::string distroverpkg() const;
465 * Defaults to \c /usr/lib/zypp/plugins
467 Pathname pluginsPath() const;
478 /** Pointer to implementation */
479 RW_pointer<Impl, rw_pointer::Scoped<Impl> > _pimpl;
481 ///////////////////////////////////////////////////////////////////
483 /////////////////////////////////////////////////////////////////
485 ///////////////////////////////////////////////////////////////////
486 #endif // ZYPP_ZCONFIG_H