19 #include <sys/types.h> 72 inline void sigMultiversionSpecChanged()
74 sat::detail::PoolMember::myPool().multiversionSpecChanged();
90 for (
const Transaction::Step & step : steps_r )
92 if ( step.stepType() != Transaction::TRANSACTION_IGNORE )
102 static const std::string strType(
"type" );
103 static const std::string strStage(
"stage" );
104 static const std::string strSolvable(
"solvable" );
106 static const std::string strTypeDel(
"-" );
107 static const std::string strTypeIns(
"+" );
108 static const std::string strTypeMul(
"M" );
110 static const std::string strStageDone(
"ok" );
111 static const std::string strStageFailed(
"err" );
113 static const std::string strSolvableN(
"n" );
114 static const std::string strSolvableE(
"e" );
115 static const std::string strSolvableV(
"v" );
116 static const std::string strSolvableR(
"r" );
117 static const std::string strSolvableA(
"a" );
124 case Transaction::TRANSACTION_IGNORE:
break;
125 case Transaction::TRANSACTION_ERASE: ret.
add( strType, strTypeDel );
break;
126 case Transaction::TRANSACTION_INSTALL: ret.
add( strType, strTypeIns );
break;
127 case Transaction::TRANSACTION_MULTIINSTALL: ret.
add( strType, strTypeMul );
break;
132 case Transaction::STEP_TODO:
break;
133 case Transaction::STEP_DONE: ret.
add( strStage, strStageDone );
break;
134 case Transaction::STEP_ERROR: ret.
add( strStage, strStageFailed );
break;
143 ident = solv.ident();
150 ident = step_r.
ident();
152 arch = step_r.
arch();
157 { strSolvableV, ed.
version() },
158 { strSolvableR, ed.
release() },
162 s.add( strSolvableE, epoch );
164 ret.
add( strSolvable, s );
178 SolvIdentFile::Data getUserInstalledFromHistory(
const Pathname & historyFile_r )
180 SolvIdentFile::Data onSystemByUserList;
183 std::ifstream infile( historyFile_r.c_str() );
184 for( iostr::EachLine in( infile ); in; in.next() )
186 const char * ch( (*in).c_str() );
188 if ( *ch <
'1' ||
'9' < *ch )
190 const char * sep1 = ::strchr( ch,
'|' );
195 bool installs =
true;
196 if ( ::strncmp( sep1,
"install|", 8 ) )
198 if ( ::strncmp( sep1,
"remove |", 8 ) )
205 const char * sep2 = ::strchr( sep1,
'|' );
206 if ( !sep2 || sep1 == sep2 )
208 (*in)[sep2-ch] =
'\0';
209 IdString pkg( sep1 );
213 onSystemByUserList.erase( pkg );
217 if ( (sep1 = ::strchr( sep2+1,
'|' ))
218 && (sep1 = ::strchr( sep1+1,
'|' ))
219 && (sep2 = ::strchr( sep1+1,
'|' )) )
221 (*in)[sep2-ch] =
'\0';
222 if ( ::strchr( sep1+1,
'@' ) )
225 onSystemByUserList.insert( pkg );
230 MIL <<
"onSystemByUserList found: " << onSystemByUserList.size() << endl;
231 return onSystemByUserList;
239 inline PluginFrame transactionPluginFrame(
const std::string & command_r, ZYppCommitResult::TransactionStepList & steps_r )
241 return PluginFrame( command_r, json::Object {
242 {
"TransactionStepList", steps_r }
251 unsigned toKeep( ZConfig::instance().solver_upgradeTestcasesToKeep() );
252 MIL <<
"Testcases to keep: " << toKeep << endl;
258 WAR <<
"No Target no Testcase!" << endl;
262 std::string stem(
"updateTestcase" );
263 Pathname dir( target->assertRootPrefix(
"/var/log/") );
264 Pathname next( dir / Date::now().
form( stem+
"-%Y-%m-%d-%H-%M-%S" ) );
267 std::list<std::string> content;
269 std::set<std::string> cases;
270 for_( c, content.begin(), content.end() )
275 if ( cases.size() >= toKeep )
277 unsigned toDel = cases.size() - toKeep + 1;
278 for_( c, cases.begin(), cases.end() )
287 MIL <<
"Write new testcase " << next << endl;
288 getZYpp()->resolver()->createSolverTestcase( next.asString(),
false );
305 std::pair<bool,PatchScriptReport::Action> doExecuteScript(
const Pathname & root_r,
309 MIL <<
"Execute script " <<
PathInfo(Pathname::assertprefix( root_r,script_r)) << endl;
315 for ( std::string output = prog.receiveLine(); output.length(); output = prog.receiveLine() )
318 if ( ! report_r->progress( PatchScriptReport::OUTPUT, output ) )
320 WAR <<
"User request to abort script " << script_r << endl;
327 std::pair<bool,PatchScriptReport::Action> ret( std::make_pair(
false, PatchScriptReport::ABORT ) );
329 if ( prog.close() != 0 )
331 ret.second = report_r->problem( prog.execError() );
332 WAR <<
"ACTION" << ret.second <<
"(" << prog.execError() <<
")" << endl;
333 std::ostringstream sstr;
334 sstr << script_r <<
_(
" execution failed") <<
" (" << prog.execError() <<
")" << endl;
335 historylog.
comment(sstr.str(),
true);
347 bool executeScript(
const Pathname & root_r,
348 const Pathname & script_r,
349 callback::SendReport<PatchScriptReport> & report_r )
351 std::pair<bool,PatchScriptReport::Action> action( std::make_pair(
false, PatchScriptReport::ABORT ) );
354 action = doExecuteScript( root_r, script_r, report_r );
358 switch ( action.second )
360 case PatchScriptReport::ABORT:
361 WAR <<
"User request to abort at script " << script_r << endl;
365 case PatchScriptReport::IGNORE:
366 WAR <<
"User request to skip script " << script_r << endl;
370 case PatchScriptReport::RETRY:
373 }
while ( action.second == PatchScriptReport::RETRY );
376 INT <<
"Abort on unknown ACTION request " << action.second <<
" returned" << endl;
385 bool RunUpdateScripts(
const Pathname & root_r,
386 const Pathname & scriptsPath_r,
387 const std::vector<sat::Solvable> & checkPackages_r,
390 if ( checkPackages_r.empty() )
393 MIL <<
"Looking for new update scripts in (" << root_r <<
")" << scriptsPath_r << endl;
394 Pathname scriptsDir( Pathname::assertprefix( root_r, scriptsPath_r ) );
395 if ( ! PathInfo( scriptsDir ).isDir() )
398 std::list<std::string> scripts;
400 if ( scripts.empty() )
408 std::map<std::string, Pathname> unify;
409 for_( it, checkPackages_r.begin(), checkPackages_r.end() )
411 std::string prefix(
str::form(
"%s-%s", it->name().c_str(), it->edition().c_str() ) );
412 for_( sit, scripts.begin(), scripts.end() )
417 if ( (*sit)[prefix.size()] !=
'\0' && (*sit)[prefix.size()] !=
'-' )
420 PathInfo script( scriptsDir / *sit );
421 Pathname localPath( scriptsPath_r/(*sit) );
422 std::string unifytag;
424 if ( script.isFile() )
430 else if ( ! script.isExist() )
438 if ( unifytag.empty() )
442 if ( unify[unifytag].empty() )
444 unify[unifytag] = localPath;
451 std::string msg(
str::form(
_(
"%s already executed as %s)"), localPath.asString().c_str(), unify[unifytag].c_str() ) );
452 MIL <<
"Skip update script: " << msg << endl;
453 HistoryLog().comment( msg,
true );
457 if ( abort || aborting_r )
459 WAR <<
"Aborting: Skip update script " << *sit << endl;
460 HistoryLog().comment(
461 localPath.asString() +
_(
" execution skipped while aborting"),
466 MIL <<
"Found update script " << *sit << endl;
467 callback::SendReport<PatchScriptReport>
report;
468 report->start( make<Package>( *it ), script.path() );
470 if ( ! executeScript( root_r, localPath,
report ) )
482 inline void copyTo( std::ostream & out_r,
const Pathname & file_r )
484 std::ifstream infile( file_r.c_str() );
485 for( iostr::EachLine in( infile ); in; in.next() )
487 out_r << *in << endl;
491 inline std::string notificationCmdSubst(
const std::string & cmd_r,
const UpdateNotificationFile & notification_r )
493 std::string ret( cmd_r );
494 #define SUBST_IF(PAT,VAL) if ( ret.find( PAT ) != std::string::npos ) ret = str::gsub( ret, PAT, VAL ) 495 SUBST_IF(
"%p", notification_r.solvable().asString() );
496 SUBST_IF(
"%P", notification_r.file().asString() );
501 void sendNotification(
const Pathname & root_r,
504 if ( notifications_r.empty() )
507 std::string cmdspec( ZConfig::instance().updateMessagesNotify() );
508 MIL <<
"Notification command is '" << cmdspec <<
"'" << endl;
509 if ( cmdspec.empty() )
513 if ( pos == std::string::npos )
515 ERR <<
"Can't send Notification: Missing 'format |' in command spec." << endl;
516 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
521 std::string commandStr(
str::trim( cmdspec.substr( pos + 1 ) ) );
523 enum Format { UNKNOWN, NONE, SINGLE, DIGEST, BULK };
524 Format format = UNKNOWN;
525 if ( formatStr ==
"none" )
527 else if ( formatStr ==
"single" )
529 else if ( formatStr ==
"digest" )
531 else if ( formatStr ==
"bulk" )
535 ERR <<
"Can't send Notification: Unknown format '" << formatStr <<
" |' in command spec." << endl;
536 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
544 if ( format == NONE || format == SINGLE )
546 for_( it, notifications_r.begin(), notifications_r.end() )
548 std::vector<std::string> command;
549 if ( format == SINGLE )
550 command.push_back(
"<"+Pathname::assertprefix( root_r, it->file() ).
asString() );
551 str::splitEscaped( notificationCmdSubst( commandStr, *it ), std::back_inserter( command ) );
553 ExternalProgram prog( command, ExternalProgram::Stderr_To_Stdout,
false, -1,
true, root_r );
556 for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
560 int ret = prog.close();
563 ERR <<
"Notification command returned with error (" << ret <<
")." << endl;
564 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
570 else if ( format == DIGEST || format == BULK )
572 filesystem::TmpFile tmpfile;
573 ofstream out( tmpfile.path().c_str() );
574 for_( it, notifications_r.begin(), notifications_r.end() )
576 if ( format == DIGEST )
578 out << it->file() << endl;
580 else if ( format == BULK )
582 copyTo( out <<
'\f', Pathname::assertprefix( root_r, it->file() ) );
586 std::vector<std::string> command;
587 command.push_back(
"<"+tmpfile.path().asString() );
588 str::splitEscaped( notificationCmdSubst( commandStr, *notifications_r.begin() ), std::back_inserter( command ) );
590 ExternalProgram prog( command, ExternalProgram::Stderr_To_Stdout,
false, -1,
true, root_r );
593 for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
597 int ret = prog.close();
600 ERR <<
"Notification command returned with error (" << ret <<
")." << endl;
601 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
608 INT <<
"Can't send Notification: Missing handler for 'format |' in command spec." << endl;
609 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
620 void RunUpdateMessages(
const Pathname & root_r,
621 const Pathname & messagesPath_r,
622 const std::vector<sat::Solvable> & checkPackages_r,
623 ZYppCommitResult & result_r )
625 if ( checkPackages_r.empty() )
628 MIL <<
"Looking for new update messages in (" << root_r <<
")" << messagesPath_r << endl;
629 Pathname messagesDir( Pathname::assertprefix( root_r, messagesPath_r ) );
630 if ( ! PathInfo( messagesDir ).isDir() )
633 std::list<std::string> messages;
635 if ( messages.empty() )
641 HistoryLog historylog;
642 for_( it, checkPackages_r.begin(), checkPackages_r.end() )
644 std::string prefix(
str::form(
"%s-%s", it->name().c_str(), it->edition().c_str() ) );
645 for_( sit, messages.begin(), messages.end() )
650 if ( (*sit)[prefix.size()] !=
'\0' && (*sit)[prefix.size()] !=
'-' )
653 PathInfo message( messagesDir / *sit );
654 if ( ! message.isFile() || message.size() == 0 )
657 MIL <<
"Found update message " << *sit << endl;
658 Pathname localPath( messagesPath_r/(*sit) );
659 result_r.rUpdateMessages().push_back( UpdateNotificationFile( *it, localPath ) );
660 historylog.comment( str::Str() <<
_(
"New update message") <<
" " << localPath,
true );
663 sendNotification( root_r, result_r.updateMessages() );
672 const std::vector<sat::Solvable> & checkPackages_r,
674 { RunUpdateMessages( root_r, messagesPath_r, checkPackages_r, result_r ); }
685 TargetImpl::TargetImpl(
const Pathname & root_r,
bool doRebuild_r )
687 , _requestedLocalesFile( home() /
"RequestedLocales" )
688 , _autoInstalledFile( home() /
"AutoInstalled" )
696 sigMultiversionSpecChanged();
697 MIL <<
"Initialized target on " <<
_root << endl;
705 std::ifstream uuidprovider(
"/proc/sys/kernel/random/uuid" );
715 boost::function<
bool ()> condition,
716 boost::function<
string ()> value )
718 string val = value();
726 MIL <<
"updating '" << filename <<
"' content." << endl;
730 std::ofstream filestr;
733 filestr.open( filename.
c_str() );
735 if ( filestr.good() )
771 WAR <<
"Can't create anonymous id file" << endl;
780 Pathname flavorpath(
home() /
"LastDistributionFlavor");
786 WAR <<
"No base product, I won't create flavor cache" << endl;
790 string flavor = p->flavor();
802 WAR <<
"Can't create flavor cache" << endl;
815 sigMultiversionSpecChanged();
816 MIL <<
"Targets closed" << endl;
840 Pathname rpmsolvcookie = base/
"cookie";
842 bool build_rpm_solv =
true;
852 MIL <<
"Read cookie: " << cookie << endl;
857 if ( status == rpmstatus )
858 build_rpm_solv =
false;
859 MIL <<
"Read cookie: " << rpmsolvcookie <<
" says: " 860 << (build_rpm_solv ?
"outdated" :
"uptodate") << endl;
864 if ( build_rpm_solv )
878 bool switchingToTmpSolvfile =
false;
879 Exception ex(
"Failed to cache rpm database.");
885 rpmsolv = base/
"solv";
886 rpmsolvcookie = base/
"cookie";
893 WAR <<
"Using a temporary solv file at " << base << endl;
894 switchingToTmpSolvfile =
true;
903 if ( ! switchingToTmpSolvfile )
913 cmd.push_back(
"rpmdb2solv" );
915 cmd.push_back(
"-r" );
918 cmd.push_back(
"-X" );
920 cmd.push_back(
"-p" );
923 if ( ! oldSolvFile.
empty() )
924 cmd.push_back( oldSolvFile.
asString() );
926 cmd.push_back(
"-o" );
930 std::string errdetail;
933 WAR <<
" " << output;
934 if ( errdetail.empty() ) {
941 int ret = prog.
close();
973 if ( !
PathInfo(base/
"solv.idx").isExist() )
976 return build_rpm_solv;
994 MIL <<
"New cache built: " << (newCache?
"true":
"false") <<
995 ", force loading: " << (force?
"true":
"false") << endl;
1000 MIL <<
"adding " << rpmsolv <<
" to pool(" << satpool.
systemRepoAlias() <<
")" << endl;
1007 if ( newCache || force )
1024 MIL <<
"adding " << rpmsolv <<
" to system" << endl;
1030 MIL <<
"Try to handle exception by rebuilding the solv-file" << endl;
1055 if (
PathInfo( historyFile ).isExist() )
1062 if ( onSystemByUser.find( ident ) == onSystemByUser.end() )
1063 onSystemByAuto.insert( ident );
1083 for (
const auto &
idstr : file.
data() ) {
1087 #warning Hotfix: temp workaround missing SolvableSpec Parser 1117 for (
const auto &
idstr : file.
data() ) {
1129 if ( ! hardLocks.empty() )
1138 MIL <<
"Target loaded: " << system.
solvablesSize() <<
" resolvables" << endl;
1158 if (
root() ==
"/" )
1168 MIL <<
"TargetImpl::commit(<pool>, " << policy_r <<
")" << endl;
1187 steps.push_back( *it );
1194 MIL <<
"Todo: " << result << endl;
1204 if ( commitPlugins )
1205 commitPlugins.
send( transactionPluginFrame(
"COMMITBEGIN", steps ) );
1212 if ( ! policy_r.
dryRun() )
1218 DBG <<
"dryRun: Not writing upgrade testcase." << endl;
1225 if ( ! policy_r.
dryRun() )
1247 DBG <<
"dryRun: Not stroring non-package data." << endl;
1254 if ( ! policy_r.
dryRun() )
1256 for_( it, steps.begin(), steps.end() )
1258 if ( ! it->satSolvable().isKind<
Patch>() )
1266 if ( ! patch ||patch->message().empty() )
1269 MIL <<
"Show message for " << patch << endl;
1271 if ( !
report->show( patch ) )
1273 WAR <<
"commit aborted by the user" << endl;
1280 DBG <<
"dryRun: Not checking patch messages." << endl;
1299 for_( it, steps.begin(), steps.end() )
1301 switch ( it->stepType() )
1320 localfile = packageCache.
get( pi );
1323 catch (
const AbortRequestException & exp )
1327 WAR <<
"commit cache preload aborted by the user" << endl;
1331 catch (
const SkipRequestException & exp )
1336 WAR <<
"Skipping cache preload package " << pi->asKind<
Package>() <<
" in commit" << endl;
1346 INT <<
"Unexpected Error: Skipping cache preload package " << pi->asKind<
Package>() <<
" in commit" << endl;
1356 ERR <<
"Some packages could not be provided. Aborting commit."<< endl;
1360 if ( ! policy_r.
dryRun() )
1364 commit( policy_r, packageCache, result );
1368 DBG <<
"dryRun/downloadOnly: Not installing/deleting anything." << endl;
1374 DBG <<
"dryRun: Not downloading/installing/deleting anything." << endl;
1380 if ( commitPlugins )
1381 commitPlugins.
send( transactionPluginFrame(
"COMMITEND", steps ) );
1386 if ( ! policy_r.
dryRun() )
1391 MIL <<
"TargetImpl::commit(<pool>, " << policy_r <<
") returns: " << result << endl;
1402 struct NotifyAttemptToModify
1420 MIL <<
"TargetImpl::commit(<list>" << policy_r <<
")" << steps.size() << endl;
1425 NotifyAttemptToModify attemptToModify( result_r );
1430 std::vector<sat::Solvable> successfullyInstalledPackages;
1433 for_( step, steps.begin(), steps.end() )
1455 localfile = packageCache_r.
get( citem );
1457 catch (
const AbortRequestException &e )
1459 WAR <<
"commit aborted by the user" << endl;
1464 catch (
const SkipRequestException &e )
1467 WAR <<
"Skipping package " << p <<
" in commit" << endl;
1476 INT <<
"Unexpected Error: Skipping package " << p <<
" in commit" << endl;
1481 #warning Exception handling 1486 bool success =
false;
1512 if ( progress.aborted() )
1514 WAR <<
"commit aborted by the user" << endl;
1523 auto rebootNeededFile =
root() /
"/var/run/reboot-needed";
1539 WAR <<
"dry run failed" << endl;
1544 if ( progress.aborted() )
1546 WAR <<
"commit aborted by the user" << endl;
1551 WAR <<
"Install failed" << endl;
1557 if ( success && !policy_r.
dryRun() )
1560 successfullyInstalledPackages.push_back( citem.
satSolvable() );
1569 bool success =
false;
1580 if ( progress.aborted() )
1582 WAR <<
"commit aborted by the user" << endl;
1596 if ( progress.aborted() )
1598 WAR <<
"commit aborted by the user" << endl;
1604 WAR <<
"removal of " << p <<
" failed";
1607 if ( success && !policy_r.
dryRun() )
1614 else if ( ! policy_r.
dryRun() )
1618 if ( ! citem.
buddy() )
1625 ERR <<
"Can't install orphan product without release-package! " << citem << endl;
1631 std::string referenceFilename( p->referenceFilename() );
1632 if ( referenceFilename.empty() )
1634 ERR <<
"Can't remove orphan product without 'referenceFilename'! " << citem << endl;
1641 ERR <<
"Delete orphan product failed: " << referenceFile << endl;
1668 if ( ! successfullyInstalledPackages.empty() )
1671 successfullyInstalledPackages, abort ) )
1673 WAR <<
"Commit aborted by the user" << endl;
1679 successfullyInstalledPackages,
1715 if ( baseproduct.isFile() )
1728 ERR <<
"baseproduct symlink is dangling or missing: " << baseproduct << endl;
1733 inline Pathname staticGuessRoot(
const Pathname & root_r )
1735 if ( root_r.empty() )
1740 return Pathname(
"/");
1746 inline std::string firstNonEmptyLineIn(
const Pathname & file_r )
1748 std::ifstream idfile( file_r.c_str() );
1749 for( iostr::EachLine in( idfile ); in; in.next() )
1752 if ( ! line.empty() )
1755 return std::string();
1766 if ( p->isTargetDistribution() )
1774 const Pathname needroot( staticGuessRoot(root_r) );
1775 const Target_constPtr target( getZYpp()->getTarget() );
1776 if ( target && target->root() == needroot )
1777 return target->requestedLocales();
1783 MIL <<
"updateAutoInstalled if changed..." << endl;
1791 {
return baseproductdata(
_root ).registerTarget(); }
1794 {
return baseproductdata( staticGuessRoot(root_r) ).registerTarget(); }
1797 {
return baseproductdata(
_root ).registerRelease(); }
1800 {
return baseproductdata( staticGuessRoot(root_r) ).registerRelease();}
1803 {
return baseproductdata(
_root ).registerFlavor(); }
1806 {
return baseproductdata( staticGuessRoot(root_r) ).registerFlavor();}
1839 std::string
distributionVersion = baseproductdata( staticGuessRoot(root_r) ).edition().version();
1846 scoped_ptr<rpm::RpmDb> tmprpmdb;
1852 tmprpmdb->initDatabase( );
1869 return firstNonEmptyLineIn(
home() /
"LastDistributionFlavor" );
1874 return firstNonEmptyLineIn( staticGuessRoot(root_r) /
"/var/lib/zypp/LastDistributionFlavor" );
1880 std::string guessAnonymousUniqueId(
const Pathname & root_r )
1883 std::string ret( firstNonEmptyLineIn( root_r /
"/var/lib/zypp/AnonymousUniqueId" ) );
1884 if ( ret.
empty() && root_r !=
"/" )
1887 ret = firstNonEmptyLineIn(
"/var/lib/zypp/AnonymousUniqueId" );
1895 return guessAnonymousUniqueId(
root() );
1900 return guessAnonymousUniqueId( staticGuessRoot(root_r) );
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.
void setRebootNeededIdents(const Queue &rebootNeeded_r)
Set ident list of all solvables that trigger the "reboot needed" flag.
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.
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.
Listentry returned by readdir.
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 (
bool solvfilesPathIsTemp() const
Whether we're using a temp.
const Pathname & path() const
Return current Pathname.
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.
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.
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.
void updateFileContent(const Pathname &filename, boost::function< bool()> condition, boost::function< string()> value)
updates the content of filename if condition is true, setting the content the the value returned by v...
void stampCommand()
Log info about the current process.
Target::commit helper optimizing package provision.
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.
Date timestamp() const
timestamp of the rpm database (last modification)
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.
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.
std::vector< std::string > Arguments
std::string targetDistributionRelease() const
This is register.release attribute of the installed base product.
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.
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.
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.
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 @System .
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.
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'.
std::string release() const
Release.
Interim helper class to collect global options and settings.
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
bool startsWith(const C_Str &str_r, const C_Str &prefix_r)
alias for hasPrefix
std::list< DirEntry > DirContent
Returned by readdir.
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
std::string receiveLine()
Read one line from the input stream.
void closeDatabase()
Block further access to the rpm database and go back to uninitialized state.
Date timestamp() const
return the last modification date of the target
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
std::string toLower(const std::string &s)
Return lowercase version of s.
bool identTriggersRebootNeededHint() const
Pathname home() const
The directory to store things.
int touch(const Pathname &path)
Change file's modification and access times.
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.
Save and restore a list of solvable names (ident IdString)
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.
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.
std::string asJSON() const
JSON representation.
void remove(const PoolItem &pi)
Log removal of a package.
void initDatabase(Pathname root_r=Pathname(), Pathname dbPath_r=Pathname(), bool doRebuild_r=false)
Prepare access to the rpm database.
void removePackage(const std::string &name_r, RpmInstFlags flags=RPMINST_NONE)
remove rpm package
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.
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.
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
std::string toJSON(const sat::Transaction::Step &step_r)
See COMMITBEGIN (added in v1) on page Commit plugin for the specs.
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
#define IMPL_PTR_TYPE(NAME)
ZYppCommitResult & _result
static ResPool instance()
Singleton ctor.
void load(bool force=true)