namespace cache
{ /////////////////////////////////////////////////////////////////
-#define SOURCES_TABLE_SCHEMA "create table sources ( alias varchar primary key, type varchar, description varchar, url varchar, path varchar, enabled integer, autorefresh integer, timestamp varchar, checksum varchar);"
+#define SOURCES_TABLE_SCHEMA "create table sources ( alias varchar primary key, type varchar, description varchar, url varchar, path varchar, enabled integer, autorefresh integer, timestamp varchar, checksum varchar);"
// alias 0 , type 1, desc 2, url 3, path 4, enabled 5, autorefresh 6, timestamp 7, checksum 8
SourceCacheInitializer::SourceCacheInitializer( const Pathname &root_r, const Pathname &db_file )
createTables();
_just_initialized = true;
_con->close();
+ MIL << "Source cache initialized" << std::endl;
+ }
+ else
+ {
+ MIL << "Source cache already initialized" << std::endl;
}
}
catch(exception &ex)
{
ERR << "Exception Occured: " << ex.what() << endl;
}
-
+
}
bool SourceCacheInitializer::justInitialized() const
Builtin.h \
PackageDelta.h \
MediaSet.h \
- SourceInfo.h
+ SourceInfo.h \
+ SourceMediaAccess.h
noinst_LTLIBRARIES = lib@PACKAGE@_source.la
SourceImpl.cc \
PackageDelta.cc \
MediaSet.cc \
- SourceInfo.cc
+ SourceInfo.cc \
+ SourceMediaAccess.cc
lib@PACKAGE@_source_la_LIBADD = \
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/source/SourceMediaAccess.cc
+ *
+*/
+#include <iostream>
+#include <fstream>
+
+#include "zypp/base/LogTools.h"
+#include "zypp/source/SourceMediaAccess.h"
+//#include "zypp/source/SourceMediaAccessReportReceivers.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////
+namespace source
+{ /////////////////////////////////////////////////////////////////
+
+
+ SourceMediaAccess::SourceMediaAccess( const Url &url, const Pathname &path, std::vector<media::MediaVerifierRef> verifiers )
+ : _url(url),
+ _path(path)
+ {
+
+ }
+
+ SourceMediaAccess::~SourceMediaAccess()
+ {
+ }
+
+
+
+// media::MediaVerifierRef SourceMediaAccess::verifier(unsigned media_nr)
+// { return media::MediaVerifierRef(new media::NoVerifier()); }
+
+ SourceMediaVerifier::SourceMediaVerifier(const std::string & vendor_r, const std::string & id_r, const media::MediaNr media_nr)
+ : _media_vendor(vendor_r)
+ , _media_id(id_r)
+ , _media_nr(media_nr)
+ {}
+
+ bool SourceMediaVerifier::isDesiredMedia(const media::MediaAccessRef &ref)
+ {
+ if (_media_vendor.empty() || _media_id.empty())
+ return true;
+
+ Pathname media_file = "/media." + str::numstring(_media_nr) + "/media";
+ ref->provideFile (media_file);
+ media_file = ref->localPath(media_file);
+ std::ifstream str(media_file.asString().c_str());
+ std::string vendor;
+ std::string id;
+
+#warning check the stream status
+ getline(str, vendor);
+ getline(str, id);
+
+ return (vendor == _media_vendor && id == _media_id );
+ }
+
+
+/////////////////////////////////////////////////////////////////
+} // namespace source
+///////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#ifndef ZYPP_SourceMediaAccess_H
+#define ZYPP_SourceMediaAccess_H
+
+#include <iosfwd>
+#include <string>
+#include <vector>
+
+#include "zypp/base/ReferenceCounted.h"
+#include "zypp/base/NonCopyable.h"
+#include "zypp/base/PtrTypes.h"
+#include "zypp/media/MediaManager.h"
+#include "zypp/Pathname.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace source
+ { /////////////////////////////////////////////////////////////////
+
+ DEFINE_PTR_TYPE(SourceMediaAccess);
+
+
+ class SourceMediaVerifier : public zypp::media::MediaVerifierBase
+ {
+ public:
+ /** ctor */
+ SourceMediaVerifier(const std::string & vendor_r, const std::string & id_r, const media::MediaNr media_nr = 1);
+ /**
+ * Check if the specified attached media contains
+ * the desired media number (e.g. SLES10 CD1).
+ */
+ virtual bool isDesiredMedia(const media::MediaAccessRef &ref);
+ private:
+ std::string _media_vendor;
+ std::string _media_id;
+ media::MediaNr _media_nr;
+ };
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : SourceCache
+ //
+ class SourceMediaAccess : public base::ReferenceCounted, private base::NonCopyable
+ {
+ friend std::ostream & operator<<( std::ostream & str, const SourceMediaAccess & obj );
+
+ public:
+ SourceMediaAccess( const Url &url, const Pathname &path, std::vector<media::MediaVerifierRef> verifiers );
+ ~SourceMediaAccess();
+ protected:
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ private:
+ Url _url;
+ Pathname _path;
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates SourceMediaAccess Stream output */
+ inline std::ostream & operator<<( std::ostream & str, const SourceMediaAccess & obj )
+ { return obj.dumpOn( str ); }
+
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace source
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SOURCE_SourceMediaAccess_H
YUMPatchImpl.h \
YUMGroupImpl.h \
YUMPatternImpl.h \
- YUMProductImpl.h
+ YUMProductImpl.h \
+ YUMSourceCacher.h
noinst_LTLIBRARIES = lib@PACKAGE@_source_yum.la
YUMPatchImpl.cc \
YUMGroupImpl.cc \
YUMPatternImpl.cc \
- YUMProductImpl.cc
+ YUMProductImpl.cc \
+ YUMSourceCacher.cc
## ##################################################
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#include "zypp/base/Logger.h"
+#include "zypp/cache/SourceCacher.h"
+#include "zypp/source/yum/YUMSourceCacher.h"
+
+using namespace std;
+
+//////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+namespace source
+{ /////////////////////////////////////////////////////////////////
+namespace yum
+{ /////////////////////////////////////////////////////////////////
+
+
+YUMSourceCacher::YUMSourceCacher( const Pathname &root_r ) : cache::SourceCacher(root_r)
+{
+
+}
+
+YUMSourceCacher::~YUMSourceCacher()
+{
+}
+
+std::ostream & YUMSourceCacher::dumpOn( std::ostream & str ) const
+{
+ return str;
+}
+
+}
+}
+}
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+
+#ifndef ZYPP_YUMSourceCacher_H
+#define ZYPP_YUMSourceCacher_H
+
+#include <iosfwd>
+#include <string>
+
+#include "zypp/cache/SourceCacher.h"
+#include "zypp/Pathname.h"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace source
+ { /////////////////////////////////////////////////////////////////
+
+ namespace yum
+ { /////////////////////////////////////////////////////////////////
+
+ DEFINE_PTR_TYPE(YUMSourceCacher);
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : SourceCacher
+ //
+ class YUMSourceCacher : public cache::SourceCacher
+ {
+ friend std::ostream & operator<<( std::ostream & str, const YUMSourceCacher & obj );
+
+ public:
+ /** root path */
+ YUMSourceCacher( const Pathname &root_r );
+ ~YUMSourceCacher();
+ protected:
+
+ /** Overload to realize stream output. */
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+ //typedef std::map<media::MediaNr, media::MediaAccessId> MediaMap
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ /** \relates SourceCacher Stream output */
+ inline std::ostream & operator<<( std::ostream & str, const YUMSourceCacher & obj )
+ { return obj.dumpOn( str ); }
+
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace cache
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+}
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_SOURCE_SourceCacher_H