has changed. Resolver must discard any cached filesystem dependencies.
(required for #271912)
DBG << p->deps() << endl;
}
-
+namespace zypp {
+namespace filesystem {
+ void touch( const char * p )
+ {
+ static std::string w;
+ ofstream s(p);
+ s<<w<<endl;
+ w+="a";
+ }
+}
+}
/******************************************************************
**
** FUNCTION NAME : main
INT << "===[START]==========================================" << endl;
ResPool pool( getZYpp()->pool() );
- SerialNumberWatcher poolchanged( pool.serial() );
USR << pool << endl;
- USR << poolchanged << endl;
-
- if ( poolchanged.remember( pool.serial() ) )
- {
- SEC << "CHANGED" << endl;
- }
const char *const lines[] = {
"@ package",
"@ fin"
};
- debug::addPool( lines, lines+(sizeof(lines)/sizeof(const char *const)) );
+ //debug::addPool( lines, lines+(sizeof(lines)/sizeof(const char *const)) );
//debug::addPool( "/tmp/a" );
USR << pool << endl;
- if ( poolchanged.remember( pool.serial() ) )
- {
- SEC << "CHANGED" << endl;
- }
- USR << pool << endl;
-
for_each( pool.begin(), pool.end(), chk );
- if ( poolchanged.remember( pool.serial() ) )
- {
- SEC << "CHANGED" << endl;
- }
- if ( poolchanged.remember( pool.serial() ) )
- {
- SEC << "CHANGED" << endl;
- }
- if ( poolchanged.remember( pool.serial() ) )
- {
- SEC << "CHANGED" << endl;
- }
+ SEC << pool.serial().serial() << endl;
+ SEC << pool.serial().serial() << endl;
+ filesystem::touch( "/etc/sysconfig/storage" );
+ SEC << pool.serial().serial() << endl;
+ SEC << pool.serial().serial() << endl;
+ SEC << pool.serial().serial() << endl;
+ filesystem::touch( "/etc/sysconfig/storage" );
+ SEC << pool.serial().serial() << endl;
+ SEC << pool.serial().serial() << endl;
+ filesystem::touch( "/etc/sysconfig/storage" );
+ SEC << pool.serial().serial() << endl;
+ SEC << pool.serial().serial() << endl;
+ SEC << pool.serial().serial() << endl;
INT << "===[END]============================================" << endl
<< endl;
*
* int main()
* {
+ * check(); // This call would trigger, if check used a
+ * // default constructed SerialNumberWatcher.
+ *
* check(); //
+ * sno.dirty();
+ * check(); // "Serial number changed."
* check(); //
* sno.dirty();
* check(); // "Serial number changed."
friend std::ostream & operator<<( std::ostream & str, const SerialNumberWatcher & obj );
public:
- /** Ctor taking an initial \c serial value. */
- SerialNumberWatcher( unsigned serial_r = 0 );
+ /** Ctor taking an initial \c serial value.
+ *
+ * A default constructed SerialNumberWatcher remembers the serial
+ * number <tt>(unsigned)-1</tt>. So it is most likely the the 1st
+ * call to \ref remember returns \ref isDirty.
+ *
+ * Vice versa, initializing the SerialNumberWatcher with the current
+ * SerialNumber, most likely prevents the 1st to \ref remember to
+ * return \ref isDirty.
+ */
+ SerialNumberWatcher( unsigned serial_r = (unsigned)-1 );
/** Ctor taking an initial \c serial value. */
SerialNumberWatcher( const SerialNumber & serial_r );
/** Dtor */
#include "zypp/base/Logger.h"
#include "zypp/base/WatchFile.h"
#include "zypp/base/Sysconfig.h"
+#include "zypp/base/SerialNumber.h"
#include "zypp/capability/FilesystemCap.h"
namespace capability
{ /////////////////////////////////////////////////////////////////
+ namespace
+ {
+ const Pathname & sysconfigStoragePath()
+ {
+ static Pathname _p( "/etc/sysconfig/storage" );
+ return _p;
+ }
+ }
+
IMPL_PTR_TYPE(FilesystemCap)
-
+
/** Ctor */
FilesystemCap::FilesystemCap( const Resolvable::Kind & refers_r,
const std::string & name_r )
bool FilesystemCap::isEvalCmd() const
{ return _name.empty(); }
+
+
bool FilesystemCap::evaluate() const
{
- static WatchFile sysconfigFile( "/etc/sysconfig/storage", WatchFile::NO_INIT );
+ static SerialNumberWatcher sysconfigStorage;
static std::set<std::string> fs;
- if ( sysconfigFile.hasChanged() )
+ if ( sysconfigStorage.remember( sysconfigStorageSerial() ) )
{
std::set<std::string> newfs;
- str::split( base::sysconfig::read( sysconfigFile.path() )["USED_FS_LIST"],
+ str::split( base::sysconfig::read( sysconfigStoragePath() )["USED_FS_LIST"],
std::inserter( newfs, newfs.end() ) );
fs.swap( newfs );
}
return( fs.find( _name ) != fs.end() );
}
+ const SerialNumber & FilesystemCap::sysconfigStorageSerial()
+ {
+ static WatchFile _sysconfigFile( sysconfigStoragePath(), WatchFile::NO_INIT );
+ static SerialNumber _serial;
+
+ if ( _sysconfigFile.hasChanged() )
+ {
+ _serial.setDirty();
+ }
+ return _serial;
+ }
+
/////////////////////////////////////////////////////////////////
} // namespace capability
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
+
+ class SerialNumber;
+
///////////////////////////////////////////////////////////////////
namespace capability
{ /////////////////////////////////////////////////////////////////
DEFINE_PTR_TYPE(FilesystemCap)
-
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : FilesystemCap
typedef FilesystemCap Self;
typedef FilesystemCap_Ptr Ptr;
typedef FilesystemCap_constPtr constPtr;
-
+
public:
/** Ctor */
FilesystemCap( const Resolvable::Kind & refers_r, const std::string & name_r );
private:
/** */
std::string _name;
+
+ public:
+ /** Serial number indicating a change in /etc/sysconfig/storage */
+ static const SerialNumber & sysconfigStorageSerial();
};
///////////////////////////////////////////////////////////////////
*/
#include <iostream>
#include "zypp/base/Logger.h"
+#include "zypp/capability/FilesystemCap.h"
#include "zypp/pool/PoolImpl.h"
#include "zypp/pool/PoolStats.h"
// METHOD TYPE : Ctor
//
PoolImpl::PoolImpl()
+ : _watchFilesystemSysconfigStorage( capability::FilesystemCap::sysconfigStorageSerial() )
{}
///////////////////////////////////////////////////////////////////
//
const SerialNumber & PoolImpl::serial() const
{
-#warning INCLUDE CHECK FOR CHANGED DEPENDENCIES
+ if ( _watchFilesystemSysconfigStorage.remember( capability::FilesystemCap::sysconfigStorageSerial() ) )
+ {
+ const_cast<PoolImpl*>(this)->_serial.setDirty(); // propagate changed /etc/sysconfig/storage
+ }
return _serial;
}
private:
/** Serial number. */
- SerialNumber _serial;
+ SerialNumber _serial;
+ /** Watch for changes in /etc/sysconfig/storage. */
+ SerialNumberWatcher _watchFilesystemSysconfigStorage;
public:
ContainerT _store;