1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/RepoInfo.h
12 #ifndef ZYPP2_REPOSITORYINFO_H
13 #define ZYPP2_REPOSITORYINFO_H
18 #include "zypp/base/Iterator.h"
19 #include "zypp/base/Deprecated.h"
22 #include "zypp/repo/RepoType.h"
23 #include "zypp/repo/RepoVariables.h"
25 #include "zypp/repo/RepoInfoBase.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.
65 class RepoInfo : public repo::RepoInfoBase
67 friend std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
70 static unsigned defaultPrioity();
77 * Repository priority for solver.
78 * Some number between \c 1 (highest priority) and \c 99 (\ref defaultPriority).
80 unsigned priority() const;
82 * The default priority (\c 99).
84 static unsigned defaultPriority();
86 * Set repository priority for solver.
87 * A \c newval_r of \c 0 sets the default priority.
90 RepoInfo & setPriority( unsigned newval_r );
93 * A Url under which the metadata are located, or a set of mirrors.
95 * This can't be empty in order the repository to be valid
96 * unless the download of the mirror list succeeds and it
97 * contains a valid url.
99 * \deprecated IMO superfluous as we provide begin/end iterator.
101 ZYPP_DEPRECATED std::set<Url> baseUrls() const;
104 * \short Repository path
106 * Pathname relative to the base Url where the product/repository
109 * For medias containing more than one product, or repositories not
110 * located at the root of the media it is important to
111 * know the path of the media root relative to the product directory
112 * so a media verifier can be set for that media.
114 * It is not mandatory, and the default is /
116 * \note As a repository can have multiple Urls, the path is unique and
117 * the same for all Urls, so it is assumed all the Urls have the
121 Pathname path() const;
124 * Url of a file which contains a list of Urls
125 * If empty, the base url will be used.
127 Url mirrorListUrl() const;
129 typedef std::set<Url> url_set;
130 //typedef url_set::const_iterator urls_const_iterator;
131 typedef url_set::size_type urls_size_type;
132 typedef transform_iterator<repo::RepoVariablesUrlReplacer, url_set::const_iterator> urls_const_iterator;
135 * iterator that points at begin of repository urls
137 urls_const_iterator baseUrlsBegin() const;
140 * iterator that points at end of repository urls
142 urls_const_iterator baseUrlsEnd() const;
145 * number of repository urls
147 urls_size_type baseUrlsSize() const;
150 * whether repository urls are available
152 bool baseUrlsEmpty() const;
155 * Type of repository,
158 repo::RepoType type() const;
161 * \short Path where this repo metadata was read from
163 * \note could be an empty pathname for repo
164 * infos created in memory.
166 Pathname metadataPath() const;
169 * \short Path where this repo packages are cached
171 Pathname packagesPath() const;
174 * \short Whether to check or not this repository with gpg
176 * \note This is a just a hint to the application and can
180 bool gpgCheck() const;
183 * \short Key to use for gpg checking of this repository
185 * \param url Url to the key in ASCII armored format
187 * \note This is a just a hint to the application and can
191 Url gpgKeyUrl() const;
194 * \short Whether to keep the packages downloaded from this repository will be kept in local cache
196 bool keepPackages() const;
199 * Gets name of the service to which this repository belongs or empty string
200 * if it has been added manually.
202 std::string service() const;
206 * Add a base url. \see baseUrls
207 * \param url The base url for the repository.
208 * \note can change keepPackages,so change it after this call
210 * To recreate the base URLs list, use \ref setBaseUrl(const Url &) followed
213 RepoInfo & addBaseUrl( const Url &url );
216 * Clears current base URL list and adds \a url.
217 * \note can change keepPackages,so change it after this call
219 RepoInfo & setBaseUrl( const Url &url );
222 * set the product path. \see path()
223 * \param path the path to the product
225 RepoInfo & setPath( const Pathname &path );
228 * Set mirror list url. \see mirrorListUrl
229 * \param url The base url for the list
231 RepoInfo & setMirrorListUrl( const Url &url );
234 * set the repository type \see type
237 RepoInfo & setType( const repo::RepoType &t );
240 * This allows to adjust the \ref RepoType lazy, from \c NONE to
241 * some probed value, even for const objects.
243 * This is a NOOP if the current type is not \c NONE.
245 void setProbedType( const repo::RepoType &t ) const;
248 * \short set the path where the local metadata is stored
250 * The path to the metadata of this repository
251 * was defined, or empty if nowhere.
253 * \param path directory path
255 RepoInfo & setMetadataPath( const Pathname &path );
258 * \short set the path where the local packages are stored
260 * \param path directory path
262 RepoInfo & setPackagesPath( const Pathname &path );
265 * \short Whether to check or not this repository with gpg
267 * \param check true (check) or false (dont'check)
269 * \note This is a just a hint to the application and can
273 RepoInfo & setGpgCheck( bool check );
276 * \short Key to use for gpg checking of this repository
278 * \param url Url to the key in ASCII armored format
280 * \note This is a just a hint to the application and can
284 RepoInfo & setGpgKeyUrl( const Url &gpgkey );
287 * \short Set if the packaqes downloaded from this repository will be kept in local cache
289 * If the setting is true, all downloaded packages from this repository will be
290 * copied to the local raw cache.
292 * \param keep true (keep the downloaded packages) or false (delete them after installation)
295 RepoInfo & setKeepPackages( bool keep );
298 * sets service which added this repository
300 RepoInfo & setService( const std::string& name );
303 * Write a human-readable representation of this RepoInfo object
304 * into the \a str stream. Useful for logging.
306 virtual std::ostream & dumpOn( std::ostream & str ) const;
309 * Write this RepoInfo object into \a str in a <tr>.repo</tt> file format.
311 virtual std::ostream & dumpRepoOn( std::ostream & str ) const;
315 /** Pointer to implementation */
316 RWCOW_pointer<Impl> _pimpl;
318 ///////////////////////////////////////////////////////////////////
320 /** \relates RepoInfo Stream output */
321 std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
323 inline bool operator<( const RepoInfo& lhs, const RepoInfo & rhs )
324 { return lhs.alias() < rhs.alias(); }
326 typedef std::list<RepoInfo> RepoInfoList;
328 /////////////////////////////////////////////////////////////////
330 ///////////////////////////////////////////////////////////////////
331 #endif // ZYPP2_REPOSITORYINFO_H