Author: jkupec
Date: Wed Sep 24 16:16:56 2008
New Revision: 11142
URL: http://svn.opensuse.org/viewcvs/zypp?rev=11142&view=rev
Log:
- new History Log, first version (fate #110205)
- todo: HistoryFileReader API
- todo: log @System.solv changes (post 11.1 maybe?)
Added:
trunk/libzypp/zypp/HistoryLog.cc (contents, props changed)
- copied, changed from r11113, trunk/libzypp/zypp/target/CommitLog.cc
trunk/libzypp/zypp/HistoryLog.h (contents, props changed)
- copied, changed from r11113, trunk/libzypp/zypp/target/CommitLog.h
Removed:
trunk/libzypp/zypp/target/CommitLog.cc
trunk/libzypp/zypp/target/CommitLog.h
Modified:
trunk/libzypp/zypp.conf
trunk/libzypp/zypp/CMakeLists.txt
trunk/libzypp/zypp/RepoManager.cc
trunk/libzypp/zypp/Target.cc
trunk/libzypp/zypp/ZConfig.cc
trunk/libzypp/zypp/ZConfig.h
trunk/libzypp/zypp/target/TargetImpl.cc
trunk/libzypp/zypp/target/TargetImpl.h
trunk/libzypp/zypp/target/rpm/RpmDb.cc
Modified: trunk/libzypp/zypp.conf
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp.conf?rev=11142&r1=11141&r2=11142&view=diff
==============================================================================
--- trunk/libzypp/zypp.conf (original)
+++ trunk/libzypp/zypp.conf Wed Sep 24 16:16:56 2008
@@ -250,3 +250,14 @@
## 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
Modified: trunk/libzypp/zypp/CMakeLists.txt
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=11142&r1=11141&r2=11142&view=diff
==============================================================================
--- trunk/libzypp/zypp/CMakeLists.txt (original)
+++ trunk/libzypp/zypp/CMakeLists.txt Wed Sep 24 16:16:56 2008
@@ -24,6 +24,7 @@
ExternalProgram.cc
Fetcher.cc
FileChecker.cc
+ HistoryLog.cc
IdString.cc
KeyRing.cc
Locks.cc
@@ -102,6 +103,7 @@
ExternalProgram.h
Fetcher.h
FileChecker.h
+ HistoryLog.h
IdString.h
IdStringType.h
KeyContext.h
@@ -530,7 +532,6 @@
target/RequestedLocalesFile.cc
target/SoftLocksFile.cc
target/HardLocksFile.cc
- target/CommitLog.cc
target/CommitPackageCache.cc
target/CommitPackageCacheImpl.cc
target/CommitPackageCacheReadAhead.cc
@@ -543,7 +544,6 @@
target/RequestedLocalesFile.h
target/SoftLocksFile.h
target/HardLocksFile.h
- target/CommitLog.h
target/CommitPackageCache.h
target/CommitPackageCacheImpl.h
target/CommitPackageCacheReadAhead.h
Copied: trunk/libzypp/zypp/HistoryLog.cc (from r11113, trunk/libzypp/zypp/target/CommitLog.cc)
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/HistoryLog.cc?p2=trunk/libzypp/zypp/HistoryLog.cc&p1=trunk/libzypp/zypp/target/CommitLog.cc&r1=11113&r2=11142&rev=11142&view=diff
==============================================================================
--- trunk/libzypp/zypp/target/CommitLog.cc (original)
+++ trunk/libzypp/zypp/HistoryLog.cc Wed Sep 24 16:16:56 2008
@@ -1,4 +1,4 @@
- /*---------------------------------------------------------------------\
+/*---------------------------------------------------------------------\
| ____ _ __ __ ___ |
| |__ / \ / / . \ . \ |
| / / \ V /| _/ _/ |
@@ -6,74 +6,330 @@
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \file zypp/target/CommitLog.cc
+/** \file zypp/target/HistoryLog.cc
*
-*/
+ */
#include <iostream>
#include <fstream>
+#include
+#include "zypp/ZConfig.h"
+#include "zypp/base/String.h"
#include "zypp/base/Logger.h"
-#include "zypp/target/CommitLog.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::mapstd::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;
+ }
-namespace zypp {
- namespace target {
+ std::mapstd::string,HistoryActionID::ID::const_iterator it =
+ _table.find(strval_r);
- ///////////////////////////////////////////////////////////////////
+ if (it == _table.end())
+ WAR << "Unknown history action ID '" + strval_r + "'";
- Pathname CommitLog::_fname;
- std::ofstream CommitLog::_log;
- unsigned CommitLog::_refcnt = 0;
+ return it->second;
+ }
+
+
+ const std::string & HistoryActionID::asString(bool pad) const
+ {
+ static std::map _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 = '|';
///////////////////////////////////////////////////////////////////
- void CommitLog::openLog() {
- if ( !_fname.empty() ) {
+ 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 CommitLog::closeLog() {
+
+ void HistoryLog::closeLog()
+ {
_log.clear();
_log.close();
}
- void CommitLog::refUp() {
+
+ void HistoryLog::refUp()
+ {
if ( !_refcnt )
openLog();
++_refcnt;
}
- void CommitLog::refDown() {
+
+ void HistoryLog::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;
+ void HistoryLog::setRoot( const Pathname & rootdir )
+ {
+ if (rootdir.empty() || !rootdir.absolute())
+ return;
+
if ( _refcnt )
closeLog();
- _fname = fname_r;
- if ( ! _fname.empty() )
- filesystem::assert_dir( _fname.dirname() );
+
+ _fname = rootdir / "/var/log/zypp/history";
+ filesystem::assert_dir( _fname.dirname() );
+ MIL << "installation log file " << _fname << endl;
+
if ( _refcnt )
openLog();
}
- const Pathname & CommitLog::fname()
+
+ const Pathname & HistoryLog::fname()
{ return _fname; }
- } // namespace target
+ /////////////////////////////////////////////////////////////////////////
+
+ 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
Copied: trunk/libzypp/zypp/HistoryLog.h (from r11113, trunk/libzypp/zypp/target/CommitLog.h)
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/HistoryLog.h?p2=trunk/libzypp/zypp/HistoryLog.h&p1=trunk/libzypp/zypp/target/CommitLog.h&r1=11113&r2=11142&rev=11142&view=diff
==============================================================================
--- trunk/libzypp/zypp/target/CommitLog.h (original)
+++ trunk/libzypp/zypp/HistoryLog.h Wed Sep 24 16:16:56 2008
@@ -1,4 +1,4 @@
- /*---------------------------------------------------------------------\
+/*---------------------------------------------------------------------\
| ____ _ __ __ ___ |
| |__ / \ / / . \ . \ |
| / / \ V /| _/ _/ |
@@ -6,9 +6,9 @@
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \file zypp/target/CommitLog.h
+/** \file zypp/target/HistoryLog.h
*
-*/
+ */
#ifndef ZYPP_TARGET_COMMITLOG_H
#define ZYPP_TARGET_COMMITLOG_H
@@ -16,52 +16,114 @@
#include "zypp/Pathname.h"
-namespace zypp {
- namespace target {
+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 : CommitLog
+ // 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;
+ * permanently.
*
* Usage:
- * some methothd ()
+ * <code>
+ * some method ()
* {
- * CommitLog progresslog;
+ * PoolItem pi;
* ...
- * progresslog() << "some message" << endl;
+ * HistoryLog().install(pi);
* ...
+ * HistoryLog().comment(someMessage);
* }
- **/
- class CommitLog {
- CommitLog( const CommitLog & );
- CommitLog & operator=( const CommitLog & );
+ * </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:
- CommitLog() { refUp(); }
- ~CommitLog() { refDown(); }
- std::ostream & operator()( bool timestamp = false );
- static void setFname( const Pathname & fname_r );
+ 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 target
} // namespace zypp
-
#endif // ZYPP_TARGET_COMMITLOG_H
Modified: trunk/libzypp/zypp/RepoManager.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoManager.cc?rev=11142&r1=11141&r2=11142&view=diff
==============================================================================
--- trunk/libzypp/zypp/RepoManager.cc (original)
+++ trunk/libzypp/zypp/RepoManager.cc Wed Sep 24 16:16:56 2008
@@ -17,6 +17,7 @@
#include <list>
#include <map>
#include <algorithm>
+
#include "zypp/base/InputStream.h"
#include "zypp/base/Logger.h"
#include "zypp/base/Gettext.h"
@@ -24,8 +25,8 @@
#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"
@@ -44,6 +45,7 @@
#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"
@@ -1237,6 +1239,8 @@
//! \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;
@@ -1286,7 +1290,10 @@
it->setFilepath(repofile.asString());
it->dumpAsIniOn(file);
_pimpl->repos.insert(*it);
+
+ HistoryLog(_pimpl->options.rootDir).addRepository(*it);
}
+
MIL << "done" << endl;
}
@@ -1365,6 +1372,7 @@
cleanMetadata( todelete, cleansubprogrcv);
_pimpl->repos.erase(todelete);
MIL << todelete.alias() << " sucessfully deleted." << endl;
+ HistoryLog(_pimpl->options.rootDir).removeRepository(todelete);
return;
} // else filepath is empty
@@ -1427,6 +1435,7 @@
_pimpl->repos.erase(toedit);
_pimpl->repos.insert(newinfo);
+ HistoryLog(_pimpl->options.rootDir).modifyRepository(toedit, newinfo);
}
}
Modified: trunk/libzypp/zypp/Target.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Target.cc?rev=11142&r1=11141&r2=11142&view=diff
==============================================================================
--- trunk/libzypp/zypp/Target.cc (original)
+++ trunk/libzypp/zypp/Target.cc Wed Sep 24 16:16:56 2008
@@ -91,9 +91,6 @@
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(); }
Modified: trunk/libzypp/zypp/ZConfig.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZConfig.cc?rev=11142&r1=11141&r2=11142&view=diff
==============================================================================
--- trunk/libzypp/zypp/ZConfig.cc (original)
+++ trunk/libzypp/zypp/ZConfig.cc Wed Sep 24 16:16:56 2008
@@ -282,6 +282,10 @@
{
rpmInstallFlags.setFlag( target::rpm::RPMINST_EXCLUDEDOCS );
}
+ else if ( entry == "history.logfile" )
+ {
+ history_log_path = Pathname(value);
+ }
}
}
}
@@ -343,7 +347,8 @@
bool apply_locks_file;
target::rpm::RpmInstFlags rpmInstallFlags;
-
+
+ Pathname history_log_path;
};
///////////////////////////////////////////////////////////////////
@@ -497,12 +502,6 @@
///////////////////////////////////////////////////////////////////
- const std::string & ZConfig::cacheDBSplitJoinSeparator() const
- {
- static std::string s("!@$");
- return s;
- }
-
bool ZConfig::repo_add_probe() const
{
return _pimpl->repo_add_probe;
@@ -562,6 +561,14 @@
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
///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/ZConfig.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZConfig.h?rev=11142&r1=11141&r2=11142&view=diff
==============================================================================
--- trunk/libzypp/zypp/ZConfig.h (original)
+++ trunk/libzypp/zypp/ZConfig.h Wed Sep 24 16:16:56 2008
@@ -139,12 +139,6 @@
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
@@ -220,7 +214,6 @@
*/
Pathname update_messagesPath() const;
- public:
/** \name Options for package installation */
//@{
/** The default \ref target::rpm::RpmInstFlags for \ref ZYppCommitPolicy.
@@ -232,6 +225,8 @@
target::rpm::RpmInstFlags rpmInstallFlags() const;
//@}
+ Pathname historyLogFile() const;
+
public:
class Impl;
/** Dtor */
Modified: trunk/libzypp/zypp/target/TargetImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/TargetImpl.cc?rev=11142&r1=11141&r2=11142&view=diff
==============================================================================
--- trunk/libzypp/zypp/target/TargetImpl.cc (original)
+++ trunk/libzypp/zypp/target/TargetImpl.cc Wed Sep 24 16:16:56 2008
@@ -37,7 +37,7 @@
#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"
@@ -81,13 +81,13 @@
{
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;
@@ -103,7 +103,9 @@
{
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;
}
@@ -187,7 +189,9 @@
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
{
@@ -288,6 +292,8 @@
{
_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");
@@ -551,12 +557,8 @@
///////////////////////////////////////////////////////////////////
// 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;
@@ -739,6 +741,7 @@
{
progress.tryLevel( target::rpm::InstallResolvableReport::RPM_NODEPS_FORCE );
rpm().installPackage( localfile, flags );
+ HistoryLog().install(*it);
if ( progress.aborted() )
{
@@ -785,6 +788,7 @@
try
{
rpm().removePackage( p, flags );
+ HistoryLog().remove(*it);
if ( progress.aborted() )
{
@@ -852,12 +856,6 @@
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
{
Modified: trunk/libzypp/zypp/target/TargetImpl.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/TargetImpl.h?rev=11142&r1=11141&r2=11142&view=diff
==============================================================================
--- trunk/libzypp/zypp/target/TargetImpl.h (original)
+++ trunk/libzypp/zypp/target/TargetImpl.h Wed Sep 24 16:16:56 2008
@@ -135,9 +135,6 @@
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;
Modified: trunk/libzypp/zypp/target/rpm/RpmDb.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/rpm/RpmDb.cc?rev=11142&r1=11141&r2=11142&view=diff
==============================================================================
--- trunk/libzypp/zypp/target/rpm/RpmDb.cc (original)
+++ trunk/libzypp/zypp/target/rpm/RpmDb.cc Wed Sep 24 16:16:56 2008
@@ -17,6 +17,7 @@
#include <iostream>
#include <fstream>
+#include <sstream>
#include <list>
#include <map>
#include <set>
@@ -28,7 +29,6 @@
#include "zypp/base/Logger.h"
#include "zypp/base/String.h"
-#include "zypp/base/Regex.h"
#include "zypp/base/Gettext.h"
#include "zypp/Date.h"
@@ -39,7 +39,7 @@
#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"
@@ -1973,7 +1973,7 @@
void RpmDb::doInstallPackage( const Pathname & filename, RpmInstFlags flags, callback::SendReport<RpmInstallReport> & report )
{
FAILIFNOTINITIALIZED;
- CommitLog progresslog;
+ HistoryLog historylog;
MIL << "RpmDb::installPackage(" << filename << "," << flags << ")" << endl;
@@ -2072,8 +2072,10 @@
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)));
@@ -2081,10 +2083,14 @@
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());
}
}
}
@@ -2144,7 +2150,7 @@
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;
@@ -2206,18 +2212,23 @@
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());
}
}
}
@@ -2245,7 +2256,7 @@
//
bool RpmDb::backupPackage(const string& packageName)
{
- CommitLog progresslog;
+ HistoryLog progresslog;
bool ret = true;
Pathname backupFilename;
Pathname filestobackupfile = _root+_backuppath+FILEFORBACKUPFILES;
@@ -2359,7 +2370,9 @@
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);
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org