19 #include <sys/types.h>
77 for (
const Transaction::Step & step : steps_r )
79 if ( step.stepType() != Transaction::TRANSACTION_IGNORE )
89 static const std::string strType(
"type" );
90 static const std::string strStage(
"stage" );
91 static const std::string strSolvable(
"solvable" );
93 static const std::string strTypeDel(
"-" );
94 static const std::string strTypeIns(
"+" );
95 static const std::string strTypeMul(
"M" );
97 static const std::string strStageDone(
"ok" );
98 static const std::string strStageFailed(
"err" );
100 static const std::string strSolvableN(
"n" );
101 static const std::string strSolvableE(
"e" );
102 static const std::string strSolvableV(
"v" );
103 static const std::string strSolvableR(
"r" );
104 static const std::string strSolvableA(
"a" );
111 case Transaction::TRANSACTION_IGNORE:
break;
112 case Transaction::TRANSACTION_ERASE: ret.
add( strType, strTypeDel );
break;
113 case Transaction::TRANSACTION_INSTALL: ret.
add( strType, strTypeIns );
break;
114 case Transaction::TRANSACTION_MULTIINSTALL: ret.
add( strType, strTypeMul );
break;
119 case Transaction::STEP_TODO:
break;
120 case Transaction::STEP_DONE: ret.
add( strStage, strStageDone );
break;
121 case Transaction::STEP_ERROR: ret.
add( strStage, strStageFailed );
break;
130 ident = solv.ident();
137 ident = step_r.
ident();
139 arch = step_r.
arch();
144 { strSolvableV, ed.
version() },
145 { strSolvableR, ed.
release() },
149 s.add( strSolvableE, epoch );
151 ret.
add( strSolvable, s );
165 SolvIdentFile::Data getUserInstalledFromHistory(
const Pathname & historyFile_r )
167 SolvIdentFile::Data onSystemByUserList;
170 std::ifstream infile( historyFile_r.c_str() );
171 for( iostr::EachLine in( infile ); in; in.next() )
173 const char * ch( (*in).c_str() );
175 if ( *ch <
'1' ||
'9' < *ch )
177 const char * sep1 = ::strchr( ch,
'|' );
182 bool installs =
true;
183 if ( ::strncmp( sep1,
"install|", 8 ) )
185 if ( ::strncmp( sep1,
"remove |", 8 ) )
192 const char * sep2 = ::strchr( sep1,
'|' );
193 if ( !sep2 || sep1 == sep2 )
195 (*in)[sep2-ch] =
'\0';
196 IdString pkg( sep1 );
200 onSystemByUserList.erase( pkg );
204 if ( (sep1 = ::strchr( sep2+1,
'|' ))
205 && (sep1 = ::strchr( sep1+1,
'|' ))
206 && (sep2 = ::strchr( sep1+1,
'|' )) )
208 (*in)[sep2-ch] =
'\0';
209 if ( ::strchr( sep1+1,
'@' ) )
212 onSystemByUserList.insert( pkg );
217 MIL <<
"onSystemByUserList found: " << onSystemByUserList.size() << endl;
218 return onSystemByUserList;
226 inline PluginFrame transactionPluginFrame(
const std::string & command_r, ZYppCommitResult::TransactionStepList & steps_r )
228 return PluginFrame( command_r, json::Object {
229 {
"TransactionStepList", steps_r }
238 unsigned toKeep( ZConfig::instance().solver_upgradeTestcasesToKeep() );
239 MIL <<
"Testcases to keep: " << toKeep << endl;
245 WAR <<
"No Target no Testcase!" << endl;
249 std::string stem(
"updateTestcase" );
250 Pathname dir( target->assertRootPrefix(
"/var/log/") );
251 Pathname next( dir / Date::now().
form( stem+
"-%Y-%m-%d-%H-%M-%S" ) );
254 std::list<std::string> content;
256 std::set<std::string> cases;
257 for_( c, content.begin(), content.end() )
262 if ( cases.size() >= toKeep )
264 unsigned toDel = cases.size() - toKeep + 1;
265 for_( c, cases.begin(), cases.end() )
274 MIL <<
"Write new testcase " << next << endl;
275 getZYpp()->resolver()->createSolverTestcase( next.asString(),
false );
292 std::pair<bool,PatchScriptReport::Action> doExecuteScript(
const Pathname & root_r,
293 const Pathname & script_r,
296 MIL <<
"Execute script " << PathInfo(Pathname::assertprefix( root_r,script_r)) << endl;
299 historylog.
comment(script_r.asString() +
_(
" executed"),
true);
300 ExternalProgram prog( script_r.asString(), ExternalProgram::Stderr_To_Stdout,
false, -1,
true, root_r );
302 for ( std::string output = prog.receiveLine(); output.length(); output = prog.receiveLine() )
305 if ( ! report_r->progress( PatchScriptReport::OUTPUT, output ) )
307 WAR <<
"User request to abort script " << script_r << endl;
314 std::pair<bool,PatchScriptReport::Action> ret( std::make_pair(
false, PatchScriptReport::ABORT ) );
316 if ( prog.close() != 0 )
318 ret.second = report_r->problem( prog.execError() );
319 WAR <<
"ACTION" << ret.second <<
"(" << prog.execError() <<
")" << endl;
320 std::ostringstream sstr;
321 sstr << script_r <<
_(
" execution failed") <<
" (" << prog.execError() <<
")" << endl;
322 historylog.
comment(sstr.str(),
true);
334 bool executeScript(
const Pathname & root_r,
335 const Pathname & script_r,
336 callback::SendReport<PatchScriptReport> & report_r )
338 std::pair<bool,PatchScriptReport::Action> action( std::make_pair(
false, PatchScriptReport::ABORT ) );
341 action = doExecuteScript( root_r, script_r, report_r );
345 switch ( action.second )
347 case PatchScriptReport::ABORT:
348 WAR <<
"User request to abort at script " << script_r << endl;
352 case PatchScriptReport::IGNORE:
353 WAR <<
"User request to skip script " << script_r << endl;
357 case PatchScriptReport::RETRY:
360 }
while ( action.second == PatchScriptReport::RETRY );
363 INT <<
"Abort on unknown ACTION request " << action.second <<
" returned" << endl;
372 bool RunUpdateScripts(
const Pathname & root_r,
373 const Pathname & scriptsPath_r,
374 const std::vector<sat::Solvable> & checkPackages_r,
377 if ( checkPackages_r.empty() )
380 MIL <<
"Looking for new update scripts in (" << root_r <<
")" << scriptsPath_r << endl;
381 Pathname scriptsDir( Pathname::assertprefix( root_r, scriptsPath_r ) );
382 if ( ! PathInfo( scriptsDir ).isDir() )
385 std::list<std::string> scripts;
387 if ( scripts.empty() )
395 std::map<std::string, Pathname> unify;
396 for_( it, checkPackages_r.begin(), checkPackages_r.end() )
398 std::string prefix(
str::form(
"%s-%s", it->name().c_str(), it->edition().c_str() ) );
399 for_( sit, scripts.begin(), scripts.end() )
404 if ( (*sit)[prefix.size()] !=
'\0' && (*sit)[prefix.size()] !=
'-' )
407 PathInfo script( scriptsDir / *sit );
408 Pathname localPath( scriptsPath_r/(*sit) );
409 std::string unifytag;
411 if ( script.isFile() )
417 else if ( ! script.isExist() )
425 if ( unifytag.empty() )
429 if ( unify[unifytag].empty() )
431 unify[unifytag] = localPath;
438 std::string msg(
str::form(
_(
"%s already executed as %s)"), localPath.asString().c_str(), unify[unifytag].c_str() ) );
439 MIL <<
"Skip update script: " << msg << endl;
440 HistoryLog().comment( msg,
true );
444 if ( abort || aborting_r )
446 WAR <<
"Aborting: Skip update script " << *sit << endl;
447 HistoryLog().comment(
448 localPath.asString() +
_(
" execution skipped while aborting"),
453 MIL <<
"Found update script " << *sit << endl;
454 callback::SendReport<PatchScriptReport>
report;
455 report->start( make<Package>( *it ), script.path() );
457 if ( ! executeScript( root_r, localPath, report ) )
469 inline void copyTo( std::ostream & out_r,
const Pathname & file_r )
471 std::ifstream infile( file_r.c_str() );
472 for( iostr::EachLine in( infile ); in; in.next() )
474 out_r << *in << endl;
478 inline std::string notificationCmdSubst(
const std::string & cmd_r,
const UpdateNotificationFile & notification_r )
480 std::string ret( cmd_r );
481 #define SUBST_IF(PAT,VAL) if ( ret.find( PAT ) != std::string::npos ) ret = str::gsub( ret, PAT, VAL )
482 SUBST_IF(
"%p", notification_r.solvable().asString() );
483 SUBST_IF(
"%P", notification_r.file().asString() );
488 void sendNotification(
const Pathname & root_r,
491 if ( notifications_r.empty() )
494 std::string cmdspec( ZConfig::instance().updateMessagesNotify() );
495 MIL <<
"Notification command is '" << cmdspec <<
"'" << endl;
496 if ( cmdspec.empty() )
500 if ( pos == std::string::npos )
502 ERR <<
"Can't send Notification: Missing 'format |' in command spec." << endl;
503 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
508 std::string commandStr(
str::trim( cmdspec.substr( pos + 1 ) ) );
510 enum Format { UNKNOWN, NONE, SINGLE, DIGEST, BULK };
511 Format format = UNKNOWN;
512 if ( formatStr ==
"none" )
514 else if ( formatStr ==
"single" )
516 else if ( formatStr ==
"digest" )
518 else if ( formatStr ==
"bulk" )
522 ERR <<
"Can't send Notification: Unknown format '" << formatStr <<
" |' in command spec." << endl;
523 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
531 if ( format == NONE || format == SINGLE )
533 for_( it, notifications_r.begin(), notifications_r.end() )
535 std::vector<std::string> command;
536 if ( format == SINGLE )
537 command.push_back(
"<"+Pathname::assertprefix( root_r, it->file() ).
asString() );
538 str::splitEscaped( notificationCmdSubst( commandStr, *it ), std::back_inserter( command ) );
540 ExternalProgram prog( command, ExternalProgram::Stderr_To_Stdout,
false, -1,
true, root_r );
543 for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
547 int ret = prog.close();
550 ERR <<
"Notification command returned with error (" << ret <<
")." << endl;
551 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
557 else if ( format == DIGEST || format == BULK )
559 filesystem::TmpFile tmpfile;
560 ofstream out( tmpfile.path().c_str() );
561 for_( it, notifications_r.begin(), notifications_r.end() )
563 if ( format == DIGEST )
565 out << it->file() << endl;
567 else if ( format == BULK )
569 copyTo( out <<
'\f', Pathname::assertprefix( root_r, it->file() ) );
573 std::vector<std::string> command;
574 command.push_back(
"<"+tmpfile.path().asString() );
575 str::splitEscaped( notificationCmdSubst( commandStr, *notifications_r.begin() ), std::back_inserter( command ) );
577 ExternalProgram prog( command, ExternalProgram::Stderr_To_Stdout,
false, -1,
true, root_r );
580 for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
584 int ret = prog.close();
587 ERR <<
"Notification command returned with error (" << ret <<
")." << endl;
588 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
595 INT <<
"Can't send Notification: Missing handler for 'format |' in command spec." << endl;
596 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
607 void RunUpdateMessages(
const Pathname & root_r,
608 const Pathname & messagesPath_r,
609 const std::vector<sat::Solvable> & checkPackages_r,
610 ZYppCommitResult & result_r )
612 if ( checkPackages_r.empty() )
615 MIL <<
"Looking for new update messages in (" << root_r <<
")" << messagesPath_r << endl;
616 Pathname messagesDir( Pathname::assertprefix( root_r, messagesPath_r ) );
617 if ( ! PathInfo( messagesDir ).isDir() )
620 std::list<std::string> messages;
622 if ( messages.empty() )
628 HistoryLog historylog;
629 for_( it, checkPackages_r.begin(), checkPackages_r.end() )
631 std::string prefix(
str::form(
"%s-%s", it->name().c_str(), it->edition().c_str() ) );
632 for_( sit, messages.begin(), messages.end() )
637 if ( (*sit)[prefix.size()] !=
'\0' && (*sit)[prefix.size()] !=
'-' )
640 PathInfo message( messagesDir / *sit );
641 if ( ! message.isFile() || message.size() == 0 )
644 MIL <<
"Found update message " << *sit << endl;
645 Pathname localPath( messagesPath_r/(*sit) );
646 result_r.rUpdateMessages().push_back( UpdateNotificationFile( *it, localPath ) );
647 historylog.comment( str::Str() <<
_(
"New update message") <<
" " << localPath,
true );
650 sendNotification( root_r, result_r.updateMessages() );
658 const Pathname & messagesPath_r,
659 const std::vector<sat::Solvable> & checkPackages_r,
661 { RunUpdateMessages( root_r, messagesPath_r, checkPackages_r, result_r ); }
667 TargetImpl_Ptr TargetImpl::_nullimpl;
670 TargetImpl_Ptr TargetImpl::nullimpl()
682 TargetImpl::TargetImpl(
const Pathname & root_r,
bool doRebuild_r )
684 , _requestedLocalesFile( home() /
"RequestedLocales" )
685 , _autoInstalledFile( home() /
"AutoInstalled" )
686 , _hardLocksFile( Pathname::assertprefix(
_root,
ZConfig::instance().locksFile() ) )
694 MIL <<
"Initialized target on " <<
_root << endl;
702 std::ifstream uuidprovider(
"/proc/sys/kernel/random/uuid" );
712 boost::function<
bool ()> condition,
713 boost::function<
string ()> value )
715 string val = value();
723 MIL <<
"updating '" << filename <<
"' content." << endl;
727 std::ofstream filestr;
730 filestr.open( filename.c_str() );
732 if ( filestr.good() )
748 return ! PathInfo(pathname).isExist();
756 Pathname idpath(
home() /
"AnonymousUniqueId");
766 WAR <<
"Can't create anonymous id file" << endl;
775 Pathname flavorpath(
home() /
"LastDistributionFlavor");
781 WAR <<
"No base product, I won't create flavor cache" << endl;
785 string flavor = p->flavor();
797 WAR <<
"Can't create flavor cache" << endl;
810 MIL <<
"Targets closed" << endl;
833 Pathname rpmsolv = base/
"solv";
834 Pathname rpmsolvcookie = base/
"cookie";
836 bool build_rpm_solv =
true;
841 bool solvexisted = PathInfo(rpmsolv).isExist();
845 PathInfo cookie( rpmsolvcookie );
846 MIL <<
"Read cookie: " << cookie << endl;
847 if ( cookie.isExist() )
851 if ( status == rpmstatus )
852 build_rpm_solv =
false;
853 MIL <<
"Read cookie: " << rpmsolvcookie <<
" says: "
854 << (build_rpm_solv ?
"outdated" :
"uptodate") << endl;
858 if ( build_rpm_solv )
863 Pathname oldSolvFile( solvexisted ? rpmsolv : Pathname() );
872 bool switchingToTmpSolvfile =
false;
873 Exception ex(
"Failed to cache rpm database.");
879 rpmsolv = base/
"solv";
880 rpmsolvcookie = base/
"cookie";
887 WAR <<
"Using a temporary solv file at " << base << endl;
888 switchingToTmpSolvfile =
true;
897 if ( ! switchingToTmpSolvfile )
906 std::ostringstream cmd;
908 if ( !
_root.empty() )
909 cmd <<
" -r '" <<
_root <<
"'";
912 cmd <<
" -p '" << Pathname::assertprefix(
_root,
"/etc/products.d" ) <<
"'";
914 if ( ! oldSolvFile.empty() )
915 cmd <<
" '" << oldSolvFile <<
"'";
917 cmd <<
" > '" << tmpsolv.
path() <<
"'";
919 MIL <<
"Executing: " << cmd << endl;
923 for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() ) {
924 WAR <<
" " << output;
925 cmd <<
" " << output;
928 int ret = prog.close();
956 return build_rpm_solv;
974 MIL <<
"New cache built: " << (newCache?
"true":
"false") <<
975 ", force loading: " << (force?
"true":
"false") << endl;
980 MIL <<
"adding " << rpmsolv <<
" to pool(" << satpool.
systemRepoAlias() <<
")" << endl;
987 if ( newCache || force )
1004 MIL <<
"adding " << rpmsolv <<
" to system" << endl;
1010 MIL <<
"Try to handle exception by rebuilding the solv-file" << endl;
1035 if ( PathInfo( historyFile ).isExist() )
1042 if ( onSystemByUser.find( ident ) == onSystemByUser.end() )
1043 onSystemByAuto.insert( ident );
1053 q.
push( idstr.id() );
1059 if ( ! hardLocks.empty() )
1068 MIL <<
"Target loaded: " << system.
solvablesSize() <<
" resolvables" << endl;
1080 bool explicitDryRun = policy_r.
dryRun();
1088 if (
root() ==
"/" )
1098 MIL <<
"TargetImpl::commit(<pool>, " << policy_r <<
")" << endl;
1117 steps.push_back( *it );
1124 MIL <<
"Todo: " << result << endl;
1134 if ( commitPlugins )
1135 commitPlugins.
send( transactionPluginFrame(
"COMMITBEGIN", steps ) );
1142 if ( ! policy_r.
dryRun() )
1148 DBG <<
"dryRun: Not writing upgrade testcase." << endl;
1155 if ( ! policy_r.
dryRun() )
1177 DBG <<
"dryRun: Not stroring non-package data." << endl;
1184 if ( ! policy_r.
dryRun() )
1186 for_( it, steps.begin(), steps.end() )
1188 if ( ! it->satSolvable().isKind<
Patch>() )
1196 if ( ! patch ||patch->message().empty() )
1199 MIL <<
"Show message for " << patch << endl;
1201 if ( ! report->show( patch ) )
1203 WAR <<
"commit aborted by the user" << endl;
1210 DBG <<
"dryRun: Not checking patch messages." << endl;
1229 for_( it, steps.begin(), steps.end() )
1231 switch ( it->stepType() )
1250 localfile = packageCache.
get( pi );
1253 catch (
const AbortRequestException & exp )
1257 WAR <<
"commit cache preload aborted by the user" << endl;
1261 catch (
const SkipRequestException & exp )
1266 WAR <<
"Skipping cache preload package " << pi->asKind<
Package>() <<
" in commit" << endl;
1276 INT <<
"Unexpected Error: Skipping cache preload package " << pi->asKind<
Package>() <<
" in commit" << endl;
1286 ERR <<
"Some packages could not be provided. Aborting commit."<< endl;
1290 if ( ! policy_r.
dryRun() )
1294 commit( policy_r, packageCache, result );
1298 DBG <<
"dryRun/downloadOnly: Not installing/deleting anything." << endl;
1299 if ( explicitDryRun ) {
1308 DBG <<
"dryRun: Not downloading/installing/deleting anything." << endl;
1309 if ( explicitDryRun ) {
1318 if ( commitPlugins )
1319 commitPlugins.
send( transactionPluginFrame(
"COMMITEND", steps ) );
1324 if ( ! policy_r.
dryRun() )
1329 MIL <<
"TargetImpl::commit(<pool>, " << policy_r <<
") returns: " << result << endl;
1340 struct NotifyAttemptToModify
1358 MIL <<
"TargetImpl::commit(<list>" << policy_r <<
")" << steps.size() << endl;
1361 NotifyAttemptToModify attemptToModify( result_r );
1366 std::vector<sat::Solvable> successfullyInstalledPackages;
1369 for_( step, steps.begin(), steps.end() )
1374 if ( citem->isKind<
Package>() )
1383 if ( citem->isKind<
Package>() )
1391 localfile = packageCache_r.
get( citem );
1393 catch (
const AbortRequestException &e )
1395 WAR <<
"commit aborted by the user" << endl;
1400 catch (
const SkipRequestException &e )
1403 WAR <<
"Skipping package " << p <<
" in commit" << endl;
1412 INT <<
"Unexpected Error: Skipping package " << p <<
" in commit" << endl;
1417 #warning Exception handling
1422 bool success =
false;
1448 if ( progress.aborted() )
1450 WAR <<
"commit aborted by the user" << endl;
1469 WAR <<
"dry run failed" << endl;
1474 if ( progress.aborted() )
1476 WAR <<
"commit aborted by the user" << endl;
1481 WAR <<
"Install failed" << endl;
1487 if ( success && !policy_r.
dryRun() )
1490 successfullyInstalledPackages.push_back( citem.
satSolvable() );
1499 bool success =
false;
1510 if ( progress.aborted() )
1512 WAR <<
"commit aborted by the user" << endl;
1526 if ( progress.aborted() )
1528 WAR <<
"commit aborted by the user" << endl;
1534 WAR <<
"removal of " << p <<
" failed";
1537 if ( success && !policy_r.
dryRun() )
1544 else if ( ! policy_r.
dryRun() )
1548 if ( ! citem.
buddy() )
1550 if ( citem->isKind<
Product>() )
1555 ERR <<
"Can't install orphan product without release-package! " << citem << endl;
1561 std::string referenceFilename( p->referenceFilename() );
1562 if ( referenceFilename.empty() )
1564 ERR <<
"Can't remove orphan product without 'referenceFilename'! " << citem << endl;
1568 PathInfo referenceFile( Pathname::assertprefix(
_root, Pathname(
"/etc/products.d" ) ) / referenceFilename );
1571 ERR <<
"Delete orphan product failed: " << referenceFile << endl;
1599 if ( ! successfullyInstalledPackages.empty() )
1602 successfullyInstalledPackages, abort ) )
1604 WAR <<
"Commit aborted by the user" << endl;
1610 successfullyInstalledPackages,
1644 PathInfo baseproduct( Pathname::assertprefix( root_r,
"/etc/products.d/baseproduct" ) );
1646 if ( baseproduct.isFile() )
1657 else if ( PathInfo( Pathname::assertprefix( root_r,
"/etc/products.d" ) ).isDir() )
1659 ERR <<
"baseproduct symlink is dangling or missing: " << baseproduct << endl;
1664 inline Pathname staticGuessRoot(
const Pathname & root_r )
1666 if ( root_r.empty() )
1671 return Pathname(
"/");
1677 inline std::string firstNonEmptyLineIn(
const Pathname & file_r )
1679 std::ifstream idfile( file_r.c_str() );
1680 for( iostr::EachLine in( idfile ); in; in.next() )
1683 if ( ! line.empty() )
1686 return std::string();
1697 if ( p->isTargetDistribution() )
1705 const Pathname needroot( staticGuessRoot(root_r) );
1706 const Target_constPtr target( getZYpp()->getTarget() );
1707 if ( target && target->root() == needroot )
1708 return target->requestedLocales();
1713 {
return baseproductdata(
_root ).registerTarget(); }
1716 {
return baseproductdata( staticGuessRoot(root_r) ).registerTarget(); }
1719 {
return baseproductdata(
_root ).registerRelease(); }
1722 {
return baseproductdata( staticGuessRoot(root_r) ).registerRelease();}
1725 {
return baseproductdata(
_root ).registerFlavor(); }
1728 {
return baseproductdata( staticGuessRoot(root_r) ).registerFlavor();}
1761 std::string
distributionVersion = baseproductdata( staticGuessRoot(root_r) ).edition().version();
1762 if ( distributionVersion.empty() )
1768 scoped_ptr<rpm::RpmDb> tmprpmdb;
1774 tmprpmdb->initDatabase( );
1783 distributionVersion = it->tag_version();
1791 return firstNonEmptyLineIn(
home() /
"LastDistributionFlavor" );
1796 return firstNonEmptyLineIn( staticGuessRoot(root_r) /
"/var/lib/zypp/LastDistributionFlavor" );
1803 return firstNonEmptyLineIn(
home() /
"AnonymousUniqueId" );
1808 return firstNonEmptyLineIn( staticGuessRoot(root_r) /
"/var/lib/zypp/AnonymousUniqueId" );
void saveToCookieFile(const Pathname &path_r) const
Save the status information to a cookie file.
StringQueue autoInstalled() const
Return the ident strings of all packages that would be auto-installed after the transaction is run...
static bool fileMissing(const Pathname &pathname)
helper functor
bool upgradingRepos() const
Whether there is at least one UpgradeRepo request pending.
ZYppCommitResult commit(ResPool pool_r, const ZYppCommitPolicy &policy_r)
Commit changes in the pool.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
std::string asJSON() const
JSON representation.
std::string shortName() const
Interface to the rpm program.
A Solvable object within the sat Pool.
std::vector< sat::Transaction::Step > TransactionStepList
Save and restore locale set from file.
Alternating download and install.
void setRequestedLocales(const LocaleSet &locales_r)
Set the requested locales.
Target::DistributionLabel distributionLabel() const
This is version attribute of the installed base product.
ZYppCommitPolicy & rpmNoSignature(bool yesNo_r)
Use rpm option –nosignature (default: false)
[M] Install(multiversion) item (
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
byKind_iterator byKindBegin(const ResKind &kind_r) const
Result returned from ZYpp::commit.
static ZConfig & instance()
Singleton ctor.
void addSolv(const Pathname &file_r)
Load Solvables from a solv-file.
const std::string & asString() const
std::string md5sum(const Pathname &file)
Compute a files md5sum.
Command frame for communication with PluginScript.
Pathname home() const
The directory to store things.
std::string distroverpkg() const
Package telling the "product version" on systems not using /etc/product.d/baseproduct.
Pathname _tmpSolvfilesPath
bool findByProvides(const std::string &tag_r)
Reset to iterate all packages that provide a certain tag.
int readlink(const Pathname &symlink_r, Pathname &target_r)
Like 'readlink'.
void setData(const Data &data_r)
Store new Data.
SolvIdentFile _autoInstalledFile
user/auto installed database
detail::IdType value_type
void resetDispose()
Set no dispose function.
static ProductFileData scanFile(const Pathname &file_r)
Parse one file (or symlink) and return the ProductFileData parsed.
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...
std::string release() const
Release.
Target::commit helper optimizing package provision.
ZYppCommitPolicy & rpmInstFlags(target::rpm::RpmInstFlags newFlags_r)
The default target::rpm::RpmInstFlags.
TransactionStepList & rTransactionStepList()
Manipulate transactionStepList.
const Data & data() const
Return the data.
void discardScripts()
Discard all remembered scrips.
Pathname root() const
The root set for this target.
int chmod(const Pathname &path, mode_t mode)
Like 'chmod'.
void installPackage(const Pathname &filename, RpmInstFlags flags=RPMINST_NONE)
install rpm package
ZYppCommitPolicy & dryRun(bool yesNo_r)
Set dry run (default: false).
#define N_(MSG)
Just tag text for translation.
ZYppCommitPolicy & rpmExcludeDocs(bool yesNo_r)
Use rpm option –excludedocs (default: false)
std::string _distributionVersion
Cache distributionVersion.
void commitFindFileConflicts(const ZYppCommitPolicy &policy_r, ZYppCommitResult &result_r)
Commit helper checking for file conflicts after download.
Parallel execution of stateful PluginScripts.
void setData(const Data &data_r)
Store new Data.
void setAutoInstalled(const Queue &autoInstalled_r)
Set ident list of all autoinstalled solvables.
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
Access to the sat-pools string space.
Libsolv transaction wrapper.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Edition represents [epoch:]version[-release]
bool resetTransact(TransactByValue causer_r)
Not the same as setTransact( false ).
Similar to DownloadInAdvance, but try to split the transaction into heaps, where at the end of each h...
TraitsType::constPtrType constPtr
Provide a new empty temporary file and delete it when no longer needed.
unsigned epoch_t
Type of an epoch.
void writeUpgradeTestcase()
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
static RepoStatus fromCookieFile(const Pathname &path)
Reads the status from a cookie file.
byKind_iterator byKindEnd(const ResKind &kind_r) const
Class representing a patch.
void installSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Install a source package on the Target.
LocaleSet requestedLocales() const
Languages to be supported by the system.
std::string summary() const
ManagedFile provideSrcPackage(const SrcPackage_constPtr &srcPackage_r) const
Provide SrcPackage in a local file.
void install(const PoolItem &pi)
Log installation (or update) of a package.
unsigned splitEscaped(const C_Str &line_r, _OutputIterator result_r, const C_Str &sepchars_r=" \t", bool withEmpty=false)
Split line_r into words with respect to escape delimeters.
std::string distributionVersion() const
This is version attribute of the installed base product.
std::string asString() const
Conversion to std::string
Extract and remember posttrans scripts for later execution.
const_iterator begin() const
Iterator to the first TransactionStep.
Subclass to retrieve database content.
std::tr1::unordered_set< IdString > Data
void remember(const Exception &old_r)
Store an other Exception as history.
StepStage stepStage() const
Step action result.
rpm::RpmDb _rpm
RPM database.
Repository systemRepo()
Return the system repository, create it if missing.
Date timestamp() const
return the last modification date of the target
[ ] Nothing (includes implicit deletes due to obsoletes and non-package actions)
ResObject::constPtr resolvable() const
Returns the ResObject::constPtr.
int addmod(const Pathname &path, mode_t mode)
Add the mode bits to the file given by path.
void push(value_type val_r)
Push a value to the end off the Queue.
const Data & data() const
Return the data.
std::string getline(std::istream &str)
Read one line from stream.
StepType stepType() const
Type of action to perform in this step.
Store and operate on date (time_t).
Base class for concrete Target implementations.
static Pool instance()
Singleton ctor.
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
Pathname _root
Path to the target.
Pathname defaultSolvfilesPath() const
The systems default solv file location.
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
std::string trim(const std::string &s, const Trim trim_r)
int unlink(const Pathname &path)
Like 'unlink'.
static const std::string & systemRepoAlias()
Reserved system repository alias .
bool collectScriptFromPackage(ManagedFile rpmPackage_r)
Extract and remember a packages posttrans script for later execution.
static const Pathname & fname()
Get the current log file path.
void send(const PluginFrame &frame_r)
Send PluginFrame to all open plugins.
int rename(const Pathname &oldpath, const Pathname &newpath)
Like 'rename'.
Just download all packages to the local cache.
Options and policies for ZYpp::commit.
libzypp will decide what to do.
bool solvfilesPathIsTemp() const
Whether we're using a temp.
A single step within a Transaction.
ZYppCommitPolicy & downloadMode(DownloadMode val_r)
Commit download policy to use.
RequestedLocalesFile _requestedLocalesFile
Requested Locales database.
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::...
void setLocales(const LocaleSet &locales_r)
Store a new locale set.
void getHardLockQueries(HardLockQueries &activeLocks_r)
Suggest a new set of queries based on the current selection.
int recursive_rmdir(const Pathname &path)
Like 'rm -r DIR'.
Interim helper class to collect global options and settings.
void createLastDistributionFlavorCache() const
generates a cache of the last product flavor
std::string targetDistributionFlavor() const
This is register.flavor attribute of the installed base product.
bool startsWith(const C_Str &str_r, const C_Str &prefix_r)
alias for hasPrefix
epoch_t epoch() const
Epoch.
std::string version() const
Version.
Pathname rootDir() const
Get rootdir (for file conflicts check)
ResStatus & status() const
Returns the current status.
const LocaleSet & getRequestedLocales() const
Return the requested locales.
bool order()
Order transaction steps for commit.
Writing the zypp history fileReference counted signleton for writhing the zypp history file...
TraitsType::constPtrType constPtr
std::tr1::unordered_set< Locale > LocaleSet
Pathname solvfilesPath() const
The solv file location actually in use (default or temp).
void closeDatabase()
Block further access to the rpm database and go back to uninitialized state.
ZYppCommitPolicy & restrictToMedia(unsigned mediaNr_r)
Restrict commit to media 1.
std::list< PoolItem > PoolItemList
list of pool items
std::string anonymousUniqueId() const
anonymous unique id
sat::Transaction getTransaction()
Return the Transaction computed by the last solver run.
bool solvablesEmpty() const
Whether Repository contains solvables.
std::string toLower(const std::string &s)
Return lowercase version of s.
static std::string generateRandomId()
generates a random id using uuidgen
ManagedFile get(const PoolItem &citem_r)
Provide a package.
HardLocksFile _hardLocksFile
Hard-Locks database.
Solvable satSolvable() const
Return the corresponding Solvable.
std::string asJSON() const
JSON representation.
static void setRoot(const Pathname &root)
Set new root directory to the default history log file path.
std::string targetDistribution() const
This is register.target attribute of the installed base product.
size_type solvablesSize() const
Number of solvables in Repository.
void setHardLockQueries(const HardLockQueries &newLocks_r)
Set a new set of queries.
#define SUBST_IF(PAT, VAL)
std::list< UpdateNotificationFile > UpdateNotifications
Libsolv Id queue wrapper.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
const LocaleSet & locales() const
Return the loacale set.
std::string distributionFlavor() const
This is flavor attribute of the installed base product but does not require the target to be loaded a...
sat::Solvable buddy() const
Return the buddy we share our status object with.
Pathname systemRoot() const
The target root directory.
ZYppCommitPolicy & allMedia()
Process all media (default)
pool::PoolTraits::HardLockQueries Data
const sat::Transaction & transaction() const
The full transaction list.
void add(const Value &val_r)
Push JSON Value to Array.
Base class for Exception.
Resolver & resolver() const
The Resolver.
bool isToBeInstalled() const
void load(const Pathname &path_r)
Find and launch plugins sending PLUGINBEGIN.
Data returned by ProductFileReader.
const_iterator end() const
Iterator behind the last TransactionStep.
void remove(const PoolItem &pi)
Log removal of a package.
Product::constPtr baseProduct() const
returns the target base installed product, also known as the distribution or platform.
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
virtual ~TargetImpl()
Dtor.
Reference counted access to a _Tp object calling a custom Dispose function when the last AutoDispose ...
void eraseFromPool()
Remove this Repository from it's Pool.
sat::Solvable satSolvable() const
Return the corresponding sat::Solvable.
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 ...
void comment(const std::string &comment, bool timestamp=false)
Log a comment (even multiline).
TraitsType::constPtrType constPtr
Date timestamp() const
timestamp of the rpm database (last modification)
ResObject::Ptr makeResObject(const sat::Solvable &solvable_r)
Create ResObject from sat::Solvable.
sat::Transaction & rTransaction()
Manipulate transaction.
Reference to a PoolItem connecting ResObject and ResStatus.
void executeScripts()
Execute te remembered scripts.
ManagedFile provideSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Provides a source package on the Target.
static TmpFile makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Track changing files or directories.
std::string toJSON(const sat::Transaction::Step &step_r)
See COMMITBEGIN (added in v1) on page Commit plugin for the specs.
void XRunUpdateMessages(const Pathname &root_r, const Pathname &messagesPath_r, const std::vector< sat::Solvable > &checkPackages_r, ZYppCommitResult &result_r)
std::string targetDistributionRelease() const
This is register.release attribute of the installed base product.
std::string asString(const std::string &t)
Global asString() that works with std::string too.
void add(const String &key_r, const Value &val_r)
Add key/value pair.
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
void createAnonymousId() const
generates the unique anonymous id which is called when creating the target
bool empty() const
Whether this is an empty object without valid data.
void setCommitList(std::vector< sat::Solvable > commitList_r)
Download(commit) sequence of solvables to compute read ahead.
const Pathname & file() const
Return the file path.
rpm::RpmDb & rpm()
The RPM database.
TraitsType::constPtrType constPtr
#define IMPL_PTR_TYPE(NAME)
bool preloaded() const
Whether preloaded hint is set.
ZYppCommitResult & _result
static ResPool instance()
Singleton ctor.
void load(bool force=true)