19 #include <sys/types.h>
70 inline void sigMultiversionSpecChanged()
72 sat::detail::PoolMember::myPool().multiversionSpecChanged();
88 for (
const Transaction::Step & step : steps_r )
90 if ( step.stepType() != Transaction::TRANSACTION_IGNORE )
100 static const std::string strType(
"type" );
101 static const std::string strStage(
"stage" );
102 static const std::string strSolvable(
"solvable" );
104 static const std::string strTypeDel(
"-" );
105 static const std::string strTypeIns(
"+" );
106 static const std::string strTypeMul(
"M" );
108 static const std::string strStageDone(
"ok" );
109 static const std::string strStageFailed(
"err" );
111 static const std::string strSolvableN(
"n" );
112 static const std::string strSolvableE(
"e" );
113 static const std::string strSolvableV(
"v" );
114 static const std::string strSolvableR(
"r" );
115 static const std::string strSolvableA(
"a" );
122 case Transaction::TRANSACTION_IGNORE:
break;
123 case Transaction::TRANSACTION_ERASE: ret.
add( strType, strTypeDel );
break;
124 case Transaction::TRANSACTION_INSTALL: ret.
add( strType, strTypeIns );
break;
125 case Transaction::TRANSACTION_MULTIINSTALL: ret.
add( strType, strTypeMul );
break;
130 case Transaction::STEP_TODO:
break;
131 case Transaction::STEP_DONE: ret.
add( strStage, strStageDone );
break;
132 case Transaction::STEP_ERROR: ret.
add( strStage, strStageFailed );
break;
141 ident = solv.ident();
148 ident = step_r.
ident();
150 arch = step_r.
arch();
155 { strSolvableV, ed.
version() },
156 { strSolvableR, ed.
release() },
160 s.add( strSolvableE, epoch );
162 ret.
add( strSolvable, s );
176 SolvIdentFile::Data getUserInstalledFromHistory(
const Pathname & historyFile_r )
178 SolvIdentFile::Data onSystemByUserList;
181 std::ifstream infile( historyFile_r.c_str() );
182 for( iostr::EachLine in( infile ); in; in.next() )
184 const char * ch( (*in).c_str() );
186 if ( *ch <
'1' ||
'9' < *ch )
188 const char * sep1 = ::strchr( ch,
'|' );
193 bool installs =
true;
194 if ( ::strncmp( sep1,
"install|", 8 ) )
196 if ( ::strncmp( sep1,
"remove |", 8 ) )
203 const char * sep2 = ::strchr( sep1,
'|' );
204 if ( !sep2 || sep1 == sep2 )
206 (*in)[sep2-ch] =
'\0';
207 IdString pkg( sep1 );
211 onSystemByUserList.erase( pkg );
215 if ( (sep1 = ::strchr( sep2+1,
'|' ))
216 && (sep1 = ::strchr( sep1+1,
'|' ))
217 && (sep2 = ::strchr( sep1+1,
'|' )) )
219 (*in)[sep2-ch] =
'\0';
220 if ( ::strchr( sep1+1,
'@' ) )
223 onSystemByUserList.insert( pkg );
228 MIL <<
"onSystemByUserList found: " << onSystemByUserList.size() << endl;
229 return onSystemByUserList;
237 inline PluginFrame transactionPluginFrame(
const std::string & command_r, ZYppCommitResult::TransactionStepList & steps_r )
239 return PluginFrame( command_r, json::Object {
240 {
"TransactionStepList", steps_r }
249 unsigned toKeep( ZConfig::instance().solver_upgradeTestcasesToKeep() );
250 MIL <<
"Testcases to keep: " << toKeep << endl;
253 Target_Ptr target( getZYpp()->getTarget() );
256 WAR <<
"No Target no Testcase!" << endl;
260 std::string stem(
"updateTestcase" );
261 Pathname dir( target->assertRootPrefix(
"/var/log/") );
262 Pathname next( dir / Date::now().
form( stem+
"-%Y-%m-%d-%H-%M-%S" ) );
265 std::list<std::string> content;
267 std::set<std::string> cases;
268 for_( c, content.begin(), content.end() )
273 if ( cases.size() >= toKeep )
275 unsigned toDel = cases.size() - toKeep + 1;
276 for_( c, cases.begin(), cases.end() )
285 MIL <<
"Write new testcase " << next << endl;
286 getZYpp()->resolver()->createSolverTestcase( next.
asString(),
false );
303 std::pair<bool,PatchScriptReport::Action> doExecuteScript(
const Pathname & root_r,
307 MIL <<
"Execute script " <<
PathInfo(Pathname::assertprefix( root_r,script_r)) << endl;
313 for ( std::string output = prog.receiveLine(); output.length(); output = prog.receiveLine() )
316 if ( ! report_r->progress( PatchScriptReport::OUTPUT, output ) )
318 WAR <<
"User request to abort script " << script_r << endl;
325 std::pair<bool,PatchScriptReport::Action> ret( std::make_pair(
false, PatchScriptReport::ABORT ) );
327 if ( prog.close() != 0 )
329 ret.second = report_r->problem( prog.execError() );
330 WAR <<
"ACTION" << ret.second <<
"(" << prog.execError() <<
")" << endl;
331 std::ostringstream sstr;
332 sstr << script_r <<
_(
" execution failed") <<
" (" << prog.execError() <<
")" << endl;
333 historylog.
comment(sstr.str(),
true);
345 bool executeScript(
const Pathname & root_r,
346 const Pathname & script_r,
347 callback::SendReport<PatchScriptReport> & report_r )
349 std::pair<bool,PatchScriptReport::Action> action( std::make_pair(
false, PatchScriptReport::ABORT ) );
352 action = doExecuteScript( root_r, script_r, report_r );
356 switch ( action.second )
358 case PatchScriptReport::ABORT:
359 WAR <<
"User request to abort at script " << script_r << endl;
363 case PatchScriptReport::IGNORE:
364 WAR <<
"User request to skip script " << script_r << endl;
368 case PatchScriptReport::RETRY:
371 }
while ( action.second == PatchScriptReport::RETRY );
374 INT <<
"Abort on unknown ACTION request " << action.second <<
" returned" << endl;
383 bool RunUpdateScripts(
const Pathname & root_r,
384 const Pathname & scriptsPath_r,
385 const std::vector<sat::Solvable> & checkPackages_r,
388 if ( checkPackages_r.empty() )
391 MIL <<
"Looking for new update scripts in (" << root_r <<
")" << scriptsPath_r << endl;
392 Pathname scriptsDir( Pathname::assertprefix( root_r, scriptsPath_r ) );
393 if ( ! PathInfo( scriptsDir ).isDir() )
396 std::list<std::string> scripts;
398 if ( scripts.empty() )
406 std::map<std::string, Pathname> unify;
407 for_( it, checkPackages_r.begin(), checkPackages_r.end() )
409 std::string prefix(
str::form(
"%s-%s", it->name().c_str(), it->edition().c_str() ) );
410 for_( sit, scripts.begin(), scripts.end() )
415 if ( (*sit)[prefix.size()] !=
'\0' && (*sit)[prefix.size()] !=
'-' )
418 PathInfo script( scriptsDir / *sit );
419 Pathname localPath( scriptsPath_r/(*sit) );
420 std::string unifytag;
422 if ( script.isFile() )
428 else if ( ! script.isExist() )
436 if ( unifytag.empty() )
440 if ( unify[unifytag].empty() )
442 unify[unifytag] = localPath;
449 std::string msg(
str::form(
_(
"%s already executed as %s)"), localPath.asString().c_str(), unify[unifytag].c_str() ) );
450 MIL <<
"Skip update script: " << msg << endl;
451 HistoryLog().comment( msg,
true );
455 if ( abort || aborting_r )
457 WAR <<
"Aborting: Skip update script " << *sit << endl;
458 HistoryLog().comment(
459 localPath.asString() +
_(
" execution skipped while aborting"),
464 MIL <<
"Found update script " << *sit << endl;
465 callback::SendReport<PatchScriptReport>
report;
466 report->start( make<Package>( *it ), script.path() );
468 if ( ! executeScript( root_r, localPath,
report ) )
480 inline void copyTo( std::ostream & out_r,
const Pathname & file_r )
482 std::ifstream infile( file_r.c_str() );
483 for( iostr::EachLine in( infile ); in; in.next() )
485 out_r << *in << endl;
489 inline std::string notificationCmdSubst(
const std::string & cmd_r,
const UpdateNotificationFile & notification_r )
491 std::string ret( cmd_r );
492 #define SUBST_IF(PAT,VAL) if ( ret.find( PAT ) != std::string::npos ) ret = str::gsub( ret, PAT, VAL )
493 SUBST_IF(
"%p", notification_r.solvable().asString() );
494 SUBST_IF(
"%P", notification_r.file().asString() );
499 void sendNotification(
const Pathname & root_r,
502 if ( notifications_r.empty() )
505 std::string cmdspec( ZConfig::instance().updateMessagesNotify() );
506 MIL <<
"Notification command is '" << cmdspec <<
"'" << endl;
507 if ( cmdspec.empty() )
511 if ( pos == std::string::npos )
513 ERR <<
"Can't send Notification: Missing 'format |' in command spec." << endl;
514 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
519 std::string commandStr(
str::trim( cmdspec.substr( pos + 1 ) ) );
521 enum Format { UNKNOWN, NONE, SINGLE, DIGEST, BULK };
522 Format format = UNKNOWN;
523 if ( formatStr ==
"none" )
525 else if ( formatStr ==
"single" )
527 else if ( formatStr ==
"digest" )
529 else if ( formatStr ==
"bulk" )
533 ERR <<
"Can't send Notification: Unknown format '" << formatStr <<
" |' in command spec." << endl;
534 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
542 if ( format == NONE || format == SINGLE )
544 for_( it, notifications_r.begin(), notifications_r.end() )
546 std::vector<std::string> command;
547 if ( format == SINGLE )
548 command.push_back(
"<"+Pathname::assertprefix( root_r, it->file() ).asString() );
549 str::splitEscaped( notificationCmdSubst( commandStr, *it ), std::back_inserter( command ) );
551 ExternalProgram prog( command, ExternalProgram::Stderr_To_Stdout,
false, -1,
true, root_r );
554 for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
558 int ret = prog.close();
561 ERR <<
"Notification command returned with error (" << ret <<
")." << endl;
562 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
568 else if ( format == DIGEST || format == BULK )
570 filesystem::TmpFile tmpfile;
571 ofstream out( tmpfile.path().c_str() );
572 for_( it, notifications_r.begin(), notifications_r.end() )
574 if ( format == DIGEST )
576 out << it->file() << endl;
578 else if ( format == BULK )
580 copyTo( out <<
'\f', Pathname::assertprefix( root_r, it->file() ) );
584 std::vector<std::string> command;
585 command.push_back(
"<"+tmpfile.path().asString() );
586 str::splitEscaped( notificationCmdSubst( commandStr, *notifications_r.begin() ), std::back_inserter( command ) );
588 ExternalProgram prog( command, ExternalProgram::Stderr_To_Stdout,
false, -1,
true, root_r );
591 for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
595 int ret = prog.close();
598 ERR <<
"Notification command returned with error (" << ret <<
")." << endl;
599 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
606 INT <<
"Can't send Notification: Missing handler for 'format |' in command spec." << endl;
607 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
618 void RunUpdateMessages(
const Pathname & root_r,
619 const Pathname & messagesPath_r,
620 const std::vector<sat::Solvable> & checkPackages_r,
621 ZYppCommitResult & result_r )
623 if ( checkPackages_r.empty() )
626 MIL <<
"Looking for new update messages in (" << root_r <<
")" << messagesPath_r << endl;
627 Pathname messagesDir( Pathname::assertprefix( root_r, messagesPath_r ) );
628 if ( ! PathInfo( messagesDir ).isDir() )
631 std::list<std::string> messages;
633 if ( messages.empty() )
639 HistoryLog historylog;
640 for_( it, checkPackages_r.begin(), checkPackages_r.end() )
642 std::string prefix(
str::form(
"%s-%s", it->name().c_str(), it->edition().c_str() ) );
643 for_( sit, messages.begin(), messages.end() )
648 if ( (*sit)[prefix.size()] !=
'\0' && (*sit)[prefix.size()] !=
'-' )
651 PathInfo message( messagesDir / *sit );
652 if ( ! message.isFile() || message.size() == 0 )
655 MIL <<
"Found update message " << *sit << endl;
656 Pathname localPath( messagesPath_r/(*sit) );
657 result_r.rUpdateMessages().push_back( UpdateNotificationFile( *it, localPath ) );
658 historylog.comment( str::Str() <<
_(
"New update message") <<
" " << localPath,
true );
661 sendNotification( root_r, result_r.updateMessages() );
670 const std::vector<sat::Solvable> & checkPackages_r,
672 { RunUpdateMessages( root_r, messagesPath_r, checkPackages_r, result_r ); }
683 TargetImpl::TargetImpl(
const Pathname & root_r,
bool doRebuild_r )
685 , _requestedLocalesFile( home() /
"RequestedLocales" )
686 , _autoInstalledFile( home() /
"AutoInstalled" )
694 sigMultiversionSpecChanged();
695 MIL <<
"Initialized target on " <<
_root << endl;
703 std::ifstream uuidprovider(
"/proc/sys/kernel/random/uuid" );
713 boost::function<
bool ()> condition,
714 boost::function<
string ()> value )
716 string val = value();
724 MIL <<
"updating '" << filename <<
"' content." << endl;
728 std::ofstream filestr;
731 filestr.open( filename.
c_str() );
733 if ( filestr.good() )
769 WAR <<
"Can't create anonymous id file" << endl;
778 Pathname flavorpath(
home() /
"LastDistributionFlavor");
784 WAR <<
"No base product, I won't create flavor cache" << endl;
788 string flavor = p->flavor();
800 WAR <<
"Can't create flavor cache" << endl;
813 sigMultiversionSpecChanged();
814 MIL <<
"Targets closed" << endl;
838 Pathname rpmsolvcookie = base/
"cookie";
840 bool build_rpm_solv =
true;
850 MIL <<
"Read cookie: " << cookie << endl;
855 if ( status == rpmstatus )
856 build_rpm_solv =
false;
857 MIL <<
"Read cookie: " << rpmsolvcookie <<
" says: "
858 << (build_rpm_solv ?
"outdated" :
"uptodate") << endl;
862 if ( build_rpm_solv )
876 bool switchingToTmpSolvfile =
false;
877 Exception ex(
"Failed to cache rpm database.");
883 rpmsolv = base/
"solv";
884 rpmsolvcookie = base/
"cookie";
891 WAR <<
"Using a temporary solv file at " << base << endl;
892 switchingToTmpSolvfile =
true;
901 if ( ! switchingToTmpSolvfile )
911 cmd.push_back(
"/usr/lib/zypp/tools/rpmdb2solv" );
913 cmd.push_back(
"-r" );
916 cmd.push_back(
"-X" );
918 cmd.push_back(
"-p" );
921 if ( ! oldSolvFile.
empty() )
922 cmd.push_back( oldSolvFile.
asString() );
924 cmd.push_back(
"-o" );
928 std::string errdetail;
931 WAR <<
" " << output;
932 if ( errdetail.empty() ) {
939 int ret = prog.
close();
971 if ( !
PathInfo(base/
"solv.idx").isExist() )
974 return build_rpm_solv;
992 MIL <<
"New cache built: " << (newCache?
"true":
"false") <<
993 ", force loading: " << (force?
"true":
"false") << endl;
998 MIL <<
"adding " << rpmsolv <<
" to pool(" << satpool.
systemRepoAlias() <<
")" << endl;
1005 if ( newCache || force )
1022 MIL <<
"adding " << rpmsolv <<
" to system" << endl;
1028 MIL <<
"Try to handle exception by rebuilding the solv-file" << endl;
1053 if (
PathInfo( historyFile ).isExist() )
1060 if ( onSystemByUser.find( ident ) == onSystemByUser.end() )
1061 onSystemByAuto.insert( ident );
1077 if ( ! hardLocks.empty() )
1086 MIL <<
"Target loaded: " << system.
solvablesSize() <<
" resolvables" << endl;
1098 bool explicitDryRun = policy_r.
dryRun();
1106 if (
root() ==
"/" )
1116 MIL <<
"TargetImpl::commit(<pool>, " << policy_r <<
")" << endl;
1135 steps.push_back( *it );
1142 MIL <<
"Todo: " << result << endl;
1152 if ( commitPlugins )
1153 commitPlugins.
send( transactionPluginFrame(
"COMMITBEGIN", steps ) );
1160 if ( ! policy_r.
dryRun() )
1166 DBG <<
"dryRun: Not writing upgrade testcase." << endl;
1173 if ( ! policy_r.
dryRun() )
1195 DBG <<
"dryRun: Not stroring non-package data." << endl;
1202 if ( ! policy_r.
dryRun() )
1204 for_( it, steps.begin(), steps.end() )
1206 if ( ! it->satSolvable().isKind<
Patch>() )
1214 if ( ! patch ||patch->message().empty() )
1217 MIL <<
"Show message for " << patch << endl;
1219 if ( !
report->show( patch ) )
1221 WAR <<
"commit aborted by the user" << endl;
1228 DBG <<
"dryRun: Not checking patch messages." << endl;
1247 for_( it, steps.begin(), steps.end() )
1249 switch ( it->stepType() )
1268 localfile = packageCache.
get( pi );
1271 catch (
const AbortRequestException & exp )
1275 WAR <<
"commit cache preload aborted by the user" << endl;
1279 catch (
const SkipRequestException & exp )
1284 WAR <<
"Skipping cache preload package " << pi->asKind<
Package>() <<
" in commit" << endl;
1294 INT <<
"Unexpected Error: Skipping cache preload package " << pi->asKind<
Package>() <<
" in commit" << endl;
1304 ERR <<
"Some packages could not be provided. Aborting commit."<< endl;
1308 if ( ! policy_r.
dryRun() )
1312 commit( policy_r, packageCache, result );
1316 DBG <<
"dryRun/downloadOnly: Not installing/deleting anything." << endl;
1317 if ( explicitDryRun ) {
1326 DBG <<
"dryRun: Not downloading/installing/deleting anything." << endl;
1327 if ( explicitDryRun ) {
1336 if ( commitPlugins )
1337 commitPlugins.
send( transactionPluginFrame(
"COMMITEND", steps ) );
1342 if ( ! policy_r.
dryRun() )
1347 MIL <<
"TargetImpl::commit(<pool>, " << policy_r <<
") returns: " << result << endl;
1358 struct NotifyAttemptToModify
1376 MIL <<
"TargetImpl::commit(<list>" << policy_r <<
")" << steps.size() << endl;
1381 NotifyAttemptToModify attemptToModify( result_r );
1386 std::vector<sat::Solvable> successfullyInstalledPackages;
1389 for_( step, steps.begin(), steps.end() )
1411 localfile = packageCache_r.
get( citem );
1413 catch (
const AbortRequestException &e )
1415 WAR <<
"commit aborted by the user" << endl;
1420 catch (
const SkipRequestException &e )
1423 WAR <<
"Skipping package " << p <<
" in commit" << endl;
1432 INT <<
"Unexpected Error: Skipping package " << p <<
" in commit" << endl;
1437 #warning Exception handling
1442 bool success =
false;
1470 WAR <<
"commit aborted by the user" << endl;
1489 WAR <<
"dry run failed" << endl;
1496 WAR <<
"commit aborted by the user" << endl;
1501 WAR <<
"Install failed" << endl;
1507 if ( success && !policy_r.
dryRun() )
1510 successfullyInstalledPackages.push_back( citem.
satSolvable() );
1519 bool success =
false;
1532 WAR <<
"commit aborted by the user" << endl;
1548 WAR <<
"commit aborted by the user" << endl;
1554 WAR <<
"removal of " << p <<
" failed";
1557 if ( success && !policy_r.
dryRun() )
1564 else if ( ! policy_r.
dryRun() )
1568 if ( ! citem.
buddy() )
1575 ERR <<
"Can't install orphan product without release-package! " << citem << endl;
1581 std::string referenceFilename( p->referenceFilename() );
1582 if ( referenceFilename.empty() )
1584 ERR <<
"Can't remove orphan product without 'referenceFilename'! " << citem << endl;
1591 ERR <<
"Delete orphan product failed: " << referenceFile << endl;
1619 if ( ! successfullyInstalledPackages.empty() )
1622 successfullyInstalledPackages, abort ) )
1624 WAR <<
"Commit aborted by the user" << endl;
1630 successfullyInstalledPackages,
1666 if ( baseproduct.isFile() )
1679 ERR <<
"baseproduct symlink is dangling or missing: " << baseproduct << endl;
1684 inline Pathname staticGuessRoot(
const Pathname & root_r )
1686 if ( root_r.empty() )
1691 return Pathname(
"/");
1697 inline std::string firstNonEmptyLineIn(
const Pathname & file_r )
1699 std::ifstream idfile( file_r.c_str() );
1700 for( iostr::EachLine in( idfile ); in; in.next() )
1703 if ( ! line.empty() )
1706 return std::string();
1717 if ( p->isTargetDistribution() )
1725 const Pathname needroot( staticGuessRoot(root_r) );
1726 const Target_constPtr target( getZYpp()->getTarget() );
1727 if ( target && target->root() == needroot )
1728 return target->requestedLocales();
1734 MIL <<
"updateAutoInstalled if changed..." << endl;
1742 {
return baseproductdata(
_root ).registerTarget(); }
1745 {
return baseproductdata( staticGuessRoot(root_r) ).registerTarget(); }
1748 {
return baseproductdata(
_root ).registerRelease(); }
1751 {
return baseproductdata( staticGuessRoot(root_r) ).registerRelease();}
1754 {
return baseproductdata(
_root ).registerFlavor(); }
1757 {
return baseproductdata( staticGuessRoot(root_r) ).registerFlavor();}
1790 std::string
distributionVersion = baseproductdata( staticGuessRoot(root_r) ).edition().version();
1797 scoped_ptr<rpm::RpmDb> tmprpmdb;
1803 tmprpmdb->initDatabase( );
1820 return firstNonEmptyLineIn(
home() /
"LastDistributionFlavor" );
1825 return firstNonEmptyLineIn( staticGuessRoot(root_r) /
"/var/lib/zypp/LastDistributionFlavor" );
1831 std::string guessAnonymousUniqueId(
const Pathname & root_r )
1834 std::string ret( firstNonEmptyLineIn( root_r /
"/var/lib/zypp/AnonymousUniqueId" ) );
1835 if ( ret.
empty() && root_r !=
"/" )
1838 ret = firstNonEmptyLineIn(
"/var/lib/zypp/AnonymousUniqueId" );
1846 return guessAnonymousUniqueId(
root() );
1851 return guessAnonymousUniqueId( staticGuessRoot(root_r) );
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
#define N_(MSG)
Just tag text for translation.
#define IMPL_PTR_TYPE(NAME)
#define SUBST_IF(PAT, VAL)
ZYppCommitResult & _result
const std::string & asString() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
void resetDispose()
Set no dispose function.
Store and operate on date (time_t).
Edition represents [epoch:]version[-release]
unsigned epoch_t
Type of an epoch.
std::string version() const
Version.
std::string release() const
Release.
epoch_t epoch() const
Epoch.
Base class for Exception.
void remember(const Exception &old_r)
Store an other Exception as history.
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
std::vector< std::string > Arguments
int close()
Wait for the progamm to complete.
const std::string & command() const
The command we're executing.
Writing the zypp history file.
void stampCommand()
Log info about the current process.
static void setRoot(const Pathname &root)
Set new root directory to the default history log file path.
void remove(const PoolItem &pi)
Log removal of a package.
static const Pathname & fname()
Get the current log file path.
void install(const PoolItem &pi)
Log installation (or update) of a package.
void comment(const std::string &comment, bool timestamp=false)
Log a comment (even multiline).
Access to the sat-pools string space.
std::string asString() const
Conversion to std::string
TraitsType::constPtrType constPtr
Class representing a patch.
TraitsType::constPtrType constPtr
Parallel execution of stateful PluginScripts.
void load(const Pathname &path_r)
Find and launch plugins sending PLUGINBEGIN.
void send(const PluginFrame &frame_r)
Send PluginFrame to all open plugins.
Command frame for communication with PluginScript.
Combining sat::Solvable and ResStatus.
ResObject::constPtr resolvable() const
Returns the ResObject::constPtr.
ResStatus & status() const
Returns the current status.
sat::Solvable buddy() const
Return the buddy we share our status object with.
TraitsType::constPtrType constPtr
Track changing files or directories.
static RepoStatus fromCookieFile(const Pathname &path)
Reads the status from a cookie file.
void saveToCookieFile(const Pathname &path_r) const
Save the status information to a cookie file.
bool solvablesEmpty() const
Whether Repository contains solvables.
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
size_type solvablesSize() const
Number of solvables in Repository.
void addSolv(const Pathname &file_r)
Load Solvables from a solv-file.
void eraseFromPool()
Remove this Repository from it's Pool.
static ResPool instance()
Singleton ctor.
void setHardLockQueries(const HardLockQueries &newLocks_r)
Set a new set of queries.
Resolver & resolver() const
The Resolver.
const LocaleSet & getRequestedLocales() const
Return the requested locales.
byKind_iterator byKindEnd(const ResKind &kind_r) const
byKind_iterator byKindBegin(const ResKind &kind_r) const
void getHardLockQueries(HardLockQueries &activeLocks_r)
Suggest a new set of queries based on the current selection.
bool isToBeInstalled() const
bool resetTransact(TransactByValue causer_r)
Not the same as setTransact( false ).
sat::Transaction getTransaction()
Return the Transaction computed by the last solver run.
bool upgradingRepos() const
Whether there is at least one UpgradeRepo request pending.
TraitsType::constPtrType constPtr
Interim helper class to collect global options and settings.
static ZConfig & instance()
Singleton ctor.
std::string distroverpkg() const
Package telling the "product version" on systems not using /etc/product.d/baseproduct.
Options and policies for ZYpp::commit.
ZYppCommitPolicy & rpmInstFlags(target::rpm::RpmInstFlags newFlags_r)
The default target::rpm::RpmInstFlags.
ZYppCommitPolicy & rpmExcludeDocs(bool yesNo_r)
Use rpm option –excludedocs (default: false)
ZYppCommitPolicy & dryRun(bool yesNo_r)
Set dry run (default: false).
ZYppCommitPolicy & restrictToMedia(unsigned mediaNr_r)
Restrict commit to media 1.
ZYppCommitPolicy & allMedia()
Process all media (default)
ZYppCommitPolicy & downloadMode(DownloadMode val_r)
Commit download policy to use.
ZYppCommitPolicy & rpmNoSignature(bool yesNo_r)
Use rpm option –nosignature (default: false)
Result returned from ZYpp::commit.
TransactionStepList & rTransactionStepList()
Manipulate transactionStepList.
std::vector< sat::Transaction::Step > TransactionStepList
const sat::Transaction & transaction() const
The full transaction list.
sat::Transaction & rTransaction()
Manipulate transaction.
std::string receiveLine()
Read one line from the input stream.
Wrapper class for ::stat/::lstat.
bool isExist() const
Return whether valid stat info exists.
const Pathname & path() const
Return current Pathname.
Pathname dirname() const
Return all but the last component od this path.
const std::string & asString() const
String representation.
bool empty() const
Test for an empty path.
static Pathname assertprefix(const Pathname &root_r, const Pathname &path_r)
Return path_r prefixed with root_r, unless it is already prefixed.
const char * c_str() const
String representation.
Provide a new empty temporary file and delete it when no longer needed.
static TmpFile makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Data returned by ProductFileReader.
bool empty() const
Whether this is an empty object without valid data.
std::string summary() const
std::string shortName() const
static ProductFileData scanFile(const Pathname &file_r)
Parse one file (or symlink) and return the ProductFileData parsed.
ManagedFile provideSrcPackage(const SrcPackage_constPtr &srcPackage_r) const
Provide SrcPackage in a local file.
void setAutoInstalled(const Queue &autoInstalled_r)
Set ident list of all autoinstalled solvables.
Pathname rootDir() const
Get rootdir (for file conflicts check)
static Pool instance()
Singleton ctor.
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
Repository systemRepo()
Return the system repository, create it if missing.
void initRequestedLocales(const LocaleSet &locales_r)
Start tracking changes based on this locales_r.
Libsolv Id queue wrapper.
detail::IdType value_type
void push(value_type val_r)
Push a value to the end off the Queue.
A Solvable object within the sat Pool.
A single step within a Transaction.
StepType stepType() const
Type of action to perform in this step.
StepStage stepStage() const
Step action result.
Solvable satSolvable() const
Return the corresponding Solvable.
Libsolv transaction wrapper.
const_iterator end() const
Iterator behind the last TransactionStep.
StringQueue autoInstalled() const
Return the ident strings of all packages that would be auto-installed after the transaction is run.
const_iterator begin() const
Iterator to the first TransactionStep.
bool order()
Order transaction steps for commit.
@ TRANSACTION_MULTIINSTALL
[M] Install(multiversion) item (
@ TRANSACTION_INSTALL
[+] Install(update) item
@ TRANSACTION_IGNORE
[ ] Nothing (includes implicit deletes due to obsoletes and non-package actions)
Target::commit helper optimizing package provision.
void setCommitList(std::vector< sat::Solvable > commitList_r)
Download(commit) sequence of solvables to compute read ahead.
bool preloaded() const
Whether preloaded hint is set.
ManagedFile get(const PoolItem &citem_r)
Provide a package.
void setData(const Data &data_r)
Store new Data.
const Data & data() const
Return the data.
pool::PoolTraits::HardLockQueries Data
Save and restore locale set from file.
void setLocales(const LocaleSet &locales_r)
Store a new locale set.
const LocaleSet & locales() const
Return the loacale set.
void tryLevel(target::rpm::InstallResolvableReport::RpmLevel level_r)
Extract and remember posttrans scripts for later execution.
bool collectScriptFromPackage(ManagedFile rpmPackage_r)
Extract and remember a packages posttrans script for later execution.
void executeScripts()
Execute te remembered scripts.
void discardScripts()
Discard all remembered scrips.
bool aborted() const
Returns true if removing is aborted during progress.
const Pathname & file() const
Return the file path.
std::unordered_set< IdString > Data
const Data & data() const
Return the data.
void setData(const Data &data_r)
Store new Data.
Base class for concrete Target implementations.
std::string targetDistributionRelease() const
This is register.release attribute of the installed base product.
std::string targetDistribution() const
This is register.target attribute of the installed base product.
LocaleSet requestedLocales() const
Languages to be supported by the system.
void updateAutoInstalled()
Update the database of autoinstalled packages.
ManagedFile provideSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Provides a source package on the Target.
Pathname _root
Path to the target.
RequestedLocalesFile _requestedLocalesFile
Requested Locales database.
void createLastDistributionFlavorCache() const
generates a cache of the last product flavor
Pathname _tmpSolvfilesPath
Date timestamp() const
return the last modification date of the target
std::string _distributionVersion
Cache distributionVersion.
std::list< PoolItem > PoolItemList
list of pool items
rpm::RpmDb _rpm
RPM database.
rpm::RpmDb & rpm()
The RPM database.
Pathname solvfilesPath() const
The solv file location actually in use (default or temp).
std::string distributionVersion() const
This is version attribute of the installed base product.
void createAnonymousId() const
generates the unique anonymous id which is called when creating the target
SolvIdentFile _autoInstalledFile
user/auto installed database
Product::constPtr baseProduct() const
returns the target base installed product, also known as the distribution or platform.
Target::DistributionLabel distributionLabel() const
This is shortName and summary attribute of the installed base product.
virtual ~TargetImpl()
Dtor.
bool providesFile(const std::string &path_str, const std::string &name_str) const
If the package is installed and provides the file Needed to evaluate split provides during Resolver::...
HardLocksFile _hardLocksFile
Hard-Locks database.
Pathname root() const
The root set for this target.
void load(bool force=true)
std::string distributionFlavor() const
This is flavor attribute of the installed base product but does not require the target to be loaded a...
void installSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Install a source package on the Target.
ZYppCommitResult commit(ResPool pool_r, const ZYppCommitPolicy &policy_r)
Commit changes in the pool.
Pathname home() const
The directory to store things.
void commitFindFileConflicts(const ZYppCommitPolicy &policy_r, ZYppCommitResult &result_r)
Commit helper checking for file conflicts after download.
Pathname defaultSolvfilesPath() const
The systems default solv file location.
std::string anonymousUniqueId() const
anonymous unique id
bool solvfilesPathIsTemp() const
Whether we're using a temp.
std::string targetDistributionFlavor() const
This is register.flavor attribute of the installed base product.
Interface to the rpm program.
Date timestamp() const
timestamp of the rpm database (last modification)
void installPackage(const Pathname &filename, RpmInstFlags flags=RPMINST_NONE)
install rpm package
void initDatabase(Pathname root_r=Pathname(), Pathname dbPath_r=Pathname(), bool doRebuild_r=false)
Prepare access to the rpm database.
void removePackage(const std::string &name_r, RpmInstFlags flags=RPMINST_NONE)
remove rpm package
void closeDatabase()
Block further access to the rpm database and go back to uninitialized state.
bool hasFile(const std::string &file_r, const std::string &name_r="") const
Return true if at least one package owns a certain file (name_r empty) Return true if package name_r ...
Subclass to retrieve database content.
bool findByProvides(const std::string &tag_r)
Reset to iterate all packages that provide a certain tag.
int chmod(const Pathname &path, mode_t mode)
Like 'chmod'.
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
int unlink(const Pathname &path)
Like 'unlink'.
int rename(const Pathname &oldpath, const Pathname &newpath)
Like 'rename'.
int recursive_rmdir(const Pathname &path)
Like 'rm -r DIR'.
int addmod(const Pathname &path, mode_t mode)
Add the mode bits to the file given by path.
int readlink(const Pathname &symlink_r, Pathname &target_r)
Like 'readlink'.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
std::string md5sum(const Pathname &file)
Compute a files md5sum.
std::string getline(std::istream &str)
Read one line from stream.
std::string toJSON(const sat::Transaction::Step &step_r)
See COMMITBEGIN (added in v1) on page Commit plugin for the specs.
void updateSolvFileIndex(const Pathname &solvfile_r)
Create solv file content digest for zypper bash completion.
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
bool startsWith(const C_Str &str_r, const C_Str &prefix_r)
alias for hasPrefix
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
std::string toLower(const std::string &s)
Return lowercase version of s.
unsigned splitEscaped(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \t", bool withEmpty=false)
Split line_r into words with respect to escape delimeters.
std::string trim(const std::string &s, const Trim trim_r)
void XRunUpdateMessages(const Pathname &root_r, const Pathname &messagesPath_r, const std::vector< sat::Solvable > &checkPackages_r, ZYppCommitResult &result_r)
void updateFileContent(const Pathname &filename, boost::function< bool()> condition, boost::function< string()> value)
updates the content of filename if condition is true, setting the content the the value returned by v...
void writeUpgradeTestcase()
static bool fileMissing(const Pathname &pathname)
helper functor
static std::string generateRandomId()
generates a random id using uuidgen
Easy-to use interface to the ZYPP dependency resolver.
std::string asString(const DefaultIntegral< Tp, TInitial > &obj)
std::unordered_set< Locale > LocaleSet
ResObject::Ptr makeResObject(const sat::Solvable &solvable_r)
Create ResObject from sat::Solvable.
std::list< UpdateNotificationFile > UpdateNotifications
@ DownloadInHeaps
Similar to DownloadInAdvance, but try to split the transaction into heaps, where at the end of each h...
@ DownloadOnly
Just download all packages to the local cache.
@ DownloadAsNeeded
Alternating download and install.
@ DownloadDefault
libzypp will decide what to do.
std::string asJSON() const
JSON representation.
void add(const Value &val_r)
Push JSON Value to Array.
void add(const String &key_r, const Value &val_r)
Add key/value pair.
std::string asJSON() const
JSON representation.
bool isKind(const ResKind &kind_r) const
Solvable satSolvable() const
Return the corresponding sat::Solvable.
@ RPM_NODEPS_FORCE
only this one used