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;
236 if ( ! _scripts.empty() )
243 {
return _scripts.empty(); }
251 DBG <<
"+++++++++++++++ send " << frame_r << endl;
252 for (
auto it = _scripts.begin(); it != _scripts.end(); )
254 doSend( *it, frame_r );
258 it = _scripts.erase( it );
260 DBG <<
"--------------- send " << frame_r << endl;
269 void load(
const Pathname & path_r )
271 PathInfo pi( path_r );
272 DBG <<
"+++++++++++++++ load " << pi << endl;
275 std::list<Pathname> entries;
278 WAR <<
"Plugin dir is not readable: " << pi << endl;
281 for_( it, entries.begin(), entries.end() )
284 if ( pii.isFile() && pii.userMayRX() )
288 else if ( pi.isFile() )
290 if ( pi.userMayRX() )
293 WAR <<
"Plugin file is not executable: " << pi << endl;
297 WAR <<
"Plugin path is neither dir nor file: " << pi << endl;
299 DBG <<
"--------------- load " << pi << endl;
313 script_r.
send( frame_r );
321 WAR <<
"Bad plugin response from " << script_r << endl;
332 MIL <<
"Load plugin: " << pi_r << endl;
338 if ( ZConfig::instance().hasUserData() )
339 frame.
setHeader(
"userdata", ZConfig::instance().userData() );
341 doSend( plugin, frame );
342 if ( plugin.isOpen() )
343 _scripts.push_back( plugin );
347 WAR <<
"Failed to load plugin " << pi_r << endl;
357 USR <<
"+++++" << endl;
361 USR <<
"=====" << endl;
363 USR <<
"-----" << endl;
372 {
"TransactionStepList", steps_r }
381 unsigned toKeep( ZConfig::instance().solver_upgradeTestcasesToKeep() );
382 MIL <<
"Testcases to keep: " << toKeep << endl;
385 Target_Ptr target( getZYpp()->getTarget() );
388 WAR <<
"No Target no Testcase!" << endl;
392 std::string stem(
"updateTestcase" );
393 Pathname dir( target->assertRootPrefix(
"/var/log/") );
394 Pathname next( dir / Date::now().
form( stem+
"-%Y-%m-%d-%H-%M-%S" ) );
397 std::list<std::string> content;
399 std::set<std::string> cases;
400 for_( c, content.begin(), content.end() )
405 if ( cases.size() >= toKeep )
407 unsigned toDel = cases.size() - toKeep + 1;
408 for_( c, cases.begin(), cases.end() )
417 MIL <<
"Write new testcase " << next << endl;
418 getZYpp()->resolver()->createSolverTestcase( next.asString(),
false );
435 std::pair<bool,PatchScriptReport::Action> doExecuteScript(
const Pathname & root_r,
436 const Pathname & script_r,
439 MIL <<
"Execute script " << PathInfo(Pathname::assertprefix( root_r,script_r)) << endl;
442 historylog.
comment(script_r.asString() +
_(
" executed"),
true);
443 ExternalProgram prog( script_r.asString(), ExternalProgram::Stderr_To_Stdout,
false, -1,
true, root_r );
445 for ( std::string output = prog.receiveLine(); output.length(); output = prog.receiveLine() )
448 if ( ! report_r->progress( PatchScriptReport::OUTPUT, output ) )
450 WAR <<
"User request to abort script " << script_r << endl;
457 std::pair<bool,PatchScriptReport::Action> ret( std::make_pair(
false, PatchScriptReport::ABORT ) );
459 if ( prog.close() != 0 )
461 ret.second = report_r->problem( prog.execError() );
462 WAR <<
"ACTION" << ret.second <<
"(" << prog.execError() <<
")" << endl;
463 std::ostringstream sstr;
464 sstr << script_r <<
_(
" execution failed") <<
" (" << prog.execError() <<
")" << endl;
465 historylog.
comment(sstr.str(),
true);
477 bool executeScript(
const Pathname & root_r,
478 const Pathname & script_r,
479 callback::SendReport<PatchScriptReport> & report_r )
481 std::pair<bool,PatchScriptReport::Action> action( std::make_pair(
false, PatchScriptReport::ABORT ) );
484 action = doExecuteScript( root_r, script_r, report_r );
488 switch ( action.second )
490 case PatchScriptReport::ABORT:
491 WAR <<
"User request to abort at script " << script_r << endl;
495 case PatchScriptReport::IGNORE:
496 WAR <<
"User request to skip script " << script_r << endl;
500 case PatchScriptReport::RETRY:
503 }
while ( action.second == PatchScriptReport::RETRY );
506 INT <<
"Abort on unknown ACTION request " << action.second <<
" returned" << endl;
515 bool RunUpdateScripts(
const Pathname & root_r,
516 const Pathname & scriptsPath_r,
517 const std::vector<sat::Solvable> & checkPackages_r,
520 if ( checkPackages_r.empty() )
523 MIL <<
"Looking for new update scripts in (" << root_r <<
")" << scriptsPath_r << endl;
524 Pathname scriptsDir( Pathname::assertprefix( root_r, scriptsPath_r ) );
525 if ( ! PathInfo( scriptsDir ).isDir() )
528 std::list<std::string> scripts;
530 if ( scripts.empty() )
538 std::map<std::string, Pathname> unify;
539 for_( it, checkPackages_r.begin(), checkPackages_r.end() )
541 std::string prefix(
str::form(
"%s-%s", it->name().c_str(), it->edition().c_str() ) );
542 for_( sit, scripts.begin(), scripts.end() )
547 if ( (*sit)[prefix.size()] !=
'\0' && (*sit)[prefix.size()] !=
'-' )
550 PathInfo script( scriptsDir / *sit );
551 Pathname localPath( scriptsPath_r/(*sit) );
552 std::string unifytag;
554 if ( script.isFile() )
560 else if ( ! script.isExist() )
568 if ( unifytag.empty() )
572 if ( unify[unifytag].empty() )
574 unify[unifytag] = localPath;
581 std::string msg(
str::form(
_(
"%s already executed as %s)"), localPath.asString().c_str(), unify[unifytag].c_str() ) );
582 MIL <<
"Skip update script: " << msg << endl;
583 HistoryLog().comment( msg,
true );
587 if ( abort || aborting_r )
589 WAR <<
"Aborting: Skip update script " << *sit << endl;
590 HistoryLog().comment(
591 localPath.asString() +
_(
" execution skipped while aborting"),
596 MIL <<
"Found update script " << *sit << endl;
597 callback::SendReport<PatchScriptReport>
report;
598 report->start( make<Package>( *it ), script.path() );
600 if ( ! executeScript( root_r, localPath, report ) )
612 inline void copyTo( std::ostream & out_r,
const Pathname & file_r )
614 std::ifstream infile( file_r.c_str() );
615 for( iostr::EachLine in( infile ); in; in.next() )
617 out_r << *in << endl;
621 inline std::string notificationCmdSubst(
const std::string & cmd_r,
const UpdateNotificationFile & notification_r )
623 std::string ret( cmd_r );
624 #define SUBST_IF(PAT,VAL) if ( ret.find( PAT ) != std::string::npos ) ret = str::gsub( ret, PAT, VAL )
625 SUBST_IF(
"%p", notification_r.solvable().asString() );
626 SUBST_IF(
"%P", notification_r.file().asString() );
631 void sendNotification(
const Pathname & root_r,
634 if ( notifications_r.empty() )
637 std::string cmdspec( ZConfig::instance().updateMessagesNotify() );
638 MIL <<
"Notification command is '" << cmdspec <<
"'" << endl;
639 if ( cmdspec.empty() )
643 if ( pos == std::string::npos )
645 ERR <<
"Can't send Notification: Missing 'format |' in command spec." << endl;
646 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
651 std::string commandStr(
str::trim( cmdspec.substr( pos + 1 ) ) );
653 enum Format { UNKNOWN, NONE, SINGLE, DIGEST, BULK };
654 Format format = UNKNOWN;
655 if ( formatStr ==
"none" )
657 else if ( formatStr ==
"single" )
659 else if ( formatStr ==
"digest" )
661 else if ( formatStr ==
"bulk" )
665 ERR <<
"Can't send Notification: Unknown format '" << formatStr <<
" |' in command spec." << endl;
666 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
674 if ( format == NONE || format == SINGLE )
676 for_( it, notifications_r.begin(), notifications_r.end() )
678 std::vector<std::string> command;
679 if ( format == SINGLE )
680 command.push_back(
"<"+Pathname::assertprefix( root_r, it->file() ).
asString() );
681 str::splitEscaped( notificationCmdSubst( commandStr, *it ), std::back_inserter( command ) );
683 ExternalProgram prog( command, ExternalProgram::Stderr_To_Stdout,
false, -1,
true, root_r );
686 for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
690 int ret = prog.close();
693 ERR <<
"Notification command returned with error (" << ret <<
")." << endl;
694 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
700 else if ( format == DIGEST || format == BULK )
702 filesystem::TmpFile tmpfile;
703 ofstream out( tmpfile.path().c_str() );
704 for_( it, notifications_r.begin(), notifications_r.end() )
706 if ( format == DIGEST )
708 out << it->file() << endl;
710 else if ( format == BULK )
712 copyTo( out <<
'\f', Pathname::assertprefix( root_r, it->file() ) );
716 std::vector<std::string> command;
717 command.push_back(
"<"+tmpfile.path().asString() );
718 str::splitEscaped( notificationCmdSubst( commandStr, *notifications_r.begin() ), std::back_inserter( command ) );
720 ExternalProgram prog( command, ExternalProgram::Stderr_To_Stdout,
false, -1,
true, root_r );
723 for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
727 int ret = prog.close();
730 ERR <<
"Notification command returned with error (" << ret <<
")." << endl;
731 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
738 INT <<
"Can't send Notification: Missing handler for 'format |' in command spec." << endl;
739 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
750 void RunUpdateMessages(
const Pathname & root_r,
751 const Pathname & messagesPath_r,
752 const std::vector<sat::Solvable> & checkPackages_r,
753 ZYppCommitResult & result_r )
755 if ( checkPackages_r.empty() )
758 MIL <<
"Looking for new update messages in (" << root_r <<
")" << messagesPath_r << endl;
759 Pathname messagesDir( Pathname::assertprefix( root_r, messagesPath_r ) );
760 if ( ! PathInfo( messagesDir ).isDir() )
763 std::list<std::string> messages;
765 if ( messages.empty() )
771 HistoryLog historylog;
772 for_( it, checkPackages_r.begin(), checkPackages_r.end() )
774 std::string prefix(
str::form(
"%s-%s", it->name().c_str(), it->edition().c_str() ) );
775 for_( sit, messages.begin(), messages.end() )
780 if ( (*sit)[prefix.size()] !=
'\0' && (*sit)[prefix.size()] !=
'-' )
783 PathInfo message( messagesDir / *sit );
784 if ( ! message.isFile() || message.size() == 0 )
787 MIL <<
"Found update message " << *sit << endl;
788 Pathname localPath( messagesPath_r/(*sit) );
789 result_r.rUpdateMessages().push_back( UpdateNotificationFile( *it, localPath ) );
790 historylog.comment( str::Str() <<
_(
"New update message") <<
" " << localPath,
true );
793 sendNotification( root_r, result_r.updateMessages() );
801 const Pathname & messagesPath_r,
802 const std::vector<sat::Solvable> & checkPackages_r,
804 { RunUpdateMessages( root_r, messagesPath_r, checkPackages_r, result_r ); }
810 TargetImpl_Ptr TargetImpl::_nullimpl;
813 TargetImpl_Ptr TargetImpl::nullimpl()
825 TargetImpl::TargetImpl(
const Pathname & root_r,
bool doRebuild_r )
827 , _requestedLocalesFile( home() /
"RequestedLocales" )
828 , _autoInstalledFile( home() /
"AutoInstalled" )
829 , _hardLocksFile( Pathname::assertprefix( _root,
ZConfig::instance().locksFile() ) )
837 MIL <<
"Initialized target on " <<
_root << endl;
845 std::ifstream uuidprovider(
"/proc/sys/kernel/random/uuid" );
855 boost::function<
bool ()> condition,
856 boost::function<
string ()> value )
858 string val = value();
866 MIL <<
"updating '" << filename <<
"' content." << endl;
870 std::ofstream filestr;
873 filestr.open( filename.c_str() );
875 if ( filestr.good() )
891 return ! PathInfo(pathname).isExist();
899 Pathname idpath(
home() /
"AnonymousUniqueId");
909 WAR <<
"Can't create anonymous id file" << endl;
918 Pathname flavorpath(
home() /
"LastDistributionFlavor");
924 WAR <<
"No base product, I won't create flavor cache" << endl;
928 string flavor = p->flavor();
940 WAR <<
"Can't create flavor cache" << endl;
953 MIL <<
"Targets closed" << endl;
976 Pathname rpmsolv = base/
"solv";
977 Pathname rpmsolvcookie = base/
"cookie";
979 bool build_rpm_solv =
true;
984 bool solvexisted = PathInfo(rpmsolv).isExist();
988 PathInfo cookie( rpmsolvcookie );
989 MIL <<
"Read cookie: " << cookie << endl;
990 if ( cookie.isExist() )
994 if ( status == rpmstatus )
995 build_rpm_solv =
false;
996 MIL <<
"Read cookie: " << rpmsolvcookie <<
" says: "
997 << (build_rpm_solv ?
"outdated" :
"uptodate") << endl;
1001 if ( build_rpm_solv )
1006 Pathname oldSolvFile( solvexisted ? rpmsolv : Pathname() );
1015 bool switchingToTmpSolvfile =
false;
1016 Exception ex(
"Failed to cache rpm database.");
1022 rpmsolv = base/
"solv";
1023 rpmsolvcookie = base/
"cookie";
1030 WAR <<
"Using a temporary solv file at " << base << endl;
1031 switchingToTmpSolvfile =
true;
1040 if ( ! switchingToTmpSolvfile )
1049 std::ostringstream cmd;
1050 cmd <<
"rpmdb2solv";
1051 if ( !
_root.empty() )
1052 cmd <<
" -r '" <<
_root <<
"'";
1055 cmd <<
" -p '" << Pathname::assertprefix(
_root,
"/etc/products.d" ) <<
"'";
1057 if ( ! oldSolvFile.empty() )
1058 cmd <<
" '" << oldSolvFile <<
"'";
1060 cmd <<
" > '" << tmpsolv.
path() <<
"'";
1062 MIL <<
"Executing: " << cmd.str() << endl;
1066 for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() ) {
1067 WAR <<
" " << output;
1068 cmd <<
" " << output;
1071 int ret = prog.close();
1094 Pathname script( Pathname::assertprefix(
_root,
ZConfig::instance().pluginsPath()/
"system/spacewalk" ) );
1095 if ( PathInfo( script ).isX() )
1101 spacewalk.
send( notify );
1105 if ( ret.command() ==
"ERROR" )
1106 ret.writeTo(
WAR ) << endl;
1114 return build_rpm_solv;
1132 MIL <<
"New cache built: " << (newCache?
"true":
"false") <<
1133 ", force loading: " << (force?
"true":
"false") << endl;
1138 MIL <<
"adding " << rpmsolv <<
" to pool(" << satpool.
systemRepoAlias() <<
")" << endl;
1145 if ( newCache || force )
1162 MIL <<
"adding " << rpmsolv <<
" to system" << endl;
1168 MIL <<
"Try to handle exception by rebuilding the solv-file" << endl;
1193 if ( PathInfo( historyFile ).isExist() )
1200 if ( onSystemByUser.find( ident ) == onSystemByUser.end() )
1201 onSystemByAuto.insert( ident );
1217 if ( ! hardLocks.empty() )
1226 MIL <<
"Target loaded: " << system.
solvablesSize() <<
" resolvables" << endl;
1245 if (
root() ==
"/" )
1255 MIL <<
"TargetImpl::commit(<pool>, " << policy_r <<
")" << endl;
1274 steps.push_back( *it );
1281 MIL <<
"Todo: " << result << endl;
1290 commitPlugins.
load( plugindir );
1292 if ( ! commitPlugins.
empty() )
1293 commitPlugins.
send( transactionPluginFrame(
"COMMITBEGIN", steps ) );
1298 if ( getZYpp()->resolver()->upgradeMode() )
1300 if ( ! policy_r.
dryRun() )
1306 DBG <<
"dryRun: Not writing upgrade testcase." << endl;
1313 if ( ! policy_r.
dryRun() )
1335 DBG <<
"dryRun: Not stroring non-package data." << endl;
1342 if ( ! policy_r.
dryRun() )
1344 for_( it, steps.begin(), steps.end() )
1346 if ( ! it->satSolvable().isKind<
Patch>() )
1354 if ( ! patch ||patch->message().empty() )
1357 MIL <<
"Show message for " << patch << endl;
1359 if ( ! report->show( patch ) )
1361 WAR <<
"commit aborted by the user" << endl;
1368 DBG <<
"dryRun: Not checking patch messages." << endl;
1387 for_( it, steps.begin(), steps.end() )
1389 switch ( it->stepType() )
1411 localfile = packageCache.
get( pi );
1421 INT <<
"Don't know howto cache: Neither Package nor SrcPackage: " << pi << endl;
1426 catch (
const AbortRequestException & exp )
1430 WAR <<
"commit cache preload aborted by the user" << endl;
1434 catch (
const SkipRequestException & exp )
1439 WAR <<
"Skipping cache preload package " << pi->asKind<
Package>() <<
" in commit" << endl;
1449 INT <<
"Unexpected Error: Skipping cache preload package " << pi->asKind<
Package>() <<
" in commit" << endl;
1459 ERR <<
"Some packages could not be provided. Aborting commit."<< endl;
1463 if ( ! policy_r.
dryRun() )
1467 commit( policy_r, packageCache, result );
1471 DBG <<
"dryRun/downloadOnly: Not installing/deleting anything." << endl;
1477 DBG <<
"dryRun: Not downloading/installing/deleting anything." << endl;
1483 if ( ! commitPlugins.
empty() )
1484 commitPlugins.
send( transactionPluginFrame(
"COMMITEND", steps ) );
1489 if ( ! policy_r.
dryRun() )
1494 MIL <<
"TargetImpl::commit(<pool>, " << policy_r <<
") returns: " << result << endl;
1509 MIL <<
"TargetImpl::commit(<list>" << policy_r <<
")" << steps.size() << endl;
1513 std::vector<sat::Solvable> successfullyInstalledPackages;
1516 for_( step, steps.begin(), steps.end() )
1521 if ( citem->isKind<
Package>() )
1530 if ( citem->isKind<
Package>() )
1538 localfile = packageCache_r.
get( citem );
1540 catch (
const AbortRequestException &e )
1542 WAR <<
"commit aborted by the user" << endl;
1547 catch (
const SkipRequestException &e )
1550 WAR <<
"Skipping package " << p <<
" in commit" << endl;
1559 INT <<
"Unexpected Error: Skipping package " << p <<
" in commit" << endl;
1564 #warning Exception handling
1569 bool success =
false;
1594 if ( progress.aborted() )
1596 WAR <<
"commit aborted by the user" << endl;
1615 WAR <<
"dry run failed" << endl;
1620 if ( progress.aborted() )
1622 WAR <<
"commit aborted by the user" << endl;
1627 WAR <<
"Install failed" << endl;
1633 if ( success && !policy_r.
dryRun() )
1636 successfullyInstalledPackages.push_back( citem.
satSolvable() );
1645 bool success =
false;
1654 if ( progress.aborted() )
1656 WAR <<
"commit aborted by the user" << endl;
1670 if ( progress.aborted() )
1672 WAR <<
"commit aborted by the user" << endl;
1678 WAR <<
"removal of " << p <<
" failed";
1681 if ( success && !policy_r.
dryRun() )
1688 else if ( ! policy_r.
dryRun() )
1692 if ( ! citem.
buddy() )
1694 if ( citem->isKind<
Product>() )
1699 ERR <<
"Can't install orphan product without release-package! " << citem << endl;
1705 std::string referenceFilename( p->referenceFilename() );
1706 if ( referenceFilename.empty() )
1708 ERR <<
"Can't remove orphan product without 'referenceFilename'! " << citem << endl;
1712 PathInfo referenceFile( Pathname::assertprefix(
_root, Pathname(
"/etc/products.d" ) ) / referenceFilename );
1715 ERR <<
"Delete orphan product failed: " << referenceFile << endl;
1743 if ( ! successfullyInstalledPackages.empty() )
1746 successfullyInstalledPackages, abort ) )
1748 WAR <<
"Commit aborted by the user" << endl;
1754 successfullyInstalledPackages,
1788 PathInfo baseproduct( Pathname::assertprefix( root_r,
"/etc/products.d/baseproduct" ) );
1790 if ( baseproduct.isFile() )
1801 else if ( PathInfo( Pathname::assertprefix( root_r,
"/etc/products.d" ) ).isDir() )
1803 ERR <<
"baseproduct symlink is dangling or missing: " << baseproduct << endl;
1808 inline Pathname staticGuessRoot(
const Pathname & root_r )
1810 if ( root_r.empty() )
1815 return Pathname(
"/");
1821 inline std::string firstNonEmptyLineIn(
const Pathname & file_r )
1823 std::ifstream idfile( file_r.c_str() );
1824 for( iostr::EachLine in( idfile ); in; in.next() )
1827 if ( ! line.empty() )
1830 return std::string();
1841 if ( p->isTargetDistribution() )
1849 const Pathname needroot( staticGuessRoot(root_r) );
1850 const Target_constPtr target( getZYpp()->getTarget() );
1851 if ( target && target->root() == needroot )
1852 return target->requestedLocales();
1857 {
return baseproductdata(
_root ).registerTarget(); }
1860 {
return baseproductdata( staticGuessRoot(root_r) ).registerTarget(); }
1863 {
return baseproductdata(
_root ).registerRelease(); }
1866 {
return baseproductdata( staticGuessRoot(root_r) ).registerRelease();}
1869 {
return baseproductdata(
_root ).registerFlavor(); }
1872 {
return baseproductdata( staticGuessRoot(root_r) ).registerFlavor();}
1905 std::string
distributionVersion = baseproductdata( staticGuessRoot(root_r) ).edition().version();
1906 if ( distributionVersion.empty() )
1912 scoped_ptr<rpm::RpmDb> tmprpmdb;
1918 tmprpmdb->initDatabase( );
1927 distributionVersion = it->tag_version();
1935 return firstNonEmptyLineIn(
home() /
"LastDistributionFlavor" );
1940 return firstNonEmptyLineIn( staticGuessRoot(root_r) /
"/var/lib/zypp/LastDistributionFlavor" );
1947 return firstNonEmptyLineIn(
home() /
"AnonymousUniqueId" );
1952 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
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.
CommitPlugins()
Default ctor: Empty plugin list.
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.
bool isEnomethodCommand() const
Convenience to identify an _ENOMETHOD command.
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.
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.
void load(const Pathname &path_r)
Find and launch plugins sending PLUGINSTART message.
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.
PluginFrame doSend(PluginScript &script_r, const PluginFrame &frame_r)
Send PluginFrame and expect valid answer (ACK|_ENOMETHOD).
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.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
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.
~CommitPlugins()
Dtor: Send PLUGINEND message and close plugins.
Pathname defaultSolvfilesPath() const
The systems default solv file location.
bool empty() const
Whether no plugins are waiting.
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.
int rename(const Pathname &oldpath, const Pathname &newpath)
Like 'rename'.
Just download all packages to the local cache.
Options and policies for ZYpp::commit.
void send(const PluginFrame &frame_r)
Send PluginFrame to all open plugins.
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.
bool isAckCommand() const
Convenience to identify an ACK command.
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.
void updateSolvFileIndex(const Pathname &solvfile_r)
Create solv file content digest for zypper bash completion.
void open()
Setup connection and execute script.
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.
PluginFrame receive() const
Receive a PluginFrame.
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.
void testCommitPlugins(const Pathname &path_r)
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.
void doLoad(const PathInfo &pi_r)
Launch a plugin sending PLUGINSTART message.
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.
int close()
Close any open connection.
Base class for Exception.
Resolver & resolver() const
The Resolver.
bool isToBeInstalled() const
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).
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
detail::Dump< _Tp > dump(const _Tp &obj_r)
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.
Helper for commit plugin execution.
sat::Transaction & rTransaction()
Manipulate transaction.
void setHeader(const std::string &key_r, const std::string &value_r=std::string())
Set header for key_r removing all other occurences of key_r.
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)
Interface to pluigin scripts using a Stomp inspired communication protocol.
std::string targetDistributionRelease() const
This is register.release attribute of the installed base product.
Easy-to use interface to the ZYPP dependency resolver.
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
void send(const PluginFrame &frame_r) const
Send a PluginFrame.
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.
static ResPool instance()
Singleton ctor.
std::list< PluginScript > _scripts
void load(bool force=true)