14#include <zypp-media/ng/Provide>
15#include <zypp-media/ng/ProvideSpec>
16#include <zypp/ng/Context>
17#include <zypp/ng/repo/Downloader>
30#undef ZYPP_BASE_LOGGER_LOGGROUP
31#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::repomanager"
38 template <
class Executor,
class OpType >
39 struct DownloadMasterIndexLogic :
public LogicBase<Executor, OpType>
46 using ProvideType =
typename ZyppContextType::ProvideType;
47 using MediaHandle =
typename ProvideType::MediaHandle;
52 ,
_media(std::move( mediaHandle ))
72 | [
this]( std::vector<expected<zypp::ManagedFile>> &&
res ) {
75 std::for_each(
res.begin (),
res.end(),
78 _dlContext->files().push_back( std::move(f.get()));
86 |
and_then( std::bind( &DownloadMasterIndexLogic::pluginVerification,
this, std::placeholders::_1 ) )
89 |
and_then( std::bind( &DownloadMasterIndexLogic::signatureCheck,
this, std::placeholders::_1 ) )
118 if (
_dlContext->repoInfo().repoGpgCheck() ) {
149 DBG <<
"Keyhint remember buddy " << keyData << std::endl;
150 vCtx.addBuddyKey( keyData.id() );
162 WAR <<
"Accept unsigned repository because repoGpgCheck is not mandatory for " <<
_dlContext->repoInfo().alias() << std::endl;
165 WAR <<
"Signature checking disabled in config of repository " <<
_dlContext->repoInfo().alias() << std::endl;
175 if (
_dlContext->pluginRepoverification() &&
_dlContext->pluginRepoverification()->isNeeded() ) {
196 if ( keyhints.empty() )
198 DBG <<
"Check keyhints: " << keyhints.size() << std::endl;
200 auto keyRing {
_dlContext->zyppContext()->keyRing() };
202 |
transform([
this, keyRing]( std::pair<std::string, std::string> val ) {
204 const auto& [ file,
keyid ] = val;
205 auto keyData = keyRing->trustedPublicKeyData(
keyid );
207 DBG <<
"Keyhint is already trusted: " <<
keyid <<
" (" << file <<
")" << std::endl;
211 DBG <<
"Keyhint search key " <<
keyid <<
" (" << file <<
")" << std::endl;
213 keyData = keyRing->publicKeyData(
keyid );
223 if ( key.fileProvidesKey(
keyid ) )
238 if (
not key.fileProvidesKey(
keyid ) ) {
239 const auto &
str =
zypp::str::Str() <<
"Keyhint " << file <<
" does not contain a key with id " <<
keyid <<
". Skipping it.";
250 res->resetDispose ();
257 keyRing->importKey( key,
false );
263 if ( keyData && *keyData ) {
264 if ( not zypp::PublicKey::isSafeKeyId( keyData->id() ) ) {
265 WAR <<
"Keyhint " << keyData->id() <<
" for " << *keyData <<
" is not strong enough for auto import. Just caching it." << std::endl;
268 _buddyKeys.push_back ( std::move(keyData.get()) );
272 MIL <<
"Check keyhints done. Buddy keys: " <<
_buddyKeys.size() << std::endl;
304 return dl->zyppContext()->provider()->attachMediaIfNeeded( mediaHandle )
313 return dl->zyppContext()->provider()->attachMediaIfNeeded( mediaHandle )
321 template <
class DlContextRefType,
class MediaHandleType>
324 constexpr bool isAsync = std::is_same_v<DlContextRefType,repo::AsyncDownloadContextRef>;
330 switch(
dlCtx->repoInfo().type().toEnum()) {
332 return RpmmdWorkflows::repoStatus(
dlCtx, std::forward<MediaHandleType>(mediaHandle) ) | and_then( std::move(
finalizeStatus) );
334 return SuseTagsWorkflows::repoStatus(
dlCtx, std::forward<MediaHandleType>(mediaHandle) ) | and_then( std::move(
finalizeStatus) );
336 return PlaindirWorkflows::repoStatus (
dlCtx, std::forward<MediaHandleType>(mediaHandle) ) | and_then( std::move(
finalizeStatus) );
355 return dl->zyppContext()->provider()->attachMediaIfNeeded( mediaHandle )
357 return repoStatus(
dl, std::move(handle) );
363 return dl->zyppContext()->provider()->attachMediaIfNeeded( mediaHandle )
365 return repoStatus(
dl, std::move(handle) );
371 template <
class DlContextRefType,
class MediaHandleType>
374 constexpr bool isAsync = std::is_same_v<DlContextRefType,repo::AsyncDownloadContextRef>;
376 switch(
dlCtx->repoInfo().type().toEnum()) {
378 return RpmmdWorkflows::download( std::move(
dlCtx), std::forward<MediaHandleType>(mediaHandle), std::move(
progressObserver) );
380 return SuseTagsWorkflows::download( std::move(
dlCtx), std::forward<MediaHandleType>(mediaHandle), std::move(
progressObserver) );
382 return PlaindirWorkflows::download ( std::move(
dlCtx), std::forward<MediaHandleType>(mediaHandle) );
404 return dl->zyppContext()->provider()->attachMediaIfNeeded( mediaHandle )
413 return dl->zyppContext()->provider()->attachMediaIfNeeded( mediaHandle )
Interface of repomd.xml file reader.
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Store and operate with byte count.
static const Unit MB
1000^2 Byte
Base class for Exception.
Class representing one GPG Public Key (PublicKeyData + ASCII armored in a tempfile).
static PublicKey noThrow(const Pathname &keyFile_r)
Static ctor returning an empty PublicKey rather than throwing.
Track changing files or directories.
Interim helper class to collect global options and settings.
Wrapper class for stat/lstat.
bool isExist() const
Return whether valid stat info exists.
Pathname extend(const std::string &r) const
Append string r to the last component of the path.
std::string basename() const
Return the last component of this path.
I/O context for KeyRing::verifyFileSignatureWorkflow.
Reads through a repomd.xml file and collects type, location, checksum and other data about metadata f...
std::vector< std::pair< std::string, std::string > > keyhints() const
gpg key hits shipped in keywords (bsc#1184326)
thrown when it was impossible to determine this repo type.
A ProvideRes object is a reference counted ownership of a resource in the cache provided by a Provide...
static expected success(ConsParams &&...params)
#define ZYPP_ENABLE_LOGIC_BASE(Executor, OpType)
typename conditional< B, T, F >::type conditional_t
String related utilities and Regular expression matching.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
AsyncOpRef< expected< repo::AsyncDownloadContextRef > > downloadMasterIndex(repo::AsyncDownloadContextRef dl, ProvideMediaHandle mediaHandle, zypp::filesystem::Pathname masterIndex_r)
expected< zypp::keyring::VerifyFileContext > verifySignature(SyncContextRef ctx, zypp::keyring::VerifyFileContext context)
std::conditional_t< isAsync, AsyncOpRef< T >, T > makeReadyResult(T &&result)
typename remove_smart_ptr< T >::type remove_smart_ptr_t
static expected< std::decay_t< Type >, Err > make_expected_success(Type &&t)
ResultType or_else(const expected< T, E > &exp, Function &&f)
ResultType and_then(const expected< T, E > &exp, Function &&f)
Container< Ret > transform(Container< Msg, CArgs... > &&val, Transformation &&transformation)
zypp::Pathname _masterIndex
std::vector< zypp::PublicKeyData > _buddyKeys
zypp::TriBool _repoSigValidated
DlContextRefType _dlContext
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
#define ZYPP_EXCPT_PTR(EXCPT)
Drops a logline and returns Exception as a std::exception_ptr.
#define ZYPP_FWD_CURRENT_EXCPT()
Drops a logline and returns the current Exception as a std::exception_ptr.