11 #include <zypp-core/ng/ui/ProgressObserver> 12 #include <zypp-media/ng/ProvideSpec> 13 #include <zypp/ng/Context> 16 #include <zypp-core/parser/ParseException> 25 #undef ZYPP_BASE_LOGGER_LOGGROUP 26 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::repomanager" 42 using MediaHandle =
typename ProvideType::MediaHandle;
45 StatusLogic( repo::DownloadContextRef ctx, MediaHandle &&media )
46 :
_ctx(std::move(ctx))
50 MaybeAwaitable<expected<zypp::RepoStatus>> execute() {
60 if ( !status.empty() ) {
73 repo::DownloadContextRef
_ctx;
80 StatusLogic impl( std::move(dl), std::move(mediaHandle) );
81 zypp_co_return zypp_co_await( impl.execute() );
101 using MediaHandle =
typename ProvideType::MediaHandle;
104 DlLogic( repo::DownloadContextRef ctx, MediaHandle &&mediaHandle, ProgressObserverRef &&progressObserver )
113 | [
this]( expected<zypp::ManagedFile> &&mediaInfo ) {
116 if ( mediaInfo )
_ctx->files().push_back ( std::move(mediaInfo.get()) );
122 |
and_then( [
this] ( repo::DownloadContextRef && ) {
125 std::vector<zypp::OnMediaLocation> requiredFiles;
132 MIL <<
"Consuming repo index" << std::endl;
135 content.
parse( inputfile );
142 if (
_repoindex->metaFileChecksums.empty() ) {
147 WAR <<
"No signing keys defined." << std::endl;
154 std::map<std::string,zypp::parser::susetags::RepoIndex::FileChecksumMap::const_iterator> availablePackageTranslations;
161 static const zypp::str::regex rx_packages(
"^packages((.gz)?|(.([^.]*))(.gz)?)$" );
169 else if ( what[4] ==
"FL" )
174 availablePackageTranslations[what[4]] = it;
181 }
else if ( it->first ==
"patterns.pat" 182 || it->first ==
"patterns.pat.gz" ) {
194 std::vector<std::string> patparts;
195 unsigned archpos = 2;
197 unsigned count =
zypp::str::split( it->first, std::back_inserter(patparts),
"." );
198 if ( patparts[count-1] ==
"gz" )
201 if ( count > archpos ) {
203 zypp::Arch patarch( patparts[count-archpos] );
204 if ( !patarch.compatibleWith( zConfig().systemArchitecture() ) ) {
206 MIL <<
"Discarding pattern " << it->first << std::endl;
211 WAR <<
"Pattern file name does not contain recognizable architecture: " << it->first << std::endl;
217 MIL <<
"adding job " << it->first << std::endl;
220 .
setDeltafile( search_deltafile(
_ctx->deltaDir() + descr_dir, it->first) );
222 requiredFiles.push_back( std::move(location) );
228 auto fnc_checkTransaltions( [&](
const zypp::Locale & locale_r ) {
230 auto it( availablePackageTranslations.find( toGet.code() ) );
231 if ( it != availablePackageTranslations.end() ) {
232 auto mit( it->second );
233 MIL <<
"adding job " << mit->first << std::endl;
236 .
setDeltafile( search_deltafile( deltaDir() + descr_dir, mit->first) ));
242 for (
const zypp::Locale & it : zConfig().repoRefreshLocales() ) {
243 fnc_checkTransaltions( it );
245 fnc_checkTransaltions( zConfig().textLocale() );
248 for(
const auto &it :
_repoindex->mediaFileChecksums ) {
250 if ( it.first !=
"license.tar.gz" )
253 MIL <<
"adding job " << it.first << std::endl;
256 .
setDeltafile( search_deltafile( deltaDir(), it.first ) ));
259 for(
const auto &it :
_repoindex->signingKeys ) {
260 MIL <<
"adding job " << it.first << std::endl;
262 location.setChecksum( it.second );
263 requiredFiles.push_back( std::move(location) );
281 }) |
and_then ( [
this]( std::vector<zypp::ManagedFile> &&dlFiles ) {
282 auto &downloadedFiles =
_ctx->files();
283 downloadedFiles.insert( downloadedFiles.end(), std::make_move_iterator(dlFiles.begin()), std::make_move_iterator(dlFiles.end()) );
294 return _ctx->repoInfo();
298 return _ctx->deltaDir();
302 return _ctx->zyppContext()->config();
305 repo::DownloadContextRef
_ctx;
312 MaybeAwaitable<expected<repo::DownloadContextRef> >
download(repo::DownloadContextRef dl,
ProvideMediaHandle mediaHandle, ProgressObserverRef progressObserver)
314 DlLogic impl( std::move(dl), std::move(mediaHandle), std::move(progressObserver) );
315 zypp_co_return zypp_co_await( impl.execute() );
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
MaybeAwaitable< expected< repo::DownloadContextRef > > downloadMasterIndex(repo::DownloadContextRef dl, ProvideMediaHandle mediaHandle, zypp::filesystem::Pathname masterIndex_r)
std::string asString(const Patch::Category &obj)
relates: Patch::Category string representation.
expected< T, E > inspect(expected< T, E > exp, Function &&f)
auto finishProgress(ProgressObserverRef progressObserver, ProgressObserver::FinishResult result=ProgressObserver::Success)
Locale fallback() const
Return the fallback locale for this locale, if no fallback exists the empty Locale::noCode.
What is known about a repository.
static expected< std::decay_t< Type >, Err > make_expected_success(Type &&t)
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
std::string basename() const
Return the last component of this path.
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.
MaybeAwaitable< expected< zypp::ManagedFile > > provideToCacheDir(CacheProviderContextRef cacheContext, ProvideMediaHandle medium, zypp::Pathname file, ProvideFileSpec filespec)
bool isExist() const
Return whether valid stat info exists.
ProvideFileSpec & setMirrorsAllowed(bool set=true)
Enables or disables the use of mirrors when fetching this file.
Interim helper class to collect global options and settings.
Parse repoindex part from a content file.
std::enable_if_t< is_instance_of_v< expected, Ret >, expected< Container< typename Ret::value_type > > > transform_collect(Container< Msg, CArgs... > &&in, Transformation &&f)
void setRepoIndexConsumer(const RepoIndexConsumer &fnc_r)
Consumer to call when repo index was parsed.
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).
Regular expression match result.
Base class for Exception.
Wrapper class for ::stat/::lstat.
bool regex_match(const char *s, smatch &matches, const regex ®ex) ZYPP_API
Regular expression matching.
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={})