Go to the documentation of this file.
29 #undef ZYPP_BASE_LOGGER_LOGGROUP
30 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp::posttrans"
61 WAR <<
"Unexpectedly this is no package: " << rpmPackage_r << endl;
65 std::string prog( pkg->tag_posttransprog() );
66 if ( prog.empty() || prog ==
"<lua>" )
73 std::ofstream out( script.
path().
c_str() );
74 out <<
"#! " << pkg->tag_posttransprog() << endl
75 << pkg->tag_posttrans() << endl;
78 MIL <<
"COLLECT posttrans: '" <<
PathInfo( script.
path() ) <<
"' for package: '" << pkg->tag_name() <<
"'" << endl;
98 bool firstScript =
true;
101 const auto &scriptPair =
_scripts.front();
102 const std::string & script = scriptPair.first;
103 const std::string & pkgident( script.substr( 0, script.size()-6 ) );
105 scriptProgress.
name(
str::Format(
_(
"Executing %%posttrans script '%1%'")) % pkgident );
107 bool canContinue =
true;
110 canContinue = scriptProgress.
toMin();
112 canContinue = scriptProgress.
incr();
117 msg <<
"Execution of %posttrans scripts cancelled";
119 historylog.
comment( msg,
true );
126 for ( it.
findByName( scriptPair.second ); *it; ++it )
129 MIL <<
"EXECUTE posttrans: " << script <<
" with argument: " << npkgs << endl;
136 collect <<
" " << line;
142 int ret = prog.
close();
143 const std::string & scriptmsg( collect );
145 if ( ret != 0 || ! scriptmsg.empty() )
147 if ( ! scriptmsg.empty() )
150 msg <<
"Output of " << pkgident <<
" %posttrans script:\n" << scriptmsg;
151 historylog.
comment( msg,
true );
159 msg << pkgident <<
" %posttrans script failed (returned " << ret <<
")";
161 historylog.
comment( msg,
true );
168 scriptProgress.
name(
_(
"Executing %posttrans scripts") );
169 scriptProgress.
toMax();
183 msg <<
"%posttrans scripts skipped while aborting:\n";
184 for (
const auto & script :
_scripts )
186 const std::string & pkgident( script.first.substr( 0, script.first.size()-6 ) );
187 WAR <<
"UNEXECUTED posttrans: " << script.first << endl;
188 msg <<
" " << pkgident <<
"\n";
191 historylog.
comment( msg,
true );
209 std::list< std::pair< std::string, std::string > >
_scripts;
215 {
return str <<
"RpmPostTransCollector::Impl"; }
219 {
return str << obj; }
228 : _pimpl( new
Impl( root_r ) )
bool executeScripts()
Execute the remembered scripts.
friend std::ostream & dumpOn(std::ostream &str, const Impl &obj)
std::list< std::pair< std::string, std::string > > _scripts
std::ostream & dumpOn(std::ostream &str, const RpmPostTransCollector &obj)
RpmPostTransCollector implementation.
Impl(const Pathname &root_r)
static bool info(const std::string &msg_r, const UserData &userData_r=UserData())
send message text
std::ostream & dumpOn(std::ostream &str, const RpmPostTransCollector::Impl &obj)
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
Typesafe passing of user data via callbacks.
void name(const std::string &name_r)
Set counter name.
~RpmPostTransCollector()
Dtor.
RW_pointer< Impl > _pimpl
Implementation class.
Extract and remember posttrans scripts for later execution.
void discardScripts()
Discard all remembered scrips.
Wrapper class for ::stat/::lstat.
std::ostream & operator<<(std::ostream &str, const CommitPackageCache &obj)
Provide a new empty temporary file and delete it when no longer needed.
Provide a new empty temporary directory and recursively delete it when no longer needed.
Pathname tmpDir()
Lazy create tmpdir on demand.
const char * c_str() const
String representation.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Writing the zypp history file.
boost::scoped_ptr< filesystem::TmpDir > _ptrTmpdir
static ZConfig & instance()
Singleton ctor.
Easy-to use interface to the ZYPP dependency resolver.
std::string numstring(char n, int w=0)
RpmPostTransCollector(const Pathname &root_r)
Default ctor.
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
int close()
Wait for the progamm to complete.
bool collectScriptFromPackage(ManagedFile rpmPackage_r)
Extract and remember a packages posttrans script for later execution.
bool collectScriptFromPackage(ManagedFile rpmPackage_r)
Extract and remember a packages posttrans script for later execution.
Subclass to retrieve database content.
bool findByName(const std::string &name_r)
Reset to iterate all packages with a certain name.
int addmod(const Pathname &path, mode_t mode)
Add the mode bits to the file given by path.
std::string asString(const DefaultIntegral< Tp, TInitial > &obj)
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
void sendTo(const ReceiverFnc &fnc_r)
Set ReceiverFnc.
bool toMax()
Set counter value to current max value (unless no range).
std::string receiveLine()
Read one line from the input stream.
static bool warning(const std::string &msg_r, const UserData &userData_r=UserData())
send warning text
bool toMin()
Set counter value to current min value.
void discardScripts()
Discard all remembered scrips.
bool executeScripts()
Execute the remembered scripts.
std::string basename() const
Return the last component of this path.
String related utilities and Regular expression matching.
friend std::ostream & operator<<(std::ostream &str, const Impl &obj)
void comment(const std::string &comment, bool timestamp=false)
Log a comment (even multiline).
bool autoCleanup() const
Whether path is valid and deleted when the last reference drops.
std::ostream & operator<<(std::ostream &str, const RpmPostTransCollector::Impl &obj)
Maintain [min,max] and counter (value) for progress counting.
bool incr(value_type val_r=1)
Increment counter value (default by 1).