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/APIConfig.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 * whether there are manualy configured repository urls
104 bool baseUrlSet() const;
106 * number of repository urls
108 urls_size_type baseUrlsSize() const;
110 * iterator that points at begin of repository urls
112 urls_const_iterator baseUrlsBegin() const;
114 * iterator that points at end of repository urls
116 urls_const_iterator baseUrlsEnd() const;
118 * Pars pro toto: The first repository url
121 { return( baseUrlsEmpty() ? Url() : *baseUrlsBegin()); }
123 * A Url under which the metadata are located, or a set of mirrors.
125 * This can't be empty in order the repository to be valid
126 * unless the download of the mirror list succeeds and it
127 * contains a valid url.
129 * \deprecated IMO superfluous as we provide begin/end iterator.
131 std::set<Url> baseUrls() const;
133 * Add a base url. \see baseUrls
134 * \param url The base url for the repository.
136 * To recreate the base URLs list, use \ref setBaseUrl(const Url &) followed
139 void addBaseUrl( const Url &url );
141 * Clears current base URL list and adds \a url.
143 void setBaseUrl( const Url &url );
146 * \short Repository path
148 * Pathname relative to the base Url where the product/repository
151 * For media containing more than one product, or repositories not
152 * located at the root of the media it is important to know the path
153 * to the product directory relative to the media root. So a media
154 * verifier can be set for that media. You may also read it as
155 * <tt>baseUrl = url to mount</tt> and <tt>path = path on the
156 * mounted media</tt>.
158 * It is not mandatory, and the default is \c /.
160 * \note As a repository can have multiple Urls, the path is unique and
161 * the same for all Urls, so it is assumed all the Urls have the
165 Pathname path() const;
167 * set the product path. \see path()
168 * \param path the path to the product
170 void setPath( const Pathname &path );
173 * Url of a file which contains a list of Urls
174 * If empty, the base url will be used.
176 Url mirrorListUrl() const;
178 * Set mirror list url. \see mirrorListUrl
179 * \param url The base url for the list
181 void setMirrorListUrl( const Url &url );
184 * Type of repository,
187 repo::RepoType type() const;
189 * This allows to adjust the \ref RepoType lazy, from \c NONE to
190 * some probed value, even for const objects.
192 * This is a NOOP if the current type is not \c NONE.
194 void setProbedType( const repo::RepoType &t ) const;
196 * set the repository type \see type
199 void setType( const repo::RepoType &t );
202 * \short Path where this repo metadata was read from
204 * \note could be an empty pathname for repo
205 * infos created in memory.
207 Pathname metadataPath() const;
209 * \short set the path where the local metadata is stored
211 * The path to the metadata of this repository
212 * was defined, or empty if nowhere.
214 * \param path directory path
216 void setMetadataPath( const Pathname &path );
219 * \short Path where this repo packages are cached
221 Pathname packagesPath() const;
223 * \short set the path where the local packages are stored
225 * \param path directory path
227 void setPackagesPath( const Pathname &path );
230 * \short Whether to check or not this repository with gpg
232 * \note This is a just a hint to the application and can
236 bool gpgCheck() const;
238 * \short Whether to check or not this repository with gpg
240 * \param check true (check) or false (dont'check)
242 * \note This is a just a hint to the application and can
246 void setGpgCheck( bool check );
249 * \short Key to use for gpg checking of this repository
251 * \param url Url to the key in ASCII armored format
253 * \note This is a just a hint to the application and can
257 Url gpgKeyUrl() const;
259 * \short Key to use for gpg checking of this repository
261 * \param url Url to the key in ASCII armored format
263 * \note This is a just a hint to the application and can
267 void setGpgKeyUrl( const Url &gpgkey );
270 * \short Whether packages downloaded from this repository will be kept in local cache
272 bool keepPackages() const;
274 * \short Set if packaqes downloaded from this repository will be kept in local cache
276 * If the setting is true, all downloaded packages from this repository will be
277 * copied to the local raw cache.
279 * \param keep true (keep the downloaded packages) or false (delete them after installation)
282 void setKeepPackages( bool keep );
285 * Gets name of the service to which this repository belongs or empty string
286 * if it has been added manually.
288 std::string service() const;
290 * sets service which added this repository
292 void setService( const std::string& name );
295 * Distribution for which is this repository meant.
297 std::string targetDistribution() const;
299 * Sets the distribution for which is this repository meant. This is
300 * an in-memory value only, does not get written to the .repo file upon
303 void setTargetDistribution(const std::string & targetDistribution);
306 /** \name Repository license
309 /** Whether there is a license associated with the repo. */
310 bool hasLicense() const;
312 /** Whether the repo license has to be accepted, e.g. there is no
313 * no acceptance needed for openSUSE.
315 bool needToAcceptLicense() const;
317 /** Return the best license for the current (or a specified) locale. */
318 std::string getLicense( const Locale & lang_r = Locale() );
320 /** Return the locales the license is available for.
321 * \ref Locale::noCode is included in case of \c license.txt which does
322 * not specify a specific locale.
324 LocaleSet getLicenseLocales() const;
327 /** \name Repository global unique id
336 * Write a human-readable representation of this RepoInfo object
337 * into the \a str stream. Useful for logging.
339 virtual std::ostream & dumpOn( std::ostream & str ) const;
342 * Write this RepoInfo object into \a str in a <tr>.repo</tt> file format.
344 virtual std::ostream & dumpAsIniOn( std::ostream & str ) const;
347 * Write an XML representation of this RepoInfo object.
350 * \param content this argument is ignored (used in other classed derived
353 virtual std::ostream & dumpAsXmlOn( std::ostream & str, const std::string & content = "" ) const;
355 /** \deprecated Use camel cased dumpAsXmlOn */
356 ZYPP_DEPRECATED std::ostream & dumpAsXMLOn( std::ostream & str, const std::string & content = "" ) const { return dumpAsXmlOn( str, content ); }
360 /** Pointer to implementation */
361 RWCOW_pointer<Impl> _pimpl;
363 ///////////////////////////////////////////////////////////////////
365 /** \relates RepoInfo */
366 typedef shared_ptr<RepoInfo> RepoInfo_Ptr;
367 /** \relates RepoInfo */
368 typedef shared_ptr<const RepoInfo> RepoInfo_constPtr;
369 /** \relates RepoInfo */
370 typedef std::list<RepoInfo> RepoInfoList;
372 /** \relates RepoInfo Stream output */
373 std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
376 /////////////////////////////////////////////////////////////////
378 ///////////////////////////////////////////////////////////////////
379 #endif // ZYPP2_REPOSITORYINFO_H