## Default value: no
##
# rpm.install.excludedocs = no
+
+##
+## Location of history log file.
+##
+## The history log is described at
+## http://en.opensuse.org/Libzypp/Package_History
+##
+## Valid values: absolute path to a file
+## Default value: /var/log/zypp/history
+##
+# history.logfile = /var/log/zypp/history
ExternalProgram.cc
Fetcher.cc
FileChecker.cc
+ HistoryLog.cc
IdString.cc
KeyRing.cc
Locks.cc
ExternalProgram.h
Fetcher.h
FileChecker.h
+ HistoryLog.h
IdString.h
IdStringType.h
KeyContext.h
target/RequestedLocalesFile.cc
target/SoftLocksFile.cc
target/HardLocksFile.cc
- target/CommitLog.cc
target/CommitPackageCache.cc
target/CommitPackageCacheImpl.cc
target/CommitPackageCacheReadAhead.cc
target/RequestedLocalesFile.h
target/SoftLocksFile.h
target/HardLocksFile.h
- target/CommitLog.h
target/CommitPackageCache.h
target/CommitPackageCacheImpl.h
target/CommitPackageCacheReadAhead.h
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/target/HistoryLog.cc
+ *
+ */
+#include <iostream>
+#include <fstream>
+#include <unistd.h>
+
+#include "zypp/ZConfig.h"
+#include "zypp/base/String.h"
+#include "zypp/base/Logger.h"
+
+#include "zypp/PathInfo.h"
+#include "zypp/Date.h"
+
+#include "zypp/PoolItem.h"
+#include "zypp/Package.h"
+#include "zypp/RepoInfo.h"
+
+#include "zypp/HistoryLog.h"
+
+using std::endl;
+using std::string;
+
+namespace
+{
+ inline string timestamp()
+ { return zypp::Date::now().form( "%Y-%m-%d %H:%M:%S" ); }
+
+ inline string userAtHostname()
+ {
+ static char buf[256];
+ string result;
+ char * tmp = ::cuserid(buf);
+ if (tmp)
+ {
+ result = string(tmp);
+ if (!::gethostname(buf, 255))
+ result += "@" + string(buf);
+ }
+ return result;
+ }
+}
+
+namespace zypp
+{
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : HistoryActionID
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ static std::map<std::string,HistoryActionID::ID> _table;
+
+ const HistoryActionID HistoryActionID::NONE(HistoryActionID::NONE_e);
+ const HistoryActionID HistoryActionID::INSTALL(HistoryActionID::INSTALL_e);
+ const HistoryActionID HistoryActionID::REMOVE(HistoryActionID::REMOVE_e);
+ const HistoryActionID HistoryActionID::REPO_ADD(HistoryActionID::REPO_ADD_e);
+ const HistoryActionID HistoryActionID::REPO_REMOVE(HistoryActionID::REPO_REMOVE_e);
+ const HistoryActionID HistoryActionID::REPO_CHANGE_ALIAS(HistoryActionID::REPO_CHANGE_ALIAS_e);
+ const HistoryActionID HistoryActionID::REPO_CHANGE_URL(HistoryActionID::REPO_CHANGE_URL_e);
+
+ HistoryActionID::HistoryActionID(const std::string & strval_r)
+ : _id(parse(strval_r))
+ {}
+
+ HistoryActionID::ID HistoryActionID::parse(const std::string & strval_r)
+ {
+ if (_table.empty())
+ {
+ // initialize it
+ _table["install"] = INSTALL_e;
+ _table["remove"] = REMOVE_e;
+ _table["radd"] = REPO_ADD_e;
+ _table["rremove"] = REPO_REMOVE_e;
+ _table["ralias"] = REPO_CHANGE_ALIAS_e;
+ _table["rurl"] = REPO_CHANGE_URL_e;
+ _table["NONE"] = _table["none"] = HistoryActionID::NONE_e;
+ }
+
+ std::map<std::string,HistoryActionID::ID>::const_iterator it =
+ _table.find(strval_r);
+
+ if (it == _table.end())
+ WAR << "Unknown history action ID '" + strval_r + "'";
+
+ return it->second;
+ }
+
+
+ const std::string & HistoryActionID::asString(bool pad) const
+ {
+ static std::map<ID, std::string> _table;
+ if ( _table.empty() )
+ {
+ // initialize it
+ _table[INSTALL_e] = "install";
+ _table[REMOVE_e] = "remove";
+ _table[REPO_ADD_e] = "radd";
+ _table[REPO_REMOVE_e] = "rremove";
+ _table[REPO_CHANGE_ALIAS_e] = "ralias";
+ _table[REPO_CHANGE_URL_e] = "rurl";
+ _table[NONE_e] = "NONE";
+ }
+ // add spaces so that the size of the returned string is always 7 (for now)
+ if (pad)
+ return _table[_id].append(7 - _table[_id].size(), ' ');
+ return _table[_id];
+ }
+
+ std::ostream & operator << (std::ostream & str, const HistoryActionID & id)
+ { return str << id.asString(); }
+
+ ///////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : HistoryLog
+ //
+ ///////////////////////////////////////////////////////////////////
+
+ Pathname HistoryLog::_fname(ZConfig::instance().historyLogFile());
+ std::ofstream HistoryLog::_log;
+ unsigned HistoryLog::_refcnt = 0;
+ const char HistoryLog::_sep = '|';
+
+ ///////////////////////////////////////////////////////////////////
+
+ HistoryLog::HistoryLog( const Pathname & rootdir )
+ {
+ refUp();
+ if (!rootdir.empty() && rootdir.absolute())
+ _fname = rootdir / ZConfig::instance().historyLogFile();
+ }
+
+ void HistoryLog::openLog()
+ {
+ if ( !_fname.empty() )
+ {
+ _log.clear();
+ _log.open( _fname.asString().c_str(), std::ios::out|std::ios::app );
+ if( !_log )
+ ERR << "Could not open logfile '" << _fname << "'" << endl;
+ }
+ }
+
+ void HistoryLog::closeLog()
+ {
+ _log.clear();
+ _log.close();
+ }
+
+ void HistoryLog::refUp()
+ {
+ if ( !_refcnt )
+ openLog();
+ ++_refcnt;
+ }
+
+ void HistoryLog::refDown()
+ {
+ --_refcnt;
+ if ( !_refcnt )
+ closeLog();
+ }
+
+
+ void HistoryLog::setRoot( const Pathname & rootdir )
+ {
+ if (rootdir.empty() || !rootdir.absolute())
+ return;
+
+ if ( _refcnt )
+ closeLog();
+
+ _fname = rootdir / "/var/log/zypp/history";
+ filesystem::assert_dir( _fname.dirname() );
+ MIL << "installation log file " << _fname << endl;
+
+ if ( _refcnt )
+ openLog();
+ }
+
+
+ const Pathname & HistoryLog::fname()
+ { return _fname; }
+
+ /////////////////////////////////////////////////////////////////////////
+
+ void HistoryLog::comment( const string & comment, bool timestamp )
+ {
+ if (comment.empty())
+ return;
+
+ _log << "# ";
+ if ( timestamp )
+ _log << ::timestamp() << " ";
+
+ const char * s = comment.c_str();
+ const char * c = s;
+ unsigned size = comment.size();
+
+ // ignore the last newline
+ if (comment[size-1] == '\n')
+ --size;
+
+ for ( unsigned i = 0; i < size; ++i, ++c )
+ if ( *c == '\n' )
+ {
+ _log << string( s, c + 1 - s ) << "# ";
+ s = c + 1;
+ }
+
+ if ( s < c )
+ _log << std::string( s, c-s );
+
+ _log << endl;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+
+ void HistoryLog::install( const PoolItem & pi )
+ {
+ const Package::constPtr p = asKind<Package>(pi.resolvable());
+ if (!p)
+ return;
+
+ _log
+ << timestamp() // 1 timestamp
+ << _sep << HistoryActionID::INSTALL.asString(true) // 2 action
+ << _sep << p->name() // 3 name
+ << _sep << p->edition() // 4 evr
+ << _sep << p->arch(); // 5 arch
+
+ if (pi.status().isByUser())
+ _log << _sep << userAtHostname(); // 6 reqested by
+ //else if (pi.status().isByApplHigh() || pi.status().isByApplLow())
+ // _log << _sep << "appl";
+ else
+ _log << _sep;
+
+ _log
+ << _sep << p->repoInfo().alias() // 7 repo alias
+ << _sep << p->checksum().checksum(); // 8 checksum
+
+ _log << endl;
+
+ //_log << pi << endl;
+ }
+
+
+ void HistoryLog::remove( const PoolItem & pi )
+ {
+ const Package::constPtr p = asKind<Package>(pi.resolvable());
+ if (!p)
+ return;
+
+ _log
+ << timestamp() // 1 timestamp
+ << _sep << HistoryActionID::REMOVE.asString(true) // 2 action
+ << _sep << p->name() // 3 name
+ << _sep << p->edition() // 4 evr
+ << _sep << p->arch(); // 5 arch
+
+ if (pi.status().isByUser())
+ _log << _sep << userAtHostname(); // 6 reqested by
+ //else if (pi.status().isByApplHigh() || pi.status().isByApplLow())
+ // _log << _sep << "appl";
+ else
+ _log << _sep;
+
+ // we don't have checksum in rpm db
+ // << _sep << p->checksum().checksum(); // x checksum
+
+ _log << endl;
+
+ //_log << pi << endl;
+ }
+
+ /////////////////////////////////////////////////////////////////////////
+
+ void HistoryLog::addRepository(const RepoInfo & repo)
+ {
+ _log
+ << timestamp() // 1 timestamp
+ << _sep << HistoryActionID::REPO_ADD.asString(true) // 2 action
+ << _sep << repo.alias() // 3 alias
+ // what about the rest of the URLs??
+ << _sep << *repo.baseUrlsBegin() // 4 primary URL
+ << endl;
+ }
+
+
+ void HistoryLog::removeRepository(const RepoInfo & repo)
+ {
+ _log
+ << timestamp() // 1 timestamp
+ << _sep << HistoryActionID::REPO_REMOVE.asString(true) // 2 action
+ << _sep << repo.alias() // 3 alias
+ << endl;
+ }
+
+
+ void HistoryLog::modifyRepository(
+ const RepoInfo & oldrepo, const RepoInfo & newrepo)
+ {
+ if (oldrepo.alias() != newrepo.alias())
+ {
+ _log
+ << timestamp() // 1 timestamp
+ << _sep << HistoryActionID::REPO_CHANGE_ALIAS.asString(true) // 2 action
+ << _sep << oldrepo.alias() // 3 old alias
+ << _sep << newrepo.alias(); // 4 new alias
+ }
+
+ if (*oldrepo.baseUrlsBegin() != *newrepo.baseUrlsBegin())
+ {
+ _log
+ << timestamp() // 1 timestamp
+ << _sep << HistoryActionID::REPO_CHANGE_URL.asString(true) // 2 action
+ << _sep << oldrepo.alias() // 3 old url
+ << _sep << newrepo.alias(); // 4 new url
+ }
+ }
+
+ ///////////////////////////////////////////////////////////////////
+
+} // namespace zypp
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/target/HistoryLog.h
+ *
+ */
+#ifndef ZYPP_TARGET_COMMITLOG_H
+#define ZYPP_TARGET_COMMITLOG_H
+
+#include <iosfwd>
+
+#include "zypp/Pathname.h"
+
+namespace zypp
+{
+ class PoolItem;
+ class RepoInfo;
+
+ struct HistoryActionID
+ {
+ static const HistoryActionID NONE;
+
+ static const HistoryActionID INSTALL;
+ static const HistoryActionID REMOVE;
+ static const HistoryActionID REPO_ADD;
+ static const HistoryActionID REPO_REMOVE;
+ static const HistoryActionID REPO_CHANGE_ALIAS;
+ static const HistoryActionID REPO_CHANGE_URL;
+
+ enum ID
+ {
+ NONE_e,
+
+ INSTALL_e,
+ REMOVE_e,
+ REPO_ADD_e,
+ REPO_REMOVE_e,
+ REPO_CHANGE_ALIAS_e,
+ REPO_CHANGE_URL_e
+ };
+
+ HistoryActionID() : _id(NONE_e) {}
+
+ HistoryActionID(ID id) : _id(id) {}
+
+ explicit HistoryActionID(const std::string & strval_r);
+
+ ID toEnum() const { return _id; }
+
+ HistoryActionID::ID parse(const std::string & strval_r);
+
+ const std::string & asString(bool pad = false) const;
+
+ ID _id;
+ };
+
+ /** \relates HistoryActionID */
+ std::ostream & operator << (std::ostream & str, const HistoryActionID & id);
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : HistoryLog
+ /**
+ * Simple wrapper for progress log. Refcnt, filename and corresponding
+ * ofstream are static members. Logfile constructor raises, destructor
+ * lowers refcounter. On refcounter changing from 0->1, file is opened.
+ * Changing from 1->0 the file is closed. Thus Logfile objects should be
+ * local to those functions, writing the log, and must not be stored
+ * permanently.
+ *
+ * Usage:
+ * <code>
+ * some method ()
+ * {
+ * PoolItem pi;
+ * ...
+ * HistoryLog().install(pi);
+ * ...
+ * HistoryLog().comment(someMessage);
+ * }
+ * </code>
+ *
+ * \note Take care to set proper target root dir if needed. Either pass
+ * it via the constructor, or set it via setRoot(Pathname) method.
+ * The default location of the file is determined by
+ * \ref ZConfig::historyLogPath() which defaults to
+ * /var/log/zypp/history.
+ */
+ class HistoryLog
+ {
+ HistoryLog( const HistoryLog & );
+ HistoryLog & operator=( const HistoryLog & );
+ private:
+ static std::ofstream _log;
+ static unsigned _refcnt;
+ static Pathname _fname;
+ static const char _sep;
+
+ static void openLog();
+ static void closeLog();
+ static void refUp();
+ static void refDown();
+
+ public:
+ HistoryLog( const Pathname & rootdir = Pathname() );
+ ~HistoryLog()
+ { refDown(); }
+
+ static void setRoot( const Pathname & root );
+ static const Pathname & fname();
+
+ void comment( const std::string & comment, bool timestamp = false );
+ void install( const PoolItem & pi );
+ void remove( const PoolItem & pi );
+
+ void addRepository( const RepoInfo & repo );
+ void removeRepository( const RepoInfo & repo );
+ void modifyRepository( const RepoInfo & oldrepo, const RepoInfo & newrepo );
+ };
+ ///////////////////////////////////////////////////////////////////
+
+} // namespace zypp
+
+#endif // ZYPP_TARGET_COMMITLOG_H
#include <list>
#include <map>
#include <algorithm>
+
#include "zypp/base/InputStream.h"
#include "zypp/base/Logger.h"
#include "zypp/base/Gettext.h"
#include "zypp/base/Regex.h"
#include "zypp/PathInfo.h"
#include "zypp/TmpPath.h"
-#include "zypp/ServiceInfo.h"
+#include "zypp/ServiceInfo.h"
#include "zypp/repo/RepoException.h"
#include "zypp/RepoManager.h"
#include "zypp/Target.h" // for Target::targetDistribution() for repo index services
#include "zypp/ZYppFactory.h" // to get the Target from ZYpp instance
+#include "zypp/HistoryLog.h" // to write history :O)
#include "zypp/ZYppCallbacks.h"
//! \todo use a method calling UI callbacks to ask where to save creds?
cm.saveInUser(media::AuthData(*urlit));
}
+
+ HistoryLog().addRepository(tosave);
progress.toMax();
MIL << "done" << endl;
it->setFilepath(repofile.asString());
it->dumpAsIniOn(file);
_pimpl->repos.insert(*it);
+
+ HistoryLog(_pimpl->options.rootDir).addRepository(*it);
}
+
MIL << "done" << endl;
}
cleanMetadata( todelete, cleansubprogrcv);
_pimpl->repos.erase(todelete);
MIL << todelete.alias() << " sucessfully deleted." << endl;
+ HistoryLog(_pimpl->options.rootDir).removeRepository(todelete);
return;
} // else filepath is empty
_pimpl->repos.erase(toedit);
_pimpl->repos.insert(newinfo);
+ HistoryLog(_pimpl->options.rootDir).modifyRepository(toedit, newinfo);
}
}
std::ostream & Target::dumpOn( std::ostream & str ) const
{ return _pimpl->dumpOn( str ); }
- bool Target::setInstallationLogfile(const Pathname & path_r)
- { return _pimpl->setInstallationLogfile(path_r); }
-
Date Target::timestamp() const
{ return _pimpl->timestamp(); }
{
rpmInstallFlags.setFlag( target::rpm::RPMINST_EXCLUDEDOCS );
}
+ else if ( entry == "history.logfile" )
+ {
+ history_log_path = Pathname(value);
+ }
}
}
}
bool apply_locks_file;
target::rpm::RpmInstFlags rpmInstallFlags;
-
+
+ Pathname history_log_path;
};
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
- const std::string & ZConfig::cacheDBSplitJoinSeparator() const
- {
- static std::string s("!@$");
- return s;
- }
-
bool ZConfig::repo_add_probe() const
{
return _pimpl->repo_add_probe;
target::rpm::RpmInstFlags ZConfig::rpmInstallFlags() const
{ return _pimpl->rpmInstallFlags; }
+
+ Pathname ZConfig::historyLogFile() const
+ {
+ return ( _pimpl->history_log_path.empty() ?
+ Pathname("/var/log/zypp/history") : _pimpl->history_log_path );
+ }
+
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
Pathname knownServicesPath() const;
/**
- * Separator string for storing/reading sets of strings to/from
- * metadata cache DB.
- */
- const std::string & cacheDBSplitJoinSeparator() const;
-
- /**
* Whether repository urls should be probed.
/ config option
* repo.add.probe
*/
Pathname update_messagesPath() const;
- public:
/** \name Options for package installation */
//@{
/** The default \ref target::rpm::RpmInstFlags for \ref ZYppCommitPolicy.
target::rpm::RpmInstFlags rpmInstallFlags() const;
//@}
+ Pathname historyLogFile() const;
+
public:
class Impl;
/** Dtor */
+++ /dev/null
- /*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/target/CommitLog.cc
- *
-*/
-#include <iostream>
-#include <fstream>
-
-#include "zypp/base/Logger.h"
-
-#include "zypp/target/CommitLog.h"
-#include "zypp/PathInfo.h"
-#include "zypp/Date.h"
-
-using std::endl;
-
-namespace zypp {
- namespace target {
-
- ///////////////////////////////////////////////////////////////////
-
- Pathname CommitLog::_fname;
- std::ofstream CommitLog::_log;
- unsigned CommitLog::_refcnt = 0;
-
- ///////////////////////////////////////////////////////////////////
-
- void CommitLog::openLog() {
- if ( !_fname.empty() ) {
- _log.clear();
- _log.open( _fname.asString().c_str(), std::ios::out|std::ios::app );
- if( !_log )
- ERR << "Could not open logfile '" << _fname << "'" << endl;
- }
- }
- void CommitLog::closeLog() {
- _log.clear();
- _log.close();
- }
- void CommitLog::refUp() {
- if ( !_refcnt )
- openLog();
- ++_refcnt;
- }
- void CommitLog::refDown() {
- --_refcnt;
- if ( !_refcnt )
- closeLog();
- }
-
- std::ostream & CommitLog::operator()( bool timestamp ) {
- if ( timestamp ) {
- _log << Date(Date::now()).form( "%Y-%m-%d %H:%M:%S ");
- }
- return _log;
- }
-
- void CommitLog::setFname( const Pathname & fname_r ) {
- MIL << "installation log file " << fname_r << endl;
- if ( _refcnt )
- closeLog();
- _fname = fname_r;
- if ( ! _fname.empty() )
- filesystem::assert_dir( _fname.dirname() );
- if ( _refcnt )
- openLog();
- }
-
- const Pathname & CommitLog::fname()
- { return _fname; }
-
- } // namespace target
-} // namespace zypp
+++ /dev/null
- /*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/target/CommitLog.h
- *
-*/
-#ifndef ZYPP_TARGET_COMMITLOG_H
-#define ZYPP_TARGET_COMMITLOG_H
-
-#include <iosfwd>
-
-#include "zypp/Pathname.h"
-
-namespace zypp {
- namespace target {
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : CommitLog
- /**
- * Simple wrapper for progress log. Refcnt, filename and corresponding
- * ofstream are static members. Logfile constructor raises, destructor
- * lowers refcounter. On refcounter changing from 0->1, file is opened.
- * Changing from 1->0 the file is closed. Thus Logfile objects should be
- * local to those functions, writing the log, and must not be stored
- * permanently;
- *
- * Usage:
- * some methothd ()
- * {
- * CommitLog progresslog;
- * ...
- * progresslog() << "some message" << endl;
- * ...
- * }
- **/
- class CommitLog {
- CommitLog( const CommitLog & );
- CommitLog & operator=( const CommitLog & );
- private:
- static std::ofstream _log;
- static unsigned _refcnt;
- static Pathname _fname;
-
- static void openLog();
- static void closeLog();
- static void refUp();
- static void refDown();
- public:
- CommitLog() { refUp(); }
- ~CommitLog() { refDown(); }
- std::ostream & operator()( bool timestamp = false );
- static void setFname( const Pathname & fname_r );
- static const Pathname & fname();
- };
- ///////////////////////////////////////////////////////////////////
-
- } // namespace target
-} // namespace zypp
-
-
-#endif // ZYPP_TARGET_COMMITLOG_H
#include "zypp/Repository.h"
#include "zypp/ResFilters.h"
-#include "zypp/target/CommitLog.h"
+#include "zypp/HistoryLog.h"
#include "zypp/target/TargetImpl.h"
#include "zypp/target/TargetCallbackReceiver.h"
#include "zypp/target/rpm/librpmDb.h"
{
MIL << "Execute script " << PathInfo(script_r) << endl;
- CommitLog progresslog;
- progresslog(/*timestamp*/true) << script_r << _(" executed") << endl;
+ HistoryLog historylog;
+ historylog.comment(script_r.asString() + _(" executed"), /*timestamp*/true);
ExternalProgram prog( script_r.asString(), ExternalProgram::Stderr_To_Stdout, false, -1, true /*, root_r*/ );
for ( std::string output = prog.receiveLine(); output.length(); output = prog.receiveLine() )
{
- progresslog() << output;
+ historylog.comment(output);
if ( ! report_r->progress( PatchScriptReport::OUTPUT, output ) )
{
WAR << "User request to abort script " << script_r << endl;
{
ret.second = report_r->problem( prog.execError() );
WAR << "ACTION" << ret.second << "(" << prog.execError() << ")" << endl;
- progresslog(/*timestamp*/true)<< script_r << _(" execution failed") << " (" << prog.execError() << ")" << endl;
+ std::ostringstream sstr;
+ sstr << script_r << _(" execution failed") << " (" << prog.execError() << ")" << endl;
+ historylog.comment(sstr.str(), /*timestamp*/true);
return ret;
}
if ( abort || aborting_r )
{
WAR << "Aborting: Skip patch script " << *sit << endl;
- CommitLog()(/*timestamp*/true) << script.path() << _(" execution skipped while aborting") << endl;
+ HistoryLog().comment(
+ script.path().asString() + _(" execution skipped while aborting"),
+ /*timestamp*/true);
}
else
{
{
_rpm.initDatabase( root_r, Pathname(), doRebuild_r );
+ HistoryLog::setRoot(_root);
+
// create the anonymous unique id
// this value is used for statistics
Pathname idpath( home() / "AnonymousUniqueId");
///////////////////////////////////////////////////////////////////
// Process packages:
///////////////////////////////////////////////////////////////////
- if ( root() == "/" && CommitLog::fname().empty() )
- {
- // Yes, we simply hijack /var/log/YaST2/y2logRPM
- // until we maintain some zypp history database.
- CommitLog::setFname( "/var/log/YaST2/y2logRPM" );
- }
+
+ DBG << "commit log file is set to: " << HistoryLog::fname() << endl;
ZYppCommitResult result;
{
progress.tryLevel( target::rpm::InstallResolvableReport::RPM_NODEPS_FORCE );
rpm().installPackage( localfile, flags );
+ HistoryLog().install(*it);
if ( progress.aborted() )
{
try
{
rpm().removePackage( p, flags );
+ HistoryLog().remove(*it);
if ( progress.aborted() )
{
return _rpm.hasFile(path_str, name_str);
}
- /** Set the log file for target */
- bool TargetImpl::setInstallationLogfile(const Pathname & path_r)
- {
- CommitLog::setFname(path_r);
- return true;
- }
Date TargetImpl::timestamp() const
{
std::string whoOwnsFile (const std::string & path_str) const
{ return _rpm.whoOwnsFile (path_str); }
- /** Set the log file for target */
- bool setInstallationLogfile(const Pathname & path_r);
-
/** return the last modification date of the target */
Date timestamp() const;
#include <iostream>
#include <fstream>
+#include <sstream>
#include <list>
#include <map>
#include <set>
#include "zypp/base/Logger.h"
#include "zypp/base/String.h"
-#include "zypp/base/Regex.h"
#include "zypp/base/Gettext.h"
#include "zypp/Date.h"
#include "zypp/target/rpm/RpmDb.h"
#include "zypp/target/rpm/RpmCallbacks.h"
-#include "zypp/target/CommitLog.h"
+#include "zypp/HistoryLog.h"
#include "zypp/target/rpm/librpmDb.h"
#include "zypp/target/rpm/RpmException.h"
#include "zypp/TmpPath.h"
void RpmDb::doInstallPackage( const Pathname & filename, RpmInstFlags flags, callback::SendReport<RpmInstallReport> & report )
{
FAILIFNOTINITIALIZED;
- CommitLog progresslog;
+ HistoryLog historylog;
MIL << "RpmDb::installPackage(" << filename << "," << flags << ")" << endl;
if ( rpm_status != 0 )
{
// %s = filename of rpm package
- progresslog(/*timestamp*/true) << str::form(_("%s install failed"), Pathname::basename(filename).c_str()) << endl;
- progresslog() << _("rpm output:") << endl << rpmmsg << endl;
+ // historylog(/*timestamp*/true) << str::form(_("%s install failed"), Pathname::basename(filename).c_str()) << endl;
+ ostringstream sstr;
+ sstr << _("rpm output:") << endl << rpmmsg << endl;
+ historylog.comment(sstr.str());
//TranslatorExplanation after semicolon is error message
ZYPP_THROW(RpmSubprocessException(string(_("RPM failed: ")) +
(rpmmsg.empty() ? error_message : rpmmsg)));
else
{
// %s = filename of rpm package
- progresslog(/*timestamp*/true) << str::form(_("%s installed ok"), Pathname::basename(filename).c_str()) << endl;
+ // historylog.comment(
+ // str::form(_("%s installed ok"), Pathname::basename(filename).c_str()),
+ // /*timestamp*/true);
if ( ! rpmmsg.empty() )
{
- progresslog() << _("Additional rpm output:") << endl << rpmmsg << endl;
+ ostringstream sstr;
+ sstr << _("Additional rpm output:") << endl << rpmmsg << endl;
+ historylog.comment(sstr.str());
}
}
}
void RpmDb::doRemovePackage( const string & name_r, RpmInstFlags flags, callback::SendReport<RpmRemoveReport> & report )
{
FAILIFNOTINITIALIZED;
- CommitLog progresslog;
+ HistoryLog historylog;
MIL << "RpmDb::doRemovePackage(" << name_r << "," << flags << ")" << endl;
if ( rpm_status != 0 )
{
// %s = name of rpm package
- progresslog(/*timestamp*/true) << str::form(_("%s remove failed"), name_r.c_str()) << endl;
- progresslog() << _("rpm output:") << endl << rpmmsg << endl;
- //TranslatorExplanation after semicolon is error message
+ historylog.comment(
+ str::form(_("%s remove failed"), name_r.c_str()), /*timestamp*/true);
+ ostringstream sstr;
+ sstr << _("rpm output:") << endl << rpmmsg << endl;
+ historylog.comment(sstr.str());
+ // TranslatorExplanation after semicolon is error message
ZYPP_THROW(RpmSubprocessException(string(_("RPM failed: ")) +
(rpmmsg.empty() ? error_message: rpmmsg)));
}
else
{
- progresslog(/*timestamp*/true) << str::form(_("%s remove ok"), name_r.c_str()) << endl;
+ // historylog.comment(str::form(_("%s remove ok"), name_r.c_str()), /*timestamp*/true);
if ( ! rpmmsg.empty() )
{
- progresslog() << _("Additional rpm output:") << endl << rpmmsg << endl;
+ ostringstream sstr;
+ sstr << _("Additional rpm output:") << endl << rpmmsg << endl;
+ historylog.comment(sstr.str());
}
}
}
//
bool RpmDb::backupPackage(const string& packageName)
{
- CommitLog progresslog;
+ HistoryLog progresslog;
bool ret = true;
Pathname backupFilename;
Pathname filestobackupfile = _root+_backuppath+FILEFORBACKUPFILES;
else
{
MIL << "tar backup ok" << endl;
- progresslog(/*timestamp*/true) << str::form(_("created backup %s"), backupFilename.asString().c_str()) << endl;
+ progresslog.comment(
+ str::form(_("created backup %s"), backupFilename.asString().c_str())
+ , /*timestamp*/true);
}
filesystem::unlink(filestobackupfile);