65 ,
type(repo::RepoType::NONE_e)
93 std::string licenseStem(
"license" );
94 if ( !name_r.empty() )
97 licenseStem += name_r;
116 if (
_baseUrls.empty() && ! mlurl.asString().empty() )
155 if ( PathInfo( (master=
metadataPath()/
"/repodata/repomd.xml") ).isFile() )
166 else if ( PathInfo( (master=
metadataPath()/
"/content") ).isFile() )
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;
216 Pathname gpgcheckFile(
metadataPath() /
".repo_gpgcheck" );
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];
249 ssize_t ret =
::readlink( path_r.c_str(), buf, bufsiz );
250 buf[ret == -1 ? 0 : ret] =
'\0';
252 Pathname linkval( buf );
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 );
459 case GpgCheck::Strict:
460 changed = changeGpgCheckTo( ogpg,
true,
true,
true );
462 case GpgCheck::AllowUnsigned:
463 changed = changeGpgCheckTo( ogpg,
true,
false,
false );
465 case GpgCheck::AllowUnsignedRepo:
466 changed = changeGpgCheckTo( ogpg,
true,
false, indeterminate );
468 case GpgCheck::AllowUnsignedPackage:
469 changed = changeGpgCheckTo( ogpg,
true, indeterminate,
false );
471 case GpgCheck::Default:
472 changed = changeGpgCheckTo( ogpg, indeterminate, indeterminate, indeterminate );
475 changed = changeGpgCheckTo( ogpg,
false, indeterminate, indeterminate );
477 case GpgCheck::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 ){
524 PathInfo fileInfo ( dir_r/str_r );
530 tempKeyRing.multiKeyImport(dir_r/str_r,
true);
534 ERR <<
"Error importing cached key from file '"<<dir_r/str_r<<
"'."<<endl;
541 if ( !tempKeyRing.isKeyTrusted(keyID_r) ) {
558 tempKeyRing.multiKeyImport(f,
true);
560 }
catch (
const std::exception & e ) {
563 MIL <<
"Key import from url:'"<<
url<<
"' failed." << endl;
577 for (
const auto & key: tempKeyRing.trustedPublicKeyData()) {
578 MIL <<
"KEY ID in KEYRING: " << key.id() << endl;
582 std::ofstream fout( keyFile.c_str(), std::ios_base::out | std::ios_base::trunc );
587 tempKeyRing.dumpTrustedPublicKey( key.id(), fout );
591 if ( !tempKeyRing.isKeyTrusted(keyID_r) ) {
595 PublicKeyData keyData( tempKeyRing.trustedPublicKeyData( keyID_r ) );
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;
874 str <<
"- priority : " <<
priority() << 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;
891 str <<
"- keeppackages: " <<
keepPackages() << 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;
926 str <<
"priority=" <<
priority() << endl;
938 std::string indent(
"gpgkey=");
941 str << indent <<
url << endl;
942 if ( indent[0] !=
' ' )
951 str <<
"service=" <<
service() << endl;
966 <<
" priority=\"" <<
priority() <<
"\""
967 <<
" enabled=\"" <<
enabled() <<
"\""
969 <<
" gpgcheck=\"" <<
gpgCheck() <<
"\""
973 str <<
" gpgkey=\"" <<
escape(tmpstr) <<
"\"";
981 str <<
"<url>" <<
escape((*it).asString()) <<
"</url>" << endl;
984 str <<
"</repo>" << endl;
998 #define OUTS( V ) case RepoInfo::V: return str << #V; break
999 OUTS( GpgCheck::On );
1000 OUTS( GpgCheck::Strict );
1001 OUTS( GpgCheck::AllowUnsigned );
1002 OUTS( GpgCheck::AllowUnsignedRepo );
1003 OUTS( GpgCheck::AllowUnsignedPackage );
1004 OUTS( GpgCheck::Default );
1005 OUTS( GpgCheck::Off );
1006 OUTS( GpgCheck::indeterminate );
1009 return str <<
"GpgCheck::UNKNOWN";