15#include <zypp-core/zyppng/pipelines/MTry>
16#include <zypp-core/zyppng/pipelines/Await>
17#include <zypp-core/zyppng/io/Process>
25#include <zypp/ng/Context>
30#undef ZYPP_BASE_LOGGER_LOGGROUP
31#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::repomanager"
43 if ( !root.
empty() && (scheme ==
"dir" || scheme ==
"file") ) {
49 template <
class Executor,
class OpType>
50 struct FetchRIMServiceLogic :
public LogicBase<Executor, OpType>
78 |
and_then( [
this](
auto mediaHandle ) {
return _ctx->provider()->provide( mediaHandle,
"repo/repoindex.xml",
ProvideFileSpec() ); } )
82 zypp::RepoInfoList repos;
83 auto callback = [&](
const zypp::RepoInfo &
r) { repos.push_back(
r);
return true; };
109 template <
class Executor,
class OpType>
110 struct FetchPluginServiceLogic :
public LogicBase<Executor, OpType>
136 return executor()->runPlugin( std::move(
stripped) )
137 |
and_then( [
this](
int exitCode ) {
139 if ( exitCode != 0 ) {
142 ERR <<
"Capture plugin error:[" << std::endl <<
_stderrBuf << std::endl <<
']' << std::endl;
147 zypp::RepoInfoList repos;
148 auto callback = [&](
const zypp::RepoInfo &
r) { repos.push_back(
r);
return true; };
150 std::stringstream
buffer( _stdoutBuf );
155 return Ret::error( std::current_exception () );
161 ZyppContextRefType
_ctx;
170 struct SyncFetchPluginService : FetchPluginServiceLogic<SyncFetchPluginService, SyncOp< expected< std::pair<zypp::ServiceInfo, RepoInfoList> >>>
172 using FetchPluginServiceLogic::FetchPluginServiceLogic;
179 args.push_back(
"/bin/sh" );
180 args.push_back(
"-c" );
181 args.push_back( command );
200 struct ASyncFetchPluginService : FetchPluginServiceLogic<ASyncFetchPluginService, AsyncOp< expected< std::pair<zypp::ServiceInfo, RepoInfoList> >>>
202 using FetchPluginServiceLogic::FetchPluginServiceLogic;
206 const char *args[] = {
223 | [
this]( ProcessRef
proc ) {
return finalize( std::move(
proc) ); };
227 if (
proc->isRunning () ) {
233 if (
proc->exitStatus() != 0 ) {
246 if ( service.
type() == zypp::repo::ServiceType::PLUGIN )
247 return ASyncFetchPluginService::run( std::move(
ctx), std::move(
root_r), std::move(service), std::move(
myProgress) );
254 if ( service.
type() == zypp::repo::ServiceType::PLUGIN )
255 return SyncFetchPluginService::run( std::move(
ctx), std::move(
root_r), std::move(service), std::move(
myProgress) );
263 template<
typename ContextRefType>
266 constexpr bool isAsync = std::is_same_v<ContextRefType, ContextRef>;
277 std::rethrow_exception( result.
error() );
297 enew.remember( std::current_exception() );
317 template <
class Executor,
class OpType>
318 struct RefreshServiceLogic :
public LogicBase<Executor, OpType>
336 if (
_service.type() == zypp::repo::ServiceType::NONE ) {
371 MIL <<
"Skip: '" <<
_service.alias() <<
"' metadata valid until " << lrf << std::endl;
376 WAR <<
"Force: '" <<
_service.alias() <<
"' metadata last refresh in the future: " << lrf << std::endl;
410 std::string servicesTargetDistro =
_repoMgr->options().servicesTargetDistro;
411 if ( servicesTargetDistro.empty() ) {
414 DBG <<
"ServicesTargetDistro: " << servicesTargetDistro << std::endl;
437 for_(
it, collector.repos.begin(), collector.repos.end() )
453 if ( !
it->path().empty() )
455 if (
it->path() !=
"/" )
460 if (
it->baseUrlsEmpty() )
465 it->setBaseUrl( std::move(url) );
467 else if ( !path.
empty() )
474 it->setBaseUrls( std::move(urls) );
494 if ( last !=
_service.repoStates().end() && ! last->second.enabled )
496 DBG <<
"Service removes user enabled repo " <<
oldRepo->alias() << std::endl;
501 DBG <<
"Service removes enabled repo " <<
oldRepo->alias() << std::endl;
504 DBG <<
"Service removes disabled repo " <<
oldRepo->alias() << std::endl;
515 for_(
it, collector.repos.begin(), collector.repos.end() )
522 DBG <<
"Service request to " << (
it->enabled()?
"enable":
"disable") <<
" service repo " <<
it->alias() << std::endl;
526 DBG <<
"Opt RefreshService_restoreStatus " <<
it->alias() << std::endl;
536 if (
_service.repoToEnableFind(
it->alias() ) )
538 DBG <<
"User request to enable service repo " <<
it->alias() << std::endl;
546 else if (
_service.repoToDisableFind(
it->alias() ) )
548 DBG <<
"User request to disable service repo " <<
it->alias() << std::endl;
562 DBG <<
"Service adds repo " <<
it->alias() <<
" " << (
it->enabled()?
"enabled":
"disabled") << std::endl;
575 if (
oldRepo->enabled() ==
it->enabled() )
580 DBG <<
"Opt RefreshService_restoreStatus " <<
it->alias() <<
" forces " << (
toBeEnabled?
"enabled":
"disabled") << std::endl;
585 if ( last ==
_service.repoStates().end() || last->second.enabled !=
it->enabled() )
590 DBG <<
"User modified service repo " <<
it->alias() <<
" may stay " << (
toBeEnabled?
"enabled":
"disabled") << std::endl;
598 DBG <<
"Service repo " <<
it->alias() <<
" stays " << (
oldRepo->enabled()?
"enabled":
"disabled") << std::endl;
602 DBG <<
"Service repo " <<
it->alias() <<
" gets enabled" << std::endl;
608 DBG <<
"Service repo " <<
it->alias() <<
" gets disabled" << std::endl;
616 if (
oldRepo->rawName() !=
it->rawName() )
618 DBG <<
"Service repo " <<
it->alias() <<
" gets new NAME " <<
it->rawName() << std::endl;
624 if (
oldRepo->autorefresh() !=
it->autorefresh() )
626 DBG <<
"Service repo " <<
it->alias() <<
" gets new AUTOREFRESH " <<
it->autorefresh() << std::endl;
627 oldRepo->setAutorefresh(
it->autorefresh() );
632 if (
oldRepo->priority() !=
it->priority() )
634 DBG <<
"Service repo " <<
it->alias() <<
" gets new PRIORITY " <<
it->priority() << std::endl;
645 DBG <<
"Service repo " <<
it->alias() <<
" gets new URLs " <<
newUrls << std::endl;
653 if (
_service.type() == zypp::repo::ServiceType::PLUGIN )
659 #define Z_CHKGPG(I,N) \
660 if ( ! sameTriboolState( ogpg[I], ngpg[I] ) ) \
662 DBG << "Service repo " << it->alias() << " gets new "#N"Check " << ngpg[I] << std::endl; \
663 oldRepo->set##N##Check( ngpg[I] ); \
664 oldRepoModified = true; \
682 if ( !
_service.reposToDisableEmpty() )
697 if (
_service.type() != zypp::repo::ServiceType::PLUGIN )
705 if ( _serviceModified )
713 if ( _informalError ) {
714 return Ret::error( std::make_exception_ptr (_informalError) );
717 return Ret::success( );
Interface of repoindex.xml file reader.
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Store and operate on date (time_t).
static Date now()
Return the current time.
Base class for Exception.
ExternalProgram extended to offer reading programs stderr.
std::vector< std::string > Arguments
What is known about a repository.
repo::ServiceType type() const
Service type.
std::map< std::string, RepoState > RepoStates
std::string targetDistribution() const
This is register.target attribute of the installed base product.
std::string asString() const
Returns a default string representation of the Url object.
std::string getPathName(EEncoding eflag=zypp::url::E_DECODED) const
Returns the path name from the URL.
void setPathName(const std::string &path, EEncoding eflag=zypp::url::E_DECODED)
Set the path name.
static Pathname stripprefix(const Pathname &root_r, const Pathname &path_r)
Return path_r with any root_r dir prefix striped.
bool empty() const
Test for an empty path.
Read repository data from a .repo file.
Reads through a repoindex.xml file and collects repositories.
Exception for repository handling.
SignalProxy< void(int)> sigFinished()
A ProvideRes object is a reference counted ownership of a resource in the cache provided by a Provide...
static expected success(ConsParams &&...params)
static expected error(ConsParams &&...params)
#define ZYPP_ENABLE_LOGIC_BASE(Executor, OpType)
typename conditional< B, T, F >::type conditional_t
RefreshServiceFlags RefreshServiceOptions
Options tuning RefreshService.
@ RefreshService_restoreStatus
Force restoring repo enabled/disabled status.
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
boost::logic::tribool TriBool
3-state boolean logic (true, false and indeterminate).
AsyncOpRef< expected< void > > refreshService(AsyncRepoManagerRef repoMgr, ServiceInfo info, zypp::RepoManagerFlags::RefreshServiceOptions options)
AsyncOpRef< expected< std::pair< zypp::ServiceInfo, RepoInfoList > > > fetchRepoListfromService(ContextRef ctx, zypp::Pathname root_r, ServiceInfo service, ProgressObserverRef myProgress)
AsyncOpRef< expected< zypp::repo::ServiceType > > probeServiceType(ContextRef ctx, const zypp::Url &url)
auto and_then(Fun &&function)
Exp mtry(F &&f, Args &&...args)
expected< void > assert_url(const ServiceInfo &info)
std::conditional_t< isAsync, AsyncOpRef< T >, T > makeReadyResult(T &&result)
static expected< std::decay_t< Type >, Err > make_expected_success(Type &&t)
expected< void > assert_alias(const RepoInfo &info)
RepoManagerRef< SyncContextRef > SyncRepoManagerRef
RepoManagerRef< ContextRef > AsyncRepoManagerRef
Iterator findAlias(const std::string &alias_r, Iterator begin_r, Iterator end_r)
Find alias_r in repo/service container.
bool foundAliasIn(const std::string &alias_r, Iterator begin_r, Iterator end_r)
Check if alias_r is present in repo/service container.
ProgressObserverRef _myProgress
std::optional< zypp::repo::ServicePluginInformalException > _informalError
zypp::RepoManager::RefreshServiceOptions _options
static constexpr RefreshServiceBit RefreshService_restoreStatus
static constexpr RefreshServiceBit RefreshService_forceRefresh
RepoManagerFlags::RefreshServiceFlags RefreshServiceOptions
Options tuning RefreshService.
Service type enumeration.
Simple callback to collect the results.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
#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.