libzypp 17.37.10

RpmPostTransCollector.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
11#include <iostream>
12#include <fstream>
13#include <optional>
14#include <utility>
15#include <zypp/base/LogTools.h>
16#include <zypp/base/NonCopyable.h>
17#include <zypp/base/Gettext.h>
18#include <zypp/base/Regex.h>
19#include <zypp/base/IOStream.h>
20#include <zypp/base/InputStream.h>
21#include <zypp/base/PtrTypes.h>
22#include <zypp/target/RpmPostTransCollector.h>
23
24#include <zypp/TmpPath.h>
25#include <zypp/PathInfo.h>
26#include <zypp/HistoryLog.h>
27#include <zypp/ZYppCallbacks.h>
28#include <zypp/ExternalProgram.h>
29#include <zypp/target/rpm/RpmDb.h>
30#include <zypp/target/rpm/librpmDb.h>
31#include <zypp/ZConfig.h>
32#include <zypp/ZYppCallbacks.h>
33
34 using std::endl;
35#undef ZYPP_BASE_LOGGER_LOGGROUP
36#define ZYPP_BASE_LOGGER_LOGGROUP "zypp::posttrans"
37
39 namespace zypp
40{
42 namespace target
43 {
48 class RpmPostTransCollector::Impl : private base::NonCopyable
49 {
50 friend std::ostream & operator<<( std::ostream & str, const Impl & obj );
51 friend std::ostream & dumpOn( std::ostream & str, const Impl & obj );
52
54 using ScriptList = std::list< std::pair<std::string,std::string> >;
55
57 struct Dumpfile
58 {
59 Dumpfile( Pathname dumpfile_r )
60 : _dumpfile { std::move(dumpfile_r) }
61 {}
62
63 Pathname _dumpfile;
64 size_t _numscripts = 0;
65 bool _runposttrans = true;
66 };
67
68 public:
69 Impl( Pathname &&root_r )
70 : _root(std::move( root_r ))
71 , _myJobReport { "cmdout", "%posttrans" }
72 {}
73
74 Impl(const Impl &) = delete;
75 Impl(Impl &&) = delete;
76 Impl &operator=(const Impl &) = delete;
77 Impl &operator=(Impl &&) = delete;
78
79 ~Impl()
80 {}
81
82 bool hasPosttransScript( const Pathname & rpmPackage_r )
83 { return bool(getHeaderIfPosttrans( rpmPackage_r )); }
84
85 void collectPosttransInfo( const Pathname & rpmPackage_r, const std::vector<std::string> & runposttrans_r )
86 { if ( not collectDumpPosttransLines( runposttrans_r ) ) collectScriptForPackage( rpmPackage_r ); }
87
88 void collectPosttransInfo( const std::vector<std::string> & runposttrans_r )
89 { collectDumpPosttransLines( runposttrans_r ); }
90
91 void collectScriptFromHeader( const rpm::RpmHeader::constPtr& pkg )
92 {
93 if ( pkg ) {
94 if ( not _scripts ) {
95 _scripts = ScriptList();
96 }
97
98 filesystem::TmpFile script( tmpDir(), pkg->ident() );
99 filesystem::addmod( script.path(), 0500 ); // script must be executable
100 script.autoCleanup( false ); // no autodelete; within a tmpdir
101 {
102 std::ofstream out( script.path().c_str() );
103 out << "#! " << pkg->tag_posttransprog() << endl
104 << pkg->tag_posttrans() << endl;
105 }
106
107 _scripts->push_back( std::make_pair( script.path().basename(), pkg->tag_name() ) );
108 MIL << "COLLECT posttrans: '" << PathInfo( script.path() ) << "' for package: '" << pkg->tag_name() << "'" << endl;
109 }
110 }
111
112 void collectScriptForPackage( const Pathname & rpmPackage_r )
113 { collectScriptFromHeader( getHeaderIfPosttrans( rpmPackage_r ) ); }
114
120 bool collectDumpPosttransLines( const std::vector<std::string> & runposttrans_r )
121 {
122 if ( runposttrans_r.empty() ) {
123 if ( _dumpfile and _dumpfile->_runposttrans ) {
124 MIL << "LOST dump_posttrans support" << endl;
125 _dumpfile->_runposttrans = false; // rpm was downgraded to a version not supporing --runposttrans
126 }
127 return false;
128 }
129
130 if ( not _dumpfile ) {
131 filesystem::TmpFile dumpfile( tmpDir(), "dumpfile" );
132 filesystem::addmod( dumpfile.path(), 0400 ); // dumpfile must be readable
133 dumpfile.autoCleanup( false ); // no autodelete; within a tmpdir
134 _dumpfile = Dumpfile( dumpfile.path() );
135 MIL << "COLLECT dump_posttrans to '" << _dumpfile->_dumpfile << endl;
136 }
137
138 std::ofstream out( _dumpfile->_dumpfile.c_str(), std::ios_base::app );
139 for ( const auto & s : runposttrans_r ) {
140 out << s << endl;
141 }
142 _dumpfile->_numscripts += runposttrans_r.size();
143 MIL << "COLLECT " << runposttrans_r.size() << " dump_posttrans lines" << endl;
144 return true;
145 }
146
155 void executeScripts( rpm::RpmDb & rpm_r, const IdStringSet & obsoletedPackages_r )
156 {
157 if ( _dumpfile && not _dumpfile->_runposttrans ) {
158 // Here a downgraded rpm lost the ability to --runposttrans. Extract at least any
159 // missing %posttrans scripts collected in _dumpfile and prepend them to the _scripts.
160 MIL << "Extract missing %posttrans scripts and prepend them to the scripts." << endl;
161
162 // collectScriptFromHeader appends to _scripts, so we save here and append again later
163 std::optional<ScriptList> savedscripts;
164 if ( _scripts ) {
165 savedscripts = std::move(*_scripts);
166 _scripts = std::nullopt;
167 }
168
169 rpm::RpmDb::db_const_iterator it { rpm_r.dbConstIterator() };
170 recallFromDumpfile( _dumpfile->_dumpfile, [&]( const std::string& n_r, const std::string& v_r, const std::string& r_r, const std::string& a_r ) -> void {
171 if ( it.findPackage( n_r, Edition( v_r, r_r ) ) && headerHasPosttrans( *it ) )
172 collectScriptFromHeader( *it );
173 } );
174
175 // append any savedscripts
176 if ( savedscripts ) {
177 if ( _scripts ) {
178 _scripts->splice( _scripts->end(), *savedscripts );
179 } else {
180 _scripts = std::move(*savedscripts);
181 }
182 }
183 _dumpfile = std::nullopt;
184 }
185
186 if ( not ( _scripts || _dumpfile ) )
187 return; // Nothing todo
188
189 // ProgressReport counting the scripts ( 0:preparation, 1->n:for n scripts, n+1: indicate success)
190 callback::SendReport<ProgressReport> report;
191 ProgressData scriptProgress( [&]() -> ProgressData::value_type {
192 ProgressData::value_type ret = 1;
193 if ( _scripts )
194 ret += _scripts->size();
195 if ( _dumpfile )
196 ret += _dumpfile->_numscripts;
197 return ret;
198 }() );
199 scriptProgress.sendTo( ProgressReportAdaptor( ProgressData::ReceiverFnc(), report ) );
200 // Translator: progress bar label
201 std::string scriptProgressName { _("Running post-transaction scripts") };
202 // Translator: progress bar label; %1% is a script identifier like '%posttrans(mypackage-2-0.noarch)'
203 str::Format fmtScriptProgressRun { _("Running %1% script") };
204 // Translator: headline; %1% is a script identifier like '%posttrans(mypackage-2-0.noarch)'
205 str::Format fmtRipoff { _("%1% script output:") };
206 std::string sendRipoff;
207
208 HistoryLog historylog;
209
210 // lambda to prepare reports for a new script
211 auto startNewScript = [&] ( const std::string & scriptident_r ) -> void {
212 // scriptident_r : script identifier like "%transfiletriggerpostun(istrigger-2-0.noarch)"
213 sendRipoff = fmtRipoff % scriptident_r;
214 scriptProgress.name( fmtScriptProgressRun % scriptident_r );
215 scriptProgress.incr();
216 };
217
218 // lambda to send script output to reports
219 auto sendScriptOutput = [&] ( const std::string & line_r ) -> void {
220 OnScopeExit cleanup; // in case we need it
221 if ( not sendRipoff.empty() ) {
222 historylog.comment( sendRipoff, true /*timestamp*/);
223 _myJobReport.set( "ripoff", std::cref(sendRipoff) );
224 cleanup.setDispose( [&]() -> void {
225 _myJobReport.erase( "ripoff" );
226 sendRipoff.clear();
227 } );
228 }
229 historylog.comment( line_r );
230 _myJobReport.info( line_r );
231 };
232
233 // send the initial progress report
234 scriptProgress.name( scriptProgressName );
235 scriptProgress.toMin();
236
237 // Scripts first...
238 if ( _scripts ) {
239 Pathname noRootScriptDir( ZConfig::instance().update_scriptsPath() / tmpDir().basename() );
240 // like rpm would report it (intentionally not translated and NL-terminated):
241 str::Format fmtScriptFailedMsg { "warning: %%posttrans(%1%) scriptlet failed, exit status %2%\n" };
242 str::Format fmtPosttrans { "%%posttrans(%1%)" };
243
244 while ( ! _scripts->empty() )
245 {
246 const auto &scriptPair = _scripts->front();
247 const std::string & script = scriptPair.first;
248 const std::string & pkgident( script.substr( 0, script.size()-6 ) ); // strip tmp file suffix[6]
249 startNewScript( fmtPosttrans % pkgident );
250
251 int npkgs = obsoletedPackages_r.count( IdString(scriptPair.second) ) ? 2 : 1; // bsc#1243279, was update if obsoleted
252 MIL << "EXECUTE posttrans: " << script << " with argument: " << npkgs << endl;
253 ExternalProgram::Arguments cmd {
254 "/bin/sh",
255 (noRootScriptDir/script).asString(),
256 str::numstring( npkgs )
257 };
258 ExternalProgram prog( cmd, ExternalProgram::Stderr_To_Stdout, false, -1, true, _root );
259
260 for( std::string line = prog.receiveLine(); ! line.empty(); line = prog.receiveLine() ) {
261 sendScriptOutput( line );
262 }
263 //script was executed, remove it from the list
264 _scripts->pop_front();
265
266 int ret = prog.close();
267 if ( ret != 0 )
268 {
269 std::string msg { fmtScriptFailedMsg % pkgident % ret };
270 WAR << msg;
271 sendScriptOutput( msg ); // info!, as rpm would have reported it.
272 }
273 }
274 _scripts = std::nullopt;
275 }
276
277 // ...then 'rpm --runposttrans'
278 int res = 0; // Indicate a failed call to rpm itself! (a failed script is just a warning)
279 if ( _dumpfile ) {
280 res = rpm_r.runposttrans( _dumpfile->_dumpfile, [&] ( const std::string & line_r ) ->void {
281 if ( str::startsWith( line_r, "RIPOFF:" ) )
282 startNewScript( line_r.substr( 7 ) ); // new scripts ident sent by rpm
283 else
284 sendScriptOutput( line_r );
285 } );
286 if ( res != 0 )
287 _myJobReport.error( str::Format("rpm --runposttrans returned %1%.") % res );
288
289 _dumpfile = std::nullopt;
290 }
291
292 // send a final progress report
293 scriptProgress.name( scriptProgressName );
294 if ( res == 0 )
295 scriptProgress.toMax(); // Indicate 100%, in case Dumpfile::_numscripts estimation was off
296 return;
297 }
298
303 void discardScripts()
304 {
305 if ( not ( _scripts || _dumpfile ) )
306 return; // Nothing todo
307
308 str::Str msg;
309
310 if ( _scripts ) {
311 // Legacy format logs all collected %posttrans
312 msg << "%posttrans scripts skipped while aborting:" << endl;
313 for ( const auto & script : *_scripts )
314 {
315 WAR << "UNEXECUTED posttrans: " << script.first << endl;
316 const std::string & pkgident( script.first.substr( 0, script.first.size()-6 ) ); // strip tmp file suffix[6]
317 msg << " " << pkgident << "\n";
318 }
319 _scripts = std::nullopt;
320 }
321
322 if ( _dumpfile ) {
323 msg << "%posttrans and %transfiletrigger scripts are not executed when aborting!" << endl;
324 _dumpfile = std::nullopt;
325 }
326
327 HistoryLog historylog;
328 historylog.comment( msg, true /*timestamp*/);
329 _myJobReport.warning( msg );
330 }
331
332 private:
334 Pathname tmpDir()
335 {
336 if ( !_ptrTmpdir ) _ptrTmpdir.reset( new filesystem::TmpDir( _root / ZConfig::instance().update_scriptsPath(), "posttrans" ) );
337 DBG << _ptrTmpdir->path() << endl;
338 return _ptrTmpdir->path();
339 }
340
342 bool headerHasPosttrans( const rpm::RpmHeader::constPtr& pkg_r ) const
343 {
344 bool ret = false;
345 if ( pkg_r ) {
346 std::string prog( pkg_r->tag_posttransprog() );
347 if ( not prog.empty() && prog != "<lua>" ) // by now leave lua to rpm
348 ret = true;
349 }
350 return ret;
351 }
352
356 rpm::RpmHeader::constPtr getHeaderIfPosttrans( const Pathname & rpmPackage_r )
357 {
358 if ( _headercache.first == rpmPackage_r )
359 return _headercache.second;
360
361 rpm::RpmHeader::constPtr ret { rpm::RpmHeader::readPackage( rpmPackage_r, rpm::RpmHeader::NOVERIFY ) };
362 if ( ret ) {
363 if ( not headerHasPosttrans( ret ) )
364 ret = nullptr;
365 } else {
366 WAR << "Unexpectedly this is no package: " << rpmPackage_r << endl;
367 }
368 _headercache = std::make_pair( rpmPackage_r, ret );
369 return ret;
370 }
371
373 void recallFromDumpfile( const Pathname & dumpfile_r, std::function<void(std::string,std::string,std::string,std::string)> consume_r )
374 {
375 // dump_posttrans: install 10 terminfo-base-6.4.20230819-19.1.x86_64
376 static const str::regex rxInstalled { "^dump_posttrans: +install +[0-9]+ +(.+)-([^-]+)-([^-]+)\\.([^.]+)" };
377 str::smatch what;
378 iostr::forEachLine( InputStream( dumpfile_r ), [&]( int num_r, const std::string& line_r ) -> bool {
379 if( str::regex_match( line_r, what, rxInstalled ) )
380 consume_r( what[1], what[2], what[3], what[4] );
381 return true; // continue iostr::forEachLine
382 } );
383 }
384
385 private:
386 Pathname _root;
387 std::optional<ScriptList> _scripts;
388 std::optional<Dumpfile> _dumpfile;
389 scoped_ptr<filesystem::TmpDir> _ptrTmpdir;
390
391 UserDataJobReport _myJobReport;
392
393 std::pair<Pathname,rpm::RpmHeader::constPtr> _headercache;
394 };
395
397 inline std::ostream & operator<<( std::ostream & str, const RpmPostTransCollector::Impl & obj )
398 { return str << "RpmPostTransCollector::Impl"; }
399
401 inline std::ostream & dumpOn( std::ostream & str, const RpmPostTransCollector::Impl & obj )
402 { return str << obj; }
403
405 //
406 // CLASS NAME : RpmPostTransCollector
407 //
409
410 RpmPostTransCollector::RpmPostTransCollector( Pathname root_r )
411 : _pimpl( new Impl( std::move(root_r) ) )
412 {}
413
414 RpmPostTransCollector::~RpmPostTransCollector()
415 {}
416
417 bool RpmPostTransCollector::hasPosttransScript( const Pathname & rpmPackage_r )
418 { return _pimpl->hasPosttransScript( rpmPackage_r ); }
419
420 void RpmPostTransCollector::collectPosttransInfo( const Pathname & rpmPackage_r, const std::vector<std::string> & runposttrans_r )
421 { _pimpl->collectPosttransInfo( rpmPackage_r, runposttrans_r ); }
422
423 void RpmPostTransCollector::collectPosttransInfo( const std::vector<std::string> & runposttrans_r )
424 { _pimpl->collectPosttransInfo( runposttrans_r ); }
425
426 void RpmPostTransCollector::executeScripts( rpm::RpmDb & rpm_r, const IdStringSet & obsoletedPackages_r )
427 { _pimpl->executeScripts( rpm_r, obsoletedPackages_r ); }
428
429 void RpmPostTransCollector::discardScripts()
430 { return _pimpl->discardScripts(); }
431
432 std::ostream & operator<<( std::ostream & str, const RpmPostTransCollector & obj )
433 { return str << *obj._pimpl; }
434
435 std::ostream & dumpOn( std::ostream & str, const RpmPostTransCollector & obj )
436 { return dumpOn( str, *obj._pimpl ); }
437
438 } // namespace target
440} // namespace zypp
HistoryLog.h
InputStream.h
RpmDb.h
RpmPostTransCollector.h
ZConfig.h
ZYppCallbacks.h
bool
scoped_ptr
zypp::ExternalProgram
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
Definition ExternalProgram.h:64
zypp::ExternalProgram::close
int close() override
Wait for the progamm to complete.
Definition ExternalProgram.cc:357
zypp::ExternalProgram::Arguments
std::vector< std::string > Arguments
Definition ExternalProgram.h:68
zypp::ExternalProgram::Stderr_To_Stdout
@ Stderr_To_Stdout
Definition ExternalProgram.h:77
zypp::HistoryLog
Writing the zypp history file.
Definition HistoryLog.h:57
zypp::HistoryLog::comment
void comment(const std::string &comment, bool timestamp=false)
Log a comment (even multiline).
Definition HistoryLog.cc:190
zypp::IdString
Access to the sat-pools string space.
Definition IdString.h:44
zypp::InputStream
Helper to create and pass std::istream.
Definition inputstream.h:57
zypp::ProgressData
Maintain [min,max] and counter (value) for progress counting.
Definition progressdata.h:132
zypp::ProgressData::value_type
long long value_type
Definition progressdata.h:134
zypp::ProgressData::sendTo
void sendTo(const ReceiverFnc &fnc_r)
Set ReceiverFnc.
Definition progressdata.h:229
zypp::ProgressData::ReceiverFnc
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
Definition progressdata.h:140
zypp::ZConfig::instance
static ZConfig & instance()
Singleton ctor.
Definition ZConfig.cc:940
zypp::externalprogram::ExternalDataSource::receiveLine
std::string receiveLine()
Read one line from the input stream.
Definition ExternalDataSource.cc:115
zypp::filesystem::PathInfo
Wrapper class for stat/lstat.
Definition PathInfo.h:226
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:47
zypp::filesystem::Pathname::c_str
const char * c_str() const
String representation.
Definition Pathname.h:112
zypp::filesystem::Pathname::basename
std::string basename() const
Return the last component of this path.
Definition Pathname.h:130
zypp::filesystem::TmpDir
Provide a new empty temporary directory and recursively delete it when no longer needed.
Definition TmpPath.h:188
zypp::filesystem::TmpFile
Provide a new empty temporary file and delete it when no longer needed.
Definition TmpPath.h:128
zypp::filesystem::TmpPath::path
Pathname path() const
Definition TmpPath.cc:152
zypp::filesystem::TmpPath::autoCleanup
bool autoCleanup() const
Whether path is valid and deleted when the last reference drops.
Definition TmpPath.cc:169
zypp::str::regex
Regular expression.
Definition Regex.h:95
zypp::str::smatch
Regular expression match result.
Definition Regex.h:168
zypp::target::RpmPostTransCollector::Impl
RpmPostTransCollector implementation.
Definition RpmPostTransCollector.cc:49
zypp::target::RpmPostTransCollector::Impl::_myJobReport
UserDataJobReport _myJobReport
JobReport with ContentType "cmdout/%posttrans".
Definition RpmPostTransCollector.cc:391
zypp::target::RpmPostTransCollector::Impl::Impl
Impl(const Impl &)=delete
zypp::target::RpmPostTransCollector::Impl::discardScripts
void discardScripts()
Discard all remembered scrips.
Definition RpmPostTransCollector.cc:303
zypp::target::RpmPostTransCollector::Impl::operator=
Impl & operator=(const Impl &)=delete
zypp::target::RpmPostTransCollector::Impl::collectPosttransInfo
void collectPosttransInfo(const std::vector< std::string > &runposttrans_r)
Definition RpmPostTransCollector.cc:88
zypp::target::RpmPostTransCollector::Impl::~Impl
~Impl()
Definition RpmPostTransCollector.cc:79
zypp::target::RpmPostTransCollector::Impl::recallFromDumpfile
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.
Definition RpmPostTransCollector.cc:373
zypp::target::RpmPostTransCollector::Impl::getHeaderIfPosttrans
rpm::RpmHeader::constPtr getHeaderIfPosttrans(const Pathname &rpmPackage_r)
Cache RpmHeader for consecutive hasPosttransScript / collectScriptForPackage calls.
Definition RpmPostTransCollector.cc:356
zypp::target::RpmPostTransCollector::Impl::tmpDir
Pathname tmpDir()
Lazy create tmpdir on demand.
Definition RpmPostTransCollector.cc:334
zypp::target::RpmPostTransCollector::Impl::_dumpfile
std::optional< Dumpfile > _dumpfile
Definition RpmPostTransCollector.cc:388
zypp::target::RpmPostTransCollector::Impl::collectDumpPosttransLines
bool collectDumpPosttransLines(const std::vector< std::string > &runposttrans_r)
Return whether runposttrans lines were collected.
Definition RpmPostTransCollector.cc:120
zypp::target::RpmPostTransCollector::Impl::_scripts
std::optional< ScriptList > _scripts
Definition RpmPostTransCollector.cc:387
zypp::target::RpmPostTransCollector::Impl::collectPosttransInfo
void collectPosttransInfo(const Pathname &rpmPackage_r, const std::vector< std::string > &runposttrans_r)
Definition RpmPostTransCollector.cc:85
zypp::target::RpmPostTransCollector::Impl::_ptrTmpdir
scoped_ptr< filesystem::TmpDir > _ptrTmpdir
Definition RpmPostTransCollector.cc:389
zypp::target::RpmPostTransCollector::Impl::Impl
Impl(Pathname &&root_r)
Definition RpmPostTransCollector.cc:69
zypp::target::RpmPostTransCollector::Impl::_root
Pathname _root
Definition RpmPostTransCollector.cc:386
zypp::target::RpmPostTransCollector::Impl::operator<<
friend std::ostream & operator<<(std::ostream &str, const Impl &obj)
zypp::target::RpmPostTransCollector::Impl::ScriptList
std::list< std::pair< std::string, std::string > > ScriptList
<posttrans script basename, pkgname> pairs.
Definition RpmPostTransCollector.cc:54
zypp::target::RpmPostTransCollector::Impl::hasPosttransScript
bool hasPosttransScript(const Pathname &rpmPackage_r)
Definition RpmPostTransCollector.cc:82
zypp::target::RpmPostTransCollector::Impl::operator=
Impl & operator=(Impl &&)=delete
zypp::target::RpmPostTransCollector::Impl::dumpOn
std::ostream & dumpOn(std::ostream &str, const RpmPostTransCollector::Impl &obj)
Verbose stream output.
Definition RpmPostTransCollector.cc:401
zypp::target::RpmPostTransCollector::Impl::executeScripts
void executeScripts(rpm::RpmDb &rpm_r, const IdStringSet &obsoletedPackages_r)
Execute the remembered scripts.
Definition RpmPostTransCollector.cc:155
zypp::target::RpmPostTransCollector::Impl::Impl
Impl(Impl &&)=delete
zypp::target::RpmPostTransCollector::Impl::collectScriptFromHeader
void collectScriptFromHeader(const rpm::RpmHeader::constPtr &pkg)
Definition RpmPostTransCollector.cc:91
zypp::target::RpmPostTransCollector::Impl::_headercache
std::pair< Pathname, rpm::RpmHeader::constPtr > _headercache
Definition RpmPostTransCollector.cc:393
zypp::target::RpmPostTransCollector::Impl::operator<<
std::ostream & operator<<(std::ostream &str, const RpmPostTransCollector::Impl &obj)
Stream output.
Definition RpmPostTransCollector.cc:397
zypp::target::RpmPostTransCollector::Impl::dumpOn
friend std::ostream & dumpOn(std::ostream &str, const Impl &obj)
zypp::target::RpmPostTransCollector::Impl::collectScriptForPackage
void collectScriptForPackage(const Pathname &rpmPackage_r)
Definition RpmPostTransCollector.cc:112
zypp::target::RpmPostTransCollector::Impl::headerHasPosttrans
bool headerHasPosttrans(const rpm::RpmHeader::constPtr &pkg_r) const
Return whether RpmHeader has a posttrans.
Definition RpmPostTransCollector.cc:342
zypp::target::RpmPostTransCollector::collectPosttransInfo
void collectPosttransInfo(const Pathname &rpmPackage_r, const std::vector< std::string > &runposttrans_r)
Extract and remember a packages posttrans script or dump_posttrans lines for later execution.
Definition RpmPostTransCollector.cc:420
zypp::target::RpmPostTransCollector::_pimpl
RW_pointer< Impl > _pimpl
Implementation class.
Definition RpmPostTransCollector.h:70
zypp::target::RpmPostTransCollector::RpmPostTransCollector
RpmPostTransCollector(Pathname root_r)
Default ctor.
Definition RpmPostTransCollector.cc:410
zypp::target::RpmPostTransCollector::hasPosttransScript
bool hasPosttransScript(const Pathname &rpmPackage_r)
Test whether a package defines a posttrans script.
Definition RpmPostTransCollector.cc:417
zypp::target::RpmPostTransCollector::executeScripts
void executeScripts(rpm::RpmDb &rpm_r, const IdStringSet &obsoletedPackages_r)
Execute the remembered scripts and/or or dump_posttrans lines.
Definition RpmPostTransCollector.cc:426
zypp::target::RpmPostTransCollector::~RpmPostTransCollector
~RpmPostTransCollector()
Dtor.
Definition RpmPostTransCollector.cc:414
zypp::target::RpmPostTransCollector::discardScripts
void discardScripts()
Discard all remembered scripts and/or or dump_posttrans lines.
Definition RpmPostTransCollector.cc:429
zypp::target::rpm::RpmDb
Interface to the rpm program.
Definition RpmDb.h:51
zypp::target::rpm::RpmDb::runposttrans
int runposttrans(const Pathname &filename_r, const std::function< void(const std::string &)> &output_r)
Run collected posttrans and transfiletrigger(postun|in) if rpm --runposttrans is supported.
Definition RpmDb.cc:2003
zypp::target::rpm::RpmDb::dbConstIterator
db_const_iterator dbConstIterator() const
Definition RpmDb.cc:244
zypp::target::rpm::RpmHeader::constPtr
intrusive_ptr< const RpmHeader > constPtr
Definition RpmHeader.h:65
zypp::target::rpm::RpmHeader::readPackage
static RpmHeader::constPtr readPackage(const Pathname &path, VERIFICATION verification=VERIFY)
Get an accessible packages data from disk.
Definition RpmHeader.cc:212
zypp::target::rpm::RpmHeader::NOVERIFY
@ NOVERIFY
Definition RpmHeader.h:198
librpmDb.h
std
Definition Arch.h:364
str
String related utilities and Regular expression matching.
zypp::base::NonCopyable
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition NonCopyable.h:26
zypp::filesystem::addmod
int addmod(const Pathname &path, mode_t mode)
Add the mode bits to the file given by path.
Definition PathInfo.cc:1109
zypp::iostr::forEachLine
int forEachLine(std::istream &str_r, const function< bool(int, std::string)> &consume_r)
Simple lineparser: Call functor consume_r for each line.
Definition IOStream.cc:100
zypp::str::numstring
std::string numstring(char n, int w=0)
Definition String.h:290
zypp::str::regex_match
bool regex_match(const std::string &s, smatch &matches, const regex &regex)
\relates regex \ingroup ZYPP_STR_REGEX \relates regex \ingroup ZYPP_STR_REGEX
Definition Regex.h:70
zypp::target::dumpOn
std::ostream & dumpOn(std::ostream &str, const RpmPostTransCollector &obj)
Definition RpmPostTransCollector.cc:435
zypp::target::operator<<
std::ostream & operator<<(std::ostream &str, const CommitPackageCache &obj)
Definition CommitPackageCache.cc:160
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::IdStringSet
std::unordered_set< IdString > IdStringSet
Definition IdString.h:29
zypp::OnScopeExit
AutoDispose< void > OnScopeExit
Definition AutoDispose.h:276
zypp::asString
std::string asString(const Patch::Category &obj)
Definition Patch.cc:122
zypp::ProgressReportAdaptor
Definition ZYppCallbacks.h:60
zypp::UserDataJobReport
JobReport convenience sending this instance of UserData with each message.
Definition ZYppCallbacks.h:1125
zypp::callback::SendReport
Definition Callback.h:237
zypp::str::Format
Convenient building of std::string with boost::format.
Definition String.h:254
zypp::str::Str
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Definition String.h:213
zypp::target::RpmPostTransCollector::Impl::Dumpfile
Data regarding the dumpfile used if rpm --runposttrans is supported.
Definition RpmPostTransCollector.cc:58
zypp::target::RpmPostTransCollector::Impl::Dumpfile::_runposttrans
bool _runposttrans
Set to false if rpm lost –runposttrans support during transaction.
Definition RpmPostTransCollector.cc:65
zypp::target::RpmPostTransCollector::Impl::Dumpfile::Dumpfile
Dumpfile(Pathname dumpfile_r)
Definition RpmPostTransCollector.cc:59
zypp::target::RpmPostTransCollector::Impl::Dumpfile::_dumpfile
Pathname _dumpfile
The file holding the collected dump_posttrans: lines.
Definition RpmPostTransCollector.cc:63
zypp::target::RpmPostTransCollector::Impl::Dumpfile::_numscripts
size_t _numscripts
Number of scripts we collected (roughly estimated)
Definition RpmPostTransCollector.cc:64
zypp::target::rpm::RpmDb::db_const_iterator
Wrapper providing a librpmDb::db_const_iterator for this RpmDb.
Definition RpmDb.h:65
_
#define _(MSG)
Definition Gettext.h:39
DBG
#define DBG
Definition Logger.h:99
MIL
#define MIL
Definition Logger.h:100
WAR
#define WAR
Definition Logger.h:101
ExternalProgram.h
PathInfo.h
TmpPath.h
Gettext.h
Interface to gettext.
IOStream.h
LogTools.h
NonCopyable.h
PtrTypes.h
Regex.h