40 : repo::RepoInfoBase::
Impl()
41 , gpgcheck(indeterminate)
42 , keeppackages(indeterminate)
43 , type(repo::RepoType::NONE_e)
44 , emptybaseurls(false)
51 static const unsigned defaultPriority = 99;
55 if ( type == repo::RepoType::NONE
56 && t != repo::RepoType::NONE )
59 const_cast<Impl*
>(
this)->type = t;
65 {
return metadatapath.empty() ? Pathname() : metadatapath / path /
"license.tar.gz"; }
68 {
return replacer(mirrorlist_url); }
71 {
return mirrorlist_url; }
75 if ( _baseUrls.empty() && ! (getmirrorListUrl().asString().empty()) )
80 DBG <<
"MetadataPath: " << metadatapath << endl;
81 if( metadatapath.empty() )
86 std::vector<Url> rmurls = rmirrorlist->
getUrls();
89 _baseUrls.insert(rmurls.begin(), rmurls.end());
98 {
return !emptybaseurls && !_baseUrls.empty(); }
118 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
121 {
return new Impl( *
this ); }
128 return str <<
"RepoInfo::Impl";
145 : _pimpl( new
Impl() )
159 {
return _pimpl->priority; }
177 {
_pimpl->baseUrls().insert(url); }
181 _pimpl->baseUrls().clear();
192 {
_pimpl->setProbedType( t ); }
202 {
_pimpl->keeppackages = keep; }
211 {
return indeterminate(
_pimpl->gpgcheck) ?
true : (bool)
_pimpl->gpgcheck; }
214 {
return indeterminate(
_pimpl->keeppackages) ?
false : (bool)
_pimpl->keeppackages; }
217 {
return _pimpl->metadatapath; }
220 {
return _pimpl->packagespath; }
226 {
return _pimpl->getmirrorListUrl(); }
229 {
return _pimpl->gpgkey_url; }
234 for ( url_set::const_iterator it =
_pimpl->baseUrls().begin();
235 it !=
_pimpl->baseUrls().end();
238 replaced_urls.insert(
_pimpl->replacer(*it));
240 return replaced_urls;
247 {
return _pimpl->service; }
250 {
return _pimpl->targetDistro; }
254 return make_transform_iterator(
_pimpl->baseUrls().begin(),
262 return make_transform_iterator(
_pimpl->baseUrls().end(),
267 {
return _pimpl->baseUrls().size(); }
270 {
return _pimpl->baseUrls().empty(); }
273 {
return _pimpl->baseurl2dump(); }
279 Pathname licenseTgz(
_pimpl->licenseTgz() );
280 SEC << licenseTgz << endl;
281 SEC << PathInfo(licenseTgz) << endl;
283 return ! licenseTgz.empty() && PathInfo(licenseTgz).isFile();
288 static const std::string noAcceptanceFile =
"no-acceptance-needed\n";
291 Pathname licenseTgz(
_pimpl->licenseTgz() );
292 if ( licenseTgz.empty() || ! PathInfo( licenseTgz ).isFile() )
296 cmd.push_back(
"tar" );
297 cmd.push_back(
"-t" );
298 cmd.push_back(
"-z" );
299 cmd.push_back(
"-f" );
300 cmd.push_back( licenseTgz.asString() );
305 if ( output == noAcceptanceFile )
310 MIL <<
"License for " << this->
name() <<
" has to be accepted: " << (accept?
"true":
"false" ) << endl;
317 if ( avlocales.empty() )
318 return std::string();
324 WAR <<
"License.tar.gz contains no fallback text! " << *
this << endl;
328 getLang = *avlocales.begin();
332 static const std::string licenseFileFallback(
"license.txt" );
334 ? licenseFileFallback
338 cmd.push_back(
"tar" );
339 cmd.push_back(
"-x" );
340 cmd.push_back(
"-z" );
341 cmd.push_back(
"-O" );
342 cmd.push_back(
"-f" );
343 cmd.push_back(
_pimpl->licenseTgz().asString() );
344 cmd.push_back( licenseFile );
358 Pathname licenseTgz(
_pimpl->licenseTgz() );
359 if ( licenseTgz.empty() || ! PathInfo( licenseTgz ).isFile() )
363 cmd.push_back(
"tar" );
364 cmd.push_back(
"-t" );
365 cmd.push_back(
"-z" );
366 cmd.push_back(
"-f" );
367 cmd.push_back( licenseTgz.asString() );
373 static const C_Str license(
"license." );
374 static const C_Str dotTxt(
".txt\n" );
377 if ( output.size() <= license.
size() + dotTxt.
size() )
380 ret.insert(
Locale( std::string( output.c_str()+license.
size(), output.size()- license.
size() - dotTxt.
size() ) ) );
392 if (
_pimpl->baseurl2dump() )
398 str <<
"- url : " << *it << std::endl;
403 auto strif( [&] (
const std::string & tag_r,
const std::string & value_r ) {
404 if ( ! value_r.empty() )
405 str << tag_r << value_r << std::endl;
408 strif(
"- mirrorlist : ",
_pimpl->getmirrorListUrl().asString() );
410 str <<
"- type : " <<
type() << std::endl;
411 str <<
"- priority : " <<
priority() << std::endl;
412 str <<
"- gpgcheck : " <<
gpgCheck() << std::endl;
415 if ( ! indeterminate(
_pimpl->keeppackages) )
416 str <<
"- keeppackages: " <<
keepPackages() << std::endl;
418 strif(
"- service : ",
service() );
428 RepoInfoBase::dumpAsIniOn(str);
430 if (
_pimpl->baseurl2dump() )
433 for ( url_set::const_iterator it =
_pimpl->baseUrls().begin();
434 it !=
_pimpl->baseUrls().end();
441 if ( !
_pimpl->path.empty() )
442 str <<
"path="<<
path() << endl;
444 if ( ! (
_pimpl->getmirrorListUrl().asString().empty()) )
445 str <<
"mirrorlist=" <<
_pimpl->getmirrorListUrl() << endl;
450 str <<
"priority=" <<
priority() << endl;
452 if (!indeterminate(
_pimpl->gpgcheck))
453 str <<
"gpgcheck=" << (
gpgCheck() ?
"1" :
"0") << endl;
457 if (!indeterminate(
_pimpl->keeppackages))
461 str <<
"service=" <<
service() << endl;
479 <<
" priority=\"" <<
priority() <<
"\""
480 <<
" enabled=\"" <<
enabled() <<
"\""
482 <<
" gpgcheck=\"" <<
gpgCheck() <<
"\"";
484 str <<
" gpgkey=\"" <<
escape(tmpstr) <<
"\"";
486 str <<
" mirrorlist=\"" <<
escape(tmpstr) <<
"\"";
489 if (
_pimpl->baseurl2dump() )
493 str <<
"<url>" <<
escape(urlit->asString()) <<
"</url>" << endl;
496 str <<
"</repo>" << endl;
static const Locale noCode
No or empty code.
LocaleSet getLicenseLocales() const
Return the locales the license is available for.
std::string name() const
Repository short label.
std::string targetDistribution() const
Distribution for which is this repository meant.
void setGpgKeyUrl(const Url &gpgkey)
Key to use for gpg checking of this repository.
static unsigned defaultPriority()
The default priority (99).
std::string alias() const
unique identifier for this source.
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
void setPriority(unsigned newval_r)
Set repository priority for solver.
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
void setMirrorListUrl(const Url &url)
Set mirror list url.
virtual std::ostream & dumpAsXMLOn(std::ostream &str) const
Write an XML representation of this RepoInfo object.
repo::RepoVariablesUrlReplacer replacer
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
std::string getLicense(const Locale &lang_r=Locale())
Return the best license for the current (or a specified) locale.
std::set< Url > & baseUrls()
std::string escape(const C_Str &str_r, const char sep_r)
Escape desired character c using a backslash.
Pathname metadataPath() const
Path where this repo metadata was read from.
std::ostream & operator<<(std::ostream &str, const RepoInfo::Impl &obj)
void setProbedType(const repo::RepoType &t) const
This allows to adjust the RepoType lazy, from NONE to some probed value, even for const objects...
What is known about a repository.
void setBaseUrl(const Url &url)
Clears current base URL list and adds url.
bool enabled() const
If enabled is false, then this repository must be ignored as if does not exists, except when checking...
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
Pathname packagesPath() const
Path where this repo packages are cached.
unsigned priority() const
Repository priority for solver.
std::vector< std::string > Arguments
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
std::string escape(const std::string &in_r)
Escape xml special charaters (& -> &; from IoBind library).
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
Url mirrorListUrl() const
Url of a file which contains a list of Urls If empty, the base url will be used.
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string...
void setPath(const Pathname &path)
set the product path.
void setService(const std::string &name)
sets service which added this repository
void setMetadataPath(const Pathname &path)
set the path where the local metadata is stored
bool gpgCheck() const
Whether to check or not this repository with gpg.
std::set< Url > _baseUrls
void setType(const repo::RepoType &t)
set the repository type
bool baseUrlSet() const
whether there are manualy configured repository urls
Impl * clone() const
clone for RWCOW_pointer
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
std::string service() const
Gets name of the service to which this repository belongs or empty string if it has been added manual...
bool baseurl2dump() const
const std::string & asString() const
std::tr1::unordered_set< Locale > LocaleSet
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
void addBaseUrl(const Url &url)
Add a base url.
std::string receiveLine()
Read one line from the input stream.
static const RepoType NONE
std::string asString(const Patch::SeverityFlag &obj)
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
int close()
Wait for the progamm to complete.
bool baseUrlsEmpty() const
whether repository urls are available
std::string form(const char *format,...)
Printf style construction of std::string.
repo::RepoType type() const
Type of repository,.
void setProbedType(const repo::RepoType &t) const
std::string code() const
Return the locale code.
Pathname licenseTgz() const
url_set::size_type urls_size_type
bool hasSuffix(const C_Str &str_r, const C_Str &suffix_r)
Return whether str_r has suffix suffix_r.
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
Url getmirrorListUrl() const
bool autorefresh() const
If true, the repostory must be refreshed before creating resolvables from it.
std::set< Url > baseUrls() const
A Url under which the metadata are located, or a set of mirrors.
bool hasLicense() const
Whether there is a license associated with the repo.
Url gpgKeyUrl() const
Key to use for gpg checking of this repository.
DefaultIntegral< unsigned, defaultPriority > priority
Url url() const
Pars pro toto: The first repository url.
void setGpgCheck(bool check)
Whether to check or not this repository with gpg.
const std::set< Url > & baseUrls() const
bool check(const std::string &sequenceinfo_r, bool quick_r)
Check via sequence info.
std::vector< Url > getUrls() const
Functor replacing repository variables.
urls_size_type baseUrlsSize() const
number of repository urls
static Locale bestMatch(const LocaleSet &avLocales_r, const Locale &requested_r=Locale())
Return the best match for Locale requested_r within the available avLocales_r.
static const unsigned defaultPriority
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
Pathname path() const
Repository path.
virtual std::ostream & dumpOn(std::ostream &str) const
Write a human-readable representation of this RepoInfo object into the str stream.
Repository type enumeration.