19 #include <sys/types.h>
67 #include <solv/repo_rpmdb.h>
77 AutoDispose<Chksum*> chk { ::solv_chksum_create( REPOKEY_TYPE_SHA1 ), []( Chksum *chk ) ->
void {
78 ::solv_chksum_free( chk,
nullptr );
80 if ( ::rpm_hash_database_state(
state, chk ) == 0 )
83 const unsigned char * md5 = ::solv_chksum_get( chk, &md5l );
87 WAR <<
"rpm_hash_database_state failed" << endl;
107 inline void sigMultiversionSpecChanged()
125 for (
const Transaction::Step & step : steps_r )
127 if ( step.stepType() != Transaction::TRANSACTION_IGNORE )
137 static const std::string strType(
"type" );
138 static const std::string strStage(
"stage" );
139 static const std::string strSolvable(
"solvable" );
141 static const std::string strTypeDel(
"-" );
142 static const std::string strTypeIns(
"+" );
143 static const std::string strTypeMul(
"M" );
145 static const std::string strStageDone(
"ok" );
146 static const std::string strStageFailed(
"err" );
148 static const std::string strSolvableN(
"n" );
149 static const std::string strSolvableE(
"e" );
150 static const std::string strSolvableV(
"v" );
151 static const std::string strSolvableR(
"r" );
152 static const std::string strSolvableA(
"a" );
159 case Transaction::TRANSACTION_IGNORE:
break;
160 case Transaction::TRANSACTION_ERASE: ret.
add( strType, strTypeDel );
break;
161 case Transaction::TRANSACTION_INSTALL: ret.
add( strType, strTypeIns );
break;
162 case Transaction::TRANSACTION_MULTIINSTALL: ret.
add( strType, strTypeMul );
break;
167 case Transaction::STEP_TODO:
break;
168 case Transaction::STEP_DONE: ret.
add( strStage, strStageDone );
break;
169 case Transaction::STEP_ERROR: ret.
add( strStage, strStageFailed );
break;
178 ident = solv.ident();
185 ident = step_r.
ident();
187 arch = step_r.
arch();
192 { strSolvableV, ed.
version() },
193 { strSolvableR, ed.
release() },
197 s.add( strSolvableE, epoch );
199 ret.
add( strSolvable, s );
218 std::ifstream infile( historyFile_r.c_str() );
219 for( iostr::EachLine in( infile ); in; in.next() )
221 const char * ch( (*in).c_str() );
223 if ( *ch <
'1' ||
'9' < *ch )
225 const char * sep1 = ::strchr( ch,
'|' );
230 bool installs =
true;
231 if ( ::strncmp( sep1,
"install|", 8 ) )
233 if ( ::strncmp( sep1,
"remove |", 8 ) )
240 const char * sep2 = ::strchr( sep1,
'|' );
241 if ( !sep2 || sep1 == sep2 )
243 (*in)[sep2-ch] =
'\0';
244 IdString pkg( sep1 );
248 onSystemByUserList.erase( pkg );
252 if ( (sep1 = ::strchr( sep2+1,
'|' ))
253 && (sep1 = ::strchr( sep1+1,
'|' ))
254 && (sep2 = ::strchr( sep1+1,
'|' )) )
256 (*in)[sep2-ch] =
'\0';
257 if ( ::strchr( sep1+1,
'@' ) )
260 onSystemByUserList.insert( pkg );
265 MIL <<
"onSystemByUserList found: " << onSystemByUserList.size() << endl;
266 return onSystemByUserList;
276 return PluginFrame( command_r, json::Object {
277 {
"TransactionStepList", steps_r }
287 MIL <<
"Testcases to keep: " << toKeep << endl;
290 Target_Ptr target( getZYpp()->getTarget() );
293 WAR <<
"No Target no Testcase!" << endl;
297 std::string stem(
"updateTestcase" );
298 Pathname dir( target->assertRootPrefix(
"/var/log/") );
302 std::list<std::string> content;
304 std::set<std::string> cases;
305 for_( c, content.begin(), content.end() )
310 if ( cases.size() >= toKeep )
312 unsigned toDel = cases.size() - toKeep + 1;
313 for_( c, cases.begin(), cases.end() )
322 MIL <<
"Write new testcase " << next << endl;
323 getZYpp()->resolver()->createSolverTestcase( next.
asString(),
false );
340 std::pair<bool,PatchScriptReport::Action> doExecuteScript(
const Pathname & root_r,
350 for ( std::string output = prog.receiveLine(); output.length(); output = prog.receiveLine() )
355 WAR <<
"User request to abort script " << script_r << endl;
364 if ( prog.close() != 0 )
366 ret.second = report_r->problem( prog.execError() );
367 WAR <<
"ACTION" << ret.second <<
"(" << prog.execError() <<
")" << endl;
368 std::ostringstream sstr;
369 sstr << script_r <<
_(
" execution failed") <<
" (" << prog.execError() <<
")" << endl;
370 historylog.
comment(sstr.str(),
true);
382 bool executeScript(
const Pathname & root_r,
383 const Pathname & script_r,
384 callback::SendReport<PatchScriptReport> & report_r )
389 action = doExecuteScript( root_r, script_r, report_r );
393 switch ( action.second )
396 WAR <<
"User request to abort at script " << script_r << endl;
401 WAR <<
"User request to skip script " << script_r << endl;
411 INT <<
"Abort on unknown ACTION request " << action.second <<
" returned" << endl;
420 bool RunUpdateScripts(
const Pathname & root_r,
421 const Pathname & scriptsPath_r,
422 const std::vector<sat::Solvable> & checkPackages_r,
425 if ( checkPackages_r.empty() )
428 MIL <<
"Looking for new update scripts in (" << root_r <<
")" << scriptsPath_r << endl;
430 if ( ! PathInfo( scriptsDir ).isDir() )
433 std::list<std::string> scripts;
435 if ( scripts.empty() )
443 std::map<std::string, Pathname> unify;
444 for_( it, checkPackages_r.begin(), checkPackages_r.end() )
446 std::string prefix(
str::form(
"%s-%s", it->name().c_str(), it->edition().c_str() ) );
447 for_( sit, scripts.begin(), scripts.end() )
452 if ( (*sit)[prefix.size()] !=
'\0' && (*sit)[prefix.size()] !=
'-' )
455 PathInfo script( scriptsDir / *sit );
456 Pathname localPath( scriptsPath_r/(*sit) );
457 std::string unifytag;
459 if ( script.isFile() )
465 else if ( ! script.isExist() )
473 if ( unifytag.empty() )
477 if ( unify[unifytag].empty() )
479 unify[unifytag] = localPath;
486 std::string msg(
str::form(
_(
"%s already executed as %s)"), localPath.asString().c_str(), unify[unifytag].c_str() ) );
487 MIL <<
"Skip update script: " << msg << endl;
488 HistoryLog().comment( msg,
true );
492 if ( abort || aborting_r )
494 WAR <<
"Aborting: Skip update script " << *sit << endl;
495 HistoryLog().comment(
496 localPath.asString() +
_(
" execution skipped while aborting"),
501 MIL <<
"Found update script " << *sit << endl;
502 callback::SendReport<PatchScriptReport>
report;
503 report->start( make<Package>( *it ), script.path() );
505 if ( ! executeScript( root_r, localPath,
report ) )
517 inline void copyTo( std::ostream & out_r,
const Pathname & file_r )
519 std::ifstream infile( file_r.c_str() );
520 for( iostr::EachLine in( infile ); in; in.next() )
522 out_r << *in << endl;
526 inline std::string notificationCmdSubst(
const std::string & cmd_r,
const UpdateNotificationFile & notification_r )
528 std::string ret( cmd_r );
529 #define SUBST_IF(PAT,VAL) if ( ret.find( PAT ) != std::string::npos ) ret = str::gsub( ret, PAT, VAL )
530 SUBST_IF(
"%p", notification_r.solvable().asString() );
531 SUBST_IF(
"%P", notification_r.file().asString() );
536 void sendNotification(
const Pathname & root_r,
539 if ( notifications_r.empty() )
543 MIL <<
"Notification command is '" << cmdspec <<
"'" << endl;
544 if ( cmdspec.empty() )
548 if ( pos == std::string::npos )
550 ERR <<
"Can't send Notification: Missing 'format |' in command spec." << endl;
551 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
556 std::string commandStr(
str::trim( cmdspec.substr( pos + 1 ) ) );
558 enum Format { UNKNOWN, NONE, SINGLE, DIGEST, BULK };
559 Format format = UNKNOWN;
560 if ( formatStr ==
"none" )
562 else if ( formatStr ==
"single" )
564 else if ( formatStr ==
"digest" )
566 else if ( formatStr ==
"bulk" )
570 ERR <<
"Can't send Notification: Unknown format '" << formatStr <<
" |' in command spec." << endl;
571 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
579 if ( format == NONE || format == SINGLE )
581 for_( it, notifications_r.begin(), notifications_r.end() )
583 std::vector<std::string> command;
584 if ( format == SINGLE )
586 str::splitEscaped( notificationCmdSubst( commandStr, *it ), std::back_inserter( command ) );
591 for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
595 int ret = prog.close();
598 ERR <<
"Notification command returned with error (" << ret <<
")." << endl;
599 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
605 else if ( format == DIGEST || format == BULK )
607 filesystem::TmpFile tmpfile;
608 std::ofstream out( tmpfile.path().c_str() );
609 for_( it, notifications_r.begin(), notifications_r.end() )
611 if ( format == DIGEST )
613 out << it->file() << endl;
615 else if ( format == BULK )
621 std::vector<std::string> command;
622 command.push_back(
"<"+tmpfile.path().asString() );
623 str::splitEscaped( notificationCmdSubst( commandStr, *notifications_r.begin() ), std::back_inserter( command ) );
628 for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
632 int ret = prog.close();
635 ERR <<
"Notification command returned with error (" << ret <<
")." << endl;
636 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
643 INT <<
"Can't send Notification: Missing handler for 'format |' in command spec." << endl;
644 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
655 void RunUpdateMessages(
const Pathname & root_r,
656 const Pathname & messagesPath_r,
657 const std::vector<sat::Solvable> & checkPackages_r,
658 ZYppCommitResult & result_r )
660 if ( checkPackages_r.empty() )
663 MIL <<
"Looking for new update messages in (" << root_r <<
")" << messagesPath_r << endl;
665 if ( ! PathInfo( messagesDir ).isDir() )
668 std::list<std::string> messages;
670 if ( messages.empty() )
676 HistoryLog historylog;
677 for_( it, checkPackages_r.begin(), checkPackages_r.end() )
679 std::string prefix(
str::form(
"%s-%s", it->name().c_str(), it->edition().c_str() ) );
680 for_( sit, messages.begin(), messages.end() )
685 if ( (*sit)[prefix.size()] !=
'\0' && (*sit)[prefix.size()] !=
'-' )
688 PathInfo message( messagesDir / *sit );
689 if ( ! message.isFile() || message.size() == 0 )
692 MIL <<
"Found update message " << *sit << endl;
693 Pathname localPath( messagesPath_r/(*sit) );
694 result_r.rUpdateMessages().push_back( UpdateNotificationFile( *it, localPath ) );
695 historylog.comment( str::Str() <<
_(
"New update message") <<
" " << localPath,
true );
698 sendNotification( root_r, result_r.updateMessages() );
704 void logPatchStatusChanges(
const sat::Transaction & transaction_r, TargetImpl & target_r )
707 if ( changedPseudoInstalled.empty() )
715 WAR <<
"Need to recompute the patch status changes as commit is incomplete!" << endl;
721 HistoryLog historylog;
722 for (
const auto & el : changedPseudoInstalled )
723 historylog.patchStateChange( el.first, el.second );
732 const std::vector<sat::Solvable> & checkPackages_r,
734 { RunUpdateMessages( root_r, messagesPath_r, checkPackages_r, result_r ); }
747 , _requestedLocalesFile( home() /
"RequestedLocales" )
748 , _autoInstalledFile( home() /
"AutoInstalled" )
757 sigMultiversionSpecChanged();
758 MIL <<
"Initialized target on " <<
_root << endl;
766 std::ifstream uuidprovider(
"/proc/sys/kernel/random/uuid" );
776 boost::function<
bool ()> condition,
777 boost::function<std::string ()> value )
779 std::string val = value();
787 MIL <<
"updating '" << filename <<
"' content." << endl;
791 std::ofstream filestr;
794 filestr.open( filename.
c_str() );
796 if ( filestr.good() )
832 WAR <<
"Can't create anonymous id file" << endl;
841 Pathname flavorpath(
home() /
"LastDistributionFlavor");
847 WAR <<
"No base product, I won't create flavor cache" << endl;
851 std::string flavor = p->flavor();
863 WAR <<
"Can't create flavor cache" << endl;
876 sigMultiversionSpecChanged();
877 MIL <<
"Targets closed" << endl;
901 Pathname rpmsolvcookie = base/
"cookie";
903 bool build_rpm_solv =
true;
913 MIL <<
"Read cookie: " << cookie << endl;
918 if ( status == rpmstatus )
919 build_rpm_solv =
false;
920 MIL <<
"Read cookie: " << rpmsolvcookie <<
" says: "
921 << (build_rpm_solv ?
"outdated" :
"uptodate") << endl;
925 if ( build_rpm_solv )
939 bool switchingToTmpSolvfile =
false;
940 Exception ex(
"Failed to cache rpm database.");
946 rpmsolv = base/
"solv";
947 rpmsolvcookie = base/
"cookie";
954 WAR <<
"Using a temporary solv file at " << base << endl;
955 switchingToTmpSolvfile =
true;
964 if ( ! switchingToTmpSolvfile )
974 cmd.push_back(
"rpmdb2solv" );
976 cmd.push_back(
"-r" );
979 cmd.push_back(
"-D" );
981 cmd.push_back(
"-X" );
983 cmd.push_back(
"-p" );
986 if ( ! oldSolvFile.
empty() )
987 cmd.push_back( oldSolvFile.
asString() );
989 cmd.push_back(
"-o" );
993 std::string errdetail;
996 WAR <<
" " << output;
997 if ( errdetail.empty() ) {
1001 errdetail += output;
1004 int ret = prog.
close();
1025 if (
root() ==
"/" )
1036 if ( !
PathInfo(base/
"solv.idx").isExist() )
1039 return build_rpm_solv;
1057 MIL <<
"New cache built: " << (newCache?
"true":
"false") <<
1058 ", force loading: " << (force?
"true":
"false") << endl;
1063 MIL <<
"adding " << rpmsolv <<
" to pool(" << satpool.
systemRepoAlias() <<
")" << endl;
1070 if ( newCache || force )
1087 MIL <<
"adding " << rpmsolv <<
" to system" << endl;
1093 MIL <<
"Try to handle exception by rebuilding the solv-file" << endl;
1118 if (
PathInfo( historyFile ).isExist() )
1125 if ( onSystemByUser.find( ident ) == onSystemByUser.end() )
1126 onSystemByAuto.insert( ident );
1146 if (
PathInfo( needrebootFile ).isFile() )
1147 needrebootSpec.
parseFrom( needrebootFile );
1150 if (
PathInfo( needrebootDir ).isDir() )
1155 [&](
const Pathname & dir_r,
const char *
const str_r )->
bool
1157 if ( ! isRpmConfigBackup( str_r ) )
1159 Pathname needrebootFile { needrebootDir / str_r };
1160 if (
PathInfo( needrebootFile ).isFile() )
1161 needrebootSpec.
parseFrom( needrebootFile );
1172 if ( ! hardLocks.empty() )
1181 MIL <<
"Target loaded: " << system.
solvablesSize() <<
" resolvables" << endl;
1193 bool explicitDryRun = policy_r.
dryRun();
1203 if (
root() ==
"/" )
1213 MIL <<
"TargetImpl::commit(<pool>, " << policy_r <<
")" << endl;
1232 steps.push_back( *it );
1239 MIL <<
"Todo: " << result << endl;
1249 if ( commitPlugins )
1250 commitPlugins.
send( transactionPluginFrame(
"COMMITBEGIN", steps ) );
1257 if ( ! policy_r.
dryRun() )
1263 DBG <<
"dryRun: Not writing upgrade testcase." << endl;
1270 if ( ! policy_r.
dryRun() )
1292 DBG <<
"dryRun: Not storing non-package data." << endl;
1299 if ( ! policy_r.
dryRun() )
1301 for_( it, steps.begin(), steps.end() )
1303 if ( ! it->satSolvable().isKind<
Patch>() )
1311 if ( ! patch ||patch->message().empty() )
1314 MIL <<
"Show message for " << patch << endl;
1316 if ( !
report->show( patch ) )
1318 WAR <<
"commit aborted by the user" << endl;
1325 DBG <<
"dryRun: Not checking patch messages." << endl;
1344 for_( it, steps.begin(), steps.end() )
1346 switch ( it->stepType() )
1365 localfile = packageCache.
get( pi );
1368 catch (
const AbortRequestException & exp )
1372 WAR <<
"commit cache preload aborted by the user" << endl;
1376 catch (
const SkipRequestException & exp )
1381 WAR <<
"Skipping cache preload package " << pi->asKind<
Package>() <<
" in commit" << endl;
1391 INT <<
"Unexpected Error: Skipping cache preload package " << pi->asKind<
Package>() <<
" in commit" << endl;
1401 ERR <<
"Some packages could not be provided. Aborting commit."<< endl;
1405 if ( ! policy_r.
dryRun() )
1409 commit( policy_r, packageCache, result );
1413 DBG <<
"dryRun/downloadOnly: Not installing/deleting anything." << endl;
1414 if ( explicitDryRun ) {
1423 DBG <<
"dryRun: Not downloading/installing/deleting anything." << endl;
1424 if ( explicitDryRun ) {
1436 WAR <<
"(rpm removed in commit?) Inject missing /var/lib/rpm compat symlink to /usr/lib/sysimage/rpm" << endl;
1445 if ( commitPlugins )
1446 commitPlugins.
send( transactionPluginFrame(
"COMMITEND", steps ) );
1451 if ( ! policy_r.
dryRun() )
1456 MIL <<
"TargetImpl::commit(<pool>, " << policy_r <<
") returns: " << result << endl;
1467 struct NotifyAttemptToModify
1485 MIL <<
"TargetImpl::commit(<list>" << policy_r <<
")" << steps.size() << endl;
1490 NotifyAttemptToModify attemptToModify( result_r );
1495 std::vector<sat::Solvable> successfullyInstalledPackages;
1498 for_( step, steps.begin(), steps.end() )
1520 localfile = packageCache_r.
get( citem );
1522 catch (
const AbortRequestException &e )
1524 WAR <<
"commit aborted by the user" << endl;
1529 catch (
const SkipRequestException &e )
1532 WAR <<
"Skipping package " << p <<
" in commit" << endl;
1541 INT <<
"Unexpected Error: Skipping package " << p <<
" in commit" << endl;
1550 bool success =
false;
1578 WAR <<
"commit aborted by the user" << endl;
1587 auto rebootNeededFile =
root() /
"/run/reboot-needed";
1603 WAR <<
"dry run failed" << endl;
1610 WAR <<
"commit aborted by the user" << endl;
1615 WAR <<
"Install failed" << endl;
1621 if ( success && !policy_r.
dryRun() )
1624 successfullyInstalledPackages.push_back( citem.
satSolvable() );
1633 bool success =
false;
1646 WAR <<
"commit aborted by the user" << endl;
1662 WAR <<
"commit aborted by the user" << endl;
1668 WAR <<
"removal of " << p <<
" failed";
1671 if ( success && !policy_r.
dryRun() )
1678 else if ( ! policy_r.
dryRun() )
1682 if ( ! citem.
buddy() )
1689 ERR <<
"Can't install orphan product without release-package! " << citem << endl;
1695 std::string referenceFilename( p->referenceFilename() );
1696 if ( referenceFilename.empty() )
1698 ERR <<
"Can't remove orphan product without 'referenceFilename'! " << citem << endl;
1702 Pathname referencePath {
Pathname(
"/etc/products.d") / referenceFilename };
1703 if ( !
rpm().hasFile( referencePath.asString() ) )
1708 ERR <<
"Delete orphan product failed: " << referencePath << endl;
1712 WAR <<
"Won't remove orphan product: '/etc/products.d/" << referenceFilename <<
"' is owned by a package." << endl;
1739 if ( ! successfullyInstalledPackages.empty() )
1742 successfullyInstalledPackages, abort ) )
1744 WAR <<
"Commit aborted by the user" << endl;
1750 successfullyInstalledPackages,
1757 logPatchStatusChanges( result_r.
transaction(), *
this );
1786 if ( baseproduct.isFile() )
1799 ERR <<
"baseproduct symlink is dangling or missing: " << baseproduct << endl;
1804 inline Pathname staticGuessRoot(
const Pathname & root_r )
1806 if ( root_r.empty() )
1811 return Pathname(
"/");
1817 inline std::string firstNonEmptyLineIn(
const Pathname & file_r )
1819 std::ifstream idfile( file_r.c_str() );
1820 for( iostr::EachLine in( idfile ); in; in.next() )
1823 if ( ! line.empty() )
1826 return std::string();
1837 if ( p->isTargetDistribution() )
1845 const Pathname needroot( staticGuessRoot(root_r) );
1846 const Target_constPtr target( getZYpp()->getTarget() );
1847 if ( target && target->root() == needroot )
1848 return target->requestedLocales();
1854 MIL <<
"updateAutoInstalled if changed..." << endl;
1862 {
return baseproductdata(
_root ).registerTarget(); }
1865 {
return baseproductdata( staticGuessRoot(root_r) ).registerTarget(); }
1868 {
return baseproductdata(
_root ).registerRelease(); }
1871 {
return baseproductdata( staticGuessRoot(root_r) ).registerRelease();}
1874 {
return baseproductdata(
_root ).registerFlavor(); }
1877 {
return baseproductdata( staticGuessRoot(root_r) ).registerFlavor();}
1910 std::string
distributionVersion = baseproductdata( staticGuessRoot(root_r) ).edition().version();
1917 scoped_ptr<rpm::RpmDb> tmprpmdb;
1923 tmprpmdb->initDatabase( );
1940 return firstNonEmptyLineIn(
home() /
"LastDistributionFlavor" );
1945 return firstNonEmptyLineIn( staticGuessRoot(root_r) /
"/var/lib/zypp/LastDistributionFlavor" );
1951 std::string guessAnonymousUniqueId(
const Pathname & root_r )
1954 std::string ret( firstNonEmptyLineIn( root_r /
"/var/lib/zypp/AnonymousUniqueId" ) );
1955 if ( ret.
empty() && root_r !=
"/" )
1958 ret = firstNonEmptyLineIn(
"/var/lib/zypp/AnonymousUniqueId" );
1966 return guessAnonymousUniqueId(
root() );
1971 return guessAnonymousUniqueId( staticGuessRoot(root_r) );
1978 MIL <<
"New VendorAttr: " << vendorAttr_r << endl;
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
#define SUBST_IF(PAT, VAL)
ZYppCommitResult & _result
const std::string & asString() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void resetDispose()
Set no dispose function.
Store and operate on date (time_t).
static Date now()
Return the current time.
Edition represents [epoch:]version[-release]
unsigned epoch_t
Type of an epoch.
std::string version() const
Version.
std::string release() const
Release.
epoch_t epoch() const
Epoch.
Base class for Exception.
void remember(const Exception &old_r)
Store an other Exception as history.
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
std::vector< std::string > Arguments
int close()
Wait for the progamm to complete.
const std::string & command() const
The command we're executing.
Writing the zypp history file.
void stampCommand()
Log info about the current process.
static void setRoot(const Pathname &root)
Set new root directory to the default history log file path.
void remove(const PoolItem &pi)
Log removal of a package.
static const Pathname & fname()
Get the current log file path.
void install(const PoolItem &pi)
Log installation (or update) of a package.
void comment(const std::string &comment, bool timestamp=false)
Log a comment (even multiline).
Access to the sat-pools string space.
std::string asString() const
Conversion to std::string
@ REGEX
Regular Expression.
TraitsType::constPtrType constPtr
Class representing a patch.
TraitsType::constPtrType constPtr
Parallel execution of stateful PluginScripts.
void load(const Pathname &path_r)
Find and launch plugins sending PLUGINBEGIN.
void send(const PluginFrame &frame_r)
Send PluginFrame to all open plugins.
Command frame for communication with PluginScript.
Combining sat::Solvable and ResStatus.
ResObject::constPtr resolvable() const
Returns the ResObject::constPtr.
ResStatus & status() const
Returns the current status.
sat::Solvable buddy() const
Return the buddy we share our status object with.
TraitsType::constPtrType constPtr
Track changing files or directories.
static RepoStatus fromCookieFile(const Pathname &path)
Reads the status from a cookie file.
void saveToCookieFile(const Pathname &path_r) const
Save the status information to a cookie file.
bool solvablesEmpty() const
Whether Repository contains solvables.
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
size_type solvablesSize() const
Number of solvables in Repository.
void addSolv(const Pathname &file_r)
Load Solvables from a solv-file.
void eraseFromPool()
Remove this Repository from it's Pool.
ChangedPseudoInstalled changedPseudoInstalled() const
Return all pseudo installed items whose current state differs from the established one.
static ResPool instance()
Singleton ctor.
EstablishedStates::ChangedPseudoInstalled ChangedPseudoInstalled
Map holding pseudo installed items where current and established status differ.
void setHardLockQueries(const HardLockQueries &newLocks_r)
Set a new set of queries.
Resolver & resolver() const
The Resolver.
const LocaleSet & getRequestedLocales() const
Return the requested locales.
ChangedPseudoInstalled changedPseudoInstalled() const
Return all pseudo installed items whose current state differs from their initial one.
byKind_iterator byKindEnd(const ResKind &kind_r) const
EstablishedStates establishedStates() const
Factory for EstablishedStates.
byKind_iterator byKindBegin(const ResKind &kind_r) const
void getHardLockQueries(HardLockQueries &activeLocks_r)
Suggest a new set of queries based on the current selection.
bool isToBeInstalled() const
bool resetTransact(TransactByValue causer_r)
Not the same as setTransact( false ).
sat::Transaction getTransaction()
Return the Transaction computed by the last solver run.
bool upgradingRepos() const
Whether there is at least one UpgradeRepo request pending.
Attempts to create a lock to prevent the system from going into hibernate/shutdown.
TraitsType::constPtrType constPtr
String matching (STRING|SUBSTRING|GLOB|REGEX).
Definition of vendor equivalence.
Interim helper class to collect global options and settings.
static ZConfig & instance()
Singleton ctor.
std::string distroverpkg() const
Package telling the "product version" on systems not using /etc/product.d/baseproduct.
Options and policies for ZYpp::commit.
ZYppCommitPolicy & rpmInstFlags(target::rpm::RpmInstFlags newFlags_r)
The default target::rpm::RpmInstFlags.
ZYppCommitPolicy & rpmExcludeDocs(bool yesNo_r)
Use rpm option –excludedocs (default: false)
ZYppCommitPolicy & dryRun(bool yesNo_r)
Set dry run (default: false).
ZYppCommitPolicy & restrictToMedia(unsigned mediaNr_r)
Restrict commit to media 1.
ZYppCommitPolicy & allMedia()
Process all media (default)
ZYppCommitPolicy & downloadMode(DownloadMode val_r)
Commit download policy to use.
ZYppCommitPolicy & rpmNoSignature(bool yesNo_r)
Use rpm option –nosignature (default: false)
Result returned from ZYpp::commit.
TransactionStepList & rTransactionStepList()
Manipulate transactionStepList.
std::vector< sat::Transaction::Step > TransactionStepList
const sat::Transaction & transaction() const
The full transaction list.
sat::Transaction & rTransaction()
Manipulate transaction.
std::string receiveLine()
Read one line from the input stream.
Wrapper class for ::stat/::lstat.
bool isExist() const
Return whether valid stat info exists.
Pathname dirname() const
Return all but the last component od this path.
const std::string & asString() const
String representation.
bool empty() const
Test for an empty path.
static Pathname assertprefix(const Pathname &root_r, const Pathname &path_r)
Return path_r prefixed with root_r, unless it is already prefixed.
const char * c_str() const
String representation.
Provide a new empty temporary file and delete it when no longer needed.
static TmpFile makeSibling(const Pathname &sibling_r)
Provide a new empty temporary directory as sibling.
Data returned by ProductFileReader.
bool empty() const
Whether this is an empty object without valid data.
std::string summary() const
std::string shortName() const
static ProductFileData scanFile(const Pathname &file_r)
Parse one file (or symlink) and return the ProductFileData parsed.
ManagedFile provideSrcPackage(const SrcPackage_constPtr &srcPackage_r) const
Provide SrcPackage in a local file.
void setAutoInstalled(const Queue &autoInstalled_r)
Set ident list of all autoinstalled solvables.
Pathname rootDir() const
Get rootdir (for file conflicts check)
static Pool instance()
Singleton ctor.
static const std::string & systemRepoAlias()
Reserved system repository alias @System .
void setNeedrebootSpec(sat::SolvableSpec needrebootSpec_r)
Solvables which should trigger the reboot-needed hint if installed/updated.
Repository systemRepo()
Return the system repository, create it if missing.
void initRequestedLocales(const LocaleSet &locales_r)
Start tracking changes based on this locales_r.
Libsolv Id queue wrapper.
detail::IdType value_type
void push(value_type val_r)
Push a value to the end off the Queue.
Define a set of Solvables by ident and provides.
void addProvides(Capability provides_r)
A all sat::Solvable matching this provides_r.
void parseFrom(const InputStream &istr_r)
Parse file istr_r and add it's specs (one per line, #-comments).
A Solvable object within the sat Pool.
A single step within a Transaction.
StepType stepType() const
Type of action to perform in this step.
StepStage stepStage() const
Step action result.
Solvable satSolvable() const
Return the corresponding Solvable.
Libsolv transaction wrapper.
const_iterator end() const
Iterator behind the last TransactionStep.
StringQueue autoInstalled() const
Return the ident strings of all packages that would be auto-installed after the transaction is run.
const_iterator begin() const
Iterator to the first TransactionStep.
bool order()
Order transaction steps for commit.
@ TRANSACTION_MULTIINSTALL
[M] Install(multiversion) item (
@ TRANSACTION_INSTALL
[+] Install(update) item
@ TRANSACTION_IGNORE
[ ] Nothing (includes implicit deletes due to obsoletes and non-package actions)
void multiversionSpecChanged()
Target::commit helper optimizing package provision.
void setCommitList(std::vector< sat::Solvable > commitList_r)
Download(commit) sequence of solvables to compute read ahead.
bool preloaded() const
Whether preloaded hint is set.
ManagedFile get(const PoolItem &citem_r)
Provide a package.
void setData(const Data &data_r)
Store new Data.
const Data & data() const
Return the data.
pool::PoolTraits::HardLockQueries Data
Save and restore locale set from file.
void setLocales(const LocaleSet &locales_r)
Store a new locale set.
const LocaleSet & locales() const
Return the loacale set.
void tryLevel(target::rpm::InstallResolvableReport::RpmLevel level_r)
Extract and remember posttrans scripts for later execution.
bool collectScriptFromPackage(ManagedFile rpmPackage_r)
Extract and remember a packages posttrans script for later execution.
bool executeScripts()
Execute the remembered scripts.
void discardScripts()
Discard all remembered scrips.
bool aborted() const
Returns true if removing is aborted during progress.
const Pathname & file() const
Return the file path.
std::unordered_set< IdString > Data
const Data & data() const
Return the data.
void setData(const Data &data_r)
Store new Data.
Base class for concrete Target implementations.
std::string targetDistributionRelease() const
This is register.release attribute of the installed base product.
std::string targetDistribution() const
This is register.target attribute of the installed base product.
LocaleSet requestedLocales() const
Languages to be supported by the system.
void updateAutoInstalled()
Update the database of autoinstalled packages.
ManagedFile provideSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Provides a source package on the Target.
Pathname _root
Path to the target.
RequestedLocalesFile _requestedLocalesFile
Requested Locales database.
void createLastDistributionFlavorCache() const
generates a cache of the last product flavor
Pathname _tmpSolvfilesPath
std::string _distributionVersion
Cache distributionVersion.
std::list< PoolItem > PoolItemList
list of pool items
rpm::RpmDb _rpm
RPM database.
rpm::RpmDb & rpm()
The RPM database.
Pathname solvfilesPath() const
The solv file location actually in use (default or temp).
std::string distributionVersion() const
This is version attribute of the installed base product.
const VendorAttr & vendorAttr() const
The targets current vendor equivalence settings.
void createAnonymousId() const
generates the unique anonymous id which is called when creating the target
SolvIdentFile _autoInstalledFile
user/auto installed database
Product::constPtr baseProduct() const
returns the target base installed product, also known as the distribution or platform.
Target::DistributionLabel distributionLabel() const
This is shortName and summary attribute of the installed base product.
virtual ~TargetImpl()
Dtor.
bool providesFile(const std::string &path_str, const std::string &name_str) const
If the package is installed and provides the file Needed to evaluate split provides during Resolver::...
HardLocksFile _hardLocksFile
Hard-Locks database.
Pathname root() const
The root set for this target.
void load(bool force=true)
std::string distributionFlavor() const
This is flavor attribute of the installed base product but does not require the target to be loaded a...
void installSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Install a source package on the Target.
ZYppCommitResult commit(ResPool pool_r, const ZYppCommitPolicy &policy_r)
Commit changes in the pool.
VendorAttr _vendorAttr
vendor equivalence settings.
Pathname home() const
The directory to store things.
void commitFindFileConflicts(const ZYppCommitPolicy &policy_r, ZYppCommitResult &result_r)
Commit helper checking for file conflicts after download.
Pathname defaultSolvfilesPath() const
The systems default solv file location.
std::string anonymousUniqueId() const
anonymous unique id
TargetImpl(const Pathname &root_r="/", bool doRebuild_r=false)
Ctor.
bool solvfilesPathIsTemp() const
Whether we're using a temp.
std::string targetDistributionFlavor() const
This is register.flavor attribute of the installed base product.
Interface to the rpm program.
void installPackage(const Pathname &filename, RpmInstFlags flags=RPMINST_NONE)
install rpm package
void initDatabase(Pathname root_r=Pathname(), bool doRebuild_r=false)
Prepare access to the rpm database below root_r.
void removePackage(const std::string &name_r, RpmInstFlags flags=RPMINST_NONE)
remove rpm package
void closeDatabase()
Block further access to the rpm database and go back to uninitialized state.
bool hasFile(const std::string &file_r, const std::string &name_r="") const
Return true if at least one package owns a certain file (name_r empty) Return true if package name_r ...
Subclass to retrieve database content.
bool findByProvides(const std::string &tag_r)
Reset to iterate all packages that provide a certain tag.
int chmod(const Pathname &path, mode_t mode)
Like 'chmod'.
const StrMatcher & matchNoDots()
Convenience returning StrMatcher( "[^.]*", Match::GLOB )
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
int unlink(const Pathname &path)
Like 'unlink'.
int rename(const Pathname &oldpath, const Pathname &newpath)
Like 'rename'.
int dirForEach(const Pathname &dir_r, function< bool(const Pathname &, const char *const)> fnc_r)
Invoke callback function fnc_r for each entry in directory dir_r.
int assert_file(const Pathname &path, unsigned mode)
Create an empty file if it does not yet exist.
int recursive_rmdir(const Pathname &path)
Like 'rm -r DIR'.
int addmod(const Pathname &path, mode_t mode)
Add the mode bits to the file given by path.
int readlink(const Pathname &symlink_r, Pathname &target_r)
Like 'readlink'.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
int touch(const Pathname &path)
Change file's modification and access times.
std::string md5sum(const Pathname &file)
Compute a files md5sum.
int symlink(const Pathname &oldpath, const Pathname &newpath)
Like 'symlink'.
std::string getline(std::istream &str)
Read one line from stream.
void updateSolvFileIndex(const Pathname &solvfile_r)
Create solv file content digest for zypper bash completion.
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
bool startsWith(const C_Str &str_r, const C_Str &prefix_r)
alias for hasPrefix
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
std::string toLower(const std::string &s)
Return lowercase version of s.
unsigned splitEscaped(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \t", bool withEmpty=false)
Split line_r into words with respect to escape delimeters.
std::string trim(const std::string &s, const Trim trim_r)
IMPL_PTR_TYPE(TargetImpl)
void XRunUpdateMessages(const Pathname &root_r, const Pathname &messagesPath_r, const std::vector< sat::Solvable > &checkPackages_r, ZYppCommitResult &result_r)
std::string rpmDbStateHash(const Pathname &root_r)
void writeUpgradeTestcase()
static bool fileMissing(const Pathname &pathname)
helper functor
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...
RepoStatus rpmDbRepoStatus(const Pathname &root_r)
static std::string generateRandomId()
generates a random id using uuidgen
Easy-to use interface to the ZYPP dependency resolver.
std::string asString(const DefaultIntegral< Tp, TInitial > &obj)
std::unordered_set< Locale > LocaleSet
ResObject::Ptr makeResObject(const sat::Solvable &solvable_r)
Create ResObject from sat::Solvable.
std::list< UpdateNotificationFile > UpdateNotifications
@ DownloadInHeaps
Similar to DownloadInAdvance, but try to split the transaction into heaps, where at the end of each h...
@ DownloadOnly
Just download all packages to the local cache.
@ DownloadAsNeeded
Alternating download and install.
@ DownloadDefault
libzypp will decide what to do.
std::string asJSON() const
JSON representation.
void add(const Value &val_r)
Push JSON Value to Array.
void add(const String &key_r, const Value &val_r)
Add key/value pair.
std::string asJSON() const
JSON representation.
bool isKind(const ResKind &kind_r) const
Solvable satSolvable() const
Return the corresponding sat::Solvable.
bool isNeedreboot() const
static PoolImpl & myPool()
@ RPM_NODEPS_FORCE
only this one used