53 ,
type(repo::RepoType::NONE_e)
81 std::string licenseStem(
"license" );
82 if ( !name_r.empty() )
85 licenseStem += name_r;
158 [
this](
int num_r, std::string line_r )->
bool
162 std::vector<std::string> words;
163 if (
str::split( line_r, std::back_inserter(words) ) > 1
164 && words[0].length() == 12 )
166 this->
_keywords.second.insert( ++words.begin(), words.end() );
197 return indeterminate;
205 if (
PathInfo(gpgcheckFile).isExist() )
207 TriBool linkval( indeterminate );
230 static const Pathname truePath(
"true" );
231 static const Pathname falsePath(
"false" );
232 static const Pathname indeterminatePath(
"indeterminate" );
235 static const ssize_t bufsiz = 63;
236 static char buf[bufsiz+1];
238 buf[ret == -1 ? 0 : ret] =
'\0';
243 if ( linkval == truePath )
245 else if ( linkval == falsePath )
247 else if ( linkval == indeterminatePath )
248 ret_r = indeterminate;
323 mutable std::pair<FalseBool, std::set<std::string> >
_keywords;
327 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
330 {
return new Impl( *
this ); }
337 return str <<
"RepoInfo::Impl";
349 : _pimpl( new
Impl() )
419 {
if ( ! sameTriboolState( lhs, rhs ) ) { lhs = rhs;
return true; }
return false; }
423 bool changed =
false;
424 if ( changeGpgCheckTo( ogpg[0], g ) ) changed =
true;
425 if ( changeGpgCheckTo( ogpg[1], r ) ) changed =
true;
426 if ( changeGpgCheckTo( ogpg[2], p ) ) changed =
true;
436 bool changed =
false;
440 changed = changeGpgCheckTo( ogpg,
true, indeterminate, indeterminate );
443 changed = changeGpgCheckTo( ogpg,
true,
true,
true );
446 changed = changeGpgCheckTo( ogpg,
true,
false,
false );
449 changed = changeGpgCheckTo( ogpg,
true,
false, indeterminate );
452 changed = changeGpgCheckTo( ogpg,
true, indeterminate,
false );
455 changed = changeGpgCheckTo( ogpg, indeterminate, indeterminate, indeterminate );
458 changed = changeGpgCheckTo( ogpg,
false, indeterminate, indeterminate );
629 if ( licenseTgz.
empty() )
633 cmd.push_back(
"tar" );
634 cmd.push_back(
"-t" );
635 cmd.push_back(
"-z" );
636 cmd.push_back(
"-f" );
637 cmd.push_back( licenseTgz.
asString() );
641 static const std::string noAcceptanceFile =
"no-acceptance-needed\n";
644 if ( output == noAcceptanceFile )
650 MIL <<
"License(" << name_r <<
") in " <<
name() <<
" has to be accepted: " << (accept?
"true":
"false" ) << endl;
659 {
return getLicense( std::string(), lang_r ); }
664 if ( avlocales.empty() )
665 return std::string();
668 if ( !getLang && avlocales.find(
Locale::noCode ) == avlocales.end() )
670 WAR <<
"License(" << name_r <<
") in " <<
name() <<
" contains no fallback text!" << endl;
674 getLang = *avlocales.begin();
678 static const std::string licenseFileFallback(
"license.txt" );
679 std::string licenseFile( !getLang ? licenseFileFallback
683 cmd.push_back(
"tar" );
684 cmd.push_back(
"-x" );
685 cmd.push_back(
"-z" );
686 cmd.push_back(
"-O" );
687 cmd.push_back(
"-f" );
689 cmd.push_back( licenseFile );
708 if ( licenseTgz.
empty() )
712 cmd.push_back(
"tar" );
713 cmd.push_back(
"-t" );
714 cmd.push_back(
"-z" );
715 cmd.push_back(
"-f" );
716 cmd.push_back( licenseTgz.
asString() );
722 static const C_Str license(
"license." );
723 static const C_Str dotTxt(
".txt\n" );
726 if ( output.size() <= license.
size() + dotTxt.
size() )
729 ret.insert(
Locale( std::string( output.c_str()+license.
size(), output.size()- license.
size() - dotTxt.
size() ) ) );
745 str <<
"- url : " <<
url << std::endl;
750 auto strif( [&] (
const std::string & tag_r,
const std::string & value_r ) {
751 if ( ! value_r.empty() )
752 str << tag_r << value_r << std::endl;
757 str <<
"- type : " <<
type() << std::endl;
761 #define OUTS(T,B) ( indeterminate(T) ? (std::string("D(")+(B?"Y":"N")+")") : ((bool)T?"Y":"N") )
771 str <<
"- gpgkey : " <<
url << std::endl;
777 strif(
"- service : ",
service() );
788 RepoInfoBase::dumpAsIniOn(
str);
796 str << indent <<
url << endl;
797 if ( indent.empty() ) indent =
" ";
802 str <<
"path="<<
path() << endl;
823 std::string indent(
"gpgkey=");
826 str << indent <<
url << endl;
827 if ( indent[0] !=
' ' )
851 <<
" priority=\"" <<
priority() <<
"\""
852 <<
" enabled=\"" <<
enabled() <<
"\""
854 <<
" gpgcheck=\"" <<
gpgCheck() <<
"\""
858 str <<
" gpgkey=\"" <<
escape(tmpstr) <<
"\"";
866 str <<
"<url>" <<
escape((*it).asString()) <<
"</url>" << endl;
869 str <<
"</repo>" << endl;
883 #define OUTS( V ) case RepoInfo::V: return str << #V; break
884 OUTS( GpgCheck::On );
885 OUTS( GpgCheck::Strict );
886 OUTS( GpgCheck::AllowUnsigned );
887 OUTS( GpgCheck::AllowUnsignedRepo );
888 OUTS( GpgCheck::AllowUnsignedPackage );
889 OUTS( GpgCheck::Default );
890 OUTS( GpgCheck::Off );
891 OUTS( GpgCheck::indeterminate );
894 return str <<
"GpgCheck::UNKNOWN";
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
base::ContainerTransform< std::list< Url >, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrlList
Helper managing repo variables replaced url lists.
base::ValueTransform< Url, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrl
Helper managing repo variables replaced urls.
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string.
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
std::vector< std::string > Arguments
int close()
Wait for the progamm to complete.
const char * c_str() const
'Language[_Country]' codes.
static const Locale noCode
Empty code.
static Locale bestMatch(const LocaleSet &avLocales_r, Locale requested_r=Locale())
Return the best match for Locale requested_r within the available avLocales_r.
What is known about a repository.
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
void setGpgKeyUrls(url_set urls)
Set a list of gpgkey URLs defined for this repo.
void setMetalinkUrl(const Url &url)
Like setMirrorListUrl but expect metalink format.
Pathname metadataPath() const
Path where this repo metadata was read from.
void addBaseUrl(const Url &url)
Add a base url.
void setGpgKeyUrl(const Url &gpgkey)
(leagcy API) Set the gpgkey URL defined for this repo
GpgCheck
Some predefined settings.
bool baseUrlsEmpty() const
whether repository urls are available
bool hasContent() const
Check for content keywords.
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
void setBaseUrl(const Url &url)
Clears current base URL list and adds url.
url_set gpgKeyUrls() const
The list of gpgkey URLs defined for this repo.
Url rawGpgKeyUrl() const
(leagcy API) The 1st raw gpgkey URL defined for this repo (no variables replaced)
void setMirrorListUrl(const Url &url)
Set mirror list url.
Url rawUrl() const
Pars pro toto: The first repository raw url (no variables replaced)
repo::RepoType type() const
Type of repository,.
url_set rawGpgKeyUrls() const
The list of raw gpgkey URLs defined for this repo (no variables replaced)
static unsigned noPriority()
The least priority (unsigned(-1)).
urls_size_type baseUrlsSize() const
number of repository urls
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
Url url() const
Pars pro toto: The first repository url.
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
const std::set< std::string > & contentKeywords() const
Content keywords defined.
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
virtual std::ostream & dumpOn(std::ostream &str) const
Write a human-readable representation of this RepoInfo object into the str stream.
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
bool baseUrlSet() const
Whether there are manualy configured repository urls.
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
void setService(const std::string &name)
sets service which added this repository
void setGpgCheck(TriBool value_r)
Set the value for gpgCheck (or indeterminate to use the default).
virtual std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const
Write an XML representation of this RepoInfo object.
Pathname path() const
Repository path.
urls_size_type gpgKeyUrlsSize() const
Number of gpgkey URLs defined.
LocaleSet getLicenseLocales() const
Return the locales the license is available for.
url_set baseUrls() const
The complete set of repository urls.
bool pkgGpgCheckIsMandatory() const
Mandatory check (pkgGpgCheck is not off) must ask to confirm using unsigned packages.
url_set rawBaseUrls() const
The complete set of raw repository urls (no variables replaced)
Url mirrorListUrl() const
Url of a file which contains a list of repository urls.
bool usesAutoMethadataPaths() const
Whether metadataPath uses AUTO% setup.
url_set::size_type urls_size_type
void setProbedType(const repo::RepoType &t) const
This allows to adjust the RepoType lazy, from NONE to some probed value, even for const objects.
void setBaseUrls(url_set urls)
Clears current base URL list and adds an url_set.
std::string service() const
Gets name of the service to which this repository belongs or empty string if it has been added manual...
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
unsigned priority() const
Repository priority for solver.
bool gpgCheck() const
Whether default signature checking should be performed.
void setPath(const Pathname &path)
set the product path.
Url gpgKeyUrl() const
(leagcy API) The 1st gpgkey URL defined for this repo
void setValidRepoSignature(TriBool value_r)
Set the value for validRepoSignature (or indeterminate if unsigned).
static unsigned defaultPriority()
The default priority (99).
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
void setPriority(unsigned newval_r)
Set repository priority for solver.
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
bool hasLicense() const
Whether there is a license associated with the repo.
bool repoGpgCheckIsMandatory() const
Mandatory check (repoGpgCheck is on) must ask to confirm using unsigned repos.
void setMetadataPath(const Pathname &path)
Set the path where the local metadata is stored.
TriBool validRepoSignature() const
Whether the repo metadata are signed and successfully validated or indeterminate if unsigned.
void setRepoGpgCheck(TriBool value_r)
Set the value for repoGpgCheck (or indeterminate to use the default).
Pathname packagesPath() const
Path where this repo packages are cached.
void addContent(const std::string &keyword_r)
Add content keywords.
bool repoGpgCheck() const
Whether the signature of repo metadata should be checked for this repo.
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
std::string targetDistribution() const
Distribution for which is this repository meant.
void getRawGpgChecks(TriBool &g_r, TriBool &r_r, TriBool &p_r) const
Raw values for RepoManager.
void setType(const repo::RepoType &t)
set the repository type
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
Url rawMirrorListUrl() const
The raw mirrorListUrl (no variables replaced).
bool gpgKeyUrlsEmpty() const
Whether gpgkey URLs are defined.
std::string asString() const
Returns a default string representation of the Url object.
bool gpgCheck() const
Turn signature checking on/off (on)
TriBool pkgGpgCheck() const
Check rpm package signatures (indeterminate - according to gpgcheck)
static ZConfig & instance()
Singleton ctor.
TriBool repoGpgCheck() const
Check repo matadata signatures (indeterminate - according to gpgcheck)
std::string receiveLine()
Read one line from the input stream.
Find pathnames matching a pattern.
bool empty() const
Whether matches were found.
const_iterator begin() const
Iterator pointing to the first result.
int add(const Pathname &pattern_r, Flags flags_r=Flags())
Add pathnames matching pattern_r to the current result.
Wrapper class for ::stat/::lstat.
Pathname dirname() const
Return all but the last component od this path.
const std::string & asString() const
String representation.
bool empty() const
Test for an empty path.
const char * c_str() const
String representation.
Pathname filepath() const
File where this repo was read from.
bool autorefresh() const
If true, the repostory must be refreshed before creating resolvables from it.
std::string name() const
Repository name.
bool enabled() const
If enabled is false, then this repository must be ignored as if does not exists, except when checking...
std::string alias() const
unique identifier for this source.
const std::vector< Url > & getUrls() const
xmlTextReader based interface to iterate xml streams.
bool seekToEndNode(int depth_r, const std::string &name_r)
XmlString nodeText()
If the current node is not empty, advances the reader to the next node, and returns the value.
bool seekToNode(int depth_r, const std::string &name_r)
std::string asString() const
Explicit conversion to std::string.
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
std::ostream & dumpOn(std::ostream &str, const zypp::shared_ptr< void > &obj)
String related utilities and Regular expression matching.
int unlink(const Pathname &path)
Like 'unlink'.
int readlink(const Pathname &symlink_r, Pathname &target_r)
Like 'readlink'.
int symlink(const Pathname &oldpath, const Pathname &newpath)
Like 'symlink'.
int forEachLine(std::istream &str_r, function< bool(int, std::string)> consume_r)
Simple lineparser: Call functor consume_r for each line.
bool hasSuffix(const C_Str &str_r, const C_Str &suffix_r)
Return whether str_r has suffix suffix_r.
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \t")
Split line_r into words.
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
bool startsWith(const C_Str &str_r, const C_Str &prefix_r)
alias for hasPrefix
std::string escape(const C_Str &str_r, const char sep_r)
Escape desired character c using a backslash.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
detail::EscapedString escape(const std::string &in_r)
Escape xml special charaters (& -> &; from IoBind library).
Easy-to use interface to the ZYPP dependency resolver.
std::string asString(const DefaultIntegral< Tp, TInitial > &obj)
std::ostream & operator<<(std::ostream &str, const Exception &obj)
std::unordered_set< Locale > LocaleSet
TriBool rawPkgGpgCheck() const
RepoVariablesReplacedUrlList & baseUrls()
TriBool _rawRepoGpgCheck
need to check repo sign.: Y/N/(ZConf(Y/N/gpgCheck))
TriBool internalValidRepoSignature() const
Signature check result needs to be stored/retrieved from _metadataPath.
bool triBoolFromPath(const Pathname &path_r, TriBool &ret_r) const
bool internalUnsignedConfirmed() const
We definitely have a symlink pointing to "indeterminate" (for repoGpgCheckIsMandatory)?...
TriBool triBoolFromPath(const Pathname &path_r) const
void packagesPath(Pathname new_r)
void rawRepoGpgCheck(TriBool val_r)
void rawPkgGpgCheck(TriBool val_r)
bool usesAutoMethadataPaths() const
Pathname licenseTgz(const std::string &name_r) const
Path to a license tarball in case it exists in the repo.
RepoVariablesReplacedUrl _mirrorListUrl
bool _mirrorListForceMetalink
Pathname metadataPath() const
DefaultIntegral< unsigned, defaultPriority > priority
std::ostream & operator<<(std::ostream &str, const RepoInfo::Impl &obj)
Stream output.
const std::set< std::string > & contentKeywords() const
bool hasContent(const std::string &keyword_r) const
TriBool cfgPkgGpgCheck() const
bool baseurl2dump() const
RepoVariablesReplacedUrlList _gpgKeyUrls
RepoVariablesReplacedUrlList _baseUrls
Impl * clone() const
clone for RWCOW_pointer
const RepoVariablesReplacedUrlList & baseUrls() const
const RepoVariablesReplacedUrlList & gpgKeyUrls() const
void rawGpgCheck(TriBool val_r)
void addContent(const std::string &keyword_r)
TriBool _rawGpgCheck
default gpgcheck behavior: Y/N/ZConf
Pathname packagesPath() const
void metadataPath(Pathname new_r)
TriBool rawGpgCheck() const
TriBool rawRepoGpgCheck() const
void internalSetValidRepoSignature(TriBool value_r)
TriBool cfgRepoGpgCheck() const
static const unsigned defaultPriority
TriBool _rawPkgGpgCheck
need to check pkg sign.: Y/N/(ZConf(Y/N/gpgCheck))
void setProbedType(const repo::RepoType &t) const
RepoVariablesReplacedUrlList & gpgKeyUrls()
TriBool _validRepoSignature
have signed and valid repo metadata
std::pair< FalseBool, std::set< std::string > > _keywords
static const unsigned noPriority
repo::RepoVariablesUrlReplacer replacer
Repository type enumeration.
const std::string & asString() const
static const RepoType NONE
Functor replacing repository variables.