19#include <zypp-core/base/DefaultIntegral>
35#include <zypp-core/base/InputStream>
56 repo::RepoType probeCache(
const Pathname & path_r )
59 if ( PathInfo(path_r).isDir() )
61 if ( PathInfo(path_r/
"/repodata/repomd.xml").isFile() )
63 else if ( PathInfo(path_r/
"/content").isFile() )
65 else if ( PathInfo(path_r/
"/cookie").isFile() )
68 DBG <<
"Probed cached type " << ret <<
" at " << path_r << endl;
85 ,
_type(repo::RepoType::NONE_e)
191 while (
reader.seekToNode( 2,
"content" ) )
194 reader.seekToEndNode( 2,
"content" );
202 [
this](
int num_r,
const std::string&
line_r )->
bool
206 std::vector<std::string>
words;
208 &&
words[0].length() == 12 )
366 mutable std::pair<FalseBool, std::set<std::string> >
_keywords;
373 {
return new Impl( *
this ); }
380 return str <<
"RepoInfo::Impl";
399 {
return _pimpl->priority; }
412 {
return _pimpl->cfgGpgCheck(); }
427 if (
ret &&
_pimpl->internalUnsignedConfirmed() )
468 {
if ( !
sameTriboolState( lhs, rhs ) ) { lhs = rhs;
return true; }
return false; }
472 bool changed =
false;
473 if ( changeGpgCheckTo( ogpg[0], g ) ) changed =
true;
474 if ( changeGpgCheckTo( ogpg[1], r ) ) changed =
true;
475 if ( changeGpgCheckTo( ogpg[2], p ) ) changed =
true;
523 {
_pimpl->_mirrorListUrl.raw() =
url_r;
_pimpl->_mirrorListForceMetalink =
false; }
529 {
_pimpl->_mirrorListUrl.raw() =
url_r;
_pimpl->_mirrorListForceMetalink =
true; }
535 {
_pimpl->gpgKeyUrls().raw().swap( urls ); }
539 _pimpl->gpgKeyUrls().raw().clear();
550 for (
const auto &
url :
_pimpl->baseUrls().raw() )
553 _pimpl->baseUrls().raw().push_back( std::move(
url_r) );
558 _pimpl->baseUrls().raw().clear();
559 _pimpl->baseUrls().raw().push_back( std::move(
url_r) );
563 {
_pimpl->baseUrls().raw().swap( urls ); }
572 {
_pimpl->setProbedType(
t ); }
594 {
return _pimpl->metadataPath(); }
597 {
return _pimpl->packagesPath(); }
600 {
return _pimpl->usesAutoMetadataPaths(); }
603 {
return _pimpl->type(); }
606 {
return _pimpl->_mirrorListUrl.transformed(); }
609 {
return _pimpl->_mirrorListUrl.raw(); }
612 {
return _pimpl->gpgKeyUrls().empty(); }
615 {
return _pimpl->gpgKeyUrls().size(); }
618 {
return _pimpl->gpgKeyUrls().transformed(); }
621 {
return _pimpl->gpgKeyUrls().raw(); }
624 {
return(
_pimpl->gpgKeyUrls().empty() ?
Url() : *
_pimpl->gpgKeyUrls().transformedBegin() ); }
627 {
return(
_pimpl->gpgKeyUrls().empty() ?
Url() : *
_pimpl->gpgKeyUrls().rawBegin() ) ; }
630 {
return _pimpl->baseUrls().transformed(); }
633 {
return _pimpl->baseUrls().raw(); }
639 {
return _pimpl->service; }
642 {
return _pimpl->targetDistro; }
645 {
return(
_pimpl->baseUrls().empty() ?
Url() : *
_pimpl->baseUrls().rawBegin() ); }
648 {
return _pimpl->baseUrls().transformedBegin(); }
651 {
return _pimpl->baseUrls().transformedEnd(); }
654 {
return _pimpl->baseUrls().size(); }
657 {
return _pimpl->baseUrls().empty(); }
660 {
return _pimpl->baseurl2dump(); }
663 {
return _pimpl->contentKeywords(); }
669 {
return _pimpl->hasContent(); }
689 if ( licenseTgz.
empty() )
693 cmd.push_back(
"tar" );
694 cmd.push_back(
"-t" );
695 cmd.push_back(
"-z" );
696 cmd.push_back(
"-f" );
710 MIL <<
"License(" <<
name_r <<
") in " <<
name() <<
" has to be accepted: " << (accept?
"true":
"false" ) << endl;
725 return std::string();
730 WAR <<
"License(" <<
name_r <<
") in " <<
name() <<
" contains no fallback text!" << endl;
743 cmd.push_back(
"tar" );
744 cmd.push_back(
"-x" );
745 cmd.push_back(
"-z" );
746 cmd.push_back(
"-O" );
747 cmd.push_back(
"-f" );
768 if ( licenseTgz.
empty() )
772 cmd.push_back(
"tar" );
773 cmd.push_back(
"-t" );
774 cmd.push_back(
"-z" );
775 cmd.push_back(
"-f" );
782 static const C_Str license(
"license." );
800 RepoInfoBase::dumpOn(
str);
801 if (
_pimpl->baseurl2dump() )
803 for (
const auto &
url :
_pimpl->baseUrls().raw() )
805 str <<
"- url : " <<
url << std::endl;
817 str <<
"- type : " <<
type() << std::endl;
821#define OUTS(T,B) ( indeterminate(T) ? (std::string("D(")+(B?"Y":"N")+")") : ((bool)T?"Y":"N") )
829 for (
const auto &
url :
_pimpl->gpgKeyUrls().raw() )
831 str <<
"- gpgkey : " <<
url << std::endl;
848 RepoInfoBase::dumpAsIniOn(
str);
850 if (
_pimpl->baseurl2dump() )
854 for (
const auto &
url :
_pimpl->baseUrls().raw() )
857 if ( indent.empty() ) indent =
" ";
861 if ( !
_pimpl->path.empty() )
862 str <<
"path="<<
path() << endl;
874 str <<
"gpgcheck=" << (
_pimpl->rawGpgCheck() ?
"1" :
"0") << endl;
877 str <<
"repo_gpgcheck=" << (
_pimpl->rawRepoGpgCheck() ?
"1" :
"0") << endl;
880 str <<
"pkg_gpgcheck=" << (
_pimpl->rawPkgGpgCheck() ?
"1" :
"0") << endl;
883 std::string indent(
"gpgkey=");
884 for (
const auto &
url :
_pimpl->gpgKeyUrls().raw() )
886 str << indent <<
url << endl;
887 if ( indent[0] !=
' ' )
906 <<
" alias=\"" << escape(
alias()) <<
"\""
907 <<
" name=\"" << escape(
name()) <<
"\"";
911 <<
" priority=\"" <<
priority() <<
"\""
912 <<
" enabled=\"" <<
enabled() <<
"\""
914 <<
" gpgcheck=\"" <<
gpgCheck() <<
"\""
918 str <<
" raw_gpgcheck=\"" << (
_pimpl->rawGpgCheck() ?
"1" :
"0") <<
"\"";
920 str <<
" raw_repo_gpgcheck=\"" << (
_pimpl->rawRepoGpgCheck() ?
"1" :
"0") <<
"\"";
922 str <<
" raw_pkg_gpgcheck=\"" << (
_pimpl->rawPkgGpgCheck() ?
"1" :
"0") <<
"\"";
925 str <<
" gpgkey=\"" << escape(
tmpstr) <<
"\"";
927 str << (
_pimpl->_mirrorListForceMetalink ?
" metalink=\"" :
" mirrorlist=\"") << escape(
tmpstr) <<
"\"";
930 if (
_pimpl->baseurl2dump() )
933 str <<
"<url>" << escape((*it).asString()) <<
"</url>" << endl;
936 str <<
"</repo>" << endl;
950#define OUTS( V ) case RepoInfo::V: return str << #V; break
951 OUTS( GpgCheck::On );
952 OUTS( GpgCheck::Strict );
953 OUTS( GpgCheck::AllowUnsigned );
954 OUTS( GpgCheck::AllowUnsignedRepo );
955 OUTS( GpgCheck::AllowUnsignedPackage );
956 OUTS( GpgCheck::Default );
957 OUTS( GpgCheck::Off );
958 OUTS( GpgCheck::indeterminate );
961 return str <<
"GpgCheck::UNKNOWN";
973 if ( mediafile.isExist() ) {
982 DBG <<
"Can SKIP media.1/media check for status calc of repo " <<
alias() << endl;
base::ValueTransform< Url, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrl
Helper managing repo variables replaced urls.
base::ContainerTransform< std::list< Url >, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrlList
Helper managing repo variables replaced url lists.
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
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
'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).
std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const override
Write an XML representation of this RepoInfo object.
void setGpgKeyUrls(url_set urls)
Set a list of gpgkey URLs defined for this repo.
void setMirrorListUrls(url_set urls)
Like setMirrorListUrl but take an url_set.
void setMetalinkUrl(const Url &url)
Like setMirrorListUrl but expect metalink format.
std::ostream & dumpOn(std::ostream &str) const override
Write a human-readable representation of this RepoInfo object into the str stream.
Pathname metadataPath() const
Path where this repo metadata was read from.
url_set::size_type urls_size_type
void setGpgKeyUrl(const Url &gpgkey)
(leagcy API) Set the gpgkey URL defined for this repo
bool usesAutoMetadataPaths() const
Whether metadataPath uses AUTO% setup.
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.
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)
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
void setMirrorListUrl(const Url &url)
Set mirror list url.
Url rawUrl() const
Pars pro toto: The first repository raw url (no variables replaced)
Pathname provideKey(const std::string &keyID_r, const Pathname &targetDirectory_r) const
downloads all configured gpg keys into the defined directory
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).
void setBaseUrl(Url url)
Clears current base URL list and adds url.
const std::set< std::string > & contentKeywords() const
Content keywords defined.
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
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.
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).
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 requireStatusWithMediaFile() const
Returns true if this repository requires the media.1/media file to be included in the metadata status...
void addBaseUrl(Url url)
Add a base url.
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.
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.
std::ostream & dumpAsIniOn(std::ostream &str) const override
Write this RepoInfo object into str in a .repo file format.
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).
void setMetalinkUrls(url_set urls)
Like setMirrorListUrls but expect metalink format.
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.
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.
static bool schemeIsDownloading(const std::string &scheme_r)
http https ftp sftp tftp
static ZConfig & instance()
Singleton ctor.
Find pathnames matching a pattern.
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.
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.
xmlTextReader based interface to iterate xml streams.
String related utilities and Regular expression matching.
int unlink(const Pathname &path)
Like 'unlink'.
int symlink(const Pathname &oldpath, const Pathname &newpath)
Like 'symlink'.
std::string asString(const Url &url_r)
int forEachLine(std::istream &str_r, const 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.
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 form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \t", const Trim trim_r=NO_TRIM)
Split line_r into words.
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::unordered_set< Locale > LocaleSet
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
std::string asString(const Patch::Category &obj)
zypp::Pathname provideKey(SyncContextRef ctx, zypp::RepoInfo info, std::string keyID_r, zypp::Pathname targetDirectory_r)
TriBool rawPkgGpgCheck() const
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
Impl(const Impl &)=default
void packagesPath(Pathname new_r)
void rawRepoGpgCheck(TriBool val_r)
void rawPkgGpgCheck(TriBool val_r)
Pathname licenseTgz(const std::string &name_r) const
Path to a license tarball in case it exists in the repo.
RepoVariablesReplacedUrl _mirrorListUrl
bool _mirrorListForceMetalink
Impl * clone() const
clone for RWCOW_pointer
Pathname metadataPath() const
DefaultIntegral< unsigned, defaultPriority > priority
std::ostream & operator<<(std::ostream &str, const RepoInfo::Impl &obj)
Stream output.
void setType(const repo::RepoType &t)
bool hasContent(const std::string &keyword_r) const
const std::set< std::string > & contentKeywords() const
TriBool cfgPkgGpgCheck() const
bool baseurl2dump() const
const RepoVariablesReplacedUrlList & baseUrls() const
RepoVariablesReplacedUrlList _gpgKeyUrls
RepoVariablesReplacedUrlList _baseUrls
Impl & operator=(Impl &&)=delete
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)
const RepoVariablesReplacedUrlList & gpgKeyUrls() const
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 & baseUrls()
TriBool _validRepoSignature
have signed and valid repo metadata
repo::RepoType type() const
Impl & operator=(const Impl &)=delete
std::pair< FalseBool, std::set< std::string > > _keywords
RepoVariablesReplacedUrlList & gpgKeyUrls()
bool usesAutoMetadataPaths() const
static const unsigned noPriority
Repository type enumeration.
static const RepoType YAST2
const std::string & asString() const
static const RepoType RPMMD
static const RepoType NONE
static const RepoType RPMPLAINDIR
#define for_(IT, BEG, END)
Convenient for-loops using iterator.