libzypp 17.31.23
zypp::target::RpmPostTransCollector::Impl Class Reference

RpmPostTransCollector implementation. More...

Inheritance diagram for zypp::target::RpmPostTransCollector::Impl:

Classes

struct  Dumpfile
 Data regarding the dumpfile used if rpm --runposttrans is supported. More...
 

Public Member Functions

 Impl (const Pathname &root_r)
 
 ~Impl ()
 
bool hasPosttransScript (const Pathname &rpmPackage_r)
 
void collectPosttransInfo (const Pathname &rpmPackage_r, const std::vector< std::string > &runposttrans_r)
 
void collectPosttransInfo (const std::vector< std::string > &runposttrans_r)
 
void collectScriptFromHeader (rpm::RpmHeader::constPtr pkg)
 
void collectScriptForPackage (const Pathname &rpmPackage_r)
 
bool collectDumpPosttransLines (const std::vector< std::string > &runposttrans_r)
 Return whether runposttrans lines were collected.
 
void executeScripts (rpm::RpmDb &rpm_r)
 Execute the remembered scripts.
 
void discardScripts ()
 Discard all remembered scrips.
 

Private Types

using ScriptList = std::list< std::pair< std::string, std::string > >
 <posttrans script basename, pkgname> pairs.
 

Private Member Functions

Pathname tmpDir ()
 Lazy create tmpdir on demand.
 
bool headerHasPosttrans (rpm::RpmHeader::constPtr pkg_r) const
 Return whether RpmHeader has a posttrans.
 
rpm::RpmHeader::constPtr getHeaderIfPosttrans (const Pathname &rpmPackage_r)
 Cache RpmHeader for consecutive hasPosttransScript / collectScriptForPackage calls.
 
void recallFromDumpfile (const Pathname &dumpfile_r, std::function< void(std::string, std::string, std::string, std::string)> consume_r)
 Retrieve "dump_posttrans: install" lines from dumpfile_r and pass n,v,r,a to the consumer_r.
 

Private Attributes

Pathname _root
 
std::optional< ScriptList_scripts
 
std::optional< Dumpfile_dumpfile
 
boost::scoped_ptr< filesystem::TmpDir_ptrTmpdir
 
UserDataJobReport _myJobReport
 JobReport with ContentType "cmdout/%posttrans".
 
std::pair< Pathname, rpm::RpmHeader::constPtr_headercache
 

Friends

std::ostream & operator<< (std::ostream &str, const Impl &obj)
 
std::ostream & dumpOn (std::ostream &str, const Impl &obj)
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &str, const RpmPostTransCollector::Impl &obj)
 Stream output.
 
std::ostream & dumpOn (std::ostream &str, const RpmPostTransCollector::Impl &obj)
 Verbose stream output.
 

Detailed Description

RpmPostTransCollector implementation.

Definition at line 46 of file RpmPostTransCollector.cc.

Member Typedef Documentation

◆ ScriptList

using zypp::target::RpmPostTransCollector::Impl::ScriptList = std::list< std::pair<std::string,std::string> >
private

<posttrans script basename, pkgname> pairs.

Definition at line 52 of file RpmPostTransCollector.cc.

Constructor & Destructor Documentation

◆ Impl()

zypp::target::RpmPostTransCollector::Impl::Impl ( const Pathname root_r)
inline

Definition at line 67 of file RpmPostTransCollector.cc.

◆ ~Impl()

zypp::target::RpmPostTransCollector::Impl::~Impl ( )
inline

Definition at line 72 of file RpmPostTransCollector.cc.

Member Function Documentation

◆ hasPosttransScript()

bool zypp::target::RpmPostTransCollector::Impl::hasPosttransScript ( const Pathname rpmPackage_r)
inline

Definition at line 75 of file RpmPostTransCollector.cc.

◆ collectPosttransInfo() [1/2]

void zypp::target::RpmPostTransCollector::Impl::collectPosttransInfo ( const Pathname rpmPackage_r,
const std::vector< std::string > &  runposttrans_r 
)
inline

Definition at line 78 of file RpmPostTransCollector.cc.

◆ collectPosttransInfo() [2/2]

void zypp::target::RpmPostTransCollector::Impl::collectPosttransInfo ( const std::vector< std::string > &  runposttrans_r)
inline

Definition at line 81 of file RpmPostTransCollector.cc.

◆ collectScriptFromHeader()

void zypp::target::RpmPostTransCollector::Impl::collectScriptFromHeader ( rpm::RpmHeader::constPtr  pkg)
inline

Definition at line 84 of file RpmPostTransCollector.cc.

◆ collectScriptForPackage()

void zypp::target::RpmPostTransCollector::Impl::collectScriptForPackage ( const Pathname rpmPackage_r)
inline

Definition at line 105 of file RpmPostTransCollector.cc.

◆ collectDumpPosttransLines()

bool zypp::target::RpmPostTransCollector::Impl::collectDumpPosttransLines ( const std::vector< std::string > &  runposttrans_r)
inline

Return whether runposttrans lines were collected.

If runposttrans is supported, rpm issues at least one 'dump_posttrans: enabled' line with every install/remove. If no line is issued, rpm does not support –runposttrans. Interesting for executeScripts is whether the final call to rpm supported it.

Definition at line 113 of file RpmPostTransCollector.cc.

◆ executeScripts()

void zypp::target::RpmPostTransCollector::Impl::executeScripts ( rpm::RpmDb rpm_r)
inline

Execute the remembered scripts.

Crucial is the mixed case, where scripts and dumpfile are present at the end. If rpm was updated in the transaction to a version supporting –runposttrans, run scripts and then the dumpfile. If rpm was downgraded in the transaction to a version no longer supporting –runposttrans, we need to extract missing posttrans scripts from the dumpfile and execute them before the collected scripts.

Definition at line 148 of file RpmPostTransCollector.cc.

◆ discardScripts()

void zypp::target::RpmPostTransCollector::Impl::discardScripts ( )
inline

Discard all remembered scrips.

As we are just logging the omitted actions, we don't pay further attention to the mixed case, where scripts and dumpfile are present (see executeScripts).

Definition at line 300 of file RpmPostTransCollector.cc.

◆ tmpDir()

Pathname zypp::target::RpmPostTransCollector::Impl::tmpDir ( )
inlineprivate

Lazy create tmpdir on demand.

Definition at line 331 of file RpmPostTransCollector.cc.

◆ headerHasPosttrans()

bool zypp::target::RpmPostTransCollector::Impl::headerHasPosttrans ( rpm::RpmHeader::constPtr  pkg_r) const
inlineprivate

Return whether RpmHeader has a posttrans.

Definition at line 339 of file RpmPostTransCollector.cc.

◆ getHeaderIfPosttrans()

rpm::RpmHeader::constPtr zypp::target::RpmPostTransCollector::Impl::getHeaderIfPosttrans ( const Pathname rpmPackage_r)
inlineprivate

Cache RpmHeader for consecutive hasPosttransScript / collectScriptForPackage calls.

Returns
RpmHeader::constPtr IFF rpmPackage_r has a posttrans

Definition at line 353 of file RpmPostTransCollector.cc.

◆ recallFromDumpfile()

void zypp::target::RpmPostTransCollector::Impl::recallFromDumpfile ( const Pathname dumpfile_r,
std::function< void(std::string, std::string, std::string, std::string)>  consume_r 
)
inlineprivate

Retrieve "dump_posttrans: install" lines from dumpfile_r and pass n,v,r,a to the consumer_r.

Definition at line 370 of file RpmPostTransCollector.cc.

Friends And Related Function Documentation

◆ operator<< [1/2]

std::ostream & operator<< ( std::ostream &  str,
const Impl obj 
)
friend

◆ dumpOn [1/2]

std::ostream & dumpOn ( std::ostream &  str,
const Impl obj 
)
friend

◆ operator<<() [2/2]

std::ostream & operator<< ( std::ostream &  str,
const RpmPostTransCollector::Impl obj 
)
related

Stream output.

Definition at line 394 of file RpmPostTransCollector.cc.

◆ dumpOn() [2/2]

std::ostream & dumpOn ( std::ostream &  str,
const RpmPostTransCollector::Impl obj 
)
related

Verbose stream output.

Definition at line 398 of file RpmPostTransCollector.cc.

Member Data Documentation

◆ _root

Pathname zypp::target::RpmPostTransCollector::Impl::_root
private

Definition at line 383 of file RpmPostTransCollector.cc.

◆ _scripts

std::optional<ScriptList> zypp::target::RpmPostTransCollector::Impl::_scripts
private

Definition at line 384 of file RpmPostTransCollector.cc.

◆ _dumpfile

std::optional<Dumpfile> zypp::target::RpmPostTransCollector::Impl::_dumpfile
private

Definition at line 385 of file RpmPostTransCollector.cc.

◆ _ptrTmpdir

boost::scoped_ptr<filesystem::TmpDir> zypp::target::RpmPostTransCollector::Impl::_ptrTmpdir
private

Definition at line 386 of file RpmPostTransCollector.cc.

◆ _myJobReport

UserDataJobReport zypp::target::RpmPostTransCollector::Impl::_myJobReport
private

JobReport with ContentType "cmdout/%posttrans".

Definition at line 388 of file RpmPostTransCollector.cc.

◆ _headercache

std::pair<Pathname,rpm::RpmHeader::constPtr> zypp::target::RpmPostTransCollector::Impl::_headercache
private

Definition at line 390 of file RpmPostTransCollector.cc.


The documentation for this class was generated from the following file: