19 #include <sys/types.h> 28 #include <zypp-core/base/UserRequestException> 63 #include <zypp-core/zyppng/base/EventLoop> 64 #include <zypp-core/zyppng/base/UnixSignalSource> 65 #include <zypp-core/zyppng/io/AsyncDataSource> 66 #include <zypp-core/zyppng/io/Process> 70 #include <zypp-core/zyppng/base/EventDispatcher> 72 #include <shared/commit/CommitMessages.h> 79 #include "tools/zypp-rpm/errorcodes.h" 80 #include <rpm/rpmlog.h> 87 static bool val = [](){
88 const char *
env = getenv(
"TRANSACTIONAL_UPDATE");
100 #include <solv/repo_rpmdb.h> 101 #include <solv/chksum.h> 111 AutoDispose<Chksum*> chk { ::solv_chksum_create( REPOKEY_TYPE_SHA1 ), []( Chksum *chk ) ->
void {
112 ::solv_chksum_free( chk,
nullptr );
114 if ( ::rpm_hash_database_state( state, chk ) == 0 )
117 const unsigned char * md5 = ::solv_chksum_get( chk, &md5l );
121 WAR <<
"rpm_hash_database_state failed" << endl;
141 inline void sigMultiversionSpecChanged()
157 static const std::string strType(
"type" );
158 static const std::string strStage(
"stage" );
159 static const std::string strSolvable(
"solvable" );
161 static const std::string strTypeDel(
"-" );
162 static const std::string strTypeIns(
"+" );
163 static const std::string strTypeMul(
"M" );
165 static const std::string strStageDone(
"ok" );
166 static const std::string strStageFailed(
"err" );
168 static const std::string strSolvableN(
"n" );
169 static const std::string strSolvableE(
"e" );
170 static const std::string strSolvableV(
"v" );
171 static const std::string strSolvableR(
"r" );
172 static const std::string strSolvableA(
"a" );
179 case Transaction::TRANSACTION_IGNORE:
break;
180 case Transaction::TRANSACTION_ERASE: ret.
add( strType, strTypeDel );
break;
181 case Transaction::TRANSACTION_INSTALL: ret.
add( strType, strTypeIns );
break;
182 case Transaction::TRANSACTION_MULTIINSTALL: ret.
add( strType, strTypeMul );
break;
187 case Transaction::STEP_TODO:
break;
188 case Transaction::STEP_DONE: ret.
add( strStage, strStageDone );
break;
189 case Transaction::STEP_ERROR: ret.
add( strStage, strStageFailed );
break;
198 ident = solv.ident();
205 ident = step_r.
ident();
207 arch = step_r.
arch();
212 { strSolvableV, ed.
version() },
213 { strSolvableR, ed.
release() },
217 s.add( strSolvableE, epoch );
219 ret.
add( strSolvable, s );
231 for (
const Transaction::Step & step : steps_r )
233 if ( step.stepType() != Transaction::TRANSACTION_IGNORE )
248 class AssertMountedBase
260 MIL <<
"We mounted " <<
_mountpoint <<
" so we unmount it" << endl;
261 execute({
"umount",
"-R",
"-l",
_mountpoint.asString() });
269 for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
281 class AssertProcMounted :
private AssertMountedBase
284 AssertProcMounted( Pathname root_r )
287 if ( ! PathInfo(root_r/
"self").isDir() ) {
288 MIL <<
"Try to make sure proc is mounted at" << root_r << endl;
290 && execute({
"mount",
"-t",
"proc",
"/proc", root_r.asString() }) == 0 ) {
294 WAR <<
"Mounting proc at " << root_r <<
" failed" << endl;
302 class AssertDevMounted :
private AssertMountedBase
305 AssertDevMounted( Pathname root_r )
308 if ( ! PathInfo(root_r/
"null").isChr() ) {
309 MIL <<
"Try to make sure dev is mounted at" << root_r << endl;
314 && execute({
"mount",
"--rbind",
"--make-rslave",
"/dev", root_r.asString() }) == 0 ) {
318 WAR <<
"Mounting dev at " << root_r <<
" failed" << endl;
335 std::ifstream infile( historyFile_r.c_str() );
336 for( iostr::EachLine in( infile ); in; in.next() )
338 const char * ch( (*in).c_str() );
340 if ( *ch <
'1' ||
'9' < *ch )
342 const char * sep1 = ::strchr( ch,
'|' );
347 bool installs =
true;
348 if ( ::strncmp( sep1,
"install|", 8 ) )
350 if ( ::strncmp( sep1,
"remove |", 8 ) )
357 const char * sep2 = ::strchr( sep1,
'|' );
358 if ( !sep2 || sep1 == sep2 )
360 (*in)[sep2-ch] =
'\0';
365 onSystemByUserList.erase( pkg );
369 if ( (sep1 = ::strchr( sep2+1,
'|' ))
370 && (sep1 = ::strchr( sep1+1,
'|' ))
371 && (sep2 = ::strchr( sep1+1,
'|' )) )
373 (*in)[sep2-ch] =
'\0';
374 if ( ::strchr( sep1+1,
'@' ) )
377 onSystemByUserList.insert( pkg );
382 MIL <<
"onSystemByUserList found: " << onSystemByUserList.size() << endl;
383 return onSystemByUserList;
393 return PluginFrame( command_r, json::Object {
404 MIL <<
"Testcases to keep: " << toKeep << endl;
410 WAR <<
"No Target no Testcase!" << endl;
414 std::string stem(
"updateTestcase" );
415 Pathname dir( target->assertRootPrefix(
"/var/log/") );
419 std::list<std::string> content;
421 std::set<std::string> cases;
422 for_( c, content.begin(), content.end() )
427 if ( cases.size() >= toKeep )
429 unsigned toDel = cases.size() - toKeep + 1;
430 for_( c, cases.begin(), cases.end() )
439 MIL <<
"Write new testcase " << next << endl;
440 getZYpp()->resolver()->createSolverTestcase( next.asString(),
false );
457 std::pair<bool,PatchScriptReport::Action> doExecuteScript(
const Pathname & root_r,
467 for ( std::string output = prog.receiveLine(); output.length(); output = prog.receiveLine() )
472 WAR <<
"User request to abort script " << script_r << endl;
481 if ( prog.close() != 0 )
483 ret.second = report_r->problem( prog.execError() );
484 WAR <<
"ACTION" << ret.second <<
"(" << prog.execError() <<
")" << endl;
485 std::ostringstream sstr;
486 sstr << script_r <<
_(
" execution failed") <<
" (" << prog.execError() <<
")" << endl;
487 historylog.
comment(sstr.str(),
true);
499 bool executeScript(
const Pathname & root_r,
500 const Pathname & script_r,
501 callback::SendReport<PatchScriptReport> & report_r )
506 action = doExecuteScript( root_r, script_r, report_r );
510 switch ( action.second )
513 WAR <<
"User request to abort at script " << script_r << endl;
518 WAR <<
"User request to skip script " << script_r << endl;
528 INT <<
"Abort on unknown ACTION request " << action.second <<
" returned" << endl;
537 bool RunUpdateScripts(
const Pathname & root_r,
538 const Pathname & scriptsPath_r,
539 const std::vector<sat::Solvable> & checkPackages_r,
542 if ( checkPackages_r.empty() )
545 MIL <<
"Looking for new update scripts in (" << root_r <<
")" << scriptsPath_r << endl;
547 if ( ! PathInfo( scriptsDir ).isDir() )
550 std::list<std::string> scripts;
552 if ( scripts.empty() )
560 std::map<std::string, Pathname> unify;
561 for_( it, checkPackages_r.begin(), checkPackages_r.end() )
563 std::string prefix(
str::form(
"%s-%s", it->name().c_str(), it->edition().c_str() ) );
564 for_( sit, scripts.begin(), scripts.end() )
569 if ( (*sit)[prefix.size()] !=
'\0' && (*sit)[prefix.size()] !=
'-' )
572 PathInfo script( scriptsDir / *sit );
573 Pathname localPath( scriptsPath_r/(*sit) );
574 std::string unifytag;
576 if ( script.isFile() )
582 else if ( ! script.isExist() )
590 if ( unifytag.empty() )
594 if ( unify[unifytag].empty() )
596 unify[unifytag] = localPath;
603 std::string msg(
str::form(
_(
"%s already executed as %s)"), localPath.asString().c_str(), unify[unifytag].c_str() ) );
604 MIL <<
"Skip update script: " << msg << endl;
605 HistoryLog().comment( msg,
true );
609 if ( abort || aborting_r )
611 WAR <<
"Aborting: Skip update script " << *sit << endl;
612 HistoryLog().comment(
613 localPath.asString() +
_(
" execution skipped while aborting"),
618 MIL <<
"Found update script " << *sit << endl;
619 callback::SendReport<PatchScriptReport> report;
620 report->start( make<Package>( *it ), script.path() );
622 if ( ! executeScript( root_r, localPath, report ) )
634 inline void copyTo( std::ostream & out_r,
const Pathname & file_r )
636 std::ifstream infile( file_r.c_str() );
637 for( iostr::EachLine in( infile ); in; in.next() )
639 out_r << *in << endl;
643 inline std::string notificationCmdSubst(
const std::string & cmd_r,
const UpdateNotificationFile & notification_r )
645 std::string ret( cmd_r );
646 #define SUBST_IF(PAT,VAL) if ( ret.find( PAT ) != std::string::npos ) ret = str::gsub( ret, PAT, VAL ) 647 SUBST_IF(
"%p", notification_r.solvable().asString() );
648 SUBST_IF(
"%P", notification_r.file().asString() );
653 void sendNotification(
const Pathname & root_r,
656 if ( notifications_r.empty() )
660 MIL <<
"Notification command is '" << cmdspec <<
"'" << endl;
661 if ( cmdspec.empty() )
665 if ( pos == std::string::npos )
667 ERR <<
"Can't send Notification: Missing 'format |' in command spec." << endl;
668 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
673 std::string commandStr(
str::trim( cmdspec.substr( pos + 1 ) ) );
675 enum Format {
UNKNOWN, NONE, SINGLE, DIGEST, BULK };
677 if ( formatStr ==
"none" )
679 else if ( formatStr ==
"single" )
681 else if ( formatStr ==
"digest" )
683 else if ( formatStr ==
"bulk" )
687 ERR <<
"Can't send Notification: Unknown format '" << formatStr <<
" |' in command spec." << endl;
688 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
696 if ( format == NONE || format == SINGLE )
698 for_( it, notifications_r.begin(), notifications_r.end() )
700 std::vector<std::string> command;
701 if ( format == SINGLE )
703 str::splitEscaped( notificationCmdSubst( commandStr, *it ), std::back_inserter( command ) );
708 for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
712 int ret = prog.close();
715 ERR <<
"Notification command returned with error (" << ret <<
")." << endl;
716 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
722 else if ( format == DIGEST || format == BULK )
724 filesystem::TmpFile tmpfile;
725 std::ofstream out( tmpfile.path().c_str() );
726 for_( it, notifications_r.begin(), notifications_r.end() )
728 if ( format == DIGEST )
730 out << it->file() << endl;
732 else if ( format == BULK )
738 std::vector<std::string> command;
739 command.push_back(
"<"+tmpfile.path().asString() );
740 str::splitEscaped( notificationCmdSubst( commandStr, *notifications_r.begin() ), std::back_inserter( command ) );
745 for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
749 int ret = prog.close();
752 ERR <<
"Notification command returned with error (" << ret <<
")." << endl;
753 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
760 INT <<
"Can't send Notification: Missing handler for 'format |' in command spec." << endl;
761 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
772 void RunUpdateMessages(
const Pathname & root_r,
773 const Pathname & messagesPath_r,
774 const std::vector<sat::Solvable> & checkPackages_r,
775 ZYppCommitResult & result_r )
777 if ( checkPackages_r.empty() )
780 MIL <<
"Looking for new update messages in (" << root_r <<
")" << messagesPath_r << endl;
782 if ( ! PathInfo( messagesDir ).isDir() )
785 std::list<std::string> messages;
787 if ( messages.empty() )
793 HistoryLog historylog;
794 for_( it, checkPackages_r.begin(), checkPackages_r.end() )
796 std::string prefix(
str::form(
"%s-%s", it->name().c_str(), it->edition().c_str() ) );
797 for_( sit, messages.begin(), messages.end() )
802 if ( (*sit)[prefix.size()] !=
'\0' && (*sit)[prefix.size()] !=
'-' )
805 PathInfo message( messagesDir / *sit );
806 if ( ! message.isFile() || message.size() == 0 )
809 MIL <<
"Found update message " << *sit << endl;
810 Pathname localPath( messagesPath_r/(*sit) );
811 result_r.rUpdateMessages().push_back( UpdateNotificationFile( *it, localPath ) );
812 historylog.comment( str::Str() <<
_(
"New update message") <<
" " << localPath,
true );
815 sendNotification( root_r, result_r.updateMessages() );
821 void logPatchStatusChanges(
const sat::Transaction & transaction_r, TargetImpl & target_r )
824 if ( changedPseudoInstalled.empty() )
832 WAR <<
"Need to recompute the patch status changes as commit is incomplete!" << endl;
838 HistoryLog historylog;
839 for (
const auto & el : changedPseudoInstalled )
840 historylog.patchStateChange( el.first, el.second );
849 const std::vector<sat::Solvable> & checkPackages_r,
851 { RunUpdateMessages( root_r, messagesPath_r, checkPackages_r, result_r ); }
864 , _requestedLocalesFile( home() /
"RequestedLocales" )
865 , _autoInstalledFile( home() /
"AutoInstalled" )
866 , _hardLocksFile(
Pathname::assertprefix( _root,
ZConfig::instance().locksFile() ) )
867 , _vendorAttr(
Pathname::assertprefix( _root,
ZConfig::instance().vendorPath() ) )
874 sigMultiversionSpecChanged();
875 MIL <<
"Initialized target on " <<
_root << endl;
883 std::ifstream uuidprovider(
"/proc/sys/kernel/random/uuid" );
893 boost::function<
bool ()> condition,
894 boost::function<std::string ()> value )
896 std::string val = value();
904 MIL <<
"updating '" << filename <<
"' content." << endl;
908 std::ofstream filestr;
911 filestr.open( filename.
c_str() );
913 if ( filestr.good() )
949 WAR <<
"Can't create anonymous id file" << endl;
958 Pathname flavorpath(
home() /
"LastDistributionFlavor");
964 WAR <<
"No base product, I won't create flavor cache" << endl;
968 std::string flavor = p->flavor();
980 WAR <<
"Can't create flavor cache" << endl;
993 sigMultiversionSpecChanged();
994 MIL <<
"Closed target on " <<
_root << endl;
1018 Pathname rpmsolvcookie = base/
"cookie";
1020 bool build_rpm_solv =
true;
1030 MIL <<
"Read cookie: " << cookie << endl;
1035 if ( status == rpmstatus )
1036 build_rpm_solv =
false;
1037 MIL <<
"Read cookie: " << rpmsolvcookie <<
" says: " 1038 << (build_rpm_solv ?
"outdated" :
"uptodate") << endl;
1042 if ( build_rpm_solv )
1056 bool switchingToTmpSolvfile =
false;
1057 Exception ex(
"Failed to cache rpm database.");
1063 rpmsolv = base/
"solv";
1064 rpmsolvcookie = base/
"cookie";
1071 WAR <<
"Using a temporary solv file at " << base << endl;
1072 switchingToTmpSolvfile =
true;
1081 if ( ! switchingToTmpSolvfile )
1091 #ifdef ZYPP_RPMDB2SOLV_PATH 1092 cmd.push_back( ZYPP_RPMDB2SOLV_PATH );
1094 cmd.push_back(
"rpmdb2solv" );
1097 cmd.push_back(
"-r" );
1100 cmd.push_back(
"-D" );
1102 cmd.push_back(
"-X" );
1104 cmd.push_back(
"-p" );
1107 if ( ! oldSolvFile.
empty() )
1108 cmd.push_back( oldSolvFile.
asString() );
1110 cmd.push_back(
"-o" );
1114 std::string errdetail;
1117 WAR <<
" " << output;
1118 if ( errdetail.empty() ) {
1122 errdetail += output;
1125 int ret = prog.
close();
1146 if (
root() ==
"/" )
1157 if ( !
PathInfo(base/
"solv.idx").isExist() )
1160 return build_rpm_solv;
1178 MIL <<
"New cache built: " << (newCache?
"true":
"false") <<
1179 ", force loading: " << (force?
"true":
"false") << endl;
1184 MIL <<
"adding " << rpmsolv <<
" to pool(" << satpool.
systemRepoAlias() <<
")" << endl;
1191 if ( newCache || force )
1208 MIL <<
"adding " << rpmsolv <<
" to system" << endl;
1214 MIL <<
"Try to handle exception by rebuilding the solv-file" << endl;
1239 if (
PathInfo( historyFile ).isExist() )
1246 if ( onSystemByUser.find( ident ) == onSystemByUser.end() )
1247 onSystemByAuto.insert( ident );
1268 if (
PathInfo( needrebootFile ).isFile() )
1269 needrebootSpec.
parseFrom( needrebootFile );
1272 if (
PathInfo( needrebootDir ).isDir() )
1277 [&](
const Pathname & dir_r,
const char *
const str_r )->
bool 1279 if ( ! isRpmConfigBackup( str_r ) )
1281 Pathname needrebootFile { needrebootDir / str_r };
1282 if (
PathInfo( needrebootFile ).isFile() )
1283 needrebootSpec.
parseFrom( needrebootFile );
1294 if ( ! hardLocks.empty() )
1303 MIL <<
"Target loaded: " << system.
solvablesSize() <<
" resolvables" << endl;
1315 bool explicitDryRun = policy_r.
dryRun();
1325 if (
root() ==
"/" )
1339 MIL <<
"TargetImpl::commit(<pool>, " << policy_r <<
")" << endl;
1358 steps.push_back( *it );
1365 MIL <<
"Todo: " << result << endl;
1376 if ( commitPlugins )
1377 commitPlugins.
send( transactionPluginFrame(
"COMMITBEGIN", steps ) );
1384 if ( ! policy_r.
dryRun() )
1390 DBG <<
"dryRun: Not writing upgrade testcase." << endl;
1397 if ( ! policy_r.
dryRun() )
1419 DBG <<
"dryRun: Not storing non-package data." << endl;
1426 if ( ! policy_r.
dryRun() )
1428 for_( it, steps.begin(), steps.end() )
1430 if ( ! it->satSolvable().isKind<
Patch>() )
1438 if ( ! patch ||patch->message().empty() )
1441 MIL <<
"Show message for " << patch << endl;
1443 if ( ! report->show( patch ) )
1445 WAR <<
"commit aborted by the user" << endl;
1452 DBG <<
"dryRun: Not checking patch messages." << endl;
1467 std::unique_ptr<CommitPackagePreloader> preloader;
1473 preloader = std::make_unique<CommitPackagePreloader>();
1474 preloader->preloadTransaction( steps );
1475 miss = preloader->missed ();
1482 for_( it, steps.begin(), steps.end() )
1484 switch ( it->stepType() )
1503 localfile = packageCache.
get( pi );
1506 catch (
const AbortRequestException & exp )
1510 WAR <<
"commit cache preload aborted by the user" << endl;
1514 catch (
const SkipRequestException & exp )
1519 WAR <<
"Skipping cache preload package " << pi->asKind<
Package>() <<
" in commit" << endl;
1529 INT <<
"Unexpected Error: Skipping cache preload package " << pi->asKind<
Package>() <<
" in commit" << endl;
1540 ERR <<
"Some packages could not be provided. Aborting commit."<< endl;
1544 if ( ! policy_r.
dryRun() )
1552 commit( policy_r, packageCache, result );
1556 preloader->cleanupCaches ();
1560 DBG <<
"dryRun/downloadOnly: Not installing/deleting anything." << endl;
1561 if ( explicitDryRun ) {
1575 DBG <<
"dryRun: Not downloading/installing/deleting anything." << endl;
1576 if ( explicitDryRun ) {
1588 WAR <<
"(rpm removed in commit?) Inject missing /var/lib/rpm compat symlink to /usr/lib/sysimage/rpm" << endl;
1597 if ( commitPlugins )
1598 commitPlugins.
send( transactionPluginFrame(
"COMMITEND", steps ) );
1603 if ( ! policy_r.
dryRun() )
1608 MIL <<
"TargetImpl::commit(<pool>, " << policy_r <<
") returns: " << result << endl;
1619 struct NotifyAttemptToModify
1637 MIL <<
"TargetImpl::commit(<list>" << policy_r <<
")" << steps.size() << endl;
1642 NotifyAttemptToModify attemptToModify( result_r );
1647 AssertProcMounted assertProcMounted(
_root );
1648 AssertDevMounted assertDevMounted(
_root );
1651 std::vector<sat::Solvable> successfullyInstalledPackages;
1654 for_( step, steps.begin(), steps.end() )
1676 localfile = packageCache_r.
get( citem );
1678 catch (
const AbortRequestException &e )
1680 WAR <<
"commit aborted by the user" << endl;
1685 catch (
const SkipRequestException &e )
1688 WAR <<
"Skipping package " << p <<
" in commit" << endl;
1697 INT <<
"Unexpected Error: Skipping package " << p <<
" in commit" << endl;
1706 bool success =
false;
1730 if ( progress.aborted() )
1732 WAR <<
"commit aborted by the user" << endl;
1741 auto rebootNeededFile =
root() /
"/run/reboot-needed";
1757 WAR <<
"dry run failed" << endl;
1762 if ( progress.aborted() )
1764 WAR <<
"commit aborted by the user" << endl;
1769 WAR <<
"Install failed" << endl;
1775 if ( success && !policy_r.
dryRun() )
1778 successfullyInstalledPackages.push_back( citem.
satSolvable() );
1787 bool success =
false;
1798 if ( progress.aborted() )
1800 WAR <<
"commit aborted by the user" << endl;
1814 if ( progress.aborted() )
1816 WAR <<
"commit aborted by the user" << endl;
1822 WAR <<
"removal of " << p <<
" failed";
1825 if ( success && !policy_r.
dryRun() )
1832 else if ( ! policy_r.
dryRun() )
1836 if ( ! citem.
buddy() )
1843 ERR <<
"Can't install orphan product without release-package! " << citem << endl;
1849 std::string referenceFilename( p->referenceFilename() );
1850 if ( referenceFilename.empty() )
1852 ERR <<
"Can't remove orphan product without 'referenceFilename'! " << citem << endl;
1856 Pathname referencePath {
Pathname(
"/etc/products.d") / referenceFilename };
1857 if ( !
rpm().hasFile( referencePath.asString() ) )
1862 ERR <<
"Delete orphan product failed: " << referencePath << endl;
1866 WAR <<
"Won't remove orphan product: '/etc/products.d/" << referenceFilename <<
"' is owned by a package." << endl;
1895 if ( ! successfullyInstalledPackages.empty() )
1898 successfullyInstalledPackages, abort ) )
1900 WAR <<
"Commit aborted by the user" << endl;
1906 successfullyInstalledPackages,
1913 logPatchStatusChanges( result_r.
transaction(), *this );
1932 void sendLogline(
const std::string & line_r, ReportType::loglevel level_r = ReportType::loglevel::msg )
1935 data.
set(
"line", std::cref(line_r) );
1936 data.set(
"level", level_r );
1942 auto u2rpmlevel = [](
unsigned rpmlevel_r ) -> ReportType::loglevel {
1943 switch ( rpmlevel_r ) {
1944 case RPMLOG_EMERG: [[fallthrough]];
1945 case RPMLOG_ALERT: [[fallthrough]];
1947 return ReportType::loglevel::crt;
1949 return ReportType::loglevel::err;
1950 case RPMLOG_WARNING:
1951 return ReportType::loglevel::war;
1952 default: [[fallthrough]];
1953 case RPMLOG_NOTICE: [[fallthrough]];
1955 return ReportType::loglevel::msg;
1957 return ReportType::loglevel::dbg;
1965 { (*this)->report( userData_r ); }
1974 MIL <<
"TargetImpl::commit(<list>" << policy_r <<
")" << steps.size() << endl;
1979 NotifyAttemptToModify attemptToModify( result_r );
1985 AssertProcMounted assertProcMounted(
_root );
1986 AssertDevMounted assertDevMounted(
_root );
2000 proto::target::Commit
commit;
2010 for (
auto &[
_, value] : data ) {
2012 value.resetDispose();
2019 auto &step = steps[stepId];
2036 locCache.value()[stepId] = packageCache_r.
get( citem );
2038 proto::target::InstallStep tStep;
2039 tStep.stepId = stepId;
2040 tStep.pathname = locCache.
value()[stepId]->asString();
2041 tStep.multiversion = p->multiversionInstall() ;
2043 commit.transactionSteps.push_back( std::move(tStep) );
2045 catch (
const AbortRequestException &e )
2047 WAR <<
"commit aborted by the user" << endl;
2052 catch (
const SkipRequestException &e )
2055 WAR <<
"Skipping package " << p <<
" in commit" << endl;
2064 INT <<
"Unexpected Error: Skipping package " << p <<
" in commit" << endl;
2070 proto::target::RemoveStep tStep;
2071 tStep.stepId = stepId;
2072 tStep.name = p->name();
2073 tStep.version = p->edition().version();
2074 tStep.release = p->edition().release();
2075 tStep.arch = p->arch().asString();
2076 commit.transactionSteps.push_back(std::move(tStep));
2087 proto::target::InstallStep tStep;
2088 tStep.stepId = stepId;
2089 tStep.pathname = locCache.value()[stepId]->asString();
2090 tStep.multiversion =
false;
2091 commit.transactionSteps.push_back(std::move(tStep));
2095 INT <<
"Unexpected Error: Skipping package " << p <<
" in commit" << endl;
2102 std::vector<sat::Solvable> successfullyInstalledPackages;
2104 if (
commit.transactionSteps.size() ) {
2111 const std::vector<int> interceptedSignals {
2118 auto unixSignals = loop->eventDispatcher()->unixSignalSource();
2119 unixSignals->sigReceived ().connect ([](
int signum ){
2121 JobReport::error (
str::Format(
_(
"Received signal :\"%1% (%2%)\", to ensure the consistency of the system it is not possible to cancel a running rpm transaction.") ) % strsignal(signum) % signum );
2123 for(
const auto &sig : interceptedSignals )
2124 unixSignals->addSignal ( sig );
2127 for(
const auto &sig : interceptedSignals )
2128 unixSignals->removeSignal ( sig );
2135 int currentStepId = -1;
2141 bool gotEndOfScript =
false;
2144 std::unique_ptr<callback::SendReport <rpm::TransactionReportSA>> transactionreport;
2145 std::unique_ptr<callback::SendReport <rpm::InstallResolvableReportSA>> installreport;
2146 std::unique_ptr<callback::SendReport <rpm::RemoveResolvableReportSA>> uninstallreport;
2147 std::unique_ptr<callback::SendReport <rpm::CommitScriptReportSA>> scriptreport;
2148 std::unique_ptr<callback::SendReport <rpm::CleanupPackageReportSA>> cleanupreport;
2151 std::optional<proto::target::TransactionError> transactionError;
2154 std::string currentScriptType;
2155 std::string currentScriptPackage;
2165 unsigned lineno = 0;
2173 zyppng::StompFrameStreamRef msgStream;
2178 const auto &sendRpmLineToReport = [&](
const std::string &line ){
2180 const auto &sendLogRep = [&](
auto &report,
const auto &cType ){
2182 if ( currentStepId >= 0 )
2183 cmdout.
set(
"solvable", steps.at(currentStepId).satSolvable() );
2184 cmdout.
set(
"line", line );
2188 if ( installreport ) {
2189 sendLogRep( (*installreport), rpm::InstallResolvableReportSA::contentRpmout );
2190 }
else if ( uninstallreport ) {
2191 sendLogRep( (*uninstallreport), rpm::RemoveResolvableReportSA::contentRpmout );
2192 }
else if ( scriptreport ) {
2193 sendLogRep( (*scriptreport), rpm::CommitScriptReportSA::contentRpmout );
2194 }
else if ( transactionreport ) {
2195 sendLogRep( (*transactionreport), rpm::TransactionReportSA::contentRpmout );
2196 }
else if ( cleanupreport ) {
2197 sendLogRep( (*cleanupreport), rpm::CleanupPackageReportSA::contentRpmout );
2199 WAR <<
"Got rpm output without active report " << line;
2204 if ( line.find(
" scriptlet failed, " ) == std::string::npos )
2208 if ( line.back() !=
'\n' )
2214 const auto &processDataFromScriptFd = [&](){
2216 while ( scriptSource->canReadLine() ) {
2218 if ( gotEndOfScript )
2221 std::string l = scriptSource->readLine().asString();
2223 gotEndOfScript =
true;
2227 l = l.substr( 0, rawsize );
2229 L_DBG(
"zypp-rpm") <<
"[rpm> " << l;
2230 sendRpmLineToReport( l );
2233 scriptSource->sigReadyRead().connect( processDataFromScriptFd );
2236 const auto &waitForScriptEnd = [&]() {
2239 if ( gotEndOfScript )
2243 processDataFromScriptFd();
2246 while ( scriptSource->readFdOpen() && scriptSource->canRead() && !gotEndOfScript ) {
2249 scriptSource->waitForReadyRead( 100 );
2253 const auto &aboutToStartNewReport = [&](){
2255 if ( transactionreport || installreport || uninstallreport || scriptreport || cleanupreport ) {
2256 ERR <<
"There is still a running report, this is a bug" << std::endl;
2260 gotEndOfScript =
false;
2263 const auto &writeRpmMsgToHistory = [&](){
2264 if ( rpmmsg.size() == 0 )
2268 rpmmsg +=
"[truncated]\n";
2270 std::ostringstream sstr;
2271 sstr <<
"rpm output:" << endl << rpmmsg << endl;
2276 const auto &finalizeCurrentReport = [&]() {
2279 if ( currentStepId >= 0 ) {
2280 step = &steps.at(currentStepId);
2284 if ( installreport ) {
2292 writeRpmMsgToHistory();
2296 ( *installreport)->progress( 100, resObj );
2299 if ( currentStepId >= 0 )
2300 locCache.value().erase( currentStepId );
2301 successfullyInstalledPackages.push_back( step->
satSolvable() );
2307 auto rebootNeededFile =
root() /
"/run/reboot-needed";
2319 writeRpmMsgToHistory();
2322 if ( uninstallreport ) {
2330 writeRpmMsgToHistory();
2334 ( *uninstallreport)->progress( 100, resObj );
2344 writeRpmMsgToHistory();
2347 if ( scriptreport ) {
2349 ( *scriptreport)->progress( 100, resObj );
2352 if ( transactionreport ) {
2354 ( *transactionreport)->progress( 100 );
2357 if ( cleanupreport ) {
2359 ( *cleanupreport)->progress( 100 );
2365 currentScriptType.clear();
2366 currentScriptPackage.clear();
2367 installreport.reset();
2368 uninstallreport.reset();
2369 scriptreport.reset();
2370 transactionreport.reset();
2371 cleanupreport.reset();
2381 constexpr std::string_view zyppRpmBinary(ZYPP_RPM_BINARY);
2383 const char *argv[] = {
2386 zyppRpmBinary.data(),
2403 prog->addFd( messagePipe->writeFd );
2404 prog->addFd( scriptPipe->writeFd );
2407 if ( !scriptSource->openFds( std::vector<int>{ scriptPipe->readFd } ) )
2410 const auto &processMessages = [&] ( ) {
2414 const auto &checkMsgWithStepId = [&steps](
auto &p ){
2416 ERR <<
"Failed to parse message from zypp-rpm." << std::endl;
2420 auto id = p->stepId;
2421 if ( id < 0 || id >= steps.size() ) {
2422 ERR <<
"Received invalid stepId: " <<
id <<
" in " << p->typeName <<
" message from zypp-rpm, ignoring." << std::endl;
2428 while (
const auto &m = msgStream->nextMessage() ) {
2434 const auto &mName = m->command();
2435 if ( mName == proto::target::RpmLog::typeName ) {
2439 ERR <<
"Failed to parse " << proto::target::RpmLog::typeName <<
" message from zypp-rpm." << std::endl;
2442 ( p->level >= RPMLOG_ERR ?
L_ERR(
"zypp-rpm")
2443 : p->level >= RPMLOG_WARNING ?
L_WAR(
"zypp-rpm")
2444 :
L_DBG(
"zypp-rpm") ) <<
"[rpm " << p->level <<
"> " << p->line;
2447 }
else if ( mName == proto::target::PackageBegin::typeName ) {
2448 finalizeCurrentReport();
2451 if ( !checkMsgWithStepId( p ) )
2454 aboutToStartNewReport();
2456 auto & step = steps.at( p->stepId );
2457 currentStepId = p->stepId;
2459 uninstallreport = std::make_unique< callback::SendReport <rpm::RemoveResolvableReportSA> > ();
2460 ( *uninstallreport )->start(
makeResObject( step.satSolvable() ) );
2462 installreport = std::make_unique< callback::SendReport <rpm::InstallResolvableReportSA> > ();
2463 ( *installreport )->start(
makeResObject( step.satSolvable() ) );
2466 }
else if ( mName == proto::target::PackageFinished::typeName ) {
2468 if ( !checkMsgWithStepId( p ) )
2475 }
else if ( mName == proto::target::PackageProgress::typeName ) {
2477 if ( !checkMsgWithStepId( p ) )
2480 if ( uninstallreport )
2481 (*uninstallreport)->progress( p->amount,
makeResObject( steps.at( p->stepId ) ));
2482 else if ( installreport )
2483 (*installreport)->progress( p->amount,
makeResObject( steps.at( p->stepId ) ));
2485 ERR <<
"Received a " << mName <<
" message but there is no corresponding report running." << std::endl;
2487 }
else if ( mName == proto::target::PackageError::typeName ) {
2489 if ( !checkMsgWithStepId( p ) )
2492 if ( p->stepId >= 0 && p->stepId < steps.size() )
2495 finalizeCurrentReport();
2497 }
else if ( mName == proto::target::ScriptBegin::typeName ) {
2498 finalizeCurrentReport();
2502 ERR <<
"Failed to parse " << proto::target::ScriptBegin::typeName <<
" message from zypp-rpm." << std::endl;
2506 aboutToStartNewReport();
2509 const auto stepId = p->stepId;
2510 if ( stepId >= 0 && static_cast<size_t>(stepId) < steps.size() ) {
2514 currentStepId = p->stepId;
2515 scriptreport = std::make_unique< callback::SendReport <rpm::CommitScriptReportSA> > ();
2516 currentScriptType = p->scriptType;
2517 currentScriptPackage = p->scriptPackage;
2518 (*scriptreport)->start( currentScriptType, currentScriptPackage, resPtr );
2520 }
else if ( mName == proto::target::ScriptFinished::typeName ) {
2524 }
else if ( mName == proto::target::ScriptError::typeName ) {
2528 ERR <<
"Failed to parse " << proto::target::ScriptError::typeName <<
" message from zypp-rpm." << std::endl;
2533 const auto stepId = p->stepId;
2534 if ( stepId >= 0 && static_cast<size_t>(stepId) < steps.size() ) {
2544 str::form(
"Failed to execute %s script for %s ", currentScriptType.c_str(), currentScriptPackage.size() ? currentScriptPackage.c_str() :
"unknown" ),
2547 writeRpmMsgToHistory();
2549 if ( !scriptreport ) {
2550 ERR <<
"Received a ScriptError message, but there is no running report. " << std::endl;
2559 scriptreport.reset();
2562 }
else if ( mName == proto::target::CleanupBegin::typeName ) {
2563 finalizeCurrentReport();
2567 ERR <<
"Failed to parse " << proto::target::CleanupBegin::typeName <<
" message from zypp-rpm." << std::endl;
2571 aboutToStartNewReport();
2572 cleanupreport = std::make_unique< callback::SendReport <rpm::CleanupPackageReportSA> > ();
2573 (*cleanupreport)->start( beg->nvra );
2574 }
else if ( mName == proto::target::CleanupFinished::typeName ) {
2576 finalizeCurrentReport();
2578 }
else if ( mName == proto::target::CleanupProgress::typeName ) {
2581 ERR <<
"Failed to parse " << proto::target::CleanupProgress::typeName <<
" message from zypp-rpm." << std::endl;
2585 if ( !cleanupreport ) {
2586 ERR <<
"Received a CleanupProgress message, but there is no running report. " << std::endl;
2590 (*cleanupreport)->progress( prog->amount );
2592 }
else if ( mName == proto::target::TransBegin::typeName ) {
2593 finalizeCurrentReport();
2597 ERR <<
"Failed to parse " << proto::target::TransBegin::typeName <<
" message from zypp-rpm." << std::endl;
2601 aboutToStartNewReport();
2602 transactionreport = std::make_unique< callback::SendReport <rpm::TransactionReportSA> > ();
2603 (*transactionreport)->start( beg->name );
2604 }
else if ( mName == proto::target::TransFinished::typeName ) {
2606 finalizeCurrentReport();
2608 }
else if ( mName == proto::target::TransProgress::typeName ) {
2611 ERR <<
"Failed to parse " << proto::target::TransProgress::typeName <<
" message from zypp-rpm." << std::endl;
2615 if ( !transactionreport ) {
2616 ERR <<
"Received a TransactionProgress message, but there is no running report. " << std::endl;
2620 (*transactionreport)->progress( prog->amount );
2621 }
else if ( mName == proto::target::TransactionError::typeName ) {
2625 ERR <<
"Failed to parse " << proto::target::TransactionError::typeName <<
" message from zypp-rpm." << std::endl;
2630 transactionError = std::move(*error);
2633 ERR <<
"Received unexpected message from zypp-rpm: "<< m->command() <<
", ignoring" << std::endl;
2641 prog->sigStarted().connect( [&](){
2644 messagePipe->unrefWrite();
2645 scriptPipe->unrefWrite();
2649 while( prog->canReadLine( channel ) ) {
2650 L_ERR(
"zypp-rpm") << ( channel ==
zyppng::Process::StdOut ?
"<stdout> " :
"<stderr> " ) << prog->channelReadLine( channel ).asStringView();
2656 if ( !msgSource->openFds( std::vector<int>{ messagePipe->readFd }, prog->stdinFd() ) )
2662 const auto &msg =
commit.toStompMessage();
2664 std::rethrow_exception ( msg.error() );
2666 if ( !msgStream->sendMessage( *msg ) ) {
2667 prog->stop( SIGKILL );
2673 int zyppRpmExitCode = -1;
2675 zyppRpmExitCode = code;
2679 if ( !prog->start( argv ) ) {
2688 msgStream->readAllMessages();
2695 finalizeCurrentReport();
2698 bool readMsgs =
false;
2708 while ( scriptSource->canReadLine() ) {
2710 MIL <<
"rpm-script-fd: " << scriptSource->readLine().asStringView();
2712 if ( scriptSource->bytesAvailable() > 0 ) {
2714 MIL <<
"rpm-script-fd: " << scriptSource->readAll().asStringView();
2719 switch ( zyppRpmExitCode ) {
2721 case zypprpm::NoError:
2722 case zypprpm::RpmFinishedWithError:
2724 case zypprpm::RpmFinishedWithTransactionError: {
2726 if ( transactionError ) {
2728 std::ostringstream sstr;
2729 sstr <<
_(
"Executing the transaction failed because of the following problems:") <<
"\n";
2730 for (
const auto & err : transactionError->problems ) {
2731 sstr <<
" " << err <<
"\n";
2741 case zypprpm::FailedToOpenDb:
2744 case zypprpm::WrongHeaderSize:
2745 case zypprpm::WrongMessageFormat:
2748 case zypprpm::RpmInitFailed:
2751 case zypprpm::FailedToReadPackage:
2754 case zypprpm::FailedToAddStepToTransaction:
2757 case zypprpm::RpmOrderFailed:
2760 case zypprpm::FailedToCreateLock:
2766 auto &step = steps[stepId];
2778 ERR <<
"Can't install orphan product without release-package! " << citem << endl;
2782 std::string referenceFilename( p->referenceFilename() );
2784 if ( referenceFilename.empty() ) {
2785 ERR <<
"Can't remove orphan product without 'referenceFilename'! " << citem << endl;
2787 Pathname referencePath {
Pathname(
"/etc/products.d") / referenceFilename };
2789 if ( !
rpm().hasFile( referencePath.asString() ) ) {
2793 ERR <<
"Delete orphan product failed: " << referencePath << endl;
2795 WAR <<
"Won't remove orphan product: '/etc/products.d/" << referenceFilename <<
"' is owned by a package." << endl;
2809 if ( ! successfullyInstalledPackages.empty() )
2812 successfullyInstalledPackages, abort ) )
2814 WAR <<
"Commit aborted by the user" << endl;
2820 successfullyInstalledPackages,
2827 logPatchStatusChanges( result_r.
transaction(), *this );
2855 if ( baseproduct.isFile() )
2868 ERR <<
"baseproduct symlink is dangling or missing: " << baseproduct << endl;
2873 inline Pathname staticGuessRoot(
const Pathname & root_r )
2875 if ( root_r.empty() )
2880 return Pathname(
"/");
2886 inline std::string firstNonEmptyLineIn(
const Pathname & file_r )
2888 std::ifstream idfile( file_r.c_str() );
2889 for( iostr::EachLine in( idfile ); in; in.next() )
2892 if ( ! line.empty() )
2895 return std::string();
2906 if ( p->isTargetDistribution() )
2914 const Pathname needroot( staticGuessRoot(root_r) );
2915 const Target_constPtr target( getZYpp()->getTarget() );
2916 if ( target && target->root() == needroot )
2917 return target->requestedLocales();
2923 MIL <<
"updateAutoInstalled if changed..." << endl;
2931 {
return baseproductdata(
_root ).registerTarget(); }
2934 {
return baseproductdata( staticGuessRoot(root_r) ).registerTarget(); }
2937 {
return baseproductdata(
_root ).registerRelease(); }
2940 {
return baseproductdata( staticGuessRoot(root_r) ).registerRelease();}
2943 {
return baseproductdata(
_root ).registerFlavor(); }
2946 {
return baseproductdata( staticGuessRoot(root_r) ).registerFlavor();}
2979 const Pathname & needroot = staticGuessRoot(root_r);
2997 return firstNonEmptyLineIn(
home() /
"LastDistributionFlavor" );
3002 return firstNonEmptyLineIn( staticGuessRoot(root_r) /
"/var/lib/zypp/LastDistributionFlavor" );
3008 std::string guessAnonymousUniqueId(
const Pathname & root_r )
3011 std::string ret( firstNonEmptyLineIn( root_r /
"/var/lib/zypp/AnonymousUniqueId" ) );
3012 if ( ret.
empty() && root_r !=
"/" )
3015 ret = firstNonEmptyLineIn(
"/var/lib/zypp/AnonymousUniqueId" );
3023 return guessAnonymousUniqueId(
root() );
3028 return guessAnonymousUniqueId( staticGuessRoot(root_r) );
3035 MIL <<
"New VendorAttr: " << vendorAttr_r << endl;
std::string asString(const Patch::Category &obj)
static bool fileMissing(const Pathname &pathname)
helper functor
std::string toLower(const std::string &s)
Return lowercase version of s.
ZYppCommitResult commit(ResPool pool_r, const ZYppCommitPolicy &policy_r)
Commit changes in the pool.
VendorAttr _vendorAttr
vendor equivalence settings.
TraitsType::constPtrType constPtr
Interface to the rpm program.
Convenience SendReport<rpm::SingleTransReport> wrapper.
TraitsType::constPtrType constPtr
const Pathname & root() const
Remembered root directory of the target.
zypp::RepoStatus RepoStatus
sat::Transaction getTransaction()
Return the Transaction computed by the last solver run.
int assert_file(const Pathname &path, unsigned mode)
Create an empty file if it does not yet exist.
bool upgradingRepos() const
Whether there is at least one UpgradeRepo request pending.
A Solvable object within the sat Pool.
Save and restore locale set from file.
static bool error(const std::string &msg_r, const UserData &userData_r=UserData())
send error text
Namespace intended to collect all environment variables we use.
Alternating download and install.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
static Ptr create(IODevice::Ptr iostr)
ZYppCommitPolicy & rpmNoSignature(bool yesNo_r)
Use rpm option –nosignature (default: false)
const LocaleSet & getRequestedLocales() const
Return the requested locales.
ManagedFile provideSrcPackage(const SrcPackage_constPtr &srcPackage_r) const
Provide SrcPackage in a local file.
[M] Install(multiversion) item (
unsigned splitEscaped(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \, bool withEmpty=false)
Split line_r into words with respect to escape delimeters.
bool solvfilesPathIsTemp() const
Whether we're using a temp.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Solvable satSolvable() const
Return the corresponding Solvable.
Result returned from ZYpp::commit.
void updateFileContent(const Pathname &filename, boost::function< bool()> condition, boost::function< std::string()> value)
updates the content of filename if condition is true, setting the content the the value returned by v...
static ZConfig & instance()
Singleton ctor.
First download all packages to the local cache.
bool isToBeInstalled() const
void addSolv(const Pathname &file_r)
Load Solvables from a solv-file.
std::string md5sum(const Pathname &file)
Compute a files md5sum.
Command frame for communication with PluginScript.
Pathname _tmpSolvfilesPath
int readlink(const Pathname &symlink_r, Pathname &target_r)
Like 'readlink'.
void setData(const Data &data_r)
Store new Data.
IMPL_PTR_TYPE(TargetImpl)
SolvIdentFile _autoInstalledFile
user/auto installed database
SignalProxy< void(int)> sigFinished()
std::string asJSON() const
JSON representation.
static ProductFileData scanFile(const Pathname &file_r)
Parse one file (or symlink) and return the ProductFileData parsed.
String matching (STRING|SUBSTRING|GLOB|REGEX).
TargetImpl(const Pathname &root_r="/", bool doRebuild_r=false)
Ctor.
void stampCommand()
Log info about the current process.
Target::commit helper optimizing package provision.
bool isNeedreboot() const
ZYppCommitPolicy & rpmInstFlags(target::rpm::RpmInstFlags newFlags_r)
The default target::rpm::RpmInstFlags.
TransactionStepList & rTransactionStepList()
Manipulate transactionStepList.
std::unordered_set< Locale > LocaleSet
const sat::Transaction & transaction() const
The full transaction list.
void discardScripts()
Discard all remembered scripts and/or or dump_posttrans lines.
StepStage stepStage() const
Step action result.
const Pathname & file() const
Return the file path.
int chmod(const Pathname &path, mode_t mode)
Like 'chmod'.
int dirForEach(const Pathname &dir_r, const StrMatcher &matcher_r, function< bool(const Pathname &, const char *const)> fnc_r)
ResStatus & status() const
Returns the current status.
void installPackage(const Pathname &filename, RpmInstFlags flags=RPMINST_NONE)
install rpm package
ZYppCommitPolicy & dryRun(bool yesNo_r)
Set dry run (default: false).
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
byKind_iterator byKindBegin(const ResKind &kind_r) const
void updateAutoInstalled()
Update the database of autoinstalled packages.
ZYppCommitPolicy & rpmExcludeDocs(bool yesNo_r)
Use rpm option –excludedocs (default: false)
const char * c_str() const
String representation.
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.
detail::IdType value_type
void setAutoInstalled(const Queue &autoInstalled_r)
Set ident list of all autoinstalled solvables.
sat::Solvable buddy() const
Return the buddy we share our status object with.
std::string getline(std::istream &str)
Read one line from stream.
Access to the sat-pools string space.
Libsolv transaction wrapper.
Edition represents [epoch:]version[-release]
Attempts to create a lock to prevent the system from going into hibernate/shutdown.
std::string receiveLine()
Read one line from the input stream.
std::list< UpdateNotificationFile > UpdateNotifications
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...
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::...
std::list< PoolItem > PoolItemList
list of pool items
const_iterator end() const
Iterator behind the last TransactionStep.
Provide a new empty temporary file and delete it when no longer needed.
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.
Class representing a patch.
void installSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Install a source package on the Target.
std::string targetDistributionFlavor() const
This is register.flavor attribute of the installed base product.
bool compatibleWith(const Arch &targetArch_r) const
Compatibility relation.
int recursive_rmdir(const Pathname &path)
Like 'rm -r DIR'.
void install(const PoolItem &pi)
Log installation (or update) of a package.
ResObject::constPtr resolvable() const
Returns the ResObject::constPtr.
ChangedPseudoInstalled changedPseudoInstalled() const
Return all pseudo installed items whose current state differs from their initial one.
std::string targetDistributionRelease() const
This is register.release attribute of the installed base product.
Define a set of Solvables by ident and provides.
Extract and remember posttrans scripts for later execution.
TraitsType::constPtrType constPtr
SignalProxy< void()> sigMessageReceived()
expected< T > fromStompMessage(const zypp::PluginFrame &message)
void remember(const Exception &old_r)
Store an other Exception as history.
EstablishedStates establishedStates() const
Factory for EstablishedStates.
rpm::RpmDb _rpm
RPM database.
Repository systemRepo()
Return the system repository, create it if missing.
std::string distributionVersion() const
This is version attribute of the installed base product.
const LocaleSet & locales() const
Return the loacale set.
void createLastDistributionFlavorCache() const
generates a cache of the last product flavor
void initRequestedLocales(const LocaleSet &locales_r)
Start tracking changes based on this locales_r.
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...
LocaleSet requestedLocales() const
Languages to be supported by the system.
[ ] Nothing (includes implicit deletes due to obsoletes and non-package actions)
bool empty() const
Test for an empty path.
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 StrMatcher & matchNoDots()
Convenience returning StrMatcher( "[^.]*", Match::GLOB )
Store and operate on date (time_t).
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
std::string shortName() const
static Pool instance()
Singleton ctor.
const Data & data() const
Return the data.
std::string version() const
Version.
Pathname _root
Path to the target.
int touch(const Pathname &path)
Change file's modification and access times.
std::string rpmDbStateHash(const Pathname &root_r)
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)
bool set(const std::string &key_r, AnyType val_r)
Set the value for key (nonconst version always returns true).
pool::PoolTraits::HardLockQueries Data
static const std::string & systemRepoAlias()
Reserved system repository alias .
TraitsType::constPtrType constPtr
static const Pathname & fname()
Get the current log file path.
const std::string & asString() const
String representation.
void send(const PluginFrame &frame_r)
Send PluginFrame to all open plugins.
Just download all packages to the local cache.
Options and policies for ZYpp::commit.
bool isExist() const
Return whether valid stat info exists.
libzypp will decide what to do.
db_const_iterator() ZYPP_DEPRECATED
Open the default rpmdb below the host system (at /).
A single step within a Transaction.
ZYppCommitPolicy & downloadMode(DownloadMode val_r)
Commit download policy to use.
void parseFrom(const InputStream &istr_r)
Parse file istr_r and add its specs (one per line, #-comments).
RequestedLocalesFile _requestedLocalesFile
Requested Locales database.
void setLocales(const LocaleSet &locales_r)
Store a new locale set.
Pathname rootDir() const
Get rootdir (for file conflicts check)
void getHardLockQueries(HardLockQueries &activeLocks_r)
Suggest a new set of queries based on the current selection.
Pathname dirname() const
Return all but the last component od this path.
static Pathname assertprefix(const Pathname &root_r, const Pathname &path_r)
Return path_r prefixed with root_r, unless it is already prefixed.
ChangedPseudoInstalled changedPseudoInstalled() const
Return all pseudo installed items whose current state differs from the established one...
std::string release() const
Release.
Interim helper class to collect global options and settings.
Definition of vendor equivalence.
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
bool startsWith(const C_Str &str_r, const C_Str &prefix_r)
alias for hasPrefix
int close() override
Wait for the progamm to complete.
void sendLoglineRpm(const std::string &line_r, unsigned rpmlevel_r)
Convenience to send a contentLogline translating a rpm loglevel.
unsigned int epoch_t
Type of an epoch.
std::string summary() const
bool order()
Order transaction steps for commit.
Pathname solvfilesPath() const
The solv file location actually in use (default or temp).
void updateSolvFileIndex(const Pathname &solvfile_r)
Create solv file content digest for zypper bash completion.
std::string targetDistribution() const
This is register.target attribute of the installed base product.
Resolver & resolver() const
The Resolver.
Writing the zypp history fileReference counted signleton for writhing the zypp history file...
void executeScripts(rpm::RpmDb &rpm_r)
Execute the remembered scripts and/or or dump_posttrans lines.
const VendorAttr & vendorAttr() const
The targets current vendor equivalence settings.
void initDatabase(Pathname root_r=Pathname(), bool doRebuild_r=false)
Prepare access to the rpm database below root_r.
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
TraitsType::constPtrType constPtr
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::string anonymousUniqueId() const
anonymous unique id
static PoolImpl & myPool()
RepoStatus rpmDbRepoStatus(const Pathname &root_r)
const char * c_str() const
Conversion to const char *
std::vector< std::string > Arguments
bool endsWith(const C_Str &str_r, const C_Str &prefix_r)
alias for hasSuffix
int unlink(const Pathname &path)
Like 'unlink'.
Pathname home() const
The directory to store things.
void addProvides(Capability provides_r)
A all sat::Solvable matching this provides_r.
static std::string generateRandomId()
generates a random id using uuidgen
void resetDispose()
Set no dispose function.
ManagedFile get(const PoolItem &citem_r)
Provide a package.
HardLocksFile _hardLocksFile
Hard-Locks database.
void add(Value val_r)
Push JSON Value to Array.
static void setRoot(const Pathname &root)
Set new root directory to the default history log file path.
byKind_iterator byKindEnd(const ResKind &kind_r) const
void setHardLockQueries(const HardLockQueries &newLocks_r)
Set a new set of queries.
void setSingleTransactionMode(bool yesno_r)
#define SUBST_IF(PAT, VAL)
Libsolv Id queue wrapper.
int symlink(const Pathname &oldpath, const Pathname &newpath)
Like 'symlink'.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
SignalProxy< void(uint)> sigChannelReadyRead()
Product::constPtr baseProduct() const
returns the target base installed product, also known as the distribution or platform.
EstablishedStates::ChangedPseudoInstalled ChangedPseudoInstalled
Map holding pseudo installed items where current and established status differ.
void createAnonymousId() const
generates the unique anonymous id which is called when creating the target
ZYppCommitPolicy & allMedia()
Process all media (default)
const_iterator begin() const
Iterator to the first TransactionStep.
~TargetImpl() override
Dtor.
#define NON_MOVABLE(CLASS)
Delete move ctor and move assign.
StepType stepType() const
Type of action to perform in this step.
const Data & data() const
Return the data.
Base class for Exception.
bool preloaded() const
Whether preloaded hint is set.
const std::string & command() const
The command we're executing.
const Pathname & root() const
static std::optional< Pipe > create(int flags=0)
reference value() const
Reference to the Tp object.
const Pathname & dbPath() const
void load(const Pathname &path_r)
Find and launch plugins sending PLUGINBEGIN.
Data returned by ProductFileReader.
static Date now()
Return the current time.
void remove(const PoolItem &pi)
Log removal of a package.
bool TRANSACTIONAL_UPDATE()
void add(String key_r, Value val_r)
Add key/value pair.
void removePackage(const std::string &name_r, RpmInstFlags flags=RPMINST_NONE)
remove rpm package
std::vector< sat::Transaction::Step > TransactionStepList
Typesafe passing of user data via callbacks.
json::Value toJSON(const sat::Transaction::Step &step_r)
See commitbegin on page plugin-commit for the specs.
bool strToBool(const C_Str &str, bool default_r)
Parse str into a bool depending on the default value.
epoch_t epoch() const
Epoch.
std::string distroverpkg() const
Package telling the "product version" on systems not using /etc/product.d/baseproduct.
Pathname root() const
The root set for this target.
void setNeedrebootSpec(sat::SolvableSpec needrebootSpec_r)
Solvables which should trigger the reboot-needed hint if installed/updated.
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
void eraseFromPool()
Remove this Repository from its Pool.
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).
#define NON_COPYABLE(CLASS)
Delete copy ctor and copy assign.
Wrapper class for ::stat/::lstat.
Arch systemArchitecture() const
The system architecture zypp uses.
bool solvablesEmpty() const
Whether Repository contains solvables.
sat::Transaction & rTransaction()
Manipulate transaction.
Combining sat::Solvable and ResStatus.
bool singleTransModeEnabled() const
Whether the single_rpmtrans backend is enabled (or the classic_rpmtrans)
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.
Target::DistributionLabel distributionLabel() const
This is shortName and summary attribute of the installed base product.
Track changing files or directories.
std::string asString() const
Conversion to std::string
bool isKind(const ResKind &kind_r) const
const std::string & asString() const
std::unordered_set< IdString > Data
void XRunUpdateMessages(const Pathname &root_r, const Pathname &messagesPath_r, const std::vector< sat::Solvable > &checkPackages_r, ZYppCommitResult &result_r)
static zypp::Pathname lockfileDir()
std::string distributionFlavor() const
This is flavor attribute of the installed base product but does not require the target to be loaded a...
int rename(const Pathname &oldpath, const Pathname &newpath)
Like 'rename'.
size_type solvablesSize() const
Number of solvables in Repository.
ResObject::Ptr makeResObject(const sat::Solvable &solvable_r)
Create ResObject from sat::Solvable.
void commitInSingleTransaction(const ZYppCommitPolicy &policy_r, CommitPackageCache &packageCache_r, ZYppCommitResult &result_r)
Commit ordered changes (internal helper)
Easy-to use interface to the ZYPP dependency resolver.
Pathname defaultSolvfilesPath() const
The systems default solv file location.
Solvable satSolvable() const
Return the corresponding sat::Solvable.
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
void setCommitList(std::vector< sat::Solvable > commitList_r)
Download(commit) sequence of solvables to compute read ahead.
bool empty() const
Whether this is an empty object without valid data.
void report(const callback::UserData &userData_r)
rpm::RpmDb & rpm()
The RPM database.
void multiversionSpecChanged()
#define MAXRPMMESSAGELINES
ZYppCommitResult & _result
static ResPool instance()
Singleton ctor.
void sendLogline(const std::string &line_r, ReportType::loglevel level_r=ReportType::loglevel::msg)
Convenience to send a contentLogline.
void load(bool force=true)