libzypp 17.37.17
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 (Pathname &&root_r)
 Impl (const Impl &)=delete
 Impl (Impl &&)=delete
Imploperator= (const Impl &)=delete
Imploperator= (Impl &&)=delete
 ~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 (const 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, const IdStringSet &obsoletedPackages_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 (const 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
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)

(Note that these are not member symbols.)

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 48 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 54 of file RpmPostTransCollector.cc.

Constructor & Destructor Documentation

◆ Impl() [1/3]

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

Definition at line 69 of file RpmPostTransCollector.cc.

◆ Impl() [2/3]

zypp::target::RpmPostTransCollector::Impl::Impl ( const Impl & )
delete

◆ Impl() [3/3]

zypp::target::RpmPostTransCollector::Impl::Impl ( Impl && )
delete

◆ ~Impl()

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

Definition at line 79 of file RpmPostTransCollector.cc.

Member Function Documentation

◆ operator=() [1/2]

Impl & zypp::target::RpmPostTransCollector::Impl::operator= ( const Impl & )
delete

◆ operator=() [2/2]

Impl & zypp::target::RpmPostTransCollector::Impl::operator= ( Impl && )
delete

◆ hasPosttransScript()

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

Definition at line 82 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 85 of file RpmPostTransCollector.cc.

◆ collectPosttransInfo() [2/2]

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

Definition at line 88 of file RpmPostTransCollector.cc.

◆ collectScriptFromHeader()

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

Definition at line 91 of file RpmPostTransCollector.cc.

◆ collectScriptForPackage()

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

Definition at line 112 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 120 of file RpmPostTransCollector.cc.

◆ executeScripts()

void zypp::target::RpmPostTransCollector::Impl::executeScripts ( rpm::RpmDb & rpm_r,
const IdStringSet & obsoletedPackages_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 155 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 303 of file RpmPostTransCollector.cc.

◆ tmpDir()

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

Lazy create tmpdir on demand.

Definition at line 334 of file RpmPostTransCollector.cc.

◆ headerHasPosttrans()

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

Return whether RpmHeader has a posttrans.

Definition at line 342 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 356 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 373 of file RpmPostTransCollector.cc.

◆ 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 397 of file RpmPostTransCollector.cc.

◆ dumpOn() [2/2]

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

Verbose stream output.

Definition at line 401 of file RpmPostTransCollector.cc.

Member Data Documentation

◆ _root

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

Definition at line 386 of file RpmPostTransCollector.cc.

◆ _scripts

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

Definition at line 387 of file RpmPostTransCollector.cc.

◆ _dumpfile

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

Definition at line 388 of file RpmPostTransCollector.cc.

◆ _ptrTmpdir

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

Definition at line 389 of file RpmPostTransCollector.cc.

◆ _myJobReport

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

JobReport with ContentType "cmdout/%posttrans".

Definition at line 391 of file RpmPostTransCollector.cc.

◆ _headercache

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

Definition at line 393 of file RpmPostTransCollector.cc.


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