11 #include <zypp-core/zyppng/ui/ProgressObserver> 12 #include <zypp-media/ng/ProvideSpec> 13 #include <zypp/ng/Context> 15 #include <zypp-core/parser/ParseException> 36 template<
class Executor,
class OpType>
37 struct StatusLogic :
public LogicBase<Executor, OpType>{
43 using ZyppContextType =
typename DlContextRefType::element_type::ContextType;
44 using ProvideType =
typename ZyppContextType::ProvideType;
45 using MediaHandle =
typename ProvideType::MediaHandle;
48 StatusLogic( DlContextRefType ctx, MediaHandle &&media )
49 :
_ctx(std::move(ctx))
53 MaybeAsyncRef<expected<zypp::RepoStatus>> execute() {
55 | [
this]( expected<ProvideRes> contentFile ) {
63 if ( !status.empty() ) {
65 | [status = std::move(status)]( expected<ProvideRes> mediaFile )
mutable {
67 return make_expected_success(status &&
zypp::RepoStatus( mediaFile->file()) );
69 return make_expected_success( std::move(status) );
72 return makeReadyResult( make_expected_success(std::move(status)) );
107 template<
class Executor,
class OpType>
108 struct DlLogic :
public LogicBase<Executor, OpType> {
114 using ZyppContextType =
typename DlContextRefType::element_type::ContextType;
115 using ProvideType =
typename ZyppContextType::ProvideType;
116 using MediaHandle =
typename ProvideType::MediaHandle;
117 using ProvideRes =
typename ProvideType::Res;
119 DlLogic( DlContextRefType ctx, MediaHandle &&mediaHandle, ProgressObserverRef &&progressObserver )
128 | [
this]( expected<zypp::ManagedFile> &&mediaInfo ) {
131 if ( mediaInfo )
_ctx->files().push_back ( std::move(mediaInfo.get()) );
137 | and_then( [
this] ( DlContextRefType && ) {
140 std::vector<zypp::OnMediaLocation> requiredFiles;
147 MIL <<
"Consuming repo index" << std::endl;
150 content.
parse( inputfile );
157 if (
_repoindex->metaFileChecksums.empty() ) {
162 WAR <<
"No signing keys defined." << std::endl;
169 std::map<std::string,zypp::parser::susetags::RepoIndex::FileChecksumMap::const_iterator> availablePackageTranslations;
176 static const zypp::str::regex rx_packages(
"^packages((.gz)?|(.([^.]*))(.gz)?)$" );
184 else if ( what[4] ==
"FL" )
189 availablePackageTranslations[what[4]] = it;
196 }
else if ( it->first ==
"patterns.pat" 197 || it->first ==
"patterns.pat.gz" ) {
209 std::vector<std::string> patparts;
210 unsigned archpos = 2;
212 unsigned count =
zypp::str::split( it->first, std::back_inserter(patparts),
"." );
213 if ( patparts[count-1] ==
"gz" )
216 if ( count > archpos ) {
218 zypp::Arch patarch( patparts[count-archpos] );
219 if ( !patarch.compatibleWith( zConfig().systemArchitecture() ) ) {
221 MIL <<
"Discarding pattern " << it->first << std::endl;
226 WAR <<
"Pattern file name does not contain recognizable architecture: " << it->first << std::endl;
232 MIL <<
"adding job " << it->first << std::endl;
235 .
setDeltafile( search_deltafile(
_ctx->deltaDir() + descr_dir, it->first) );
237 requiredFiles.push_back( std::move(location) );
243 auto fnc_checkTransaltions( [&](
const zypp::Locale & locale_r ) {
245 auto it( availablePackageTranslations.find( toGet.code() ) );
246 if ( it != availablePackageTranslations.end() ) {
247 auto mit( it->second );
248 MIL <<
"adding job " << mit->first << std::endl;
251 .
setDeltafile( search_deltafile( deltaDir() + descr_dir, mit->first) ));
257 for (
const zypp::Locale & it : zConfig().repoRefreshLocales() ) {
258 fnc_checkTransaltions( it );
260 fnc_checkTransaltions( zConfig().textLocale() );
263 for(
const auto &it :
_repoindex->mediaFileChecksums ) {
265 if ( it.first !=
"license.tar.gz" )
268 MIL <<
"adding job " << it.first << std::endl;
271 .
setDeltafile( search_deltafile( deltaDir(), it.first ) ));
274 for(
const auto &it :
_repoindex->signingKeys ) {
275 MIL <<
"adding job " << it.first << std::endl;
277 location.setChecksum( it.second );
278 requiredFiles.push_back( std::move(location) );
283 return makeReadyResult(expected<DlContextRefType>::error( std::make_exception_ptr(e) ) );
285 return makeReadyResult(expected<DlContextRefType>::error( std::current_exception() ) );
296 }) | and_then ( [
this]( std::vector<zypp::ManagedFile> &&dlFiles ) {
297 auto &downloadedFiles =
_ctx->files();
298 downloadedFiles.insert( downloadedFiles.end(), std::make_move_iterator(dlFiles.begin()), std::make_move_iterator(dlFiles.end()) );
299 return expected<DlContextRefType>::success( std::move(
_ctx) );
309 return _ctx->repoInfo();
313 return _ctx->deltaDir();
317 return _ctx->zyppContext()->config();
320 DlContextRefType
_ctx;
327 AsyncOpRef<expected<repo::AsyncDownloadContextRef> >
download(repo::AsyncDownloadContextRef dl,
ProvideMediaHandle mediaHandle, ProgressObserverRef progressObserver)
332 expected<repo::SyncDownloadContextRef>
download(repo::SyncDownloadContextRef dl,
SyncMediaHandle mediaHandle, ProgressObserverRef progressObserver)
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
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.
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.
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
bool endsWith(const C_Str &str_r, const C_Str &prefix_r)
alias for hasSuffix
'Language[_Country]' codes.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
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
Track changing files or directories.
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.