26 #undef ZYPP_BASE_LOGGER_LOGGROUP
27 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::posttrans"
42 friend std::ostream &
operator<<( std::ostream & str,
const Impl & obj );
43 friend std::ostream &
dumpOn( std::ostream & str,
const Impl & obj );
45 Impl(
const Pathname & root_r )
57 std::string prog( pkg->tag_posttransprog() );
58 if ( prog.empty() || prog ==
"<lua>" )
63 script.autoCleanup(
false );
65 std::ofstream out( script.path().c_str() );
66 out <<
"#! " << pkg->tag_posttransprog() << endl
67 << pkg->tag_posttrans() << endl;
69 _scripts.push_back( script.path().basename() );
70 MIL <<
"COLLECT posttrans: " << PathInfo( script.path() ) << endl;
86 for (
const auto & script :
_scripts )
88 MIL <<
"EXECUTE posttrans: " << script << endl;
95 collect <<
" " << line;
97 int ret = prog.
close();
98 const std::string & scriptmsg( collect );
100 if ( ret != 0 || ! scriptmsg.empty() )
102 const std::string & pkgident( script.substr( 0, script.size()-6 ) );
104 if ( ! scriptmsg.empty() )
107 msg <<
"Output of " << pkgident <<
" %posttrans script:\n" << scriptmsg;
108 historylog.
comment( msg,
true );
115 msg << pkgident <<
" %posttrans script failed (returned " << ret <<
")";
117 historylog.
comment( msg,
true );
134 msg <<
"%posttrans scripts skipped while aborting:\n";
135 for (
const auto & script :
_scripts )
137 const std::string & pkgident( script.substr( 0, script.size()-6 ) );
138 WAR <<
"UNEXECUTED posttrans: " << script << endl;
139 msg <<
" " << pkgident <<
"\n";
142 historylog.
comment( msg,
true );
165 {
return str <<
"RpmPostTransCollector::Impl"; }
169 {
return str << obj; }
178 : _pimpl( new
Impl( root_r ) )
194 {
return str << *obj.
_pimpl; }
std::string asString(const Patch::Category &obj)
static ZConfig & instance()
Singleton ctor.
void discardScripts()
Discard all remembered scrips.
friend std::ostream & dumpOn(std::ostream &str, const Impl &obj)
static bool warning(const std::string &msg_r, const UserData &userData_r=UserData())
send warning text
Impl(const Pathname &root_r)
std::ostream & dumpOn(std::ostream &str, const RpmPostTransCollector::Impl &obj)
Provide a new empty temporary file and delete it when no longer needed.
void executeScripts()
Execute te remembered scripts.
std::list< std::string > _scripts
RW_pointer< Impl > _pimpl
Implementation class.
RpmPostTransCollector(const Pathname &root_r)
Default ctor.
Extract and remember posttrans scripts for later execution.
Pathname tmpDir()
Lazy create tmpdir on demand.
int addmod(const Pathname &path, mode_t mode)
Add the mode bits to the file given by path.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Provide a new empty temporary directory and recursively delete it when no longer needed.
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
bool collectScriptFromPackage(ManagedFile rpmPackage_r)
Extract and remember a packages posttrans script for later execution.
RpmPostTransCollector implementation.
std::ostream & operator<<(std::ostream &str, const CommitPackageCache &obj)
boost::scoped_ptr< filesystem::TmpDir > _ptrTmpdir
Writing the zypp history fileReference counted signleton for writhing the zypp history file...
std::string receiveLine()
Read one line from the input stream.
std::ostream & dumpOn(std::ostream &str, const RpmPostTransCollector &obj)
int close()
Wait for the progamm to complete.
bool collectScriptFromPackage(ManagedFile rpmPackage_r)
Extract and remember a packages posttrans script for later execution.
void discardScripts()
Discard all remembered scrips.
~RpmPostTransCollector()
Dtor.
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
void comment(const std::string &comment, bool timestamp=false)
Log a comment (even multiline).
void executeScripts()
Execute te remembered scripts.
static bool info(const std::string &msg_r, const UserData &userData_r=UserData())
send message text
friend std::ostream & operator<<(std::ostream &str, const Impl &obj)
std::ostream & operator<<(std::ostream &str, const RpmPostTransCollector::Impl &obj)