52 ,
type(repo::RepoType::NONE_e)
80 if (
_baseUrls.empty() && ! mlurl.asString().empty() )
119 if ( PathInfo( (master=
metadatapath/
"/repodata/repomd.xml") ).isFile() )
130 else if ( PathInfo( (master=
metadatapath/
"/content") ).isFile() )
134 [
this](
int num_r, std::string line_r )->
bool
138 std::vector<std::string> words;
139 if (
str::split( line_r, std::back_inserter(words) ) > 1
140 && words[0].length() == 12 )
142 this->
_keywords.second.insert( ++words.begin(), words.end() );
173 return indeterminate;
180 Pathname gpgcheckFile(
metadatapath /
".repo_gpgcheck" );
181 if ( PathInfo(gpgcheckFile).isExist() )
183 TriBool linkval( indeterminate );
206 static const Pathname truePath(
"true" );
207 static const Pathname falsePath(
"false" );
208 static const Pathname indeterminatePath(
"indeterminate" );
211 static const ssize_t bufsiz = 63;
212 static char buf[bufsiz+1];
213 ssize_t ret =
::readlink( path_r.c_str(), buf, bufsiz );
214 buf[ret == -1 ? 0 : ret] =
'\0';
216 Pathname linkval( buf );
219 if ( linkval == truePath )
221 else if ( linkval == falsePath )
223 else if ( linkval == indeterminatePath )
224 ret_r = indeterminate;
274 mutable std::pair<FalseBool, std::set<std::string> >
_keywords;
278 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
281 {
return new Impl( *
this ); }
288 return str <<
"RepoInfo::Impl";
300 : _pimpl( new
Impl() )
376 {
if ( ! sameTriboolState( lhs, rhs ) ) { lhs = rhs;
return true; }
return false; }
380 bool changed =
false;
381 if ( changeGpgCheckTo( ogpg[0], g ) ) changed =
true;
382 if ( changeGpgCheckTo( ogpg[1], r ) ) changed =
true;
383 if ( changeGpgCheckTo( ogpg[2], p ) ) changed =
true;
393 bool changed =
false;
394 switch ( mode_r.asEnum() )
397 changed = changeGpgCheckTo( ogpg,
true, indeterminate, indeterminate );
399 case GpgCheck::Strict:
400 changed = changeGpgCheckTo( ogpg,
true,
true,
true );
402 case GpgCheck::AllowUnsigned:
403 changed = changeGpgCheckTo( ogpg,
true,
false,
false );
405 case GpgCheck::AllowUnsignedRepo:
406 changed = changeGpgCheckTo( ogpg,
true,
false, indeterminate );
408 case GpgCheck::AllowUnsignedPackage:
409 changed = changeGpgCheckTo( ogpg,
true, indeterminate,
false );
411 case GpgCheck::Default:
412 changed = changeGpgCheckTo( ogpg, indeterminate, indeterminate, indeterminate );
415 changed = changeGpgCheckTo( ogpg,
false, indeterminate, indeterminate );
417 case GpgCheck::indeterminate:
573 return ! licenseTgz.empty() && PathInfo(licenseTgz).isFile();
578 static const std::string noAcceptanceFile =
"no-acceptance-needed\n";
582 if ( licenseTgz.empty() || ! PathInfo( licenseTgz ).isFile() )
586 cmd.push_back(
"tar" );
587 cmd.push_back(
"-t" );
588 cmd.push_back(
"-z" );
589 cmd.push_back(
"-f" );
590 cmd.push_back( licenseTgz.asString() );
595 if ( output == noAcceptanceFile )
601 MIL <<
"License for " <<
name() <<
" has to be accepted: " << (accept?
"true":
"false" ) << endl;
611 if ( avlocales.empty() )
612 return std::string();
615 if ( !getLang && avlocales.find(
Locale::noCode ) == avlocales.end() )
617 WAR <<
"License.tar.gz contains no fallback text! " << *
this << endl;
621 getLang = *avlocales.begin();
625 static const std::string licenseFileFallback(
"license.txt" );
626 std::string licenseFile( !getLang ? licenseFileFallback
630 cmd.push_back(
"tar" );
631 cmd.push_back(
"-x" );
632 cmd.push_back(
"-z" );
633 cmd.push_back(
"-O" );
634 cmd.push_back(
"-f" );
636 cmd.push_back( licenseFile );
651 if ( licenseTgz.empty() || ! PathInfo( licenseTgz ).isFile() )
655 cmd.push_back(
"tar" );
656 cmd.push_back(
"-t" );
657 cmd.push_back(
"-z" );
658 cmd.push_back(
"-f" );
659 cmd.push_back( licenseTgz.asString() );
665 static const C_Str license(
"license." );
666 static const C_Str dotTxt(
".txt\n" );
669 if ( output.size() <= license.
size() + dotTxt.
size() )
672 ret.insert(
Locale( std::string( output.c_str()+license.
size(), output.size()- license.
size() - dotTxt.
size() ) ) );
688 str <<
"- url : " <<
url << std::endl;
693 auto strif( [&] (
const std::string & tag_r,
const std::string & value_r ) {
694 if ( ! value_r.empty() )
695 str << tag_r << value_r << std::endl;
700 str <<
"- type : " <<
type() << std::endl;
701 str <<
"- priority : " <<
priority() << std::endl;
704 #define OUTS(T,B) ( indeterminate(T) ? (std::string("D(")+(B?"Y":"N")+")") : ((bool)T?"Y":"N") )
714 str <<
"- gpgkey : " <<
url << std::endl;
718 str <<
"- keeppackages: " <<
keepPackages() << std::endl;
720 strif(
"- service : ",
service() );
730 RepoInfoBase::dumpAsIniOn(str);
738 str << indent <<
url << endl;
739 if ( indent.empty() ) indent =
" ";
744 str <<
"path="<<
path() << endl;
752 str <<
"priority=" <<
priority() << endl;
764 std::string indent(
"gpgkey=");
767 str << indent <<
url << endl;
768 if ( indent[0] !=
' ' )
777 str <<
"service=" <<
service() << endl;
792 <<
" priority=\"" <<
priority() <<
"\""
793 <<
" enabled=\"" <<
enabled() <<
"\""
795 <<
" gpgcheck=\"" <<
gpgCheck() <<
"\""
799 str <<
" gpgkey=\"" <<
escape(tmpstr) <<
"\"";
807 str <<
"<url>" <<
escape((*it).asString()) <<
"</url>" << endl;
810 str <<
"</repo>" << endl;
822 switch ( obj.asEnum() )
824 #define OUTS( V ) case RepoInfo::V: return str << #V; break
825 OUTS( GpgCheck::On );
826 OUTS( GpgCheck::Strict );
827 OUTS( GpgCheck::AllowUnsigned );
828 OUTS( GpgCheck::AllowUnsignedRepo );
829 OUTS( GpgCheck::AllowUnsignedPackage );
830 OUTS( GpgCheck::Default );
831 OUTS( GpgCheck::Off );
832 OUTS( GpgCheck::indeterminate );
835 return str <<
"GpgCheck::UNKNOWN";
std::string asString(const Patch::Category &obj)
static const Locale noCode
Empty code.
LocaleSet getLicenseLocales() const
Return the locales the license is available for.
TriBool internalValidRepoSignature() const
Signature check result needs to be stored/retrieved from _metadatapath.
std::string name() const
Repository name.
std::string targetDistribution() const
Distribution for which is this repository meant.
bool gpgKeyUrlsEmpty() const
Whether gpgkey URLs are defined.
void setGpgKeyUrl(const Url &gpgkey)
(leagcy API) Set the gpgkey URL defined for this repo
static unsigned defaultPriority()
The default priority (99).
std::string alias() const
unique identifier for this source.
TriBool repoGpgCheck() const
Check repo matadata signatures (indeterminate - according to gpgcheck)
Url rawUrl() const
Pars pro toto: The first repository raw url (no variables replaced)
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
bool _mirrorListForceMetalink
static ZConfig & instance()
Singleton ctor.
void setPriority(unsigned newval_r)
Set repository priority for solver.
int readlink(const Pathname &symlink_r, Pathname &target_r)
Like 'readlink'.
void rawGpgCheck(TriBool val_r)
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
url_set gpgKeyUrls() const
The list of gpgkey URLs defined for this repo.
void setMirrorListUrl(const Url &url)
Set mirror list url.
repo::RepoVariablesUrlReplacer replacer
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
std::string escape(const C_Str &str_r, const char sep_r)
Escape desired character c using a backslash.
std::ostream & dumpOn(std::ostream &str, const zypp::shared_ptr< void > &obj)
Pathname metadataPath() const
Path where this repo metadata was read from.
std::ostream & operator<<(std::ostream &str, const RepoInfo::Impl &obj)
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
void setProbedType(const repo::RepoType &t) const
This allows to adjust the RepoType lazy, from NONE to some probed value, even for const objects...
TriBool rawPkgGpgCheck() const
What is known about a repository.
void getRawGpgChecks(TriBool &g_r, TriBool &r_r, TriBool &p_r) const
Raw values for RepoManager.
void setGpgCheck(TriBool value_r)
Set the value for gpgCheck (or indeterminate to use the default).
TriBool _rawPkgGpgCheck
need to check pkg sign.: Y/N/(ZConf(Y/N/gpgCheck))
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
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
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
void internalSetValidRepoSignature(TriBool value_r)
Pathname packagesPath() const
Path where this repo packages are cached.
base::ValueTransform< Url, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrl
unsigned priority() const
Repository priority for solver.
TriBool triBoolFromPath(const Pathname &path_r) const
void setValidRepoSignature(TriBool value_r)
Set the value for validRepoSignature (or indeterminate if unsigned).
std::vector< std::string > Arguments
bool repoGpgCheck() const
Whether the signature of repo metadata should be checked for this repo.
bool seekToNode(int depth_r, const std::string &name_r)
url_set rawGpgKeyUrls() const
The list of raw gpgkey URLs defined for this repo (no variables replaced)
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
bool pkgGpgCheckIsMandatory() const
Mandatory check (pkgGpgCheck is not off) must ask to confirm using unsigned packages.
RepoVariablesReplacedUrlList _baseUrls
static Locale bestMatch(const LocaleSet &avLocales_r, Locale requested_r=Locale())
Return the best match for Locale requested_r within the available avLocales_r.
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.
Url rawMirrorListUrl() const
The raw mirrorListUrl (no variables replaced).
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \t")
Split line_r into words.
bool gpgCheck() const
Turn signature checking on/off (on)
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 ...
int unlink(const Pathname &path)
Like 'unlink'.
RepoVariablesReplacedUrlList & baseUrls()
void setRepoGpgCheck(TriBool value_r)
Set the value for repoGpgCheck (or indeterminate to use the default).
Url mirrorListUrl() const
Url of a file which contains a list of repository urls.
void addContent(const std::string &keyword_r)
bool internalUnsignedConfirmed() const
We definitely have a symlink pointing to "indeterminate" (for repoGpgCheckIsMandatory)? I.e.
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string...
int forEachLine(std::istream &str_r, function< bool(int, std::string)> consume_r)
Simple lineparser: Call functor consume_r for each line.
TriBool pkgGpgCheck() const
Check rpm package signatures (indeterminate - according to gpgcheck)
void setPath(const Pathname &path)
set the product path.
bool hasContent() const
Check for content keywords.
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 default signature checking should be performed.
RepoVariablesReplacedUrlList & gpgKeyUrls()
urls_size_type gpgKeyUrlsSize() const
Number of gpgkey URLs defined.
bool startsWith(const C_Str &str_r, const C_Str &prefix_r)
alias for hasPrefix
void setType(const repo::RepoType &t)
set the repository type
TriBool _rawGpgCheck
default gpgcheck behavior: Y/N/ZConf
TriBool _validRepoSignature
have signed and valid repo metadata
bool baseUrlSet() const
Whether there are manualy configured repository urls.
Impl * clone() const
clone for RWCOW_pointer
std::pair< FalseBool, std::set< std::string > > _keywords
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
TriBool cfgRepoGpgCheck() const
bool seekToEndNode(int depth_r, const std::string &name_r)
int symlink(const Pathname &oldpath, const Pathname &newpath)
Like 'symlink'.
void addBaseUrl(const Url &url)
Add a base url.
std::string receiveLine()
Read one line from the input stream.
TriBool _rawRepoGpgCheck
need to check repo sign.: Y/N/(ZConf(Y/N/gpgCheck))
static const RepoType NONE
static const unsigned noPriority
base::ContainerTransform< std::list< Url >, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrlList
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
url_set baseUrls() const
The complete set of repository urls.
const std::vector< Url > & getUrls() const
url_set rawBaseUrls() const
The complete set of raw repository urls (no variables replaced)
std::string asString() const
Explicit conversion to std::string.
'Language[_Country]' codes.
int close()
Wait for the progamm to complete.
void setMetalinkUrl(const Url &url)
Like setMirrorListUrl but expect metalink format.
bool baseUrlsEmpty() const
whether repository urls are available
void setGpgKeyUrls(url_set urls)
Set a list of gpgkey URLs defined for this repo.
repo::RepoType type() const
Type of repository,.
void setProbedType(const repo::RepoType &t) const
bool triBoolFromPath(const Pathname &path_r, TriBool &ret_r) const
const char * c_str() const
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 rawRepoGpgCheck(TriBool val_r)
const std::set< std::string > & contentKeywords() const
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
bool autorefresh() const
If true, the repostory must be refreshed before creating resolvables from it.
XmlString nodeText()
If the curent node is not empty, advances the reader to the next node, and returns the value...
bool hasLicense() const
Whether there is a license associated with the repo.
RepoVariablesReplacedUrlList _gpgKeyUrls
bool hasContent(const std::string &keyword_r) const
bool repoGpgCheckIsMandatory() const
Mandatory check (repoGpgCheck is on) must ask to confirm using unsigned repos.
Url gpgKeyUrl() const
(leagcy API) The 1st gpgkey URL defined for this repo
RepoVariablesReplacedUrl _mirrorListUrl
DefaultIntegral< unsigned, defaultPriority > priority
Url url() const
Pars pro toto: The first repository url.
const std::set< std::string > & contentKeywords() const
Content keywords defined.
void setBaseUrls(url_set urls)
Clears current base URL list and adds an url_set.
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
base::EnumClass< GpgCheckDef > GpgCheck
'enum class GpgCheck'
void addContent(const std::string &keyword_r)
Add content keywords.
void rawPkgGpgCheck(TriBool val_r)
virtual std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const
Write an XML representation of this RepoInfo object.
TriBool validRepoSignature() const
Whether the repo metadata are signed and successfully validated or indeterminate if unsigned...
Functor replacing repository variables.
urls_size_type baseUrlsSize() const
number of repository urls
TriBool rawRepoGpgCheck() const
static const unsigned defaultPriority
const RepoVariablesReplacedUrlList & gpgKeyUrls() const
static unsigned noPriority()
The least priority (unsigned(-1)).
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
TriBool rawGpgCheck() const
const RepoVariablesReplacedUrlList & baseUrls() const
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
std::unordered_set< Locale > LocaleSet
Url rawGpgKeyUrl() const
(leagcy API) The 1st raw gpgkey URL defined for this repo (no variables replaced) ...
TriBool cfgPkgGpgCheck() const
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.
detail::EscapedString escape(const std::string &in_r)
Escape xml special charaters (& -> &; from IoBind library).
Repository type enumeration.
xmlTextReader based interface to iterate xml streams.