11 #include <zypp-core/zyppng/ui/ProgressObserver> 12 #include <zypp-media/ng/ProvideSpec> 13 #include <zypp/ng/Context> 15 #include <zypp-core/parser/ParseException> 25 #undef ZYPP_BASE_LOGGER_LOGGROUP 26 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::repomanager" 39 template<
class Executor,
class OpType>
40 struct StatusLogic :
public LogicBase<Executor, OpType>{
46 using ZyppContextType =
typename DlContextRefType::element_type::ContextType;
47 using ProvideType =
typename ZyppContextType::ProvideType;
48 using MediaHandle =
typename ProvideType::MediaHandle;
51 StatusLogic( DlContextRefType ctx, MediaHandle &&media )
52 :
_ctx(std::move(ctx))
56 MaybeAsyncRef<expected<zypp::RepoStatus>> execute() {
66 if ( !status.empty() ) {
110 template<
class Executor,
class OpType>
111 struct DlLogic :
public LogicBase<Executor, OpType> {
117 using ZyppContextType =
typename DlContextRefType::element_type::ContextType;
118 using ProvideType =
typename ZyppContextType::ProvideType;
119 using MediaHandle =
typename ProvideType::MediaHandle;
120 using ProvideRes =
typename ProvideType::Res;
122 DlLogic( DlContextRefType ctx, MediaHandle &&mediaHandle, ProgressObserverRef &&progressObserver )
131 | [
this]( expected<zypp::ManagedFile> &&mediaInfo ) {
134 if ( mediaInfo )
_ctx->files().push_back ( std::move(mediaInfo.get()) );
140 |
and_then( [
this] ( DlContextRefType && ) {
143 std::vector<zypp::OnMediaLocation> requiredFiles;
150 MIL <<
"Consuming repo index" << std::endl;
153 content.
parse( inputfile );
160 if (
_repoindex->metaFileChecksums.empty() ) {
165 WAR <<
"No signing keys defined." << std::endl;
172 std::map<std::string,zypp::parser::susetags::RepoIndex::FileChecksumMap::const_iterator> availablePackageTranslations;
179 static const zypp::str::regex rx_packages(
"^packages((.gz)?|(.([^.]*))(.gz)?)$" );
187 else if ( what[4] ==
"FL" )
192 availablePackageTranslations[what[4]] = it;
199 }
else if ( it->first ==
"patterns.pat" 200 || it->first ==
"patterns.pat.gz" ) {
212 std::vector<std::string> patparts;
213 unsigned archpos = 2;
215 unsigned count =
zypp::str::split( it->first, std::back_inserter(patparts),
"." );
216 if ( patparts[count-1] ==
"gz" )
219 if ( count > archpos ) {
221 zypp::Arch patarch( patparts[count-archpos] );
222 if ( !patarch.compatibleWith( zConfig().systemArchitecture() ) ) {
224 MIL <<
"Discarding pattern " << it->first << std::endl;
229 WAR <<
"Pattern file name does not contain recognizable architecture: " << it->first << std::endl;
235 MIL <<
"adding job " << it->first << std::endl;
238 .
setDeltafile( search_deltafile(
_ctx->deltaDir() + descr_dir, it->first) );
240 requiredFiles.push_back( std::move(location) );
246 auto fnc_checkTransaltions( [&](
const zypp::Locale & locale_r ) {
248 auto it( availablePackageTranslations.find( toGet.code() ) );
249 if ( it != availablePackageTranslations.end() ) {
250 auto mit( it->second );
251 MIL <<
"adding job " << mit->first << std::endl;
254 .
setDeltafile( search_deltafile( deltaDir() + descr_dir, mit->first) ));
260 for (
const zypp::Locale & it : zConfig().repoRefreshLocales() ) {
261 fnc_checkTransaltions( it );
263 fnc_checkTransaltions( zConfig().textLocale() );
266 for(
const auto &it :
_repoindex->mediaFileChecksums ) {
268 if ( it.first !=
"license.tar.gz" )
271 MIL <<
"adding job " << it.first << std::endl;
274 .
setDeltafile( search_deltafile( deltaDir(), it.first ) ));
277 for(
const auto &it :
_repoindex->signingKeys ) {
278 MIL <<
"adding job " << it.first << std::endl;
280 location.setChecksum( it.second );
281 requiredFiles.push_back( std::move(location) );
299 }) |
and_then ( [
this]( std::vector<zypp::ManagedFile> &&dlFiles ) {
300 auto &downloadedFiles =
_ctx->files();
301 downloadedFiles.insert( downloadedFiles.end(), std::make_move_iterator(dlFiles.begin()), std::make_move_iterator(dlFiles.end()) );
312 return _ctx->repoInfo();
316 return _ctx->deltaDir();
320 return _ctx->zyppContext()->config();
323 DlContextRefType
_ctx;
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
expected< T, E > inspect(expected< T, E > exp, Function &&f)
auto finishProgress(ProgressObserverRef progressObserver, ProgressObserver::FinishResult result=ProgressObserver::Success)
A ProvideRes object is a reference counted ownership of a resource in the cache provided by a Provide...
Locale fallback() const
Return the fallback locale for this locale, if no fallback exists the empty Locale::noCode.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
What is known about a repository.
static expected< std::decay_t< Type >, Err > make_expected_success(Type &&t)
std::string basename() const
Return the last component of this path.
std::string asString(TInt val, char zero='0', char one='1')
For printing bits.
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \, const Trim trim_r=NO_TRIM)
Split line_r into words.
auto transform_collect(Container< Msg, CArgs... > &&in, Transformation &&f)
bool isExist() const
Return whether valid stat info exists.
AsyncOpRef< expected< zypp::ManagedFile > > provideToCacheDir(AsyncCacheProviderContextRef cacheContext, ProvideMediaHandle medium, zypp::Pathname file, ProvideFileSpec filespec)
Interim helper class to collect global options and settings.
Parse repoindex part from a content file.
#define ZYPP_ENABLE_LOGIC_BASE(Executor, OpType)
AsyncOpRef< expected< repo::AsyncDownloadContextRef > > downloadMasterIndex(repo::AsyncDownloadContextRef dl, ProvideMediaHandle mediaHandle, zypp::filesystem::Pathname masterIndex_r)
void setRepoIndexConsumer(const RepoIndexConsumer &fnc_r)
Consumer to call when repo index was parsed.
typename conditional< B, T, F >::type conditional_t
std::conditional_t< isAsync, AsyncOpRef< T >, T > makeReadyResult(T &&result)
bool endsWith(const C_Str &str_r, const C_Str &prefix_r)
alias for hasSuffix
static expected success(ConsParams &&...params)
'Language[_Country]' codes.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
std::shared_ptr< AsyncOp< T > > AsyncOpRef
Regular expression match result.
Base class for Exception.
Wrapper class for ::stat/::lstat.
bool regex_match(const std::string &s, smatch &matches, const regex ®ex)
regex ZYPP_STR_REGEX regex ZYPP_STR_REGEX
ResultType and_then(const expected< T, E > &exp, Function &&f)
Track changing files or directories.
#define ZYPP_FWD_CURRENT_EXCPT()
Drops a logline and returns the current Exception as a std::exception_ptr.
auto downloadMediaInfo(MediaHandle &&mediaHandle, const zypp::filesystem::Pathname &destdir)
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
virtual void parse(const InputStream &imput_r, const ProgressData::ReceiverFnc &fnc_r=ProgressData::ReceiverFnc())
Parse the stream.
auto incProgress(ProgressObserverRef progressObserver, double progrIncrease=1.0, std::optional< std::string > newStr={})