Go to the documentation of this file.
17 #define ZYPP_USE_RESOLVER_INTERNALS
67 result +=
"<" + tag +
">";
74 result +=
"</" + tag +
">";
84 std::stringstream
str;
96 std::stringstream
str;
104 std::stringstream
str;
115 str <<
" />" << endl;
124 str <<
"<dep name='packageand("
128 && detail.
lhs().
id() == NAMESPACE_OTHERPROVIDERS) {
129 str <<
"<dep name='otherproviders("
139 && detail.
lhs().
id() == NAMESPACE_MODALIAS) {
140 str <<
"<dep name='modalias(";
141 if (!packageName.
empty())
142 str << packageName <<
":";
158 std::stringstream
str;
161 for ( ; it != caps.
end(); ++it)
172 std::stringstream
str;
173 CapabilitySet::const_iterator it = caps.begin();
175 for ( ; it != caps.end(); ++it)
185 std::stringstream out;
187 if ( ! caps.
empty() )
194 std::stringstream
str;
195 str <<
"<" << item.
kind() <<
">" << endl;
199 if ( isKind<Package>( item ) ) {
200 str <<
TAB <<
"<history>" << endl <<
TAB <<
"<update>" << endl;
203 str <<
TAB <<
"</update>" << endl <<
TAB <<
"</history>" << endl;
218 str <<
"</" << item.
kind() <<
">" << endl;
259 *
file <<
"<channel><subchannel>" << endl;
264 *
file <<
"</subchannel></channel>" << endl;
285 const Arch & systemArchitecture,
287 const std::set<std::string> & multiversionSpec,
288 const std::string & systemPath);
295 *
file <<
"</setup>" << endl <<
"<trial>" << endl;
303 void addTagIf(
const std::string & tag_r,
bool yesno_r =
true )
306 writeTag() <<
"<" << tag_r <<
"/>" << endl;
321 const Arch & systemArchitecture,
323 const std::set<std::string> & multiversionSpec,
324 const std::string & systemPath)
325 :dumpFile (controlPath)
328 file =
new std::ofstream(controlPath.c_str());
333 *
file <<
"<?xml version=\"1.0\"?>" << endl
334 <<
"<!-- libzypp resolver testcase -->" << endl
336 <<
"<setup arch=\"" << systemArchitecture <<
"\">" << endl
337 <<
TAB <<
"<system file=\"" << systemPath <<
"\"/>" << endl << endl;
338 for ( RepositoryTable::const_iterator it = repoTable.begin();
339 it != repoTable.end(); ++it ) {
341 *
file <<
TAB <<
"<!-- " << endl
342 <<
TAB <<
"- alias : " << repo.
alias() << endl;
347 *
file <<
TAB <<
"- url : " << *itUrl << endl;
349 *
file <<
TAB <<
"- path : " << repo.
path() << endl;
350 *
file <<
TAB <<
"- type : " << repo.
type() << endl;
351 *
file <<
TAB <<
"- generated : " << (it->first.generatedTimestamp()).
form(
"%Y-%m-%d %H:%M:%S" ) << endl;
352 *
file <<
TAB <<
"- outdated : " << (it->first.suggestedExpirationTimestamp()).
form(
"%Y-%m-%d %H:%M:%S" ) << endl;
353 *
file <<
TAB <<
" -->" << endl;
356 <<
"-package.xml.gz\" name=\"" << repo.
alias() <<
"\""
357 <<
" priority=\"" << repo.
priority()
358 <<
"\" />" << endl << endl;
369 for (
Locale l : requestedLocales )
371 const char * fate = ( addedLocales.count(l) ?
"\" fate=\"added" :
"" );
372 *
file <<
TAB <<
"<locale name=\"" << l << fate <<
"\" />" << endl;
374 for (
Locale l : removedLocales )
376 *
file <<
TAB <<
"<locale name=\"" << l <<
"\" fate=\"removed\" />" << endl;
387 for_( it, modaliasList.begin(), modaliasList.end() ) {
392 for_( it, multiversionSpec.begin(), multiversionSpec.end() ) {
393 *
file <<
TAB <<
"<multiversion name=\"" << *it
403 *
file <<
"</trial>" << endl
404 <<
"</test>" << endl;
411 <<
" kind=\"" << pi_r.
kind() <<
"\""
412 <<
" name=\"" << pi_r.
name() <<
"\""
413 <<
" arch=\"" << pi_r.
arch() <<
"\""
416 <<
" status=\"" << pi_r.
status() <<
"\""
423 <<
" kind=\"" << pi_r.
kind() <<
"\""
424 <<
" name=\"" << pi_r.
name() <<
"\""
425 <<
" arch=\"" << pi_r.
arch() <<
"\""
428 <<
" status=\"" << pi_r.
status() <<
"\""
435 <<
" kind=\"" << pi_r.
kind() <<
"\""
436 <<
" name=\"" << pi_r.
name() <<
"\""
437 <<
" arch=\"" << pi_r.
arch() <<
"\""
440 <<
" status=\"" << pi_r.
status() <<
"\""
446 *
file <<
"<uninstall kind=\"" << pi_r.
kind() <<
"\""
447 <<
" name=\"" << pi_r.
name() <<
"\""
448 <<
" status=\"" << pi_r.
status() <<
"\""
454 for (CapabilitySet::const_iterator iter = capRequire.begin(); iter != capRequire.end(); iter++) {
455 *
file <<
"<addRequire " <<
" name=\"" << iter->asString() <<
"\"" <<
"/>" << endl;
457 for (CapabilitySet::const_iterator iter = capConflict.begin(); iter != capConflict.end(); iter++) {
458 *
file <<
"<addConflict " <<
" name=\"" << iter->asString() <<
"\"" <<
"/>" << endl;
464 for_( it, upgradeRepos_r.begin(), upgradeRepos_r.end() )
466 *
file <<
"<upgradeRepo name=\"" << it->alias() <<
"\"/>" << endl;
473 :dumpPath(
"/var/log/YaST2/solverTestcase")
476 Testcase::Testcase(
const std::string & path)
480 Testcase::~Testcase()
483 bool Testcase::createTestcase(Resolver & resolver,
bool dumpPool,
bool runSolver)
485 PathInfo path (dumpPath);
487 if ( !path.isExist() ) {
489 ERR <<
"Cannot create directory " << dumpPath << endl;
494 ERR << dumpPath <<
" is not a directory." << endl;
507 resolver.resolvePool();
510 ResPool pool = resolver.pool();
512 PoolItemList items_to_install;
513 PoolItemList items_to_remove;
514 PoolItemList items_locked;
515 PoolItemList items_keep;
516 HelixResolvable_Ptr system = NULL;
519 system =
new HelixResolvable(dumpPath +
"/solver-system.xml.gz");
521 for (
const PoolItem & pi : pool )
523 if ( system && pi.status().isInstalled() ) {
525 system->addResolvable( pi );
528 Repository repo = pi.repository();
530 if (repoTable.find (repo) == repoTable.end()) {
531 repoTable[repo] =
new HelixResolvable(dumpPath +
"/"
533 +
"-package.xml.gz");
535 repoTable[repo]->addResolvable( pi );
539 if ( pi.status().isToBeInstalled()
540 && !(pi.status().isBySolver())) {
541 items_to_install.push_back( pi );
543 if ( pi.status().isKept()
544 && !(pi.status().isBySolver())) {
545 items_keep.push_back( pi );
547 if ( pi.status().isToBeUninstalled()
548 && !(pi.status().isBySolver())) {
549 items_to_remove.push_back( pi );
551 if ( pi.status().isLocked()
552 && !(pi.status().isBySolver())) {
553 items_locked.push_back( pi );
558 HelixControl control (dumpPath +
"/solver-test.xml",
563 "solver-system.xml.gz");
566 control.writeTag() <<
"<focus value=\"" << resolver.focus() <<
"\"/>" << endl;
568 control.addTagIf(
"ignorealreadyrecommended", resolver.ignoreAlreadyRecommended() );
569 control.addTagIf(
"onlyRequires", resolver.onlyRequires() );
570 control.addTagIf(
"forceResolve", resolver.forceResolve() );
572 control.addTagIf(
"cleandepsOnRemove", resolver.cleandepsOnRemove() );
574 control.addTagIf(
"allowDowngrade", resolver.allowDowngrade() );
575 control.addTagIf(
"allowNameChange", resolver.allowNameChange() );
576 control.addTagIf(
"allowArchChange", resolver.allowArchChange() );
577 control.addTagIf(
"allowVendorChange", resolver.allowVendorChange() );
579 control.addTagIf(
"dupAllowDowngrade", resolver.dupAllowDowngrade() );
580 control.addTagIf(
"dupAllowNameChange", resolver.dupAllowNameChange() );
581 control.addTagIf(
"dupAllowArchChange", resolver.dupAllowArchChange() );
582 control.addTagIf(
"dupAllowVendorChange", resolver.dupAllowVendorChange() );
584 control.closeSetup();
587 for (
const PoolItem & pi : items_to_install )
588 { control.installResolvable( pi ); }
590 for (
const PoolItem & pi : items_locked )
591 { control.lockResolvable( pi ); }
593 for (
const PoolItem & pi : items_keep )
594 { control.keepResolvable( pi ); }
596 for (
const PoolItem & pi : items_to_remove )
597 { control.deleteResolvable( pi ); }
599 control.addDependencies (resolver.extraRequires(), resolver.extraConflicts());
600 control.addDependencies (SystemCheck::instance().requiredSystemCap(),
601 SystemCheck::instance().conflictSystemCap());
602 control.addUpgradeRepos( resolver.upgradeRepos() );
604 control.addTagIf(
"distupgrade", resolver.isUpgradeMode() );
605 control.addTagIf(
"update", resolver.isUpdateMode() );
606 control.addTagIf(
"verify", resolver.isVerifyingMode() );
sat::detail::IdType id() const
Expert backdoor.
sat::detail::IdType IdType
static Pool instance()
Singleton ctor.
std::map< Repository, HelixResolvable_Ptr > RepositoryTable
Combining sat::Solvable and ResStatus.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
std::string asString() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
static const Dep SUPPLEMENTS
int clean_dir(const Pathname &path)
Like 'rm -r DIR/ *'.
static const epoch_t noepoch
Value representing noepoch.
Queue autoInstalled() const
Get ident list of all autoinstalled solvables.
Base class for Exception.
void deleteResolvable(const PoolItem &pi_r)
RepoInfo repoInfo() const
std::string helixXML(const T &obj)
What is known about a repository.
transform_iterator< repo::RepoVariablesUrlReplacer, url_set::const_iterator > urls_const_iterator
static const Dep ENHANCES
const_iterator begin() const
Iterator pointing to the first Capability.
IMPL_PTR_TYPE(SATResolver)
epoch_t epoch() const
Epoch.
Edition represents [epoch:]version[-release]
Base class for reference counted objects.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
DEFINE_PTR_TYPE(HelixResolvable)
unsigned priority() const
Repository priority for solver.
const LocaleSet & getRemovedRequestedLocales() const
Removed since last initRequestedLocales.
static const Dep REQUIRES
void addDependencies(const CapabilitySet &capRequire, const CapabilitySet &capConflict)
std::string release() const
Release.
HelixResolvable(const std::string &path)
std::string xml_escape(const std::string &text)
bool isExpression() const
void addResolvable(const PoolItem item)
std::string asString() const
Conversion to std::string
static const Dep PREREQUIRES
Access to the sat-pools string space.
Creates a file in helix format which contains all controll action of a testcase ( file is known as *-...
std::unordered_set< Capability > CapabilitySet
void keepResolvable(const PoolItem &pi_r)
HelixControl(const std::string &controlPath, const RepositoryTable &sourceTable, const Arch &systemArchitecture, const target::Modalias::ModaliasList &modaliasList, const std::set< std::string > &multiversionSpec, const std::string &systemPath)
detail::EscapedString escape(const std::string &in_r)
Escape xml special charaters (& -> &; from IoBind library).
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
std::string alias() const
unique identifier for this source.
const_iterator end() const
Iterator pointing behind the last Capability.
static const Dep SUGGESTS
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
void addUpgradeRepos(const std::set< Repository > &upgradeRepos_r)
static ZConfig & instance()
Singleton ctor.
Easy-to use interface to the ZYPP dependency resolver.
static const Dep RECOMMENDS
String related utilities and Regular expression matching.
std::string numstring(char n, int w=0)
std::string version() const
Version.
urls_const_iterator baseUrlsBegin() const
iterator that points at begin of repository urls
std::string escape(const C_Str &str_r, const char sep_r)
Escape desired character c using a backslash.
void lockResolvable(const PoolItem &pi_r)
const std::string & asString() const
String representation of relational operator.
static const Dep OBSOLETES
static const Dep CONFLICTS
const LocaleSet & getAddedRequestedLocales() const
Added since last initRequestedLocales.
static const Dep PROVIDES
std::string asSeconds() const
Convert to string representation of calendar time in numeric form (like "1029255142").
const std::string & asString() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Turn on excessive logging for the lifetime of this object.
CapDetail detail() const
Helper providing more detailed information about a Capability.
ResStatus & status() const
Returns the current status.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Common template to define ifgzstream/ofgzstream reading/writing compressed files.
std::ostream & writeTag()
std::unordered_set< Locale > LocaleSet
std::string xml_tag_enclose(const std::string &text, const std::string &tag, bool escape=false)
Exchange LineWriter for the lifetime of this object.
std::vector< std::string > ModaliasList
void installResolvable(const PoolItem &pi_r)
String related utilities and Regular expression matching.
urls_const_iterator baseUrlsEnd() const
iterator that points at end of repository urls
void addTagIf(const std::string &tag_r, bool yesno_r=true)
Enumeration class of dependency types.
bool empty() const
Whether the container is empty.
static Modalias & instance()
Singleton access.
'Language[_Country]' codes.
constexpr bool empty() const
Whether the string is empty.
Container of Capability (currently read only).
void logfile(const Pathname &logfile_r)
Set path for the logfile.
repo::RepoType type() const
Type of repository,.
Creates a file in helix format which includes all available or installed packages,...
Helper providing more detailed information about a Capability.
Pathname path() const
Repository path.
static LogControl instance()
Singleton access.
const LocaleSet & getRequestedLocales() const
Return the requested locales.
detail::fXstream< std::ostream, gzstream_detail::fgzstreambuf > ofgzstream
ostream writing gzip files.