libzypp 17.31.23
TestcaseSetup.cc
Go to the documentation of this file.
1#include "TestcaseSetupImpl.h"
2
4{
6 {}
7
9 { }
10
11 RepoData::RepoData(RepoDataImpl &&data) : _pimpl( new RepoDataImpl( std::move(data)) )
12 { }
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
30 { return *_pimpl; }
31
33 { }
34
36 { }
37
39 { }
40
42 { return *_pimpl; }
43
45 { return *_pimpl; }
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
57 { }
58
60 { }
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->allowDowngrade; }
121
123 { return _pimpl->allowNameChange; }
124
126 { return _pimpl->allowArchChange; }
127
129 { return _pimpl->allowVendorChange; }
130
132 { return _pimpl->dupAllowDowngrade; }
133
135 { return _pimpl->dupAllowNameChange; }
136
138 { return _pimpl->dupAllowArchChange; }
139
141 { return _pimpl->dupAllowVendorChange; }
142
144 {
145 const auto &setup = data();
146 if ( !setup.architecture.empty() )
147 {
148 MIL << "Setting architecture to '" << setup.architecture << "'" << std::endl;
149 ZConfig::instance().setSystemArchitecture( setup.architecture );
150 setenv ("ZYPP_TESTSUITE_FAKE_ARCH", setup.architecture.c_str(), 1);
151 }
152
153 if ( setup.systemRepo ) {
154 if (!loadRepo( manager, *this, *setup.systemRepo ) )
155 {
156 ERR << "Can't setup 'system'" << std::endl;
157 return false;
158 }
159 }
160
161 if ( !setup.hardwareInfoFile.empty() ) {
162 setenv( "ZYPP_MODALIAS_SYSFS", setup.hardwareInfoFile.asString().c_str(), 1 );
163 MIL << "setting HardwareInfo to: " << setup.hardwareInfoFile.asString() << std::endl;
164 }
165
166 for ( const auto &channel : setup.repos ) {
167 if ( !loadRepo( manager, *this, channel ) )
168 {
169 ERR << "Can't setup 'channel'" << std::endl;
170 return false;
171 }
172 }
173
174 if ( !setup.systemCheck.empty() ) {
175 MIL << "setting systemCheck to: " << setup.systemCheck.asString() << std::endl;
176 SystemCheck::instance().setFile( setup.systemCheck );
177 }
178
179 return true;
180 }
181
182 bool TestcaseSetup::loadRepo( zypp::RepoManager &manager, const TestcaseSetup &setup, const RepoData &data )
183 {
184 const auto &repoData = data.data();
185 Pathname pathname = setup._pimpl->globalPath + repoData.path;
186 MIL << "'" << pathname << "'" << std::endl;
187
188 Repository repo;
189
191
192 if ( repoData.type == TrType::Url ) {
193 try {
194 MIL << "Load from Url '" << repoData.path << "'" << std::endl;
195
196 RepoInfo nrepo;
197 nrepo.setAlias ( repoData.alias );
198 nrepo.setName ( repoData.alias );
199 nrepo.setEnabled ( true );
200 nrepo.setAutorefresh( false );
201 nrepo.setPriority ( repoData.priority );
202 nrepo.addBaseUrl ( Url(repoData.path) );
203
204 manager.refreshMetadata( nrepo );
205 manager.buildCache( nrepo );
206 manager.loadFromCache( nrepo );
207 }
208 catch ( Exception & excpt_r ) {
209 ZYPP_CAUGHT (excpt_r);
210 ERR << "Couldn't load packages from Url '" << repoData.path << "'" << std::endl;
211 return false;
212 }
213 }
214 else {
215 try {
216 MIL << "Load from File '" << pathname << "'" << std::endl;
217 zypp::Repository satRepo;
218
219 if ( repoData.alias == "@System" ) {
221 } else {
222 satRepo = zypp::sat::Pool::instance().reposInsert( repoData.alias );
223 }
224
225 RepoInfo nrepo;
226
227 nrepo.setAlias ( repoData.alias );
228 nrepo.setName ( repoData.alias );
229 nrepo.setEnabled ( true );
230 nrepo.setAutorefresh( false );
231 nrepo.setPriority ( repoData.priority );
232 nrepo.addBaseUrl ( pathname.asUrl() );
233
234 satRepo.setInfo (nrepo);
235 if ( repoData.type == TrType::Helix )
236 satRepo.addHelix( pathname );
237 else
238 satRepo.addTesttags( pathname );
239 MIL << "Loaded " << satRepo.solvablesSize() << " resolvables from " << ( repoData.path.empty()?pathname.asString():repoData.path) << "." << std::endl;
240 }
241 catch ( Exception & excpt_r ) {
242 ZYPP_CAUGHT (excpt_r);
243 ERR << "Couldn't load packages from XML file '" << repoData.path << "'" << std::endl;
244 return false;
245 }
246 }
247 return true;
248 }
249
251 {
252 return *_pimpl;
253 }
254
256 {
257 return *_pimpl;
258 }
259
260}
Architecture.
Definition: Arch.h:37
Base class for Exception.
Definition: Exception.h:146
What is known about a repository.
Definition: RepoInfo.h:72
void addBaseUrl(const Url &url)
Add a base url.
Definition: RepoInfo.cc:635
void setPriority(unsigned newval_r)
Set repository priority for solver.
Definition: RepoInfo.cc:400
void addHelix(const Pathname &file_r)
Load Solvables from a helix-file.
Definition: Repository.cc:339
void addTesttags(const Pathname &file_r)
Load Solvables from a libsolv testtags-file.
Definition: Repository.cc:361
size_type solvablesSize() const
Number of solvables in Repository.
Definition: Repository.cc:225
void setInfo(const RepoInfo &info_r)
Set RepoInfo for this repository.
Definition: Repository.cc:279
void setSystemArchitecture(const Arch &arch_r)
Override the zypp system architecture.
Definition: ZConfig.cc:977
static ZConfig & instance()
Singleton ctor.
Definition: ZConfig.cc:922
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:91
RWCOW_pointer< ForceInstallImpl > _pimpl
Definition: TestcaseSetup.h:74
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
Definition: TestcaseSetup.h:59
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
Definition: RepoInfoBase.cc:91
void setAlias(const std::string &alias)
set the repository alias
Definition: RepoInfoBase.cc:94
void setName(const std::string &name)
set the repository name
Definition: RepoInfoBase.cc:97
void setEnabled(bool enabled)
enable or disable the repository
Definition: RepoInfoBase.cc:88
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
Libsolv Id queue wrapper.
Definition: Queue.h:35
std::vector< std::string > ModaliasList
Definition: Modalias.h:44
Definition: Arch.h:361
ResolverFocus
The resolver's general attitude.
Definition: ResolverFocus.h:22
creates and provides information about known sources.
Definition: RepoManager.cc:533
void loadFromCache(const RepoInfo &info, OPT_PROGRESS)
void refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy, OPT_PROGRESS)
void buildCache(const RepoInfo &info, CacheBuildPolicy policy, OPT_PROGRESS)
Track added/removed set items based on an initial set.
Definition: SetTracker.h:38
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
Definition: Exception.h:436
#define MIL
Definition: Logger.h:96
#define ERR
Definition: Logger.h:98