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))
53 , _handle(std::move(
media))
56 MaybeAsyncRef<expected<zypp::RepoStatus>> execute() {
57 return _ctx->zyppContext()->provider()->provide( _handle, _ctx->repoInfo().path() /
"content" ,
ProvideFileSpec().setMirrorsAllowed(
false) )
66 if ( !status.
empty() ) {
67 return _ctx->zyppContext()->provider()->provide( _handle,
"/media.1/media" ,
ProvideFileSpec().setMirrorsAllowed(
false) )
79 DlContextRefType _ctx;
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;
122 DlLogic( DlContextRefType ctx, MediaHandle &&mediaHandle, ProgressObserverRef &&progressObserver )
123 : _ctx(
std::move(ctx))
124 , _mediaHandle(
std::move(mediaHandle))
125 , _progressObserver(
std::move(progressObserver))
131 | [
this]( expected<zypp::ManagedFile> &&mediaInfo ) {
134 if ( mediaInfo ) _ctx->files().push_back ( std::move(mediaInfo.get()) );
136 if ( _progressObserver ) _progressObserver->inc();
140 |
and_then( [
this] ( DlContextRefType && ) {
142 zypp::Pathname contentPath = _ctx->files().front();
143 std::vector<zypp::OnMediaLocation> requiredFiles;
147 const zypp::Pathname &inputfile = contentPath;
148 zypp::parser::susetags::ContentFileReader content;
150 MIL <<
"Consuming repo index" << std::endl;
153 content.
parse( inputfile );
155 if ( ! _repoindex ) {
156 ZYPP_THROW( zypp::parser::ParseException( ( _ctx->destDir() / _ctx->repoInfo().path() ).asString() +
": " +
"No repository index in content file." ) );
159 MIL <<
"RepoIndex: " << _repoindex << std::endl;
160 if ( _repoindex->metaFileChecksums.empty() ) {
161 ZYPP_THROW( zypp::parser::ParseException( ( _ctx->destDir() / _ctx->repoInfo().path() ).asString() +
": " +
"No metadata checksums in content file." ) );
164 if ( _repoindex->signingKeys.empty() ) {
165 WAR <<
"No signing keys defined." << std::endl;
169 zypp::Pathname descr_dir = _repoindex->descrdir;
172 std::map<std::string,zypp::parser::susetags::RepoIndex::FileChecksumMap::const_iterator> availablePackageTranslations;
174 for_( it, _repoindex->metaFileChecksums.begin(), _repoindex->metaFileChecksums.end() )
179 static const zypp::str::regex rx_packages(
"^packages((.gz)?|(.([^.]*))(.gz)?)$" );
180 zypp::str::smatch what;
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;
228 }
catch (
const zypp::Exception & excpt ) {
229 WAR <<
"Pattern file name does not contain recognizable architecture: " << it->first << std::endl;
235 MIL <<
"adding job " << it->first << std::endl;
236 auto location = zypp::OnMediaLocation( repoInfo().path() + descr_dir + it->first, 1 )
237 .setChecksum( it->second )
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 ) {
247 for ( zypp::Locale toGet( locale_r ); toGet; toGet = toGet.fallback() ) {
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;
252 requiredFiles.push_back( zypp::OnMediaLocation( repoInfo().path() + descr_dir + mit->first, 1 )
253 .setChecksum( mit->second )
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;
272 requiredFiles.push_back( zypp::OnMediaLocation ( repoInfo().path() + it.first, 1 )
273 .setChecksum( it.second )
274 .setDeltafile( search_deltafile( deltaDir(), it.first ) ));
277 for(
const auto &it : _repoindex->signingKeys ) {
278 MIL <<
"adding job " << it.first << std::endl;
279 zypp::OnMediaLocation location( repoInfo().path() + it.first, 1 );
280 location.setChecksum( it.second );
281 requiredFiles.push_back( std::move(location) );
284 }
catch (
const zypp::Exception &e ) {
292 if ( _progressObserver ) _progressObserver->setBaseSteps ( _progressObserver->baseSteps () + requiredFiles.size() );
294 return transform_collect ( std::move(requiredFiles), [
this]( zypp::OnMediaLocation file ) {
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()) );
311 const zypp::RepoInfo &repoInfo()
const {
312 return _ctx->repoInfo();
315 const zypp::filesystem::Pathname &deltaDir()
const {
316 return _ctx->deltaDir();
319 zypp::ZConfig &zConfig() {
320 return _ctx->zyppContext()->config();
323 DlContextRefType _ctx;
324 zypp::parser::susetags::RepoIndex_Ptr _repoindex;
325 MediaHandle _mediaHandle;
326 ProgressObserverRef _progressObserver;