Go to the documentation of this file.
65 ,
type(repo::RepoType::NONE_e)
93 std::string licenseStem(
"license" );
94 if ( !name_r.empty() )
97 licenseStem += name_r;
170 [
this](
int num_r, std::string line_r )->
bool
174 std::vector<std::string> words;
175 if (
str::split( line_r, std::back_inserter(words) ) > 1
176 && words[0].length() == 12 )
178 this->
_keywords.second.insert( ++words.begin(), words.end() );
209 return indeterminate;
217 if (
PathInfo(gpgcheckFile).isExist() )
219 TriBool linkval( indeterminate );
242 static const Pathname truePath(
"true" );
243 static const Pathname falsePath(
"false" );
244 static const Pathname indeterminatePath(
"indeterminate" );
247 static const ssize_t bufsiz = 63;
248 static char buf[bufsiz+1];
250 buf[ret == -1 ? 0 : ret] =
'\0';
255 if ( linkval == truePath )
257 else if ( linkval == falsePath )
259 else if ( linkval == indeterminatePath )
260 ret_r = indeterminate;
334 mutable std::pair<FalseBool, std::set<std::string> >
_keywords;
338 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
341 {
return new Impl( *
this ); }
348 return str <<
"RepoInfo::Impl";
360 : _pimpl( new
Impl() )
436 {
if ( ! sameTriboolState( lhs, rhs ) ) { lhs = rhs;
return true; }
return false; }
440 bool changed =
false;
441 if ( changeGpgCheckTo( ogpg[0], g ) ) changed =
true;
442 if ( changeGpgCheckTo( ogpg[1], r ) ) changed =
true;
443 if ( changeGpgCheckTo( ogpg[2], p ) ) changed =
true;
453 bool changed =
false;
457 changed = changeGpgCheckTo( ogpg,
true, indeterminate, indeterminate );
460 changed = changeGpgCheckTo( ogpg,
true,
true,
true );
463 changed = changeGpgCheckTo( ogpg,
true,
false,
false );
466 changed = changeGpgCheckTo( ogpg,
true,
false, indeterminate );
469 changed = changeGpgCheckTo( ogpg,
true, indeterminate,
false );
472 changed = changeGpgCheckTo( ogpg, indeterminate, indeterminate, indeterminate );
475 changed = changeGpgCheckTo( ogpg,
false, indeterminate, indeterminate );
507 if ( keyID_r.empty() )
510 MIL <<
"Check for " << keyID_r <<
" at " << targetDirectory_r << endl;
511 std::string keyIDStr( keyID_r.size() > 8 ? keyID_r.substr( keyID_r.size()-8 ) : keyID_r );
520 [&tempKeyRing](
const Pathname & dir_r,
const std::string & str_r ){
534 ERR <<
"Error importing cached key from file '"<<dir_r/str_r<<
"'."<<endl;
560 }
catch (
const std::exception & e ) {
563 MIL <<
"Key import from url:'"<<
url<<
"' failed." << endl;
578 MIL <<
"KEY ID in KEYRING: " << key.id() << endl;
582 std::ofstream fout( keyFile.
c_str(), std::ios_base::out | std::ios_base::trunc );
597 ERR <<
"Error when exporting key from temporary keychain." << endl;
745 if ( licenseTgz.
empty() )
749 cmd.push_back(
"tar" );
750 cmd.push_back(
"-t" );
751 cmd.push_back(
"-z" );
752 cmd.push_back(
"-f" );
753 cmd.push_back( licenseTgz.
asString() );
757 static const std::string noAcceptanceFile =
"no-acceptance-needed\n";
760 if ( output == noAcceptanceFile )
766 MIL <<
"License(" << name_r <<
") in " <<
name() <<
" has to be accepted: " << (accept?
"true":
"false" ) << endl;
775 {
return getLicense( std::string(), lang_r ); }
780 if ( avlocales.empty() )
781 return std::string();
784 if ( !getLang && avlocales.find(
Locale::noCode ) == avlocales.end() )
786 WAR <<
"License(" << name_r <<
") in " <<
name() <<
" contains no fallback text!" << endl;
790 getLang = *avlocales.begin();
794 static const std::string licenseFileFallback(
"license.txt" );
795 std::string licenseFile( !getLang ? licenseFileFallback
799 cmd.push_back(
"tar" );
800 cmd.push_back(
"-x" );
801 cmd.push_back(
"-z" );
802 cmd.push_back(
"-O" );
803 cmd.push_back(
"-f" );
805 cmd.push_back( licenseFile );
824 if ( licenseTgz.
empty() )
828 cmd.push_back(
"tar" );
829 cmd.push_back(
"-t" );
830 cmd.push_back(
"-z" );
831 cmd.push_back(
"-f" );
832 cmd.push_back( licenseTgz.
asString() );
838 static const C_Str license(
"license." );
839 static const C_Str dotTxt(
".txt\n" );
842 if ( output.size() <= license.
size() + dotTxt.
size() )
845 ret.insert(
Locale( std::string( output.c_str()+license.
size(), output.size()- license.
size() - dotTxt.
size() ) ) );
861 str <<
"- url : " <<
url << std::endl;
866 auto strif( [&] (
const std::string & tag_r,
const std::string & value_r ) {
867 if ( ! value_r.empty() )
868 str << tag_r << value_r << std::endl;
873 str <<
"- type : " <<
type() << std::endl;
877 #define OUTS(T,B) ( indeterminate(T) ? (std::string("D(")+(B?"Y":"N")+")") : ((bool)T?"Y":"N") )
887 str <<
"- gpgkey : " <<
url << std::endl;
893 strif(
"- service : ",
service() );
904 RepoInfoBase::dumpAsIniOn(
str);
912 str << indent <<
url << endl;
913 if ( indent.empty() ) indent =
" ";
918 str <<
"path="<<
path() << endl;
939 std::string indent(
"gpgkey=");
942 str << indent <<
url << endl;
943 if ( indent[0] !=
' ' )
967 <<
" priority=\"" <<
priority() <<
"\""
968 <<
" enabled=\"" <<
enabled() <<
"\""
970 <<
" gpgcheck=\"" <<
gpgCheck() <<
"\""
974 str <<
" gpgkey=\"" <<
escape(tmpstr) <<
"\"";
982 str <<
"<url>" <<
escape((*it).asString()) <<
"</url>" << endl;
985 str <<
"</repo>" << endl;
999 #define OUTS( V ) case RepoInfo::V: return str << #V; break
1000 OUTS( GpgCheck::On );
1001 OUTS( GpgCheck::Strict );
1002 OUTS( GpgCheck::AllowUnsigned );
1003 OUTS( GpgCheck::AllowUnsignedRepo );
1004 OUTS( GpgCheck::AllowUnsignedPackage );
1005 OUTS( GpgCheck::Default );
1006 OUTS( GpgCheck::Off );
1007 OUTS( GpgCheck::indeterminate );
1010 return str <<
"GpgCheck::UNKNOWN";
void setPkgGpgCheck(TriBool value_r)
Set the value for pkgGpgCheck (or indeterminate to use the default).
bool internalUnsignedConfirmed() const
We definitely have a symlink pointing to "indeterminate" (for repoGpgCheckIsMandatory)?...
LocaleSet getLicenseLocales() const
Return the locales the license is available for.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
bool startsWith(const C_Str &str_r, const C_Str &prefix_r)
alias for hasPrefix
void setBaseUrl(const Url &url)
Clears current base URL list and adds url.
RepoVariablesReplacedUrlList & baseUrls()
const std::vector< Url > & getUrls() const
bool gpgKeyUrlsEmpty() const
Whether gpgkey URLs are defined.
url_set rawBaseUrls() const
The complete set of raw repository urls (no variables replaced)
GpgCheck
Some predefined settings.
TriBool repoGpgCheck() const
Check repo matadata signatures (indeterminate - according to gpgcheck)
std::string asString() const
Explicit conversion to std::string.
urls_size_type gpgKeyUrlsSize() const
Number of gpgkey URLs defined.
void setPackagesPath(const Pathname &path)
set the path where the local packages are stored
std::ostream & dumpOn(std::ostream &str, const zypp::shared_ptr< void > &obj)
TriBool _rawGpgCheck
default gpgcheck behavior: Y/N/ZConf
TriBool rawGpgCheck() const
const_iterator begin() const
Iterator pointing to the first result.
void rawRepoGpgCheck(TriBool val_r)
Base class for Exception.
String matching (STRING|SUBSTRING|GLOB|REGEX).
RepoVariablesReplacedUrlList _gpgKeyUrls
static Locale bestMatch(const LocaleSet &avLocales_r, Locale requested_r=Locale())
Return the best match for Locale requested_r within the available avLocales_r.
Find pathnames matching a pattern.
What is known about a repository.
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
void setGpgKeyUrl(const Url &gpgkey)
(leagcy API) Set the gpgkey URL defined for this repo
void multiKeyImport(const Pathname &keyfile_r, bool trusted_r=false)
Initial import from RpmDb.
TriBool _rawRepoGpgCheck
need to check repo sign.: Y/N/(ZConf(Y/N/gpgCheck))
bool seekToNode(int depth_r, const std::string &name_r)
const RepoVariablesReplacedUrlList & baseUrls() const
std::pair< FalseBool, std::set< std::string > > _keywords
RepoVariablesReplacedUrlList & gpgKeyUrls()
Class representing one GPG Public Keys data. PublicKeyData are provided e.g. by a PublicKey or a KeyR...
TriBool _rawPkgGpgCheck
need to check pkg sign.: Y/N/(ZConf(Y/N/gpgCheck))
int symlink(const Pathname &oldpath, const Pathname &newpath)
Like 'symlink'.
TriBool triBoolFromPath(const Pathname &path_r) const
bool usesAutoMethadataPaths() const
bool enabled() const
If enabled is false, then this repository must be ignored as if does not exists, except when checking...
const std::string & asString() const
bool hasContent(const std::string &keyword_r) const
bool baseUrlsEmpty() const
whether repository urls are available
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
static const Locale noCode
Empty code.
void setBaseUrls(url_set urls)
Clears current base URL list and adds an url_set.
static bool info(const std::string &msg_r, const UserData &userData_r=UserData())
send message text
void rawPkgGpgCheck(TriBool val_r)
static const RepoInfo noRepo
Represents no Repository (one with an empty alias).
void setGpgCheck(TriBool value_r)
Set the value for gpgCheck (or indeterminate to use the default).
unsigned priority() const
Repository priority for solver.
TriBool cfgRepoGpgCheck() const
std::string asUserString() const
User string: label (alias or name)
void addContent(const std::string &keyword_r)
Add content keywords.
Impl * clone() const
clone for RWCOW_pointer
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
void internalSetValidRepoSignature(TriBool value_r)
TriBool cfgPkgGpgCheck() const
void packagesPath(Pathname new_r)
static const RepoType NONE
@ STRINGEND
Match at string end.
bool empty() const
Whether matches were found.
int unlink(const Pathname &path)
Like 'unlink'.
std::ostream & operator<<(std::ostream &str, const RepoInfo::Impl &obj)
static const unsigned defaultPriority
bool baseUrlSet() const
Whether there are manualy configured repository urls.
Pathname packagesPath() const
Path where this repo packages are cached.
bool gpgCheck() const
Whether default signature checking should be performed.
void setPath(const Pathname &path)
set the product path.
DefaultIntegral< unsigned, defaultPriority > priority
void setPriority(unsigned newval_r)
Set repository priority for solver.
Url mirrorListUrl() const
Url of a file which contains a list of repository urls.
base::ValueTransform< Url, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrl
static const unsigned noPriority
bool baseurl2dump() const
url_set rawGpgKeyUrls() const
The list of raw gpgkey URLs defined for this repo (no variables replaced)
virtual std::ostream & dumpAsXmlOn(std::ostream &str, const std::string &content="") const
Write an XML representation of this RepoInfo object.
Pathname provideKey(const std::string &keyID_r, const Pathname &targetDirectory_r) const
downloads all configured gpg keys into the defined directory
Pathname packagesPath() const
bool usesAutoMethadataPaths() const
Whether metadataPath uses AUTO% setup.
Pathname licenseTgz(const std::string &name_r) const
Path to a license tarball in case it exists in the repo.
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.
std::vector< std::string > Arguments
bool seekToEndNode(int depth_r, const std::string &name_r)
void setMetadataPath(const Pathname &path)
Set the path where the local metadata is stored.
Wrapper class for ::stat/::lstat.
void setGpgKeyUrls(url_set urls)
Set a list of gpgkey URLs defined for this repo.
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)
Provide a new empty temporary directory and recursively delete it when no longer needed.
void setType(const repo::RepoType &t)
set the repository type
std::string asString() const
Returns a default string representation of the Url object.
const char * c_str() const
String representation.
base::ContainerTransform< std::list< Url >, repo::RepoVariablesUrlReplacer > RepoVariablesReplacedUrlList
detail::EscapedString escape(const std::string &in_r)
Escape xml special charaters (& -> &; from IoBind library).
std::string alias() const
unique identifier for this source.
Repository type enumeration.
void setTargetDistribution(const std::string &targetDistribution)
Sets the distribution for which is this repository meant.
void setKeepPackages(bool keep)
Set if packaqes downloaded from this repository will be kept in local cache.
bool repoGpgCheckIsMandatory() const
Mandatory check (repoGpgCheck is on) must ask to confirm using unsigned repos.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
std::string name() const
Repository name.
void setProbedType(const repo::RepoType &t) const
virtual std::ostream & dumpOn(std::ostream &str) const
Write a human-readable representation of this RepoInfo object into the str stream.
static ZConfig & instance()
Singleton ctor.
void addBaseUrl(const Url &url)
Add a base url.
void getRawGpgChecks(TriBool &g_r, TriBool &r_r, TriBool &p_r) const
Raw values for RepoManager.
Easy-to use interface to the ZYPP dependency resolver.
bool triBoolFromPath(const Pathname &path_r, TriBool &ret_r) const
RepoVariablesReplacedUrlList _baseUrls
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.
void metadataPath(Pathname new_r)
bool hasLicense() const
Whether there is a license associated with the repo.
Url rawUrl() const
Pars pro toto: The first repository raw url (no variables replaced)
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string.
void setValidRepoSignature(TriBool value_r)
Set the value for validRepoSignature (or indeterminate if unsigned).
TriBool validRepoSignature() const
Whether the repo metadata are signed and successfully validated or indeterminate if unsigned.
int close()
Wait for the progamm to complete.
const std::set< std::string > & contentKeywords() const
void addContent(const std::string &keyword_r)
bool _mirrorListForceMetalink
Pathname filepath() const
File where this repo was read from.
void setProbedType(const repo::RepoType &t) const
This allows to adjust the RepoType lazy, from NONE to some probed value, even for const objects.
bool hasSuffix(const C_Str &str_r, const C_Str &suffix_r)
Return whether str_r has suffix suffix_r.
bool pkgGpgCheck() const
Whether the signature of rpm packages should be checked for this repo.
std::string targetDistribution() const
Distribution for which is this repository meant.
url_set gpgKeyUrls() const
The list of gpgkey URLs defined for this repo.
bool autorefresh() const
If true, the repostory must be refreshed before creating resolvables from it.
std::string asString(const DefaultIntegral< Tp, TInitial > &obj)
bool hasContent() const
Check for content keywords.
TriBool _validRepoSignature
have signed and valid repo metadata
static unsigned noPriority()
The least priority (unsigned(-1)).
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Url url() const
Pars pro toto: The first repository url.
void rawGpgCheck(TriBool val_r)
Pathname dirname() const
Return all but the last component od this path.
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
bool gpgCheck() const
Turn signature checking on/off (on)
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
virtual std::ostream & dumpAsIniOn(std::ostream &str) const
Write this RepoInfo object into str in a .repo file format.
Pathname metadataPath() const
Path where this repo metadata was read from.
bool pkgGpgCheckIsMandatory() const
Mandatory check (pkgGpgCheck is not off) must ask to confirm using unsigned packages.
url_set baseUrls() const
The complete set of repository urls.
static unsigned defaultPriority()
The default priority (99).
std::list< PublicKeyData > trustedPublicKeyData()
Get a list of trusted public key data in the keyring (key data only)
bool empty() const
Test for an empty path.
XmlString nodeText()
If the current node is not empty, advances the reader to the next node, and returns the value.
bool repoGpgCheck() const
Whether the signature of repo metadata should be checked for this repo.
std::unordered_set< Locale > LocaleSet
static Date now()
Return the current time.
std::string receiveLine()
Read one line from the input stream.
void setMirrorListUrl(const Url &url)
Set mirror list url.
void setRepoGpgCheck(TriBool value_r)
Set the value for repoGpgCheck (or indeterminate to use the default).
url_set::size_type urls_size_type
TriBool rawRepoGpgCheck() const
std::string service() const
Gets name of the service to which this repository belongs or empty string if it has been added manual...
bool needToAcceptLicense() const
Whether the repo license has to be accepted, e.g.
int add(const Pathname &pattern_r, Flags flags_r=Flags())
Add pathnames matching pattern_r to the current result.
void setService(const std::string &name)
sets service which added this repository
Pathname metadataPath() const
Url gpgKeyUrl() const
(leagcy API) The 1st gpgkey URL defined for this repo
String related utilities and Regular expression matching.
bool isKeyTrusted(const std::string &id)
true if the key id is trusted
const char * c_str() const
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
std::string rpmName() const
Gpg-pubkey name as computed by rpm.
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
const std::string & asString() const
String representation.
TriBool rawPkgGpgCheck() const
TriBool internalValidRepoSignature() const
Signature check result needs to be stored/retrieved from _metadataPath.
Url rawGpgKeyUrl() const
(leagcy API) The 1st raw gpgkey URL defined for this repo (no variables replaced)
RepoVariablesReplacedUrl _mirrorListUrl
int dirForEach(const Pathname &dir_r, function< bool(const Pathname &, const char *const)> fnc_r)
Invoke callback function fnc_r for each entry in directory dir_r.
'Language[_Country]' codes.
static const ValueType month
void setMetalinkUrl(const Url &url)
Like setMirrorListUrl but expect metalink format.
const RepoVariablesReplacedUrlList & gpgKeyUrls() const
Url rawMirrorListUrl() const
The raw mirrorListUrl (no variables replaced).
void dumpTrustedPublicKey(const std::string &id, std::ostream &stream)
bool keepPackages() const
Whether packages downloaded from this repository will be kept in local cache.
repo::RepoType type() const
Type of repository,.
std::string getLicense(const Locale &lang_r=Locale()) const
Return the best license for the current (or a specified) locale.
const std::set< std::string > & contentKeywords() const
Content keywords defined.
Pathname path() const
Repository path.
urls_size_type baseUrlsSize() const
number of repository urls
int readlink(const Pathname &symlink_r, Pathname &target_r)
Like 'readlink'.