19 #include <sys/types.h>
83 for_( it, _scripts.begin(), _scripts.end() )
85 MIL <<
"Unload plugin: " << *it << endl;
89 if ( ! ret.isAckCommand() )
91 WAR <<
"Failed to unload plugin: Bad plugin response." << endl;
97 WAR <<
"Failed to unload plugin." << endl;
109 void load(
const Pathname & path_r )
111 PathInfo pi( path_r );
114 std::list<Pathname> entries;
117 WAR <<
"Plugin dir is not readable: " << pi << endl;
120 for_( it, entries.begin(), entries.end() )
123 if ( pii.isFile() && pii.userMayRX() )
127 else if ( pi.isFile() )
129 if ( pi.userMayRX() )
132 WAR <<
"Plugin file is not executable: " << pi << endl;
136 WAR <<
"Plugin path is neither dir nor file: " << pi << endl;
143 MIL <<
"Load plugin: " << pi_r << endl;
146 if ( ZConfig::instance().hasUserData() )
147 frame.
setHeader(
"userdata", ZConfig::instance().userData() );
151 plugin.send( frame );
153 if ( ret.isAckCommand() )
155 _scripts.push_back( plugin );
159 WAR <<
"Failed to load plugin: Bad plugin response." << endl;
164 WAR <<
"Failed to load plugin." << endl;
174 USR <<
"+++++" << endl;
178 USR <<
"=====" << endl;
180 USR <<
"-----" << endl;
188 unsigned toKeep( ZConfig::instance().solver_upgradeTestcasesToKeep() );
189 MIL <<
"Testcases to keep: " << toKeep << endl;
192 Target_Ptr target( getZYpp()->getTarget() );
195 WAR <<
"No Target no Testcase!" << endl;
199 std::string stem(
"updateTestcase" );
200 Pathname dir( target->assertRootPrefix(
"/var/log/") );
201 Pathname next( dir / Date::now().
form( stem+
"-%Y-%m-%d-%H-%M-%S" ) );
204 std::list<std::string> content;
206 std::set<std::string> cases;
207 for_( c, content.begin(), content.end() )
212 if ( cases.size() >= toKeep )
214 unsigned toDel = cases.size() - toKeep + 1;
215 for_( c, cases.begin(), cases.end() )
224 MIL <<
"Write new testcase " << next << endl;
225 getZYpp()->resolver()->createSolverTestcase( next.asString(),
false );
242 std::pair<bool,PatchScriptReport::Action> doExecuteScript(
const Pathname & root_r,
243 const Pathname & script_r,
246 MIL <<
"Execute script " << PathInfo(Pathname::assertprefix( root_r,script_r)) << endl;
249 historylog.
comment(script_r.asString() +
_(
" executed"),
true);
250 ExternalProgram prog( script_r.asString(), ExternalProgram::Stderr_To_Stdout,
false, -1,
true, root_r );
252 for ( std::string output = prog.receiveLine(); output.length(); output = prog.receiveLine() )
255 if ( ! report_r->progress( PatchScriptReport::OUTPUT, output ) )
257 WAR <<
"User request to abort script " << script_r << endl;
264 std::pair<bool,PatchScriptReport::Action> ret( std::make_pair(
false, PatchScriptReport::ABORT ) );
266 if ( prog.close() != 0 )
268 ret.second = report_r->problem( prog.execError() );
269 WAR <<
"ACTION" << ret.second <<
"(" << prog.execError() <<
")" << endl;
270 std::ostringstream sstr;
271 sstr << script_r <<
_(
" execution failed") <<
" (" << prog.execError() <<
")" << endl;
272 historylog.
comment(sstr.str(),
true);
284 bool executeScript(
const Pathname & root_r,
285 const Pathname & script_r,
286 callback::SendReport<PatchScriptReport> & report_r )
288 std::pair<bool,PatchScriptReport::Action> action( std::make_pair(
false, PatchScriptReport::ABORT ) );
291 action = doExecuteScript( root_r, script_r, report_r );
295 switch ( action.second )
297 case PatchScriptReport::ABORT:
298 WAR <<
"User request to abort at script " << script_r << endl;
302 case PatchScriptReport::IGNORE:
303 WAR <<
"User request to skip script " << script_r << endl;
307 case PatchScriptReport::RETRY:
310 }
while ( action.second == PatchScriptReport::RETRY );
313 INT <<
"Abort on unknown ACTION request " << action.second <<
" returned" << endl;
322 bool RunUpdateScripts(
const Pathname & root_r,
323 const Pathname & scriptsPath_r,
324 const std::vector<sat::Solvable> & checkPackages_r,
327 if ( checkPackages_r.empty() )
330 MIL <<
"Looking for new update scripts in (" << root_r <<
")" << scriptsPath_r << endl;
331 Pathname scriptsDir( Pathname::assertprefix( root_r, scriptsPath_r ) );
332 if ( ! PathInfo( scriptsDir ).isDir() )
335 std::list<std::string> scripts;
337 if ( scripts.empty() )
345 std::map<std::string, Pathname> unify;
346 for_( it, checkPackages_r.begin(), checkPackages_r.end() )
348 std::string prefix(
str::form(
"%s-%s", it->name().c_str(), it->edition().c_str() ) );
349 for_( sit, scripts.begin(), scripts.end() )
354 if ( (*sit)[prefix.size()] !=
'\0' && (*sit)[prefix.size()] !=
'-' )
357 PathInfo script( scriptsDir / *sit );
358 Pathname localPath( scriptsPath_r/(*sit) );
359 std::string unifytag;
361 if ( script.isFile() )
367 else if ( ! script.isExist() )
375 if ( unifytag.empty() )
379 if ( unify[unifytag].empty() )
381 unify[unifytag] = localPath;
388 std::string msg(
str::form(
_(
"%s already executed as %s)"), localPath.asString().c_str(), unify[unifytag].c_str() ) );
389 MIL <<
"Skip update script: " << msg << endl;
390 HistoryLog().comment( msg,
true );
394 if ( abort || aborting_r )
396 WAR <<
"Aborting: Skip update script " << *sit << endl;
397 HistoryLog().comment(
398 localPath.asString() +
_(
" execution skipped while aborting"),
403 MIL <<
"Found update script " << *sit << endl;
404 callback::SendReport<PatchScriptReport>
report;
405 report->start( make<Package>( *it ), script.path() );
407 if ( ! executeScript( root_r, localPath, report ) )
419 inline void copyTo( std::ostream & out_r,
const Pathname & file_r )
421 std::ifstream infile( file_r.c_str() );
422 for( iostr::EachLine in( infile ); in; in.next() )
424 out_r << *in << endl;
428 inline std::string notificationCmdSubst(
const std::string & cmd_r,
const UpdateNotificationFile & notification_r )
430 std::string ret( cmd_r );
431 #define SUBST_IF(PAT,VAL) if ( ret.find( PAT ) != std::string::npos ) ret = str::gsub( ret, PAT, VAL )
432 SUBST_IF(
"%p", notification_r.solvable().asString() );
433 SUBST_IF(
"%P", notification_r.file().asString() );
438 void sendNotification(
const Pathname & root_r,
441 if ( notifications_r.empty() )
444 std::string cmdspec( ZConfig::instance().updateMessagesNotify() );
445 MIL <<
"Notification command is '" << cmdspec <<
"'" << endl;
446 if ( cmdspec.empty() )
450 if ( pos == std::string::npos )
452 ERR <<
"Can't send Notification: Missing 'format |' in command spec." << endl;
453 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
458 std::string commandStr(
str::trim( cmdspec.substr( pos + 1 ) ) );
460 enum Format { UNKNOWN, NONE, SINGLE, DIGEST, BULK };
461 Format format = UNKNOWN;
462 if ( formatStr ==
"none" )
464 else if ( formatStr ==
"single" )
466 else if ( formatStr ==
"digest" )
468 else if ( formatStr ==
"bulk" )
472 ERR <<
"Can't send Notification: Unknown format '" << formatStr <<
" |' in command spec." << endl;
473 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
481 if ( format == NONE || format == SINGLE )
483 for_( it, notifications_r.begin(), notifications_r.end() )
485 std::vector<std::string> command;
486 if ( format == SINGLE )
487 command.push_back(
"<"+Pathname::assertprefix( root_r, it->file() ).
asString() );
488 str::splitEscaped( notificationCmdSubst( commandStr, *it ), std::back_inserter( command ) );
490 ExternalProgram prog( command, ExternalProgram::Stderr_To_Stdout,
false, -1,
true, root_r );
493 for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
497 int ret = prog.close();
500 ERR <<
"Notification command returned with error (" << ret <<
")." << endl;
501 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
507 else if ( format == DIGEST || format == BULK )
509 filesystem::TmpFile tmpfile;
510 ofstream out( tmpfile.path().c_str() );
511 for_( it, notifications_r.begin(), notifications_r.end() )
513 if ( format == DIGEST )
515 out << it->file() << endl;
517 else if ( format == BULK )
519 copyTo( out <<
'\f', Pathname::assertprefix( root_r, it->file() ) );
523 std::vector<std::string> command;
524 command.push_back(
"<"+tmpfile.path().asString() );
525 str::splitEscaped( notificationCmdSubst( commandStr, *notifications_r.begin() ), std::back_inserter( command ) );
527 ExternalProgram prog( command, ExternalProgram::Stderr_To_Stdout,
false, -1,
true, root_r );
530 for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() )
534 int ret = prog.close();
537 ERR <<
"Notification command returned with error (" << ret <<
")." << endl;
538 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
545 INT <<
"Can't send Notification: Missing handler for 'format |' in command spec." << endl;
546 HistoryLog().comment( str::Str() <<
_(
"Error sending update message notification."),
true );
557 void RunUpdateMessages(
const Pathname & root_r,
558 const Pathname & messagesPath_r,
559 const std::vector<sat::Solvable> & checkPackages_r,
560 ZYppCommitResult & result_r )
562 if ( checkPackages_r.empty() )
565 MIL <<
"Looking for new update messages in (" << root_r <<
")" << messagesPath_r << endl;
566 Pathname messagesDir( Pathname::assertprefix( root_r, messagesPath_r ) );
567 if ( ! PathInfo( messagesDir ).isDir() )
570 std::list<std::string> messages;
572 if ( messages.empty() )
578 HistoryLog historylog;
579 for_( it, checkPackages_r.begin(), checkPackages_r.end() )
581 std::string prefix(
str::form(
"%s-%s", it->name().c_str(), it->edition().c_str() ) );
582 for_( sit, messages.begin(), messages.end() )
587 if ( (*sit)[prefix.size()] !=
'\0' && (*sit)[prefix.size()] !=
'-' )
590 PathInfo message( messagesDir / *sit );
591 if ( ! message.isFile() || message.size() == 0 )
594 MIL <<
"Found update message " << *sit << endl;
595 Pathname localPath( messagesPath_r/(*sit) );
596 result_r.rUpdateMessages().push_back( UpdateNotificationFile( *it, localPath ) );
597 historylog.comment( str::Str() <<
_(
"New update message") <<
" " << localPath,
true );
600 sendNotification( root_r, result_r.updateMessages() );
608 const Pathname & messagesPath_r,
609 const std::vector<sat::Solvable> & checkPackages_r,
611 { RunUpdateMessages( root_r, messagesPath_r, checkPackages_r, result_r ); }
617 TargetImpl_Ptr TargetImpl::_nullimpl;
620 TargetImpl_Ptr TargetImpl::nullimpl()
632 TargetImpl::TargetImpl(
const Pathname & root_r,
bool doRebuild_r )
634 , _requestedLocalesFile( home() /
"RequestedLocales" )
635 , _softLocksFile( home() /
"SoftLocks" )
636 , _hardLocksFile( Pathname::assertprefix( _root,
ZConfig::instance().locksFile() ) )
644 MIL <<
"Initialized target on " <<
_root << endl;
652 std::ifstream uuidprovider(
"/proc/sys/kernel/random/uuid" );
662 boost::function<
bool ()> condition,
663 boost::function<
string ()> value )
665 string val = value();
673 MIL <<
"updating '" << filename <<
"' content." << endl;
677 std::ofstream filestr;
680 filestr.open( filename.c_str() );
682 if ( filestr.good() )
698 return ! PathInfo(pathname).isExist();
706 Pathname idpath(
home() /
"AnonymousUniqueId");
716 WAR <<
"Can't create anonymous id file" << endl;
725 Pathname flavorpath(
home() /
"LastDistributionFlavor");
731 WAR <<
"No base product, I won't create flavor cache" << endl;
735 string flavor = p->flavor();
747 WAR <<
"Can't create flavor cache" << endl;
760 MIL <<
"Targets closed" << endl;
783 Pathname rpmsolv = base/
"solv";
784 Pathname rpmsolvcookie = base/
"cookie";
786 bool build_rpm_solv =
true;
790 && (
_root/
"/etc/products.d") );
792 bool solvexisted = PathInfo(rpmsolv).isExist();
796 PathInfo cookie( rpmsolvcookie );
797 MIL <<
"Read cookie: " << cookie << endl;
798 if ( cookie.isExist() )
803 build_rpm_solv =
false;
804 MIL <<
"Read cookie: " << rpmsolvcookie <<
" says: "
805 << (build_rpm_solv ?
"outdated" :
"uptodate") << endl;
809 if ( build_rpm_solv )
814 Pathname oldSolvFile( solvexisted ? rpmsolv : Pathname() );
823 bool switchingToTmpSolvfile =
false;
824 Exception ex(
"Failed to cache rpm database.");
830 rpmsolv = base/
"solv";
831 rpmsolvcookie = base/
"cookie";
838 WAR <<
"Using a temporary solv file at " << base << endl;
839 switchingToTmpSolvfile =
true;
848 if ( ! switchingToTmpSolvfile )
857 std::ostringstream cmd;
859 if ( !
_root.empty() )
860 cmd <<
" -r '" <<
_root <<
"'";
862 cmd <<
" -p '" << Pathname::assertprefix(
_root,
"/etc/products.d" ) <<
"'";
864 if ( ! oldSolvFile.empty() )
865 cmd <<
" '" << oldSolvFile <<
"'";
867 cmd <<
" > '" << tmpsolv.
path() <<
"'";
869 MIL <<
"Executing: " << cmd << endl;
873 for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() ) {
874 WAR <<
" " << output;
875 cmd <<
" " << output;
878 int ret = prog.close();
901 if ( PathInfo( script ).isX() )
907 spacewalk.
send( notify );
911 if ( ret.command() ==
"ERROR" )
912 ret.writeTo(
WAR ) << endl;
920 return build_rpm_solv;
938 MIL <<
"New cache built: " << (newCache?
"true":
"false") <<
939 ", force loading: " << (force?
"true":
"false") << endl;
944 MIL <<
"adding " << rpmsolv <<
" to pool(" << satpool.
systemRepoAlias() <<
")" << endl;
951 if ( newCache || force )
968 MIL <<
"adding " << rpmsolv <<
" to system" << endl;
974 MIL <<
"Try to handle exception by rebuilding the solv-file" << endl;
995 if ( ! softLocks.empty() )
1000 softLocks.erase( it->ident() );
1008 if ( ! hardLocks.empty() )
1017 MIL <<
"Target loaded: " << system.
solvablesSize() <<
" resolvables" << endl;
1036 if (
root() ==
"/" )
1046 MIL <<
"TargetImpl::commit(<pool>, " << policy_r <<
")" << endl;
1055 commitPlugins.
load( plugindir );
1061 if ( getZYpp()->resolver()->upgradeMode() )
1063 if ( ! policy_r.
dryRun() )
1069 DBG <<
"dryRun: Not writing upgrade testcase." << endl;
1076 if ( ! policy_r.
dryRun() )
1097 DBG <<
"dryRun: Not stroring non-package data." << endl;
1117 steps.push_back( *it );
1124 MIL <<
"Todo: " << result << endl;
1130 if ( ! policy_r.
dryRun() )
1132 for_( it, steps.begin(), steps.end() )
1134 if ( ! it->satSolvable().isKind<
Patch>() )
1142 if ( ! patch ||patch->message().empty() )
1145 MIL <<
"Show message for " << patch << endl;
1147 if ( ! report->show( patch ) )
1149 WAR <<
"commit aborted by the user" << endl;
1156 DBG <<
"dryRun: Not checking patch messages." << endl;
1175 for_( it, steps.begin(), steps.end() )
1177 switch ( it->stepType() )
1199 localfile = packageCache.
get( pi );
1209 INT <<
"Don't know howto cache: Neither Package nor SrcPackage: " << pi << endl;
1214 catch (
const AbortRequestException & exp )
1218 WAR <<
"commit cache preload aborted by the user" << endl;
1222 catch (
const SkipRequestException & exp )
1227 WAR <<
"Skipping cache preload package " << pi->asKind<
Package>() <<
" in commit" << endl;
1237 INT <<
"Unexpected Error: Skipping cache preload package " << pi->asKind<
Package>() <<
" in commit" << endl;
1246 ERR <<
"Some packages could not be provided. Aborting commit."<< endl;
1248 else if ( ! policy_r.
dryRun() )
1250 commit( policy_r, packageCache, result );
1254 DBG <<
"dryRun: Not installing/deleting anything." << endl;
1259 DBG <<
"dryRun: Not downloading/installing/deleting anything." << endl;
1265 if ( ! policy_r.
dryRun() )
1270 MIL <<
"TargetImpl::commit(<pool>, " << policy_r <<
") returns: " << result << endl;
1285 MIL <<
"TargetImpl::commit(<list>" << policy_r <<
")" << steps.size() << endl;
1288 std::vector<sat::Solvable> successfullyInstalledPackages;
1291 for_( step, steps.begin(), steps.end() )
1296 if ( citem->isKind<
Package>() )
1305 if ( citem->isKind<
Package>() )
1313 localfile = packageCache_r.
get( citem );
1315 catch (
const AbortRequestException &e )
1317 WAR <<
"commit aborted by the user" << endl;
1322 catch (
const SkipRequestException &e )
1325 WAR <<
"Skipping package " << p <<
" in commit" << endl;
1334 INT <<
"Unexpected Error: Skipping package " << p <<
" in commit" << endl;
1339 #warning Exception handling
1344 bool success =
false;
1367 if ( progress.aborted() )
1369 WAR <<
"commit aborted by the user" << endl;
1388 WAR <<
"dry run failed" << endl;
1393 if ( progress.aborted() )
1395 WAR <<
"commit aborted by the user" << endl;
1400 WAR <<
"Install failed" << endl;
1406 if ( success && !policy_r.
dryRun() )
1409 successfullyInstalledPackages.push_back( citem.
satSolvable() );
1418 bool success =
false;
1427 if ( progress.aborted() )
1429 WAR <<
"commit aborted by the user" << endl;
1443 if ( progress.aborted() )
1445 WAR <<
"commit aborted by the user" << endl;
1451 WAR <<
"removal of " << p <<
" failed";
1454 if ( success && !policy_r.
dryRun() )
1461 else if ( ! policy_r.
dryRun() )
1465 if ( ! citem.
buddy() )
1467 if ( citem->isKind<
Product>() )
1472 ERR <<
"Can't install orphan product without release-package! " << citem << endl;
1478 std::string referenceFilename( p->referenceFilename() );
1479 if ( referenceFilename.empty() )
1481 ERR <<
"Can't remove orphan product without 'referenceFilename'! " << citem << endl;
1485 PathInfo referenceFile( Pathname::assertprefix(
_root, Pathname(
"/etc/products.d" ) ) / referenceFilename );
1488 ERR <<
"Delete orphan product failed: " << referenceFile << endl;
1510 if ( ! successfullyInstalledPackages.empty() )
1513 successfullyInstalledPackages, abort ) )
1515 WAR <<
"Commit aborted by the user" << endl;
1521 successfullyInstalledPackages,
1555 PathInfo baseproduct( Pathname::assertprefix( root_r,
"/etc/products.d/baseproduct" ) );
1557 if ( baseproduct.isFile() )
1568 else if ( PathInfo( Pathname::assertprefix( root_r,
"/etc/products.d" ) ).isDir() )
1570 ERR <<
"baseproduct symlink is dangling or missing: " << baseproduct << endl;
1575 inline Pathname staticGuessRoot(
const Pathname & root_r )
1577 if ( root_r.empty() )
1582 return Pathname(
"/");
1588 inline std::string firstNonEmptyLineIn(
const Pathname & file_r )
1590 std::ifstream idfile( file_r.c_str() );
1591 for( iostr::EachLine in( idfile ); in; in.next() )
1594 if ( ! line.empty() )
1597 return std::string();
1608 if ( p->isTargetDistribution() )
1616 const Pathname needroot( staticGuessRoot(root_r) );
1617 const Target_constPtr target( getZYpp()->getTarget() );
1618 if ( target && target->root() == needroot )
1619 return target->requestedLocales();
1624 {
return baseproductdata(
_root ).registerTarget(); }
1627 {
return baseproductdata( staticGuessRoot(root_r) ).registerTarget(); }
1630 {
return baseproductdata(
_root ).registerRelease(); }
1633 {
return baseproductdata( staticGuessRoot(root_r) ).registerRelease();}
1666 std::string
distributionVersion = baseproductdata( staticGuessRoot(root_r) ).edition().version();
1667 if ( distributionVersion.empty() )
1673 scoped_ptr<rpm::RpmDb> tmprpmdb;
1679 tmprpmdb->initDatabase( );
1688 distributionVersion = it->tag_version();
1696 return firstNonEmptyLineIn(
home() /
"LastDistributionFlavor" );
1701 return firstNonEmptyLineIn( staticGuessRoot(root_r) /
"/var/lib/zypp/LastDistributionFlavor" );
1708 return firstNonEmptyLineIn(
home() /
"AnonymousUniqueId" );
1713 return firstNonEmptyLineIn( staticGuessRoot(root_r) /
"/var/lib/zypp/AnonymousUniqueId" );
static bool fileMissing(const Pathname &pathname)
helper functor
ZYppCommitResult commit(ResPool pool_r, const ZYppCommitPolicy &policy_r)
Commit changes in the pool.
int assert_dir(const Pathname &path, unsigned mode)
Like 'mkdir -p'.
std::string shortName() const
void getActiveSoftLocks(AutoSoftLocks &activeLocks_r)
Suggest a new soft-lock list based on the current selection.
Interface to the rpm program.
CommitPlugins()
Default ctor: Empty plugin list.
std::vector< sat::Transaction::Step > TransactionStepList
Save and restore locale set from file.
void setData(const Data &data_r)
Store new Data.
Alternating download and install.
void setRequestedLocales(const LocaleSet &locales_r)
Set the requested locales.
Target::DistributionLabel distributionLabel() const
This is version attribute of the installed base product.
ZYppCommitPolicy & rpmNoSignature(bool yesNo_r)
Use rpm option –nosignature (default: false)
[M] Install(multiversion) item (
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
byKind_iterator byKindBegin(const ResKind &kind_r) const
Result returned from ZYpp::commit.
std::string checksum() const
Checksum of the repository.
static ZConfig & instance()
Singleton ctor.
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 home() const
The directory to store things.
std::string distroverpkg() const
Package telling the "product version" on systems not using /etc/product.d/baseproduct.
Pathname _tmpSolvfilesPath
bool findByProvides(const std::string &tag_r)
Reset to iterate all packages that provide a certain tag.
int readlink(const Pathname &symlink_r, Pathname &target_r)
Like 'readlink'.
void resetDispose()
Set no dispose function.
static ProductFileData scanFile(const Pathname &file_r)
Parse one file (or symlink) and return the ProductFileData parsed.
void updateFileContent(const Pathname &filename, boost::function< bool()> condition, boost::function< string()> value)
updates the content of filename if condition is true, setting the content the the value returned by v...
Target::commit helper optimizing package provision.
ZYppCommitPolicy & rpmInstFlags(target::rpm::RpmInstFlags newFlags_r)
The default target::rpm::RpmInstFlags.
TransactionStepList & rTransactionStepList()
Manipulate transactionStepList.
const Data & data() const
Return the data.
Pathname root() const
The root set for this target.
int chmod(const Pathname &path, mode_t mode)
Like 'chmod'.
void installPackage(const Pathname &filename, RpmInstFlags flags=RPMINST_NONE)
install rpm package
ZYppCommitPolicy & dryRun(bool yesNo_r)
Set dry run (default: false).
#define N_(MSG)
Just tag text for translation.
ZYppCommitPolicy & rpmExcludeDocs(bool yesNo_r)
Use rpm option –excludedocs (default: false)
std::string _distributionVersion
Cache distributionVersion.
const Data & data() const
Return the data.
void setData(const Data &data_r)
Store new Data.
SolvableIterator solvablesEnd() const
Iterator behind the last Solvable.
void load(const Pathname &path_r)
Find and launch plugins sending PLUGINSTART message.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
void setAutoSoftLocks(const AutoSoftLocks &newLocks_r)
Set a new soft-lock list.
bool resetTransact(TransactByValue causer_r)
Not the same as setTransact( false ).
Similar to DownloadInAdvance, but try to split the transaction into heaps, where at the end of each h...
TraitsType::constPtrType constPtr
Provide a new empty temporary file and delete it when no longer needed.
void writeUpgradeTestcase()
static RepoStatus fromCookieFile(const Pathname &path)
reads the status from a file which contains the checksum and timestamp in each line.
byKind_iterator byKindEnd(const ResKind &kind_r) const
Class representing a patch.
void installSrcPackage(const SrcPackage_constPtr &srcPackage_r)
Install a source package on the Target.
LocaleSet requestedLocales() const
Languages to be supported by the system.
std::string summary() const
ManagedFile provideSrcPackage(const SrcPackage_constPtr &srcPackage_r) const
Provide SrcPackage in a local file.
void install(const PoolItem &pi)
Log installation (or update) of a package.
unsigned splitEscaped(const C_Str &line_r, _OutputIterator result_r, const C_Str &sepchars_r=" \t", bool withEmpty=false)
Split line_r into words with respect to escape delimeters.
std::string distributionVersion() const
This is version attribute of the installed base product.
const_iterator begin() const
Iterator to the first TransactionStep.
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.
Date timestamp() const
return the last modification date of the target
[ ] Nothing (includes implicit deletes due to obsoletes and non-package actions)
ResObject::constPtr resolvable() const
Returns the ResObject::constPtr.
int addmod(const Pathname &path, mode_t mode)
Add the mode bits to the file given by path.
std::string getline(std::istream &str)
Read one line from stream.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Store and operate on date (time_t).
Base class for concrete Target implementations.
static Pool instance()
Singleton ctor.
SolvableIterator solvablesBegin() const
Iterator to the first Solvable.
Pathname _root
Path to the target.
~CommitPlugins()
Dtor: Send PLUGINEND message and close plugins.
Pathname defaultSolvfilesPath() const
The systems default solv file location.
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 .
static const Pathname & fname()
Get the current log file path.
int rename(const Pathname &oldpath, const Pathname &newpath)
Like 'rename'.
Just download all packages to the local cache.
Options and policies for ZYpp::commit.
libzypp will decide what to do.
bool solvfilesPathIsTemp() const
Whether we're using a temp.
ZYppCommitPolicy & downloadMode(DownloadMode val_r)
Commit download policy to use.
RequestedLocalesFile _requestedLocalesFile
Requested Locales database.
bool providesFile(const std::string &path_str, const std::string &name_str) const
If the package is installed and provides the file Needed to evaluate split provides during Resolver:...
void setLocales(const LocaleSet &locales_r)
Store a new locale set.
void getHardLockQueries(HardLockQueries &activeLocks_r)
Suggest a new set of queries based on the current selection.
int recursive_rmdir(const Pathname &path)
Like 'rm -r DIR'.
Interim helper class to collect global options and settings.
void createLastDistributionFlavorCache() const
generates a cache of the last product flavor
SoftLocksFile _softLocksFile
Soft-locks database.
bool startsWith(const C_Str &str_r, const C_Str &prefix_r)
alias for hasPrefix
ResStatus & status() const
Returns the current status.
const LocaleSet & getRequestedLocales() const
Return the requested locales.
bool order()
Order transaction steps for commit.
void open()
Setup connection and execute script.
Writing the zypp history fileReference counted signleton for writhing the zypp history file...
TraitsType::constPtrType constPtr
std::tr1::unordered_set< Locale > LocaleSet
Pathname solvfilesPath() const
The solv file location actually in use (default or temp).
#define _(MSG)
Return translated text.
void closeDatabase()
Block further access to the rpm database and go back to uninitialized state.
ZYppCommitPolicy & restrictToMedia(unsigned mediaNr_r)
Restrict commit to media 1.
std::list< PoolItem > PoolItemList
list of pool items
std::string anonymousUniqueId() const
anonymous unique id
sat::Transaction getTransaction()
Return the Transaction computed by the last solver run.
bool solvablesEmpty() const
Whether Repository contains solvables.
PluginFrame receive() const
Receive a PluginFrame.
std::string toLower(const std::string &s)
Return lowercase version of s.
static std::string generateRandomId()
generates a random id using uuidgen
void saveToCookieFile(const Pathname &path) const
save the status information to a cookie file
ManagedFile get(const PoolItem &citem_r)
Provide a package.
HardLocksFile _hardLocksFile
Hard-Locks database.
void testCommitPlugins(const Pathname &path_r)
static void setRoot(const Pathname &root)
Set new root directory to the default history log file path.
std::string targetDistribution() const
This is register.target attribute of the installed base product.
size_type solvablesSize() const
Number of solvables in Repository.
void setHardLockQueries(const HardLockQueries &newLocks_r)
Set a new set of queries.
#define SUBST_IF(PAT, VAL)
std::list< UpdateNotificationFile > UpdateNotifications
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
std::string form(const char *format,...)
Printf style construction of std::string.
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
void doLoad(const PathInfo &pi_r)
const LocaleSet & locales() const
Return the loacale set.
std::tr1::unordered_set< IdString > Data
std::string distributionFlavor() const
This is flavor attribute of the installed base product but does not require the target to be loaded a...
sat::Solvable buddy() const
Return the buddy we share our status object with.
Pathname systemRoot() const
The target root directory.
ZYppCommitPolicy & allMedia()
Process all media (default)
pool::PoolTraits::HardLockQueries Data
const sat::Transaction & transaction() const
The full transaction list.
Base class for Exception.
Resolver & resolver() const
The Resolver.
bool isToBeInstalled() const
Data returned by ProductFileReader.
const_iterator end() const
Iterator behind the last TransactionStep.
void remove(const PoolItem &pi)
Log removal of a package.
Product::constPtr baseProduct() const
returns the target base installed product, also known as the distribution or platform.
void initDatabase(Pathname root_r=Pathname(), Pathname dbPath_r=Pathname(), bool doRebuild_r=false)
Prepare access to the rpm database.
void removePackage(const std::string &name_r, RpmInstFlags flags=RPMINST_NONE)
remove rpm package
virtual ~TargetImpl()
Dtor.
Reference counted access to a _Tp object calling a custom Dispose function when the last AutoDispose ...
void eraseFromPool()
Remove this Repository from it's Pool.
sat::Solvable satSolvable() const
Return the corresponding sat::Solvable.
bool hasFile(const std::string &file_r, const std::string &name_r="") const
Return true if at least one package owns a certain file (name_r empty) Return true if package name_r ...
void comment(const std::string &comment, bool timestamp=false)
Log a comment (even multiline).
std::string asUserHistory() const
A single (multiline) string composed of asUserString and historyAsString.
TraitsType::constPtrType constPtr
Date timestamp() const
timestamp of the rpm database (last modification)
ResObject::Ptr makeResObject(const sat::Solvable &solvable_r)
Create ResObject from sat::Solvable.
Helper for commit plugin execution.
sat::Transaction & rTransaction()
Manipulate transaction.
void setHeader(const std::string &key_r, const std::string &value_r=std::string())
Set header for key_r removing all other occurences of key_r.
Reference to a PoolItem connecting ResObject and ResStatus.
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.
Local facts about a repository This class represents the status of a repository on the system...
void XRunUpdateMessages(const Pathname &root_r, const Pathname &messagesPath_r, const std::vector< sat::Solvable > &checkPackages_r, ZYppCommitResult &result_r)
Interface to pluigin scripts using a Stomp inspired communication protocol.
std::string targetDistributionRelease() const
This is register.release attribute of the installed base product.
std::string asString(const std::string &t)
Global asString() that works with std::string too.
bool hasPrefix(const C_Str &str_r, const C_Str &prefix_r)
Return whether str_r has prefix prefix_r.
void createAnonymousId() const
generates the unique anonymous id which is called when creating the target
void send(const PluginFrame &frame_r) const
Send a PluginFrame.
bool empty() const
Whether this is an empty object without valid data.
void setCommitList(std::vector< sat::Solvable > commitList_r)
Download(commit) sequence of solvables to compute read ahead.
rpm::RpmDb & rpm()
The RPM database.
TraitsType::constPtrType constPtr
#define IMPL_PTR_TYPE(NAME)
static ResPool instance()
Singleton ctor.
std::list< PluginScript > _scripts
void load(bool force=true)