libzypp 17.38.14
TestcaseSetup.cc
Go to the documentation of this file.
1#include "TestcaseSetupImpl.h"
2
4{
7
10
13
15 { return _pimpl->type; }
16
17 const std::string &RepoData::alias() const
18 { return _pimpl->alias; }
19
20 uint RepoData::priority() const
21 { return _pimpl->priority; }
22
23 const std::string &RepoData::path() const
24 { return _pimpl->path; }
25
27 { return *_pimpl; }
28
31
34
37
40
42 { return *_pimpl; }
43
46
47 const std::string &ForceInstall::channel() const
48 { return _pimpl->channel; }
49
50 const std::string &ForceInstall::package() const
51 { return _pimpl->package; }
52
53 const std::string &ForceInstall::kind() const
54 { return _pimpl->kind; }
55
58
61
63 { return _pimpl->architecture; }
64
65 const std::optional<RepoData> &TestcaseSetup::systemRepo() const
66 { return _pimpl->systemRepo; }
67
68 const std::vector<RepoData> &TestcaseSetup::repos() const
69 { return _pimpl->repos; }
70
72 { return _pimpl->resolverFocus; }
73
75 { return _pimpl->globalPath; }
76
78 { return _pimpl->hardwareInfoFile; }
79
81 { return _pimpl->systemCheck; }
82
84 { return _pimpl->modaliasList; }
85
87 { return _pimpl->localesTracker; }
88
89 const std::vector<std::vector<std::string> > &TestcaseSetup::vendorLists() const
90 { return _pimpl->vendorLists; }
91
93 { return _pimpl->autoinstalled; }
94
95 const std::set<std::string> &TestcaseSetup::multiversionSpec() const
96 { return _pimpl->multiversionSpec; }
97
98 const std::vector<ForceInstall> &TestcaseSetup::forceInstallTasks() const
99 { return _pimpl->forceInstallTasks; }
100
102 { return _pimpl->set_licence; }
103
105 { return _pimpl->show_mediaid; }
106
108 { return _pimpl->ignorealreadyrecommended; }
109
111 { return _pimpl->onlyRequires; }
112
114 { return _pimpl->forceResolve; }
115
117 { return _pimpl->cleandepsOnRemove; }
118
120 { return _pimpl->noUpdateProvide; }
121
123 { return _pimpl->allowDowngrade; }
124
126 { return _pimpl->allowNameChange; }
127
129 { return _pimpl->allowArchChange; }
130
132 { return _pimpl->allowVendorChange; }
133
135 { return _pimpl->dupAllowDowngrade; }
136
138 { return _pimpl->dupAllowNameChange; }
139
141 { return _pimpl->dupAllowArchChange; }
142
144 { return _pimpl->dupAllowVendorChange; }
145
147 {
148 const auto &setup = data();
149 if ( !setup.architecture.empty() )
150 {
151 MIL << "Setting architecture to '" << setup.architecture << "'" << std::endl;
152 ZConfig::instance().setSystemArchitecture( setup.architecture );
153 setenv ("ZYPP_TESTSUITE_FAKE_ARCH", setup.architecture.c_str(), 1);
154 }
155
156 if ( setup.systemRepo ) {
157 if (!loadRepo( manager, *this, *setup.systemRepo ) )
158 {
159 ERR << "Can't setup 'system'" << std::endl;
160 return false;
161 }
162 }
163
164 if ( !setup.hardwareInfoFile.empty() ) {
165 setenv( "ZYPP_MODALIAS_SYSFS", setup.hardwareInfoFile.asString().c_str(), 1 );
166 MIL << "setting HardwareInfo to: " << setup.hardwareInfoFile.asString() << std::endl;
167 }
168
169 for ( const auto &channel : setup.repos ) {
170 if ( !loadRepo( manager, *this, channel ) )
171 {
172 ERR << "Can't setup 'channel'" << std::endl;
173 return false;
174 }
175 }
176
177 if ( !setup.systemCheck.empty() ) {
178 MIL << "setting systemCheck to: " << setup.systemCheck.asString() << std::endl;
179 SystemCheck::instance().setFile( setup.systemCheck );
180 }
181
182 return true;
183 }
184
186 {
187 const auto &repoData = data.data();
188 Pathname pathname = setup._pimpl->globalPath + repoData.path;
189 MIL << "'" << pathname << "'" << std::endl;
190
192
194
195 if ( repoData.type == TrType::Url ) {
196 try {
197 MIL << "Load from Url '" << repoData.path << "'" << std::endl;
198
199 RepoInfo nrepo;
200 nrepo.setAlias ( repoData.alias );
201 nrepo.setName ( repoData.alias );
202 nrepo.setEnabled ( true );
203 nrepo.setAutorefresh( false );
204 nrepo.setPriority ( repoData.priority );
205 nrepo.addBaseUrl ( Url(repoData.path) );
206
207 manager.refreshMetadata( nrepo );
208 manager.buildCache( nrepo );
209 manager.loadFromCache( nrepo );
210 }
211 catch ( Exception & excpt_r ) {
212 ZYPP_CAUGHT (excpt_r);
213 ERR << "Couldn't load packages from Url '" << repoData.path << "'" << std::endl;
214 return false;
215 }
216 }
217 else {
218 try {
219 MIL << "Load from File '" << pathname << "'" << std::endl;
220 zypp::Repository satRepo;
221
222 if ( repoData.alias == "@System" ) {
224 } else {
225 satRepo = zypp::sat::Pool::instance().reposInsert( repoData.alias );
226 }
227
228 RepoInfo nrepo;
229
230 nrepo.setAlias ( repoData.alias );
231 nrepo.setName ( repoData.alias );
232 nrepo.setEnabled ( true );
233 nrepo.setAutorefresh( false );
234 nrepo.setPriority ( repoData.priority );
235 nrepo.addBaseUrl ( pathname.asUrl() );
236
237 satRepo.setInfo (nrepo);
238 if ( repoData.type == TrType::Helix )
239 satRepo.addHelix( pathname );
240 else
241 satRepo.addTesttags( pathname );
242 MIL << "Loaded " << satRepo.solvablesSize() << " resolvables from " << ( repoData.path.empty()?pathname.asString():repoData.path) << "." << std::endl;
243 }
244 catch ( Exception & excpt_r ) {
245 ZYPP_CAUGHT (excpt_r);
246 ERR << "Couldn't load packages from XML file '" << repoData.path << "'" << std::endl;
247 return false;
248 }
249 }
250 return true;
251 }
252
254 {
255 return *_pimpl;
256 }
257
259 {
260 return *_pimpl;
261 }
262
263}
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
Definition Exception.h:475
#define MIL
Definition Logger.h:103
#define ERR
Definition Logger.h:105
Architecture.
Definition Arch.h:37
Base class for Exception.
Definition Exception.h:153
What is known about a repository.
Definition RepoInfo.h:72
void addBaseUrl(Url url)
Add a base url.
Definition RepoInfo.cc:767
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition RepoInfo.cc:619
creates and provides information about known sources.
Definition RepoManager.h:60
void refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy=RefreshIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Refresh local raw cache.
void buildCache(const RepoInfo &info, CacheBuildPolicy policy=BuildIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Refresh local cache.
void loadFromCache(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Load resolvables into the pool.
void addHelix(const Pathname &file_r)
Load Solvables from a helix-file.
void addTesttags(const Pathname &file_r)
Load Solvables from a libsolv testtags-file.
size_type solvablesSize() const
Number of solvables in Repository.
void setInfo(const RepoInfo &info_r)
Set RepoInfo for this repository.
void setSystemArchitecture(const Arch &arch_r)
Override the zypp system architecture.
Definition ZConfig.cc:860
static ZConfig & instance()
Singleton ctor.
Definition ZConfig.cc:794
Url asUrl(const std::string &scheme_r) const
Url representation using scheme_r schema .
Definition Pathname.cc:172
const std::string & asString() const
String representation.
Definition Pathname.h:94
RWCOW_pointer< ForceInstallImpl > _pimpl
const std::string & package() const
const std::string & kind() const
const std::string & channel() const
const ForceInstallImpl & data() const
const RepoDataImpl & data() const
TestcaseRepoType type() const
RWCOW_pointer< RepoDataImpl > _pimpl
const std::string & path() const
const std::string & alias() const
const std::vector< RepoData > & repos() const
bool applySetup(zypp::RepoManager &manager) const
ResolverFocus resolverFocus() const
const target::Modalias::ModaliasList & modaliasList() const
const std::vector< ForceInstall > & forceInstallTasks() const
const std::optional< RepoData > & systemRepo() const
const std::vector< std::vector< std::string > > & vendorLists() const
const std::set< std::string > & multiversionSpec() const
RWCOW_pointer< TestcaseSetupImpl > _pimpl
const sat::StringQueue & autoinstalled() const
static bool loadRepo(zypp::RepoManager &manager, const TestcaseSetup &setup, const RepoData &data)
const Pathname & systemCheck() const
const Pathname & globalPath() const
const Pathname & hardwareInfoFile() const
const base::SetTracker< LocaleSet > & localesTracker() const
void setAutorefresh(bool autorefresh)
enable or disable autorefresh
void setAlias(const std::string &alias)
set the repository alias
void setName(const std::string &name)
set the repository name
void setEnabled(bool enabled)
enable or disable the repository
static Pool instance()
Singleton ctor.
Definition Pool.h:55
Repository reposInsert(const std::string &alias_r)
Return a Repository named alias_r.
Definition Pool.cc:143
Repository systemRepo()
Return the system repository, create it if missing.
Definition Pool.cc:178
std::vector< std::string > ModaliasList
Definition Modalias.h:45
Definition ansi.h:855
Queue StringQueue
Queue with String ids.
Definition Queue.h:28
ResolverFocus
The resolver's general attitude.
Track added/removed set items based on an initial set.
Definition SetTracker.h:39