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 );
215 class AssertProcMounted
221 AssertProcMounted( Pathname root_r )
224 if ( ! PathInfo(root_r/
"self").isDir() ) {
225 MIL <<
"Try to make sure proc is mounted at" <<
_mountpoint << endl;
227 && execute({
"mount",
"-t",
"proc",
"proc", root_r.asString() }) == 0 ) {
236 ~AssertProcMounted( )
240 MIL <<
"We mounted " <<
_mountpoint <<
" so we unmount it" << endl;
241 execute({
"umount",
"-l",
_mountpoint.asString() });
249 for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
268 std::ifstream infile( historyFile_r.c_str() );
269 for( iostr::EachLine in( infile ); in; in.next() )
271 const char * ch( (*in).c_str() );
273 if ( *ch <
'1' ||
'9' < *ch )
275 const char * sep1 = ::strchr( ch,
'|' );
280 bool installs =
true;
281 if ( ::strncmp( sep1,
"install|", 8 ) )
283 if ( ::strncmp( sep1,
"remove |", 8 ) )
290 const char * sep2 = ::strchr( sep1,
'|' );
291 if ( !sep2 || sep1 == sep2 )
293 (*in)[sep2-ch] =
'\0';
294 IdString pkg( sep1 );
298 onSystemByUserList.erase( pkg );
302 if ( (sep1 = ::strchr( sep2+1,
'|' ))
303 && (sep1 = ::strchr( sep1+1,
'|' ))
304 && (sep2 = ::strchr( sep1+1,
'|' )) )
306 (*in)[sep2-ch] =
'\0';
307 if ( ::strchr( sep1+1,
'@' ) )
310 onSystemByUserList.insert( pkg );
315 MIL <<
"onSystemByUserList found: " << onSystemByUserList.size() << endl;
316 return onSystemByUserList;
326 return PluginFrame( command_r, json::Object {
327 {
"TransactionStepList", steps_r }
337 MIL <<
"Testcases to keep: " << toKeep << endl;
343 WAR <<
"No Target no Testcase!" << endl;
347 std::string stem(
"updateTestcase" );
348 Pathname dir( target->assertRootPrefix(
"/var/log/") );
352 std::list<std::string> content;
354 std::set<std::string> cases;
355 for_( c, content.begin(), content.end() )
360 if ( cases.size() >= toKeep )
362 unsigned toDel = cases.size() - toKeep + 1;
363 for_( c, cases.begin(), cases.end() )
372 MIL <<
"Write new testcase " << next << endl;
373 getZYpp()->resolver()->createSolverTestcase( next.asString(),
false );
390 std::pair<bool,PatchScriptReport::Action> doExecuteScript(
const Pathname & root_r,
400 for ( std::string output = prog.receiveLine(); output.length(); output = prog.receiveLine() )
405 WAR <<
"User request to abort script " << script_r << endl;
414 if ( prog.close() != 0 )
416 ret.second = report_r->problem( prog.execError() );
417 WAR <<
"ACTION" << ret.second <<
"(" << prog.execError() <<
")" << endl;
418 std::ostringstream sstr;
419 sstr << script_r <<
_(
" execution failed") <<
" (" << prog.execError() <<
")" << endl;
420 historylog.
comment(sstr.str(),
true);
432 bool executeScript(
const Pathname & root_r,
433 const Pathname & script_r,
434 callback::SendReport<PatchScriptReport> & report_r )
439 action = doExecuteScript( root_r, script_r, report_r );
443 switch ( action.second )
446 WAR <<
"User request to abort at script " << script_r << endl;
451 WAR <<
"User request to skip script " << script_r << endl;
461 INT <<
"Abort on unknown ACTION request " << action.second <<
" returned" << endl;
470 bool RunUpdateScripts(
const Pathname & root_r,
471 const Pathname & scriptsPath_r,
472 const std::vector<sat::Solvable> & checkPackages_r,
475 if ( checkPackages_r.empty() )
478 MIL <<
"Looking for new update scripts in (" << root_r <<
")" << scriptsPath_r << endl;
480 if ( ! PathInfo( scriptsDir ).isDir() )
483 std::list<std::string> scripts;
485 if ( scripts.empty() )
493 std::map<std::string, Pathname> unify;
494 for_( it, checkPackages_r.begin(), checkPackages_r.end() )
496 std::string prefix(
str::form(
"%s-%s", it->name().c_str(), it->edition().c_str() ) );
497 for_( sit, scripts.begin(), scripts.end() )
502 if ( (*sit)[prefix.size()] !=
'\0' && (*sit)[prefix.size()] !=
'-' )
505 PathInfo script( scriptsDir / *sit );
506 Pathname localPath( scriptsPath_r/(*sit) );
507 std::string unifytag;
509 if ( script.isFile() )
515 else if ( ! script.isExist() )
523 if ( unifytag.empty() )
527 if ( unify[unifytag].empty() )
529 unify[unifytag] = localPath;
536 std::string msg(
str::form(
_(
"%s already executed as %s)"), localPath.asString().c_str(), unify[unifytag].c_str() ) );
537 MIL <<
"Skip update script: " << msg << endl;
538 HistoryLog().comment( msg,
true );
542 if ( abort || aborting_r )
544 WAR <<
"Aborting: Skip update script " << *sit << endl;
545 HistoryLog().comment(
546 localPath.asString() +
_(
" execution skipped while aborting"),
551 MIL <<
"Found update script " << *sit << endl;
552 callback::SendReport<PatchScriptReport>
report;
553 report->start( make<Package>( *it ), script.path() );
555 if ( ! executeScript( root_r, localPath,
report ) )
567 inline void copyTo( std::ostream & out_r,
const Pathname & file_r )
569 std::ifstream infile( file_r.c_str() );
570 for( iostr::EachLine in( infile ); in; in.next() )
572 out_r << *in << endl;
576 inline std::string notificationCmdSubst(
const std::string & cmd_r,
const UpdateNotificationFile & notification_r )
578 std::string ret( cmd_r );
579 #define SUBST_IF(PAT,VAL) if ( ret.find( PAT ) != std::string::npos ) ret = str::gsub( ret, PAT, VAL ) 580 SUBST_IF(
"%p", notification_r.solvable().asString() );
581 SUBST_IF(
"%P", notification_r.file().asString() );
586 void sendNotification(
const Pathname & root_r,
589 if ( notifications_r.empty() )
593 MIL <<
"Notification command is '" << cmdspec <<
"'" << endl;
594 if ( cmdspec.empty() )
598 if ( pos == std::string::npos )
600 ERR <<
"Can't send Notification: Missing 'format |' in command spec." << endl;
601 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
606 std::string commandStr(
str::trim( cmdspec.substr( pos + 1 ) ) );
608 enum Format { UNKNOWN, NONE, SINGLE, DIGEST, BULK };
609 Format format = UNKNOWN;
610 if ( formatStr ==
"none" )
612 else if ( formatStr ==
"single" )
614 else if ( formatStr ==
"digest" )
616 else if ( formatStr ==
"bulk" )
620 ERR <<
"Can't send Notification: Unknown format '" << formatStr <<
" |' in command spec." << endl;
621 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
629 if ( format == NONE || format == SINGLE )
631 for_( it, notifications_r.begin(), notifications_r.end() )
633 std::vector<std::string> command;
634 if ( format == SINGLE )
636 str::splitEscaped( notificationCmdSubst( commandStr, *it ), std::back_inserter( command ) );
641 for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
645 int ret = prog.close();
648 ERR <<
"Notification command returned with error (" << ret <<
")." << endl;
649 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
655 else if ( format == DIGEST || format == BULK )
657 filesystem::TmpFile tmpfile;
658 std::ofstream out( tmpfile.path().c_str() );
659 for_( it, notifications_r.begin(), notifications_r.end() )
661 if ( format == DIGEST )
663 out << it->file() << endl;
665 else if ( format == BULK )
671 std::vector<std::string> command;
672 command.push_back(
"<"+tmpfile.path().asString() );
673 str::splitEscaped( notificationCmdSubst( commandStr, *notifications_r.begin() ), std::back_inserter( command ) );
678 for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
682 int ret = prog.close();
685 ERR <<
"Notification command returned with error (" << ret <<
")." << endl;
686 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
693 INT <<
"Can't send Notification: Missing handler for 'format |' in command spec." << endl;
694 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
705 void RunUpdateMessages(
const Pathname & root_r,
706 const Pathname & messagesPath_r,
707 const std::vector<sat::Solvable> & checkPackages_r,
708 ZYppCommitResult & result_r )
710 if ( checkPackages_r.empty() )
713 MIL <<
"Looking for new update messages in (" << root_r <<
")" << messagesPath_r << endl;
715 if ( ! PathInfo( messagesDir ).isDir() )
718 std::list<std::string> messages;
720 if ( messages.empty() )
726 HistoryLog historylog;
727 for_( it, checkPackages_r.begin(), checkPackages_r.end() )
729 std::string prefix(
str::form(
"%s-%s", it->name().c_str(), it->edition().c_str() ) );
730 for_( sit, messages.begin(), messages.end() )
735 if ( (*sit)[prefix.size()] !=
'\0' && (*sit)[prefix.size()] !=
'-' )
738 PathInfo message( messagesDir / *sit );
739 if ( ! message.isFile() || message.size() == 0 )
742 MIL <<
"Found update message " << *sit << endl;
743 Pathname localPath( messagesPath_r/(*sit) );
744 result_r.rUpdateMessages().push_back( UpdateNotificationFile( *it, localPath ) );
745 historylog.comment( str::Str() <<
_(
"New update message") <<
" " << localPath,
true );
748 sendNotification( root_r, result_r.updateMessages() );
754 void logPatchStatusChanges(
const sat::Transaction & transaction_r, TargetImpl & target_r )
757 if ( changedPseudoInstalled.empty() )
765 WAR <<
"Need to recompute the patch status changes as commit is incomplete!" << endl;
771 HistoryLog historylog;
772 for (
const auto & el : changedPseudoInstalled )
773 historylog.patchStateChange( el.first, el.second );
782 const std::vector<sat::Solvable> & checkPackages_r,
784 { RunUpdateMessages( root_r, messagesPath_r, checkPackages_r, result_r ); }
797 , _requestedLocalesFile( home() /
"RequestedLocales" )
798 , _autoInstalledFile( home() /
"AutoInstalled" )
807 sigMultiversionSpecChanged();
808 MIL <<
"Initialized target on " <<
_root << endl;
816 std::ifstream uuidprovider(
"/proc/sys/kernel/random/uuid" );
826 boost::function<
bool ()> condition,
827 boost::function<std::string ()> value )
829 std::string val = value();
837 MIL <<
"updating '" << filename <<
"' content." << endl;
841 std::ofstream filestr;
844 filestr.open( filename.
c_str() );
846 if ( filestr.good() )
882 WAR <<
"Can't create anonymous id file" << endl;
891 Pathname flavorpath(
home() /
"LastDistributionFlavor");
897 WAR <<
"No base product, I won't create flavor cache" << endl;
901 std::string flavor = p->flavor();
913 WAR <<
"Can't create flavor cache" << endl;
926 sigMultiversionSpecChanged();
927 MIL <<
"Targets closed" << endl;
951 Pathname rpmsolvcookie = base/
"cookie";
953 bool build_rpm_solv =
true;
963 MIL <<
"Read cookie: " << cookie << endl;
968 if ( status == rpmstatus )
969 build_rpm_solv =
false;
970 MIL <<
"Read cookie: " << rpmsolvcookie <<
" says: " 971 << (build_rpm_solv ?
"outdated" :
"uptodate") << endl;
975 if ( build_rpm_solv )
989 bool switchingToTmpSolvfile =
false;
990 Exception ex(
"Failed to cache rpm database.");
996 rpmsolv = base/
"solv";
997 rpmsolvcookie = base/
"cookie";
1004 WAR <<
"Using a temporary solv file at " << base << endl;
1005 switchingToTmpSolvfile =
true;
1014 if ( ! switchingToTmpSolvfile )
1024 cmd.push_back(
"rpmdb2solv" );
1026 cmd.push_back(
"-r" );
1029 cmd.push_back(
"-D" );
1031 cmd.push_back(
"-X" );
1033 cmd.push_back(
"-p" );
1036 if ( ! oldSolvFile.
empty() )
1037 cmd.push_back( oldSolvFile.
asString() );
1039 cmd.push_back(
"-o" );
1043 std::string errdetail;
1046 WAR <<
" " << output;
1047 if ( errdetail.empty() ) {
1051 errdetail += output;
1054 int ret = prog.
close();
1075 if (
root() ==
"/" )
1086 if ( !
PathInfo(base/
"solv.idx").isExist() )
1089 return build_rpm_solv;
1107 MIL <<
"New cache built: " << (newCache?
"true":
"false") <<
1108 ", force loading: " << (force?
"true":
"false") << endl;
1113 MIL <<
"adding " << rpmsolv <<
" to pool(" << satpool.
systemRepoAlias() <<
")" << endl;
1120 if ( newCache || force )
1137 MIL <<
"adding " << rpmsolv <<
" to system" << endl;
1143 MIL <<
"Try to handle exception by rebuilding the solv-file" << endl;
1168 if (
PathInfo( historyFile ).isExist() )
1175 if ( onSystemByUser.find( ident ) == onSystemByUser.end() )
1176 onSystemByAuto.insert( ident );
1198 if (
PathInfo( needrebootFile ).isFile() )
1199 needrebootSpec.
parseFrom( needrebootFile );
1202 if (
PathInfo( needrebootDir ).isDir() )
1207 [&](
const Pathname & dir_r,
const char *
const str_r )->
bool 1209 if ( ! isRpmConfigBackup( str_r ) )
1211 Pathname needrebootFile { needrebootDir / str_r };
1212 if (
PathInfo( needrebootFile ).isFile() )
1213 needrebootSpec.
parseFrom( needrebootFile );
1224 if ( ! hardLocks.empty() )
1233 MIL <<
"Target loaded: " << system.
solvablesSize() <<
" resolvables" << endl;
1245 bool explicitDryRun = policy_r.
dryRun();
1255 if (
root() ==
"/" )
1265 MIL <<
"TargetImpl::commit(<pool>, " << policy_r <<
")" << endl;
1284 steps.push_back( *it );
1291 MIL <<
"Todo: " << result << endl;
1301 if ( commitPlugins )
1302 commitPlugins.
send( transactionPluginFrame(
"COMMITBEGIN", steps ) );
1309 if ( ! policy_r.
dryRun() )
1315 DBG <<
"dryRun: Not writing upgrade testcase." << endl;
1322 if ( ! policy_r.
dryRun() )
1344 DBG <<
"dryRun: Not stroring non-package data." << endl;
1351 if ( ! policy_r.
dryRun() )
1353 for_( it, steps.begin(), steps.end() )
1355 if ( ! it->satSolvable().isKind<
Patch>() )
1363 if ( ! patch ||patch->message().empty() )
1366 MIL <<
"Show message for " << patch << endl;
1368 if ( !
report->show( patch ) )
1370 WAR <<
"commit aborted by the user" << endl;
1377 DBG <<
"dryRun: Not checking patch messages." << endl;
1396 for_( it, steps.begin(), steps.end() )
1398 switch ( it->stepType() )
1417 localfile = packageCache.
get( pi );
1420 catch (
const AbortRequestException & exp )
1424 WAR <<
"commit cache preload aborted by the user" << endl;
1428 catch (
const SkipRequestException & exp )
1433 WAR <<
"Skipping cache preload package " << pi->asKind<
Package>() <<
" in commit" << endl;
1443 INT <<
"Unexpected Error: Skipping cache preload package " << pi->asKind<
Package>() <<
" in commit" << endl;
1453 ERR <<
"Some packages could not be provided. Aborting commit."<< endl;
1457 if ( ! policy_r.
dryRun() )
1461 commit( policy_r, packageCache, result );
1465 DBG <<
"dryRun/downloadOnly: Not installing/deleting anything." << endl;
1466 if ( explicitDryRun ) {
1475 DBG <<
"dryRun: Not downloading/installing/deleting anything." << endl;
1476 if ( explicitDryRun ) {
1488 WAR <<
"(rpm removed in commit?) Inject missing /var/lib/rpm compat symlink to /usr/lib/sysimage/rpm" << endl;
1497 if ( commitPlugins )
1498 commitPlugins.
send( transactionPluginFrame(
"COMMITEND", steps ) );
1503 if ( ! policy_r.
dryRun() )
1508 MIL <<
"TargetImpl::commit(<pool>, " << policy_r <<
") returns: " << result << endl;
1519 struct NotifyAttemptToModify
1537 MIL <<
"TargetImpl::commit(<list>" << policy_r <<
")" << steps.size() << endl;
1542 NotifyAttemptToModify attemptToModify( result_r );
1547 AssertProcMounted assertProcMounted(
_root );
1550 std::vector<sat::Solvable> successfullyInstalledPackages;
1553 for_( step, steps.begin(), steps.end() )
1575 localfile = packageCache_r.
get( citem );
1577 catch (
const AbortRequestException &e )
1579 WAR <<
"commit aborted by the user" << endl;
1584 catch (
const SkipRequestException &e )
1587 WAR <<
"Skipping package " << p <<
" in commit" << endl;
1596 INT <<
"Unexpected Error: Skipping package " << p <<
" in commit" << endl;
1605 bool success =
false;
1631 if ( progress.aborted() )
1633 WAR <<
"commit aborted by the user" << endl;
1642 auto rebootNeededFile =
root() /
"/run/reboot-needed";
1658 WAR <<
"dry run failed" << endl;
1663 if ( progress.aborted() )
1665 WAR <<
"commit aborted by the user" << endl;
1670 WAR <<
"Install failed" << endl;
1676 if ( success && !policy_r.
dryRun() )
1679 successfullyInstalledPackages.push_back( citem.
satSolvable() );
1688 bool success =
false;
1699 if ( progress.aborted() )
1701 WAR <<
"commit aborted by the user" << endl;
1715 if ( progress.aborted() )
1717 WAR <<
"commit aborted by the user" << endl;
1723 WAR <<
"removal of " << p <<
" failed";
1726 if ( success && !policy_r.
dryRun() )
1733 else if ( ! policy_r.
dryRun() )
1737 if ( ! citem.
buddy() )
1744 ERR <<
"Can't install orphan product without release-package! " << citem << endl;
1750 std::string referenceFilename( p->referenceFilename() );
1751 if ( referenceFilename.empty() )
1753 ERR <<
"Can't remove orphan product without 'referenceFilename'! " << citem << endl;
1757 Pathname referencePath {
Pathname(
"/etc/products.d") / referenceFilename };
1758 if ( !
rpm().hasFile( referencePath.asString() ) )
1763 ERR <<
"Delete orphan product failed: " << referencePath << endl;
1767 WAR <<
"Won't remove orphan product: '/etc/products.d/" << referenceFilename <<
"' is owned by a package." << endl;
1794 if ( ! successfullyInstalledPackages.empty() )
1797 successfullyInstalledPackages, abort ) )
1799 WAR <<
"Commit aborted by the user" << endl;
1805 successfullyInstalledPackages,
1812 logPatchStatusChanges( result_r.
transaction(), *this );
1841 if ( baseproduct.isFile() )
1854 ERR <<
"baseproduct symlink is dangling or missing: " << baseproduct << endl;
1859 inline Pathname staticGuessRoot(
const Pathname & root_r )
1861 if ( root_r.empty() )
1866 return Pathname(
"/");
1872 inline std::string firstNonEmptyLineIn(
const Pathname & file_r )
1874 std::ifstream idfile( file_r.c_str() );
1875 for( iostr::EachLine in( idfile ); in; in.next() )
1878 if ( ! line.empty() )
1881 return std::string();
1892 if ( p->isTargetDistribution() )
1900 const Pathname needroot( staticGuessRoot(root_r) );
1901 const Target_constPtr target( getZYpp()->getTarget() );
1902 if ( target && target->root() == needroot )
1903 return target->requestedLocales();
1909 MIL <<
"updateAutoInstalled if changed..." << endl;
1917 {
return baseproductdata(
_root ).registerTarget(); }
1920 {
return baseproductdata( staticGuessRoot(root_r) ).registerTarget(); }
1923 {
return baseproductdata(
_root ).registerRelease(); }
1926 {
return baseproductdata( staticGuessRoot(root_r) ).registerRelease();}
1929 {
return baseproductdata(
_root ).registerFlavor(); }
1932 {
return baseproductdata( staticGuessRoot(root_r) ).registerFlavor();}
1965 std::string
distributionVersion = baseproductdata( staticGuessRoot(root_r) ).edition().version();
1972 scoped_ptr<rpm::RpmDb> tmprpmdb;
1978 tmprpmdb->initDatabase( );
1995 return firstNonEmptyLineIn(
home() /
"LastDistributionFlavor" );
2000 return firstNonEmptyLineIn( staticGuessRoot(root_r) /
"/var/lib/zypp/LastDistributionFlavor" );
2006 std::string guessAnonymousUniqueId(
const Pathname & root_r )
2009 std::string ret( firstNonEmptyLineIn( root_r /
"/var/lib/zypp/AnonymousUniqueId" ) );
2010 if ( ret.
empty() && root_r !=
"/" )
2013 ret = firstNonEmptyLineIn(
"/var/lib/zypp/AnonymousUniqueId" );
2021 return guessAnonymousUniqueId(
root() );
2026 return guessAnonymousUniqueId( staticGuessRoot(root_r) );
2033 MIL <<
"New VendorAttr: " << vendorAttr_r << endl;
static bool fileMissing(const Pathname &pathname)
helper functor
std::string asJSON() const
JSON representation.
ZYppCommitResult commit(ResPool pool_r, const ZYppCommitPolicy &policy_r)
Commit changes in the pool.
VendorAttr _vendorAttr
vendor equivalence settings.
EstablishedStates::ChangedPseudoInstalled ChangedPseudoInstalled
Map holding pseudo installed items where current and established status differ.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
Interface to the rpm program.
sat::Transaction getTransaction()
Return the Transaction computed by the last solver run.
bool upgradingRepos() const
Whether there is at least one UpgradeRepo request pending.
A Solvable object within the sat Pool.
const std::string & command() const
The command we're executing.
std::vector< sat::Transaction::Step > TransactionStepList
Save and restore locale set from file.
Alternating download and install.
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.
int assert_file(const Pathname &path, unsigned mode)
Create an empty file if it does not yet exist.
[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.
std::string asString(const DefaultIntegral< Tp, TInitial > &obj)
#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.
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
bool findByProvides(const std::string &tag_r)
Reset to iterate all packages that provide a certain tag.
int readlink(const Pathname &symlink_r, Pathname &target_r)
Like 'readlink'.
void setData(const Data &data_r)
Store new Data.
IMPL_PTR_TYPE(TargetImpl)
SolvIdentFile _autoInstalledFile
user/auto installed database
detail::IdType value_type
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.
const sat::Transaction & transaction() const
The full transaction list.
void discardScripts()
Discard all remembered scrips.
StepStage stepStage() const
Step action result.
const Pathname & file() const
Return the file path.
int chmod(const Pathname &path, mode_t mode)
Like 'chmod'.
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).
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.
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.
Access to the sat-pools string space.
Libsolv transaction wrapper.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Edition represents [epoch:]version[-release]
Attempts to create a lock to prevent the system from going into hibernate/shutdown.
std::string receiveLine()
Read one line from the input stream.
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::...
TraitsType::constPtrType constPtr
const_iterator end() const
Iterator behind the last TransactionStep.
Provide a new empty temporary file and delete it when no longer needed.
unsigned epoch_t
Type of an epoch.
void writeUpgradeTestcase()
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
static RepoStatus fromCookieFile(const Pathname &path)
Reads the status from a cookie file.
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.
void install(const PoolItem &pi)
Log installation (or update) of a package.
ResObject::constPtr resolvable() const
Returns the ResObject::constPtr.
void addIdent(IdString ident_r)
Add all sat::Solvable with this ident_r.
ChangedPseudoInstalled changedPseudoInstalled() const
Return all pseudo installed items whose current state differs from their initial one.
std::vector< std::string > Arguments
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.
Subclass to retrieve database content.
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.
std::string getline(std::istream &str)
Read one line from stream.
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.
#define NON_COPYABLE(CLASS)
Delete copy ctor and copy assign.
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)
int unlink(const Pathname &path)
Like 'unlink'.
static const std::string & systemRepoAlias()
Reserved system repository alias .
bool collectScriptFromPackage(ManagedFile rpmPackage_r)
Extract and remember a packages posttrans script for later execution.
static const Pathname & fname()
Get the current log file path.
bool executeScripts()
Execute the remembered scripts.
const std::string & asString() const
String representation.
void send(const PluginFrame &frame_r)
Send PluginFrame to all open plugins.
int rename(const Pathname &oldpath, const Pathname &newpath)
Like 'rename'.
Just download all packages to the local cache.
Options and policies for ZYpp::commit.
bool isExist() const
Return whether valid stat info exists.
libzypp will decide what to do.
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 it's 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.
int recursive_rmdir(const Pathname &path)
Like 'rm -r DIR'.
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
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...
TraitsType::constPtrType constPtr
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 symlink(const Pathname &oldpath, const Pathname &newpath)
Like 'symlink'.
void closeDatabase()
Block further access to the rpm database and go back to uninitialized state.
ZYppCommitPolicy & restrictToMedia(unsigned mediaNr_r)
Restrict commit to media 1.
std::list< PoolItem > PoolItemList
list of pool items
std::string anonymousUniqueId() const
anonymous unique id
static PoolImpl & myPool()
RepoStatus rpmDbRepoStatus(const Pathname &root_r)
std::string toLower(const std::string &s)
Return lowercase version of s.
Pathname home() const
The directory to store things.
int touch(const Pathname &path)
Change file's modification and access times.
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.
static void setRoot(const Pathname &root)
Set new root directory to the default history log file path.
int close()
Wait for the progamm to complete.
byKind_iterator byKindEnd(const ResKind &kind_r) const
void setHardLockQueries(const HardLockQueries &newLocks_r)
Set a new set of queries.
#define SUBST_IF(PAT, VAL)
std::list< UpdateNotificationFile > UpdateNotifications
Libsolv Id queue wrapper.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
Product::constPtr baseProduct() const
returns the target base installed product, also known as the distribution or platform.
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.
#define NON_MOVABLE(CLASS)
Delete move ctor and move assign.
pool::PoolTraits::HardLockQueries Data
void add(const Value &val_r)
Push JSON Value to Array.
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.
void load(const Pathname &path_r)
Find and launch plugins sending PLUGINBEGIN.
Data returned by ProductFileReader.
static Date now()
Return the current time.
std::string asJSON() const
JSON representation.
void remove(const PoolItem &pi)
Log removal of a package.
void removePackage(const std::string &name_r, RpmInstFlags flags=RPMINST_NONE)
remove rpm package
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.
virtual ~TargetImpl()
Dtor.
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
void eraseFromPool()
Remove this Repository from it's 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).
TraitsType::constPtrType constPtr
Wrapper class for ::stat/::lstat.
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.
bool solvablesEmpty() const
Whether Repository contains solvables.
ResObject::Ptr makeResObject(const sat::Solvable &solvable_r)
Create ResObject from sat::Solvable.
sat::Transaction & rTransaction()
Manipulate transaction.
Combining sat::Solvable and ResStatus.
Pathname systemRoot() const
The target root directory.
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
void XRunUpdateMessages(const Pathname &root_r, const Pathname &messagesPath_r, const std::vector< sat::Solvable > &checkPackages_r, ZYppCommitResult &result_r)
std::string distributionFlavor() const
This is flavor attribute of the installed base product but does not require the target to be loaded a...
size_type solvablesSize() const
Number of solvables in Repository.
Easy-to use interface to the ZYPP dependency resolver.
std::unordered_set< IdString > Data
Pathname defaultSolvfilesPath() const
The systems default solv file location.
Solvable satSolvable() const
Return the corresponding sat::Solvable.
void add(const String &key_r, const Value &val_r)
Add key/value pair.
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
void 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.
std::unordered_set< Locale > LocaleSet
rpm::RpmDb & rpm()
The RPM database.
TraitsType::constPtrType constPtr
void multiversionSpecChanged()
ZYppCommitResult & _result
static ResPool instance()
Singleton ctor.
void load(bool force=true)