1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/RepoInfo.h
12 #ifndef ZYPP2_REPOSITORYINFO_H
13 #define ZYPP2_REPOSITORYINFO_H
18 #include "zypp/base/PtrTypes.h"
19 #include "zypp/base/Iterator.h"
20 #include "zypp/base/Deprecated.h"
22 #include "zypp/Pathname.h"
24 #include "zypp/repo/RepoType.h"
25 #include "zypp/repo/RepoVariables.h"
27 ///////////////////////////////////////////////////////////////////
29 { /////////////////////////////////////////////////////////////////
31 ///////////////////////////////////////////////////////////////////
33 // CLASS NAME : RepoInfo
36 * \short What is known about a repository
38 * The class RepoInfo represents everything that
39 * is known about a software repository.
41 * It can be used to store information about known
44 * This class tries to be compatible with the
45 * concept of a .repo file used by YUM and
46 * also available in the openSUSE build service.
47 * See <tt>man yum.conf</tt>.
53 * name=Ruby repository (openSUSE_10.2)
55 * baseurl=http://software.opensuse.org/download/ruby/openSUSE_10.2/
57 * gpgkey=http://software.opensuse.org/openSUSE-Build-Service.asc
62 * \note A RepoInfo is a hint about how
63 * to create a Repository.
67 friend std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
70 static unsigned defaultPrioity();
77 * unique identifier for this source. If not specified
78 * It should be generated from the base url.
80 * Normally, in a .repo file the section name is used
83 std::string alias() const;
86 * Same as alias(), just escaped in a way to be a valid file name.
88 std::string escaped_alias() const;
91 * Repository priority for solver.
92 * Some number between \c 1 (highest priority) and \c 99 (\ref defaultPriority).
94 unsigned priority() const;
96 * The default priority (\c 99).
98 static unsigned defaultPriority();
100 * Set repository priority for solver.
101 * A \c newval_r of \c 0 sets the default priority.
102 * \see \ref priority.
104 RepoInfo & setPriority( unsigned newval_r );
107 * A Url under which the metadata are located, or a set of mirrors.
109 * This can't be empty in order the repository to be valid
110 * unless the download of the mirror list succeeds and it
111 * contains a valid url.
113 * \deprecated IMO superfluous as we provide begin/end iterator.
115 ZYPP_DEPRECATED std::set<Url> baseUrls() const;
118 * \short Repository path
120 * Pathname relative to the base Url where the product/repository
123 * For medias containing more than one product, or repositories not
124 * located at the root of the media it is important to
125 * know the path of the media root relative to the product directory
126 * so a media verifier can be set for that media.
128 * It is not mandatory, and the default is /
130 * \note As a repository can have multiple Urls, the path is unique and
131 * the same for all Urls, so it is assumed all the Urls have the
135 Pathname path() const;
138 * Url of a file which contains a list of Urls
139 * If empty, the base url will be used.
141 Url mirrorListUrl() const;
143 typedef std::set<Url> url_set;
144 //typedef url_set::const_iterator urls_const_iterator;
145 typedef url_set::size_type urls_size_type;
146 typedef transform_iterator<repo::RepoVariablesUrlReplacer, url_set::const_iterator> urls_const_iterator;
149 * iterator that points at begin of repository urls
151 urls_const_iterator baseUrlsBegin() const;
154 * iterator that points at end of repository urls
156 urls_const_iterator baseUrlsEnd() const;
159 * number of repository urls
161 urls_size_type baseUrlsSize() const;
164 * whether repository urls are available
166 bool baseUrlsEmpty() const;
169 * If enabled is false, then this repository must be ignored as if does
170 * not exists, except when checking for duplicate alias.
172 bool enabled() const;
175 * If true, the repostory must be refreshed before creating resolvables
178 bool autorefresh() const;
181 * Type of repository,
184 repo::RepoType type() const;
187 * \short Repository short label
189 * Short label or description of the repository, to be used on
190 * the user interface.
191 * ie: "SUSE Linux 10.2 updates"
193 std::string name() const;
196 * \short File where this repo was read from
198 * \note could be an empty pathname for repo
199 * infos created in memory.
201 Pathname filepath() const;
204 * \short Path where this repo metadata was read from
206 * \note could be an empty pathname for repo
207 * infos created in memory.
209 Pathname metadataPath() const;
212 * \short Path where this repo packages are cached
214 Pathname packagesPath() const;
217 * \short Whether to check or not this repository with gpg
219 * \note This is a just a hint to the application and can
223 bool gpgCheck() const;
226 * \short Key to use for gpg checking of this repository
228 * \param url Url to the key in ASCII armored format
230 * \note This is a just a hint to the application and can
234 Url gpgKeyUrl() const;
237 * \short Whether to keep the packages downloaded from this repository will be kept in local cache
239 bool keepPackages() const;
243 * Add a base url. \see baseUrls
244 * \param url The base url for the repository.
245 * \note can change keepPackages,so change it after this call
247 * To recreate the base URLs list, use \ref setBaseUrl(const Url &) followed
250 RepoInfo & addBaseUrl( const Url &url );
253 * Clears current base URL list and adds \a url.
254 * \note can change keepPackages,so change it after this call
256 RepoInfo & setBaseUrl( const Url &url );
259 * set the product path. \see path()
260 * \param path the path to the product
262 RepoInfo & setPath( const Pathname &path );
265 * Set mirror list url. \see mirrorListUrl
266 * \param url The base url for the list
268 RepoInfo & setMirrorListUrl( const Url &url );
271 * enable or disable the repository \see enabled
274 RepoInfo & setEnabled( bool enabled );
277 * enable or disable autorefresh \see autorefresh
280 RepoInfo & setAutorefresh( bool autorefresh );
283 * set the repository alias \see alias
286 RepoInfo & setAlias( const std::string &alias );
289 * set the repository type \see type
292 RepoInfo & setType( const repo::RepoType &t );
295 * set the repository name \see name
298 RepoInfo & setName( const std::string &name );
301 * \short set the path to the .repo file
303 * The path to the .repo file where this repository
304 * was defined, or empty if nowhere.
306 * \param path File path
308 RepoInfo & setFilepath( const Pathname &filename );
311 * \short set the path where the local metadata is stored
313 * The path to the metadata of this repository
314 * was defined, or empty if nowhere.
316 * \param path directory path
318 RepoInfo & setMetadataPath( const Pathname &path );
321 * \short set the path where the local packages are stored
323 * \param path directory path
325 RepoInfo & setPackagesPath( const Pathname &path );
328 * \short Whether to check or not this repository with gpg
330 * \param check true (check) or false (dont'check)
332 * \note This is a just a hint to the application and can
336 RepoInfo & setGpgCheck( bool check );
339 * \short Key to use for gpg checking of this repository
341 * \param url Url to the key in ASCII armored format
343 * \note This is a just a hint to the application and can
347 RepoInfo & setGpgKeyUrl( const Url &gpgkey );
350 * \short Set if the packaqes downloaded from this repository will be kept in local cache
352 * If the setting is true, all downloaded packages from this repository will be
353 * copied to the local raw cache.
355 * \param keep true (keep the downloaded packages) or false (delete them after installation)
358 RepoInfo & setKeepPackages( bool keep );
361 * Write a human-readable representation of this RepoInfo object
362 * into the \a str stream. Useful for logging.
364 std::ostream & dumpOn( std::ostream & str ) const;
367 * Write this RepoInfo object into \a str in a <tr>.repo</tt> file format.
369 std::ostream & dumpRepoOn( std::ostream & str ) const;
373 /** Pointer to implementation */
374 RWCOW_pointer<Impl> _pimpl;
376 ///////////////////////////////////////////////////////////////////
378 /** \relates RepoInfo Stream output */
379 std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
381 typedef std::list<RepoInfo> RepoInfoList;
383 /////////////////////////////////////////////////////////////////
385 ///////////////////////////////////////////////////////////////////
386 #endif // ZYPP2_REPOSITORYINFO_H