28 #undef ZYPP_BASE_LOGGER_LOGGROUP 29 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::posttrans" 45 friend std::ostream &
dumpOn( std::ostream &
str,
const Impl & obj );
60 WAR <<
"Unexpectedly this is no package: " << rpmPackage_r << endl;
64 std::string prog( pkg->tag_posttransprog() );
65 if ( prog.empty() || prog ==
"<lua>" )
70 script.autoCleanup(
false );
72 std::ofstream out( script.path().c_str() );
73 out <<
"#! " << pkg->tag_posttransprog() << endl
74 << pkg->tag_posttrans() << endl;
76 _scripts.push_back( script.path().basename() );
77 MIL <<
"COLLECT posttrans: " <<
PathInfo( script.path() ) << endl;
97 bool firstScript =
true;
100 const std::string & script =
_scripts.front();
101 const std::string & pkgident( script.substr( 0, script.size()-6 ) );
103 scriptProgress.
name(
str::Format(
_(
"Executing %%posttrans script '%1%'")) % pkgident );
105 bool canContinue =
true;
108 canContinue = scriptProgress.
toMin();
110 canContinue = scriptProgress.
incr();
115 msg <<
"Execution of %posttrans scripts cancelled";
117 historylog.
comment( msg,
true );
122 MIL <<
"EXECUTE posttrans: " << script << endl;
129 collect <<
" " << line;
135 int ret = prog.
close();
136 const std::string & scriptmsg( collect );
138 if ( ret != 0 || ! scriptmsg.empty() )
140 if ( ! scriptmsg.empty() )
143 msg <<
"Output of " << pkgident <<
" %posttrans script:\n" << scriptmsg;
144 historylog.
comment( msg,
true );
152 msg << pkgident <<
" %posttrans script failed (returned " << ret <<
")";
154 historylog.
comment( msg,
true );
161 scriptProgress.
name(
_(
"Executing %posttrans scripts") );
162 scriptProgress.
toMax();
176 msg <<
"%posttrans scripts skipped while aborting:\n";
177 for (
const auto & script :
_scripts )
179 const std::string & pkgident( script.substr( 0, script.size()-6 ) );
180 WAR <<
"UNEXECUTED posttrans: " << script << endl;
181 msg <<
" " << pkgident <<
"\n";
184 historylog.
comment( msg,
true );
208 {
return str <<
"RpmPostTransCollector::Impl"; }
212 {
return str << obj; }
221 : _pimpl( new
Impl( root_r ) )
std::string asString(const DefaultIntegral< Tp, TInitial > &obj)
void sendTo(const ReceiverFnc &fnc_r)
Set ReceiverFnc.
static ZConfig & instance()
Singleton ctor.
void discardScripts()
Discard all remembered scrips.
friend std::ostream & dumpOn(std::ostream &str, const Impl &obj)
String related utilities and Regular expression matching.
bool toMax()
Set counter value to current max value (unless no range).
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.
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
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.
bool toMin()
Set counter value to current min value.
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.
bool executeScripts()
Execute the remembered scripts.
RpmPostTransCollector implementation.
Maintain [min,max] and counter (value) for progress counting.
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...
bool incr(value_type val_r=1)
Increment counter value (default by 1).
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.
Typesafe passing of user data via callbacks.
~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).
Wrapper class for ::stat/::lstat.
bool executeScripts()
Execute the remembered scripts.
static bool info(const std::string &msg_r, const UserData &userData_r=UserData())
send message text
void name(const std::string &name_r)
Set counter name.
Easy-to use interface to the ZYPP dependency resolver.
friend std::ostream & operator<<(std::ostream &str, const Impl &obj)
std::ostream & operator<<(std::ostream &str, const RpmPostTransCollector::Impl &obj)