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/Locale.h"
23 #include "zypp/repo/RepoType.h"
24 #include "zypp/repo/RepoVariables.h"
26 #include "zypp/repo/RepoInfoBase.h"
28 ///////////////////////////////////////////////////////////////////
30 { /////////////////////////////////////////////////////////////////
32 ///////////////////////////////////////////////////////////////////
34 // CLASS NAME : RepoInfo
37 * \short What is known about a repository
39 * The class RepoInfo represents everything that
40 * is known about a software repository.
42 * It can be used to store information about known
45 * This class tries to be compatible with the
46 * concept of a .repo file used by YUM and
47 * also available in the openSUSE build service.
48 * See <tt>man yum.conf</tt>.
54 * name=Ruby repository (openSUSE_10.2)
56 * baseurl=http://software.opensuse.org/download/ruby/openSUSE_10.2/
58 * gpgkey=http://software.opensuse.org/openSUSE-Build-Service.asc
63 * \note A RepoInfo is a hint about how
64 * to create a Repository.
66 class RepoInfo : public repo::RepoInfoBase
68 friend std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
74 /** Represents no Repository (one with an empty alias). */
75 static const RepoInfo noRepo;
79 * The default priority (\c 99).
81 static unsigned defaultPriority();
83 * Repository priority for solver.
84 * Some number between \c 1 (highest priority) and \c 99 (\ref defaultPriority).
86 unsigned priority() const;
88 * Set repository priority for solver.
89 * A \c newval_r of \c 0 sets the default priority.
92 void setPriority( unsigned newval_r );
94 typedef std::set<Url> url_set;
95 typedef url_set::size_type urls_size_type;
96 typedef transform_iterator<repo::RepoVariablesUrlReplacer, url_set::const_iterator> urls_const_iterator;
98 * whether repository urls are available
100 bool baseUrlsEmpty() const;
102 * number of repository urls
104 urls_size_type baseUrlsSize() const;
106 * iterator that points at begin of repository urls
108 urls_const_iterator baseUrlsBegin() const;
110 * iterator that points at end of repository urls
112 urls_const_iterator baseUrlsEnd() const;
114 * Pars pro toto: The first repository url
117 { return( baseUrlsEmpty() ? Url() : *baseUrlsBegin()); }
119 * A Url under which the metadata are located, or a set of mirrors.
121 * This can't be empty in order the repository to be valid
122 * unless the download of the mirror list succeeds and it
123 * contains a valid url.
125 * \deprecated IMO superfluous as we provide begin/end iterator.
127 std::set<Url> baseUrls() const;
129 * Add a base url. \see baseUrls
130 * \param url The base url for the repository.
131 * \note can change keepPackages,so change it after this call
133 * To recreate the base URLs list, use \ref setBaseUrl(const Url &) followed
136 void addBaseUrl( const Url &url );
138 * Clears current base URL list and adds \a url.
139 * \note can change keepPackages,so change it after this call
141 void setBaseUrl( const Url &url );
144 * \short Repository path
146 * Pathname relative to the base Url where the product/repository
149 * For medias containing more than one product, or repositories not
150 * located at the root of the media it is important to
151 * know the path of the media root relative to the product directory
152 * so a media verifier can be set for that media.
154 * It is not mandatory, and the default is /
156 * \note As a repository can have multiple Urls, the path is unique and
157 * the same for all Urls, so it is assumed all the Urls have the
161 Pathname path() const;
163 * set the product path. \see path()
164 * \param path the path to the product
166 void setPath( const Pathname &path );
169 * Url of a file which contains a list of Urls
170 * If empty, the base url will be used.
172 Url mirrorListUrl() const;
174 * Set mirror list url. \see mirrorListUrl
175 * \param url The base url for the list
177 void setMirrorListUrl( const Url &url );
180 * Type of repository,
183 repo::RepoType type() const;
185 * This allows to adjust the \ref RepoType lazy, from \c NONE to
186 * some probed value, even for const objects.
188 * This is a NOOP if the current type is not \c NONE.
190 void setProbedType( const repo::RepoType &t ) const;
192 * set the repository type \see type
195 void setType( const repo::RepoType &t );
198 * \short Path where this repo metadata was read from
200 * \note could be an empty pathname for repo
201 * infos created in memory.
203 Pathname metadataPath() const;
205 * \short set the path where the local metadata is stored
207 * The path to the metadata of this repository
208 * was defined, or empty if nowhere.
210 * \param path directory path
212 void setMetadataPath( const Pathname &path );
215 * \short Path where this repo packages are cached
217 Pathname packagesPath() const;
219 * \short set the path where the local packages are stored
221 * \param path directory path
223 void setPackagesPath( const Pathname &path );
226 * \short Whether to check or not this repository with gpg
228 * \note This is a just a hint to the application and can
232 bool gpgCheck() const;
234 * \short Whether to check or not this repository with gpg
236 * \param check true (check) or false (dont'check)
238 * \note This is a just a hint to the application and can
242 void setGpgCheck( bool check );
245 * \short Key to use for gpg checking of this repository
247 * \param url Url to the key in ASCII armored format
249 * \note This is a just a hint to the application and can
253 Url gpgKeyUrl() const;
255 * \short Key to use for gpg checking of this repository
257 * \param url Url to the key in ASCII armored format
259 * \note This is a just a hint to the application and can
263 void setGpgKeyUrl( const Url &gpgkey );
266 * \short Whether to keep the packages downloaded from this repository will be kept in local cache
268 bool keepPackages() const;
270 * \short Set if the packaqes downloaded from this repository will be kept in local cache
272 * If the setting is true, all downloaded packages from this repository will be
273 * copied to the local raw cache.
275 * \param keep true (keep the downloaded packages) or false (delete them after installation)
278 void setKeepPackages( bool keep );
281 * Gets name of the service to which this repository belongs or empty string
282 * if it has been added manually.
284 std::string service() const;
286 * sets service which added this repository
288 void setService( const std::string& name );
291 * Distribution for which is this repository meant.
293 std::string targetDistribution() const;
295 * Sets the distribution for which is this repository meant. This is
296 * an in-memory value only, does not get written to the .repo file upon
299 void setTargetDistribution(const std::string & targetDistribution);
302 /** \name Repository license
305 /** Whether there is a license associated with the repo. */
306 bool hasLicense() const;
308 /** Return the best license for the current (or a specified) locale. */
309 std::string getLicense( const Locale & lang_r = Locale() );
311 /** Return the locales the license is available for.
312 * \ref Locale::noCode is included in case of \c license.txt which does
313 * not specify a specific locale.
315 LocaleSet getLicenseLocales() const;
319 * Write a human-readable representation of this RepoInfo object
320 * into the \a str stream. Useful for logging.
322 virtual std::ostream & dumpOn( std::ostream & str ) const;
325 * Write this RepoInfo object into \a str in a <tr>.repo</tt> file format.
327 virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
330 * Write an XML representation of this RepoInfo object.
332 virtual std::ostream & dumpAsXMLOn(std::ostream & str) const;
335 * Write an XML representation of this RepoInfo object.
338 * \param content this argument is ignored (used in other classed derived
341 virtual std::ostream & dumpAsXMLOn( std::ostream & str, const std::string & content ) const;
345 /** Pointer to implementation */
346 RWCOW_pointer<Impl> _pimpl;
348 ///////////////////////////////////////////////////////////////////
350 /** \relates RepoInfo */
351 typedef shared_ptr<RepoInfo> RepoInfo_Ptr;
352 /** \relates RepoInfo */
353 typedef shared_ptr<const RepoInfo> RepoInfo_constPtr;
354 /** \relates RepoInfo */
355 typedef std::list<RepoInfo> RepoInfoList;
357 /** \relates RepoInfo Stream output */
358 std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
361 /////////////////////////////////////////////////////////////////
363 ///////////////////////////////////////////////////////////////////
364 #endif // ZYPP2_REPOSITORYINFO_H