+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/RepoInfo.cc
- *
-*/
-#include <iostream>
-#include "zypp/base/Logger.h"
-
-#include "zypp2/RepoInfo.h"
-
-using namespace std;
-using namespace boost;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : RepoInfo::Impl
- //
- /** RepoInfo implementation. */
- struct RepoInfo::Impl
- {
-
- Impl()
- : enabled (indeterminate),
- autorefresh(indeterminate),
- type(repo::RepoType::NONE_e)
- {}
-
- ~Impl()
- {
- //MIL << std::endl;
- }
- public:
- boost::tribool enabled;
- boost::tribool autorefresh;
- repo::RepoType type;
- Url mirrorlist_url;
- std::set<Url> urls;
- std::string alias;
- std::string name;
-
- public:
-
- private:
- friend Impl * rwcowClone<Impl>( const Impl * rhs );
- /** clone for RWCOW_pointer */
- Impl * clone() const
- { return new Impl( *this ); }
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates RepoInfo::Impl Stream output */
- inline std::ostream & operator<<( std::ostream & str, const RepoInfo::Impl & obj )
- {
- return str << "RepoInfo::Impl";
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : RepoInfo
- //
- ///////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : RepoInfo::RepoInfo
- // METHOD TYPE : Ctor
- //
- RepoInfo::RepoInfo()
- : _pimpl( new Impl() )
- {}
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : RepoInfo::~RepoInfo
- // METHOD TYPE : Dtor
- //
- RepoInfo::~RepoInfo()
- {
- //MIL << std::endl;
- }
-
-
-
- RepoInfo & RepoInfo::setEnabled( boost::tribool enabled )
- {
- _pimpl->enabled = enabled;
- return *this;
- }
-
- RepoInfo & RepoInfo::setAutorefresh( boost::tribool autorefresh )
- {
- _pimpl->autorefresh = autorefresh;
- return *this;
- }
-
- RepoInfo & RepoInfo::setMirrorListUrl( const Url &url )
- {
- _pimpl->mirrorlist_url = url;
- return *this;
- }
-
- RepoInfo & RepoInfo::addBaseUrl( const Url &url )
- {
- _pimpl->urls.insert(url);
- return *this;
- }
-
- RepoInfo & RepoInfo::setAlias( const std::string &alias )
- {
- _pimpl->alias = alias;
- return *this;
- }
-
- RepoInfo & RepoInfo::setType( const repo::RepoType &t )
- {
- _pimpl->type = t;
- return *this;
- }
-
- RepoInfo & RepoInfo::setName( const std::string &name )
- {
- _pimpl->name = name;
- return *this;
- }
-
- tribool RepoInfo::enabled() const
- { return _pimpl->enabled; }
-
- tribool RepoInfo::autorefresh() const
- { return _pimpl->autorefresh; }
-
- std::string RepoInfo::alias() const
- { return _pimpl->alias; }
-
- std::string RepoInfo::name() const
- { return _pimpl->name; }
-
- repo::RepoType RepoInfo::type() const
- { return _pimpl->type; }
-
- Url RepoInfo::mirrorListUrl() const
- { return _pimpl->mirrorlist_url; }
-
- std::set<Url> RepoInfo::urls() const
- { return _pimpl->urls; }
-
- RepoInfo::urls_const_iterator RepoInfo::urlsBegin() const
- { return _pimpl->urls.begin(); }
-
- RepoInfo::urls_const_iterator RepoInfo::urlsEnd() const
- { return _pimpl->urls.end(); }
-
- std::ostream & RepoInfo::dumpOn( std::ostream & str ) const
- {
- str << "--------------------------------------" << std::endl;
- str << "- alias : " << alias() << std::endl;
- std::set<Url> url_set(urls());
- for ( std::set<Url>::const_iterator it = url_set.begin();
- it != url_set.end();
- ++it )
- {
- str << "- url : " << *it << std::endl;
- }
-
- str << "- type : " << type() << std::endl;
- str << "- enabled : " << enabled() << std::endl;
- str << "- autorefresh : " << autorefresh() << std::endl;
- //str << "- path : " << path() << std::endl;
- return str;
- }
-
- std::ostream & operator<<( std::ostream & str, const RepoInfo & obj )
- {
- return obj.dumpOn(str);
- }
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp2
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp2/RepoInfo.h
- *
-*/
-#ifndef ZYPP2_REPOSITORYINFO_H
-#define ZYPP2_REPOSITORYINFO_H
-
-#include <iosfwd>
-#include <list>
-#include <set>
-#include "zypp/base/PtrTypes.h"
-
-#include <boost/logic/tribool.hpp>
-#include "zypp/Pathname.h"
-#include "zypp/Url.h"
-#include "zypp2/repo/RepoType.h"
-
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : RepoInfo
- //
- /**
- * \short What is known about a repository
- *
- * The class RepoInfo represents everything that
- * is known about a software repository.
- *
- * It can be used to store information about known
- * sources.
- *
- * This class tries to be compatible with the
- * concept of a .repo file used by YUM and
- * also available in the openSUSE build service.
- *
- * Example file
- *
- * \code
- * [ruby]
- * name=Ruby repository (openSUSE_10.2)
- * type=rpm-md
- * baseurl=http://software.opensuse.org/download/ruby/openSUSE_10.2/
- * gpgcheck=1
- * gpgkey=http://software.opensuse.org/openSUSE-Build-Service.asc
- * enabled=1
- * \endcode
- *
- * \note A Repository info is a hint about how
- * to create a repository.
- */
- class RepoInfo
- {
- friend std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
-
- public:
- RepoInfo();
- ~RepoInfo();
- //RepoInfo( const Url & url, const Pathname & path, const std::string & alias = "", boost::tribool autorefresh = boost::indeterminate );
-
- /**
- * unique identifier for this source. If not specified
- * It should be generated from the base url.
- *
- * Normally, in a .repo file the section name is used
- * ( [somerepo] )
- */
- std::string alias() const;
-
- /**
- * The base Url is the Url of the repository that generates
- * the authoritative metadata this repository provides.
- *
- * For example for the url http://updates.novell.com/10.2
- * the base url is http://updates.novell.com/10.2.
- * For the url http://host.com/mirror/update.novell.com/10.2
- * the base url is http://updates.novell.com/10.2
- *
- * This can't be empty in order the repository to be valid
- * unless the download of the mirror list succeeds and it
- * contains a valid url.
- */
- std::set<Url> urls() const;
-
- /**
- * Url of a file which contains a list of Urls
- * If empty, the base url will be used.
- */
- Url mirrorListUrl() const;
-
- typedef std::set<Url>::const_iterator urls_const_iterator;
-
- /**
- * iterator that points at begin of repository urls
- */
- urls_const_iterator urlsBegin() const;
-
- /**
- * iterator that points at end of repository urls
- */
- urls_const_iterator urlsEnd() const;
-
- /**
- * If enabled is false, then this repository must be ignored as if does
- * not exists, except when checking for duplicate alias.
- */
- boost::tribool enabled() const;
-
- /**
- * If true, the repostory must be refreshed before creating resolvables
- * from it
- */
- boost::tribool autorefresh() const;
-
- /**
- * Type of repository,
- *
- */
- repo::RepoType type() const;
-
- /**
- * \short Repository short label
- *
- * Short label or description of the repository, to be used on
- * the user interface.
- * ie: "SUSE Linux 10.2 updates"
- */
- std::string name() const;
-
- /**
- * Add a base url. \see baseUrl
- * \param url The base url for the repository.
- */
- RepoInfo & addBaseUrl( const Url &url );
-
- /**
- * Set mirror list url. \see mirrorListUrl
- * \param url The base url for the list
- */
- RepoInfo & setMirrorListUrl( const Url &url );
-
- /**
- * enable or disable the repository \see enabled
- * \param enabled
- */
- RepoInfo & setEnabled( boost::tribool enabled );
-
- /**
- * enable or disable autorefresh \see autorefresh
- * \param enabled
- */
- RepoInfo & setAutorefresh( boost::tribool autorefresh );
-
- /**
- * set the repository alias \see alias
- * \param alias
- */
- RepoInfo & setAlias( const std::string &alias );
-
- /**
- * set the repository type \see type
- * \param t
- */
- RepoInfo & setType( const repo::RepoType &t );
-
- /**
- * set the repository name \see name
- * \param name
- */
- RepoInfo & setName( const std::string &name );
-
- std::ostream & dumpOn( std::ostream & str ) const;
-
- class Impl;
- private:
- /** Pointer to implementation */
- RWCOW_pointer<Impl> _pimpl;
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates RepoInfo Stream output */
- std::ostream & operator<<( std::ostream & str, const RepoInfo & obj );
-
- typedef std::list<RepoInfo> RepoInfoList;
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp2
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP2_REPOSITORYINFO_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/RepoManager.cc
- *
-*/
-
-#include <iostream>
-#include <list>
-#include <algorithm>
-#include "zypp/base/InputStream.h"
-#include "zypp/base/Logger.h"
-#include "zypp/base/Function.h"
-#include "zypp/PathInfo.h"
-#include "zypp/TmpPath.h"
-
-#include "zypp2/repo/RepoException.h"
-#include "zypp2/RepoManager.h"
-
-#include "zypp2/cache/CacheStore.h"
-#include "zypp2/repo/cached/RepoImpl.h"
-#include "zypp/MediaSetAccess.h"
-
-#include "zypp2/parser/RepoFileReader.h"
-#include "zypp/source/yum/YUMDownloader.h"
-#include "zypp/parser/yum/RepoParser.h"
-
-#include "zypp/source/susetags/SUSETagsDownloader.h"
-#include "zypp2/parser/susetags/RepoParser.h"
-
-using namespace std;
-using namespace zypp;
-using namespace zypp::repo;
-using namespace zypp::filesystem;
-
-using zypp::source::yum::YUMDownloader;
-using zypp::source::susetags::SUSETagsDownloader;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : RepoManagerOptions
- //
- ///////////////////////////////////////////////////////////////////
-
- RepoManagerOptions::RepoManagerOptions()
- {
- ZConfig globalConfig;
- repoCachePath = globalConfig.defaultRepoCachePath();
- repoRawCachePath = globalConfig.defaultRepoRawCachePath();
- knownReposPath = globalConfig.defaultKnownReposPath();
- }
-
- /**
- * \short Simple callback to collect the results
- */
- struct RepoCollector
- {
- RepoCollector()
- {
- MIL << endl;
- }
-
- ~RepoCollector()
- {
- MIL << endl;
- }
-
- bool collect( const RepoInfo &repo )
- {
- //MIL << "here in collector: " << repo.alias() << endl;
- repos.push_back(repo);
- //MIL << "added: " << repo.alias() << endl;
- return true;
- }
-
- RepoInfoList repos;
- };
-
- ////////////////////////////////////////////////////////////////////////////
-
- /**
- * \short List of RepoInfo's from a directory
- *
- * Goes trough every file in a directory and adds all
- * RepoInfo's contained in that file.
- *
- * \param file pathname of the file to read.
- */
- static std::list<RepoInfo> repositories_in_path( const Pathname &dir )
- {
- MIL << " " << dir << endl;
- RepoCollector collector;
- std::list<RepoInfo> repos;
- list<Pathname> entries;
- if ( filesystem::readdir( entries, Pathname(dir), false ) != 0 )
- ZYPP_THROW(Exception("failed to read directory"));
-
- for ( list<Pathname>::const_iterator it = entries.begin(); it != entries.end(); ++it )
- {
- Pathname file = *it;
- parser::RepoFileReader parser( file, bind( &RepoCollector::collect, &collector, _1 ) );
-
- //std::copy( collector.repos.begin(), collector.repos.end(), std::back_inserter(repos));
- //MIL << "ok" << endl;
- }
- return collector.repos;
- }
-
- ////////////////////////////////////////////////////////////////////////////
-
- static void assert_alias( const RepoInfo &info )
- {
- if (info.alias().empty())
- ZYPP_THROW(RepoNoAliasException());
- }
-
- ////////////////////////////////////////////////////////////////////////////
-
- static void assert_urls( const RepoInfo &info )
- {
- if (info.urls().empty())
- ZYPP_THROW(RepoNoUrlException());
- }
-
- ////////////////////////////////////////////////////////////////////////////
-
- /**
- * \short Calculates the raw cache path for a repository
- */
- static Pathname rawcache_path_for_repoinfo( const RepoManagerOptions &opt, const RepoInfo &info )
- {
- assert_alias(info);
- return opt.repoRawCachePath + info.alias();
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : RepoManager::Impl
- //
- ///////////////////////////////////////////////////////////////////
-
- /**
- * \short RepoManager implementation.
- */
- struct RepoManager::Impl
- {
- Impl( const RepoManagerOptions &opt )
- : options(opt)
- {
-
- }
-
- Impl()
- {
-
- }
-
- RepoManagerOptions options;
-
- public:
- /** Offer default Impl. */
- static shared_ptr<Impl> nullimpl()
- {
- static shared_ptr<Impl> _nullimpl( new Impl );
- return _nullimpl;
- }
-
- private:
- friend Impl * rwcowClone<Impl>( const Impl * rhs );
- /** clone for RWCOW_pointer */
- Impl * clone() const
- { return new Impl( *this ); }
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates RepoManager::Impl Stream output */
- inline std::ostream & operator<<( std::ostream & str, const RepoManager::Impl & obj )
- {
- return str << "RepoManager::Impl";
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : RepoManager
- //
- ///////////////////////////////////////////////////////////////////
-
- RepoManager::RepoManager( const RepoManagerOptions &opt )
- : _pimpl( new Impl(opt) )
- {}
-
- ////////////////////////////////////////////////////////////////////////////
-
- RepoManager::~RepoManager()
- {}
-
- ////////////////////////////////////////////////////////////////////////////
-
- std::list<RepoInfo> RepoManager::knownRepositories() const
- {
- MIL << endl;
- return repositories_in_path("/etc/zypp/repos.d");
- MIL << endl;
- }
-
- ////////////////////////////////////////////////////////////////////////////
-
- void RepoManager::refreshMetadata( const RepoInfo &info )
- {
- assert_alias(info);
- assert_urls(info);
-
- // try urls one by one
- for ( RepoInfo::urls_const_iterator it = info.urlsBegin(); it != info.urlsEnd(); ++it )
- {
- Url url(*it);
- filesystem::TmpDir tmpdir;
-
- repo::RepoType repokind = info.type();
-
- // if the type is unknown, try probing.
- switch ( repokind.toEnum() )
- {
- case RepoType::NONE_e:
- // unknown, probe it
- repokind = probe(*it);
- break;
- default:
- break;
- }
-
- switch ( repokind.toEnum() )
- {
- case RepoType::RPMMD_e :
- {
- YUMDownloader downloader( url, "/" );
- downloader.download(tmpdir.path());
- // no error
- }
- break;
- case RepoType::YAST2_e :
- {
- SUSETagsDownloader downloader( url, "/" );
- downloader.download(tmpdir.path());
- // no error
- }
- break;
- default:
- ZYPP_THROW(RepoUnknownTypeException());
- }
-
- // ok we have the metadata, now exchange
- // the contents
- Pathname rawpath = rawcache_path_for_repoinfo(_pimpl->options, info);
- TmpDir oldmetadata;
- filesystem::assert_dir(rawpath);
- filesystem::rename( rawpath, oldmetadata.path() );
- // move the just downloaded there
- filesystem::rename( tmpdir.path(), rawpath );
-
- // we are done.
- }
- }
-
- ////////////////////////////////////////////////////////////////////////////
-
- void RepoManager::cleanMetadata( const RepoInfo &info )
- {
- filesystem::recursive_rmdir(rawcache_path_for_repoinfo(_pimpl->options, info));
- }
-
- ////////////////////////////////////////////////////////////////////////////
-
- void RepoManager::buildCache( const RepoInfo &info )
- {
- assert_alias(info);
- Pathname rawpath = rawcache_path_for_repoinfo(_pimpl->options, info);
-
- cache::CacheStore store(_pimpl->options.repoCachePath);
-
- if ( store.isCached( info.alias() ) )
- {
- MIL << info.alias() << " is already cached, cleaning..." << endl;
- data::RecordId id = store.lookupRepository(info.alias());
- store.cleanRepository(id);
- }
-
- data::RecordId id = store.lookupOrAppendRepository(info.alias());
-
- // do we have type?
- repo::RepoType repokind = info.type();
-
- // if the type is unknown, try probing.
- switch ( repokind.toEnum() )
- {
- case RepoType::NONE_e:
- // unknown, probe the local metadata
- repokind = probe(Url(rawpath.asString()));
- break;
- default:
- break;
- }
-
- switch ( repokind.toEnum() )
- {
- case RepoType::RPMMD_e :
- {
- parser::yum::RepoParser parser(id, store);
- parser.parse(rawpath);
- // no error
- }
- break;
- case RepoType::YAST2_e :
- {
- parser::susetags::RepoParser parser(id, store);
- parser.parse(rawpath);
- // no error
- }
- break;
- default:
- ZYPP_THROW(RepoUnknownTypeException());
- }
-
- MIL << "Commit cache.." << endl;
- store.commit();
- }
-
- ////////////////////////////////////////////////////////////////////////////
-
- repo::RepoType RepoManager::probe( const Url &url )
- {
- MediaSetAccess access(url);
- if ( access.doesFileExist("/repodata/repomd.xml") )
- return repo::RepoType::RPMMD;
- if ( access.doesFileExist("/content") )
- return repo::RepoType::YAST2;
-
- return repo::RepoType("UNKNOWN");
- }
-
- ////////////////////////////////////////////////////////////////////////////
-
- void RepoManager::cleanCache( const RepoInfo &info )
- {
- cache::CacheStore store(_pimpl->options.repoCachePath);
-
- data::RecordId id = store.lookupRepository(info.alias());
- store.cleanRepository(id);
- store.commit();
- }
-
- ////////////////////////////////////////////////////////////////////////////
-
- bool RepoManager::isCached( const RepoInfo &info ) const
- {
- cache::CacheStore store(_pimpl->options.repoCachePath);
- return store.isCached(info.alias());
- }
-
- Repository RepoManager::createFromCache( const RepoInfo &info )
- {
- cache::CacheStore store(_pimpl->options.repoCachePath);
-
- if ( ! store.isCached( info.alias() ) )
- ZYPP_THROW(RepoNotCachedException());
-
- MIL << "Repository " << info.alias() << " is cached" << endl;
-
- data::RecordId id = store.lookupRepository(info.alias());
- repo::cached::RepoImpl::Ptr repoimpl =
- new repo::cached::RepoImpl( info, _pimpl->options.repoCachePath, id );
- // read the resolvables from cache
- repoimpl->createResolvables();
- return Repository(repoimpl);
- }
-
- ////////////////////////////////////////////////////////////////////////////
-
- void RepoManager::addRepository( const RepoInfo &info )
- {
-
- }
-
- ////////////////////////////////////////////////////////////////////////////
-
- std::ostream & operator<<( std::ostream & str, const RepoManager & obj )
- {
- return str << *obj._pimpl;
- }
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp2
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/RepoManager.h
- *
-*/
-#ifndef ZYPP_REPOMANAGER_H
-#define ZYPP_REPOMANAGER_H
-
-#include <iosfwd>
-#include <list>
-
-#include "zypp/base/PtrTypes.h"
-//#include "zypp/base/ReferenceCounted.h"
-//#include "zypp/base/NonCopyable.h"
-#include "zypp/Pathname.h"
-#include "zypp/ZConfig.h"
-#include "zypp2/Repository.h"
-#include "zypp2/RepoInfo.h"
-#include "zypp2/repo/RepoException.h"
-#include "zypp2/repo/RepoType.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
- /**
- * Repo manager settings.
- * Settings default to ZYpp global settings.
- */
- struct RepoManagerOptions
- {
- RepoManagerOptions();
-
- Pathname repoCachePath;
- Pathname repoRawCachePath;
- Pathname knownReposPath;
- };
-
- /**
- * \short creates and provides information about known sources.
- *
- */
- class RepoManager
- {
- friend std::ostream & operator<<( std::ostream & str, const RepoManager & obj );
-
- public:
- /** Implementation */
- class Impl;
-
- public:
- RepoManager( const RepoManagerOptions &options = RepoManagerOptions() );
- /** Dtor */
- ~RepoManager();
-
- /**
- * \short List known repositories.
- *
- * The known repositories are read from
- * \ref RepoManagerOptions::knownReposPath passed on the Ctor.
- * Which defaults to ZYpp global settings.
- *
- */
- std::list<RepoInfo> knownRepositories() const;
-
- /**
- * \short Refresh local cache
- *
- * Will try to download the metadata
- *
- * In case of falure the metadata remains
- * as it was before.
- *
- * \throws RepoNoUrlException if no urls are available.
- * \throws RepoNoAliasException if can't figure an alias
- * \throws RepoUnknownTypeException if the metadata is unknown
- * \throws Exception on unknown error.
- */
- void refreshMetadata( const RepoInfo &info );
-
- /**
- * \short Clean local metadata
- *
- * Empty local metadata.
- *
- * \throws RepoNoAlias if can't figure an alias
- * \throws Exception on unknown error.
- */
- void cleanMetadata( const RepoInfo &info );
-
- /**
- * \short Refresh local cache
- *
- * Will try to build the cache from
- * local metadata.
- *
- * If the cache exists it will be overwriten.
- *
- * \note the local metadata must be valid.
- *
- * \throws RepoNoAlias if can't figure an alias to look in cache
- * \throws Exception on unknown error.
- */
- void buildCache( const RepoInfo &info );
-
- /**
- * \short clean local cache
- *
- * Clean the cached version of the metadata
- *
- * \note the local metadata must be valid.
- *
- * \throws RepoNoAlias if can't figure an alias to look in cache
- * \throws Exception on unknown error.
- */
- void cleanCache( const RepoInfo &info );
-
- /**
- * \short Wether a repository exists in cache
- *
- * \param RepoInfo to be checked.
- */
- bool isCached( const RepoInfo &info ) const;
-
- /**
- * \short Create a repository object from the cache data
- *
- * \throw RepoNotCachedException When the source is not cached.
- */
- Repository createFromCache( const RepoInfo &info );
-
- /**
- * \short Probe repo metadata type.
- *
- * \todo FIXME Should this be private?
- */
- repo::RepoType probe( const Url &url );
-
-
- /**
- * \short Adds a repository to the list of known repositories.
- *
- *
- *
- * \throws RepoAlreadyExistsException If the repo clash some
- * unique attribute like alias
- */
- void addRepository( const RepoInfo &info );
-
- /**
- * Adds a .repo file directly, which can contain
- * one or more repositories.
- */
- //void addRepositories( const Url &url );
-
-
- public:
-
- private:
- /** Pointer to implementation */
- RWCOW_pointer<Impl> _pimpl;
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates RepoManager Stream output */
- std::ostream & operator<<( std::ostream & str, const RepoManager & obj );
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp2
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP2_REPOMANAGER_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp2/RepoStatus.cc
- *
-*/
-#include <iostream>
-//#include "zypp/base/Logger.h"
-#include "zypp2/RepoStatus.h"
-
-
-using namespace std;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : RepoStatus::Impl
- //
- /** RepoStatus implementation. */
- struct RepoStatus::Impl
- {
-
- public:
-
- string checksum;
- Date timestamp;
-
- /** Offer default Impl. */
- static shared_ptr<Impl> nullimpl()
- {
- static shared_ptr<Impl> _nullimpl( new Impl );
- return _nullimpl;
- }
-
- private:
- friend Impl * rwcowClone<Impl>( const Impl * rhs );
- /** clone for RWCOW_pointer */
- Impl * clone() const
- { return new Impl( *this ); }
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates RepoStatus::Impl Stream output */
- inline std::ostream & operator<<( std::ostream & str, const RepoStatus::Impl & obj )
- {
- return str << "RepoStatus::Impl";
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : RepoStatus
- //
- ///////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : RepoStatus::RepoStatus
- // METHOD TYPE : Ctor
- //
- RepoStatus::RepoStatus()
- : _pimpl( Impl::nullimpl() )
- {}
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : RepoStatus::~RepoStatus
- // METHOD TYPE : Dtor
- //
- RepoStatus::~RepoStatus()
- {}
-
- RepoStatus & RepoStatus::setChecksum( const string &checksum )
- {
- _pimpl->checksum = checksum;
- return *this;
- }
-
- RepoStatus & RepoStatus::setTimestamp( const Date ×tamp )
- {
- _pimpl->timestamp = timestamp;
- return *this;
- }
-
- string RepoStatus::checksum() const
- { return _pimpl->checksum; }
-
- Date RepoStatus::timestamp() const
- { return _pimpl->timestamp; }
-
- /******************************************************************
- **
- ** FUNCTION NAME : operator<<
- ** FUNCTION TYPE : std::ostream &
- */
- std::ostream & operator<<( std::ostream & str, const RepoStatus & obj )
- {
- return str << *obj._pimpl;
- }
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp2
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/RepoStatus.h
- *
-*/
-#ifndef ZYPP2_REPOSTATUS_H
-#define ZYPP2_REPOSTATUS_H
-
-#include <iosfwd>
-#include "zypp/base/PtrTypes.h"
-#include "zypp/CheckSum.h"
-#include "zypp/Date.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : RepoStatus
- //
- /**
- * \short Local facts about a repository
- * This class represents the status of a
- * repository on the system.
- *
- * Anything that is not provided on the metadata
- * files, like the timestamp of the downloaded
- * metadata, and its checksum.
- */
- class RepoStatus
- {
- friend std::ostream & operator<<( std::ostream & str, const RepoStatus & obj );
-
- public:
-
- /**
- * Checksum of the repository.
- * Usually the checksum of the index, but any
- * checksum that changes when the repository changes
- * in any way is sufficient.
- */
- std::string checksum() const;
-
- /**
- * timestamp of the repository. If the repository
- * changes, it has to be updated as well with the
- * new timestamp.
- */
- Date timestamp() const;
-
- /**
- * set the repository checksum \see checksum
- * \param checksum
- */
- RepoStatus & setChecksum( const std::string &checksum );
-
- /**
- * set the repository timestamp \see timestamp
- * \param timestamp
- */
- RepoStatus & setTimestamp( const Date ×tamp );
-
- /** Implementation */
- class Impl;
-
- public:
- /** Default ctor */
- RepoStatus();
- /** Dtor */
- ~RepoStatus();
-
- public:
-
- private:
- /** Pointer to implementation */
- RWCOW_pointer<Impl> _pimpl;
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates RepoStatus Stream output */
- std::ostream & operator<<( std::ostream & str, const RepoStatus & obj );
-
- /////////////////////////////////////////////////////////////////
-} // namespace zypp2
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP2_REPOSTATUS_H
+++ /dev/null
-#include <cassert>
-#include <iostream>
-
-#include "zypp2/Repository.h"
-#include "zypp2/repo/RepositoryImpl.h"
-
-using namespace std;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-
- const Repository Repository::noRepository;
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : Repository::Repository
- // METHOD TYPE : Ctor
- //
- Repository::Repository()
- : _pimpl( Impl::nullimpl() )
- {}
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : Repository::Repository
- // METHOD TYPE : Ctor
- //
- Repository::Repository( const Impl_Ptr & impl_r )
- : _pimpl( impl_r )
- {
- assert( impl_r );
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- // Forward to RepositoryImpl:
- //
- ///////////////////////////////////////////////////////////////////
-
- Repository::NumericId Repository::numericId() const
- { return _pimpl->numericId(); }
-
- const ResStore & Repository::resolvables()
- {
- return _pimpl->resolvables();
- }
-
-}
-
+++ /dev/null
-
-#ifndef ZYPP_REPOSITORY_H
-#define ZYPP_REPOSITORY_H
-
-#include <iosfwd>
-#include <string>
-
-#include "zypp/base/PtrTypes.h"
-#include "zypp/base/SafeBool.h"
-#include "zypp/ResStore.h"
-
-namespace zypp
-{
- namespace repo
- {
- DEFINE_PTR_TYPE(RepositoryImpl);
- class RepositoryImpl;
- }
-
- class Repository : protected base::SafeBool<Repository> /* private, but gcc refuses */
- {
- public:
- friend std::ostream & operator<<( std::ostream & str, const Repository & obj );
- friend bool operator==( const Repository & lhs, const Repository & rhs );
- friend bool operator<( const Repository & lhs, const Repository & rhs );
-
- public:
- typedef repo::RepositoryImpl Impl;
- typedef repo::RepositoryImpl_Ptr Impl_Ptr;
-
- public:
-
- /** Default ctor: noRepository.
- * Real Repositorys are to be created via RepositoryFactory.
- */
- Repository();
-
- /** A dummy Repository (Id \c 0) providing nothing, doing nothing.
- * \todo provide a _constRef
- */
- static const Repository noRepository;
-
- /** Validate Repository in a boolean context.
- * \c FALSE iff == noRepository.
- */
- using base::SafeBool<Repository>::operator bool_type;
-
- public:
- typedef unsigned long NumericId;
-
- /** Runtime unique numeric Repository Id. */
- NumericId numericId() const;
-
- const ResStore & resolvables();
-
- private:
- friend base::SafeBool<Repository>::operator bool_type() const;
- /** \ref SafeBool test. */
- bool boolTest() const
- { return _pimpl != noRepository._pimpl; }
-
- private:
- /** Factory */
- friend class RepoManager;
- friend class repo::RepositoryImpl;
-
- private:
- /** Factory ctor */
- explicit
- Repository( const Impl_Ptr & impl_r );
-
- private:
- /** Pointer to implementation */
- Impl_Ptr _pimpl;
- };
-
-}
-
-#endif
-
-
+++ /dev/null
-
-#include "zypp2/RepositoryFactory.h"
-
-namespace zypp {
-
-RepositoryFactory::RepositoryFactory()
-{
-}
-
-RepositoryFactory::~RepositoryFactory()
-{
-
-}
-
-
-Repository RepositoryFactory::createFrom( const RepoInfo & context )
-{
-
-}
-
-} // ns zypp
-
-
+++ /dev/null
-
-#ifndef ZYPP_REPOSITORY_FACTORY_H
-#define ZYPP_REPOSITORY_FACTORY_H
-
-#include "zypp2/Repository.h"
-#include "zypp2/RepoInfo.h"
-
-namespace zypp
-{
- class RepositoryFactory
- {
- friend std::ostream & operator<<( std::ostream & str, const RepositoryFactory & obj );
-
- public:
- /** Default ctor */
- RepositoryFactory();
- /** Dtor */
- ~RepositoryFactory();
-
- public:
- /** Construct source.
- * \throw EXCEPTION on fail
- */
- Repository createFrom( const RepoInfo & context );
- };
-}
-
-#endif
-
-
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/repo/CacheException.cc
- *
-*/
-#include <iostream>
-//#include "zypp/base/Logger.h"
-#include "zypp2/cache/CacheException.h"
-
-using std::endl;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace cache
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : CacheException::CacheException
- // METHOD TYPE : Ctor
- //
- CacheException::CacheException()
- : Exception( "Cache exception" )
- {}
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : CacheException::CacheException
- // METHOD TYPE : Ctor
- //
- CacheException::CacheException( const std::string & msg_r )
- : Exception( msg_r )
- {}
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : CacheException::~CacheException
- // METHOD TYPE : Dtor
- //
- CacheException::~CacheException() throw()
- {}
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : CacheException::dumpOn
- // METHOD TYPE : std::ostream &
- //
- std::ostream & CacheException::dumpOn( std::ostream & str ) const
- {
- return Exception::dumpOn( str );
- }
-
- /////////////////////////////////////////////////////////////////
- } // namespace repo
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#ifndef ZYPP_REPO_REPOEXCEPTION_H
-#define ZYPP_REPO_REPOEXCEPTION_H
-
-#include <iosfwd>
-#include <string>
-
-#include "zypp/base/Exception.h"
-#include "zypp/base/UserRequestException.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace cache
- { /////////////////////////////////////////////////////////////////
-
- /**
- * \short Exception for cache errors
- */
- class CacheException : public Exception
- {
- public:
- /** Default ctor */
- CacheException();
- /** Ctor */
- CacheException( const std::string & msg_r );
- /** Dtor */
- virtual ~CacheException() throw();
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- };
- ///////////////////////////////////////////////////////////////////
-
- /**
- * The record you supplied can't be found
- */
- class CacheRecordNotFoundException : public CacheException
- {
-
- };
-
- /////////////////////////////////////////////////////////////////
- } // namespace cache
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_PARSER_TAGFILE_PARSEEXCEPTION_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp2/cache/CacheFSCK.cc
- *
-*/
-#include <iostream>
-#include "zypp/base/Logger.h"
-#include "zypp/base/Exception.h"
-#include "zypp2/cache/CacheFSCK.h"
-#include "zypp2/cache/sqlite3x/sqlite3x.hpp"
-
-using namespace zypp;
-using namespace zypp::cache;
-using namespace std;
-using namespace sqlite3x;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace cache
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : CacheFSCK::Impl
- //
- /** CacheFSCK implementation. */
- struct CacheFSCK::Impl
- {
-
- public:
-
- Impl( const Pathname &dbdir )
- : _dbdir(dbdir)
- {
-
- }
-
- void start()
- {
- try
- {
- sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
- //con.executenonquery("BEGIN;");
-
- sqlite3_command cmd( con, "PRAGMA integrity_check;");
- sqlite3_reader reader = cmd.executereader();
- while(reader.read())
- {
- cout << reader.getstring(0) << endl;
- }
- }
- catch( const std::exception &e )
- {
- ZYPP_RETHROW(Exception(e.what()));
- }
- }
-
- private:
- friend Impl * rwcowClone<Impl>( const Impl * rhs );
- /** clone for RWCOW_pointer */
- Impl * clone() const
- { return new Impl( *this ); }
-
- Pathname _dbdir;
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates CacheFSCK::Impl Stream output */
- inline std::ostream & operator<<( std::ostream & str, const CacheFSCK::Impl & obj )
- {
- return str << "CacheFSCK::Impl";
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : CacheFSCK
- //
- ///////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : CacheFSCK::CacheFSCK
- // METHOD TYPE : Ctor
- //
- CacheFSCK::CacheFSCK( const Pathname &dbdir )
- : _pimpl( new Impl(dbdir) )
- {}
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : CacheFSCK::~CacheFSCK
- // METHOD TYPE : Dtor
- //
- CacheFSCK::~CacheFSCK()
- {}
-
- void CacheFSCK::start()
- {
- _pimpl->start();
- }
-
- /******************************************************************
- **
- ** FUNCTION NAME : operator<<
- ** FUNCTION TYPE : std::ostream &
- */
- std::ostream & operator<<( std::ostream & str, const CacheFSCK & obj )
- {
- return str << *obj._pimpl;
- }
-
- /////////////////////////////////////////////////////////////////
- } // namespace cache
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp2
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp2/cache/CacheFSCK.h
- *
-*/
-#ifndef ZYPP2_CACHE_CACHEFSCK_H
-#define ZYPP2_CACHE_CACHEFSCK_H
-
-#include <iosfwd>
-
-#include "zypp/base/PtrTypes.h"
-#include "zypp/Pathname.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace cache
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : CacheFSCK
- //
- /**
- * Check for consistency of the cache
- **/
- class CacheFSCK
- {
- friend std::ostream & operator<<( std::ostream & str, const CacheFSCK & obj );
-
- public:
- /** Implementation */
- class Impl;
-
- public:
- /**
- * Default ctor
- *
- * \param dbdir Cache directory
- */
- CacheFSCK( const Pathname &dbdir );
-
- void start();
- /** Dtor */
- ~CacheFSCK();
-
- public:
-
- private:
- /** Pointer to implementation */
- RWCOW_pointer<Impl> _pimpl;
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates CacheFSCK Stream output */
- std::ostream & operator<<( std::ostream & str, const CacheFSCK & obj );
-
- /////////////////////////////////////////////////////////////////
- } // namespace cache
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp2
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP2_CACHE_CACHEFSCK_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#include <vector>
-#include <sstream>
-#include <fstream>
-
-#include "zypp/base/Logger.h"
-#include "zypp/base/String.h"
-#include "zypp/base/Measure.h"
-#include "zypp2/cache/CacheInitializer.h"
-#include "zypp2/cache/schema/schema.h"
-#include "zypp/target/store/PersistentStorage.h"
-#include "zypp2/cache/Utils.h"
-
-#include "schema.h"
-
-#define ZYPP_DB_FILE "/var/lib/zypp/zypp.db"
-
-using namespace sqlite3x;
-using namespace std;
-using zypp::debug::Measure;
-
-//////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace cache
-{ /////////////////////////////////////////////////////////////////
-
-struct CacheInitializer::Impl
-{
- Impl( const Pathname &root_r )
- : root(root_r), just_initialized(false)
- {
- }
- //typedef std::map<media::MediaNr, media::MediaAccessId> MediaMap
- shared_ptr<sqlite3x::sqlite3_connection> con;
- Pathname root;
- bool just_initialized;
-};
-
-CacheInitializer::CacheInitializer( const Pathname &root_r, const Pathname &db_file )
- : _pimpl( new Impl( root_r ) )
-{
- try
- {
- _pimpl->con.reset( new sqlite3_connection( ( _pimpl->root + db_file).asString().c_str()) );
-
- if( ! tablesCreated() )
- {
- createTables();
- _pimpl->just_initialized = true;
- _pimpl->con->close();
- MIL << "Source cache initialized" << std::endl;
- }
- else
- {
- MIL << "Source cache already initialized" << std::endl;
- }
- }
- catch( const exception &ex )
- {
- ZYPP_RETHROW(Exception(ex.what()));
- //ERR << "Exception Occured: " << ex.what() << endl;
- }
-
-}
-
-bool CacheInitializer::justInitialized() const
-{
- return _pimpl->just_initialized;
-}
-
-CacheInitializer::~CacheInitializer()
-{
-
-}
-
-bool CacheInitializer::tablesCreated() const
-{
- Measure timer("Check tables exist");
- unsigned int count = _pimpl->con->executeint("select count(*) from sqlite_master where type='table';");
- timer.elapsed();
- return ( count > 0 );
-}
-
-void CacheInitializer::createTables()
-{
- Measure timer("Create database tables");
- MIL << "Initializing cache schema..." << endl;
- sqlite3_transaction trans(*_pimpl->con);
- {
- string sql( schemaData, _schemaData_size);
- //ERR << "Executing " << statements[i] << endl;
- MIL << "Schema size: " << sql.size() << endl;
- _pimpl->con->execute(sql.c_str());
- }
- trans.commit();
- timer.elapsed();
-}
-
-std::ostream & CacheInitializer::dumpOn( std::ostream & str ) const
-{
- return str;
-}
-
-}
-}
-
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#ifndef ZYPP_CacheInitializer_H
-#define ZYPP_CacheInitializer_H
-
-#include <iosfwd>
-#include <string>
-
-#include "zypp/base/PtrTypes.h"
-#include "zypp/base/ReferenceCounted.h"
-#include "zypp/base/NonCopyable.h"
-#include "zypp/Pathname.h"
-#include "zypp2/cache/sqlite3x/sqlite3x.hpp"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace cache
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : CacheInitializer
- //
- class CacheInitializer
- {
- friend std::ostream & operator<<( std::ostream & str, const CacheInitializer & obj );
-
- public:
- /**
- * Tries to initialize the source cache if it was not
- * \throws Exception When cant initialize
- */
- CacheInitializer( const Pathname &root_r, const Pathname &db_file );
- virtual ~CacheInitializer();
-
- /**
- * only true when cache was not initialized before
- * and was just initialized with success
- */
- bool justInitialized() const;
- protected:
- bool tablesCreated() const;
- void createTables();
- /** Overload to realize stream output. */
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- private:
- /** Implementation. */
- class Impl;
- /** Pointer to implementation. */
- RW_pointer<Impl> _pimpl;
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates CacheInitializer Stream output */
- inline std::ostream & operator<<( std::ostream & str, const CacheInitializer & obj )
- { return obj.dumpOn( str ); }
-
-
- /////////////////////////////////////////////////////////////////
- } // namespace cache
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOURCE_CacheInitializer_H
+++ /dev/null
-
-#include <sqlite3.h>
-#include <map>
-#include "zypp2/cache/sqlite3x/sqlite3x.hpp"
-
-#include "zypp/base/Logger.h"
-#include "zypp/base/Measure.h"
-#include "zypp/ZYppFactory.h"
-#include "zypp/ZYpp.h"
-#include "zypp/ZConfig.h"
-
-#include "zypp2/cache/CacheInitializer.h"
-#include "zypp2/cache/CacheStore.h"
-#include "zypp2/cache/CacheException.h"
-
-using namespace std;
-using namespace zypp;
-using namespace zypp::capability;
-using namespace zypp::cache;
-using zypp::data::RecordId;
-using namespace sqlite3x;
-
-using zypp::debug::Measure;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace cache
-{ /////////////////////////////////////////////////////////////////
-
-typedef shared_ptr<sqlite3_command> sqlite3_command_ptr;
-
-struct CacheStore::Impl
-{
- Impl( const Pathname &dbdir )
- : name_cache_hits(0)
- {
- cache::CacheInitializer initializer(dbdir, "zypp.db");
- if ( initializer.justInitialized() )
- {
- MIL << "database " << (dbdir + "zypp.db") << " was just created" << endl;
- }
-
- try
- {
- con.open( (dbdir + "zypp.db").asString().c_str());
- //_insert_resolvable_cmd = new sqlite3_command( *_con, INSERT_RESOLVABLE_QUERY );
- //_insert_package_cmd = new sqlite3_command( *_con, INSERT_PACKAGE_QUERY );
- }
- catch(exception &ex)
- {
- //ZYPP_CAUGHT(ex);
- ZYPP_THROW(Exception(ex.what()));
- }
-
-
- // initialize all pre-compiled statements
-
- insert_resolvable_in_repository_cmd.reset( new sqlite3_command( con, "insert into resolvables_repositories (resolvable_id, repository_id) values (:resolvable_id, :repository_id);" ));
-
- update_repository_cmd.reset( new sqlite3_command( con, "update repositories set checksum=:checksum, timestamp=:timestamp where id=:repository_id;" ));
-
- select_repository_cmd.reset( new sqlite3_command( con, "select id from repositories where alias=:alias;" ));
- insert_repository_cmd.reset( new sqlite3_command( con, "insert into repositories (alias,timestamp) values (:alias, :timestamp);" ));
-
- select_name_cmd.reset( new sqlite3_command( con, "select id from names where name=:name;" ));
- insert_name_cmd.reset( new sqlite3_command( con, "insert into names (name) values (:name);" ));
-
- select_dirname_cmd.reset( new sqlite3_command( con, "select id from dir_names where name=:name;" ));
- insert_dirname_cmd.reset( new sqlite3_command( con, "insert into dir_names (name) values (:name);" ));
-
- select_filename_cmd.reset( new sqlite3_command( con, "select id from file_names where name=:name;" ));
- insert_filename_cmd.reset( new sqlite3_command( con, "insert into file_names (name) values (:name);" ));
-
- select_file_cmd.reset( new sqlite3_command( con, "select id from files where dir_name_id=:dir_name_id and file_name_id=:file_name_id;" ));
- insert_file_cmd.reset( new sqlite3_command( con, "insert into files (dir_name_id,file_name_id) values (:dir_name_id,:file_name_id);" ));
-
- select_type_cmd.reset( new sqlite3_command( con, "select id from types where class=:class and name=:name;" ));
- insert_type_cmd.reset( new sqlite3_command( con, "insert into types (class,name) values (:class,:name);" ));
-
- set_shared_flag_cmd.reset( new sqlite3_command( con, "update resolvables set shared_id=:shared_id where id=:resolvable_id;" ));
-
- append_text_attribute_cmd.reset( new sqlite3_command( con, "insert into text_attributes ( weak_resolvable_id, lang_id, attr_id, text ) values ( :rid, :lang_id, :attr_id, :text );" ));
- append_num_attribute_cmd.reset( new sqlite3_command( con, "insert into numeric_attributes ( weak_resolvable_id, attr_id, value ) values ( :rid, :attr_id, :value );" ));
-
- //insert_dependency_entry_cmd.reset( new sqlite3_command( con, "insert into capabilities ( resolvable_id, dependency_type, refers_kind ) values ( :resolvable_id, :dependency_type, :refers_kind );" ));
- append_file_dependency_cmd.reset( new sqlite3_command( con, "insert into file_capabilities ( resolvable_id, dependency_type, refers_kind, file_id ) values ( :resolvable_id, :dependency_type, :refers_kind, :file_id );" ));
- append_named_dependency_cmd.reset( new sqlite3_command( con, "insert into named_capabilities ( resolvable_id, dependency_type, refers_kind, name_id, version, release, epoch, relation ) values ( :resolvable_id, :dependency_type, :refers_kind, :name_id, :version, :release, :epoch, :relation );" ));
-
- append_modalias_dependency_cmd.reset( new sqlite3_command( con, "insert into modalias_capabilities ( resolvable_id, dependency_type, refers_kind, name, value, relation ) values ( :resolvable_id, :dependency_type, :refers_kind, :name, :value, :relation );" ));
-
- append_hal_dependency_cmd.reset( new sqlite3_command( con, "insert into hal_capabilities ( resolvable_id, dependency_type, refers_kind, name, value, relation ) values ( :resolvable_id, :dependency_type, :refers_kind, :name, :value, :relation );" ));
-
- append_other_dependency_cmd.reset( new sqlite3_command( con, "insert into other_capabilities ( resolvable_id, dependency_type, refers_kind, value ) values ( :resolvable_id, :dependency_type, :refers_kind, :value );" ));
-
- append_resolvable_cmd.reset( new sqlite3_command( con, "insert into resolvables ( name, version, release, epoch, arch, kind, repository_id ) values ( :name, :version, :release, :epoch, :arch, :kind, :repository_id );" ));
-
- count_shared_cmd.reset( new sqlite3_command( con, "select count(id) from resolvables where shared_id=:rid;" ));
-
- insert_patchrpm_cmd.reset( new sqlite3_command (con,
- "insert into patch_packages (media_nr, location, checksum, download_size, build_time) "
- "values (:media_nr, :location, :checksum, :download_size, :build_time);" ));
- insert_deltarpm_cmd.reset( new sqlite3_command (con,
- "insert into delta_packages (media_nr, location, checksum, download_size, build_time, "
- "baseversion_version, baseversion_release, baseversion_epoch, baseversion_checksum, "
- "baseversion_build_time, baseversion_sequence_info) "
- "values (:media_nr, :location, :checksum, :download_size, :build_time, "
- ":baseversion_version, :baseversion_release, :baseversion_epoch, :baseversion_checksum, "
- ":baseversion_build_time, :baseversion_sequence_info);" ));
- append_patch_baseversion_cmd.reset( new sqlite3_command (con,
- "insert into patch_packages_baseversions (patch_package_id, version, release, epoch) "
- "values (:patch_package_id, :version, :release, :epoch)" ));
-
-
- // disable autocommit
- con.executenonquery("BEGIN;");
- }
-
- Impl()
- {
- Impl( getZYpp()->homePath() );
- }
-
- ~Impl()
- {
- MIL << "name cache hits: " << name_cache_hits << " | cache size: " << name_cache.size() << endl;
- }
-
- /**
- * SQL statements
- * (we precompile them
- */
- sqlite3_connection con;
-
- sqlite3_command_ptr update_repository_cmd;
- sqlite3_command_ptr insert_resolvable_in_repository_cmd;
-
- sqlite3_command_ptr select_name_cmd;
- sqlite3_command_ptr insert_name_cmd;
-
- sqlite3_command_ptr select_dirname_cmd;
- sqlite3_command_ptr insert_dirname_cmd;
-
- sqlite3_command_ptr select_filename_cmd;
- sqlite3_command_ptr insert_filename_cmd;
-
- sqlite3_command_ptr select_repository_cmd;
- sqlite3_command_ptr insert_repository_cmd;
-
- sqlite3_command_ptr select_file_cmd;
- sqlite3_command_ptr insert_file_cmd;
-
- sqlite3_command_ptr select_type_cmd;
- sqlite3_command_ptr insert_type_cmd;
-
- //sqlite3_command_ptr insert_dependency_entry_cmd;
-
- sqlite3_command_ptr append_file_dependency_cmd;
- sqlite3_command_ptr append_named_dependency_cmd;
- sqlite3_command_ptr append_modalias_dependency_cmd;
- sqlite3_command_ptr append_hal_dependency_cmd;
- sqlite3_command_ptr append_other_dependency_cmd;
-
- sqlite3_command_ptr append_resolvable_cmd;
-
- sqlite3_command_ptr append_text_attribute_cmd;
- sqlite3_command_ptr append_num_attribute_cmd;
-
- sqlite3_command_ptr set_shared_flag_cmd;
-
- sqlite3_command_ptr count_shared_cmd;
-
- sqlite3_command_ptr insert_patchrpm_cmd;
- sqlite3_command_ptr insert_deltarpm_cmd;
- sqlite3_command_ptr append_patch_baseversion_cmd;
-
- map<string, RecordId> name_cache;
- map< pair<string,string>, RecordId> type_cache;
- int name_cache_hits;
-};
-
-
-CacheStore::CacheStore( const Pathname &dbdir )
- : _pimpl( new Impl(dbdir) )
-{
-
-}
-
-CacheStore::CacheStore()
- : _pimpl( new Impl() )
-{
-
-}
-
-CacheStore::~CacheStore()
-{
-
-}
-
-void CacheStore::commit()
-{
- _pimpl->con.executenonquery("COMMIT;");
-}
-
-void CacheStore::appendResObjectAttributes( const data::RecordId &rid,
- const data::ResObject_Ptr & res )
-{
- appendTranslatedStringAttribute( rid, "ResObject", "description", res->description );
- appendTranslatedStringAttribute( rid, "ResObject", "summary", res->summary );
- appendNumericAttribute( rid, "ResObject", "installedSize", res->installedSize );
- appendNumericAttribute( rid, "ResObject", "buildTime", res->buildTime );
- appendBooleanAttribute( rid, "ResObject", "installOnly", res->installOnly );
- appendStringAttribute( rid, "ResObject", "vendor", res->vendor );
- appendTranslatedStringAttribute( rid, "ResObject", "licenseToConfirm", res->licenseToConfirm );
- appendTranslatedStringAttribute( rid, "ResObject", "insnotify", res->insnotify );
- appendTranslatedStringAttribute( rid, "ResObject", "delnotify", res->delnotify );
-}
-
-
-void CacheStore::appendPackageBaseAttributes( const RecordId & pkgid,
- const data::Packagebase_Ptr & package )
-{
- appendStringAttribute( pkgid, "Package", "checksum", package->repositoryLocation.fileChecksum.checksum() );
- appendStringAttribute( pkgid, "Package", "checksumType", package->repositoryLocation.fileChecksum.type() );
- appendStringAttribute( pkgid, "Package", "buildhost", package->buildhost );
- appendStringAttribute( pkgid, "Package", "distribution", package->distribution );
- appendStringAttribute( pkgid, "Package", "license", package->license );
- appendStringAttribute( pkgid, "Package", "group", package->packager );
- appendStringAttribute( pkgid, "Package", "url", package->url );
- appendStringAttribute( pkgid, "Package", "operatingSystem", package->operatingSystem );
- appendStringAttribute( pkgid, "Package", "prein", package->prein );
- appendStringAttribute( pkgid, "Package", "postin", package->postin );
- appendStringAttribute( pkgid, "Package", "preun", package->preun );
- appendStringAttribute( pkgid, "Package", "postun", package->postun );
- appendStringContainerAttribute( pkgid, "Package", "keywords", package->keywords );
- appendStringContainerAttribute( pkgid, "Package", "authors", package->authors );
- appendStringAttribute( pkgid, "Package", "location", package->repositoryLocation.filePath.asString() );
-}
-
-void CacheStore::consumePackage( const RecordId & repository_id,
- const data::Package_Ptr & package )
-{
- RecordId pkgid = appendResolvable( repository_id, ResTraits<Package>::kind,
- NVRA( package->name, package->edition, package->arch ), package->deps );
- appendResObjectAttributes( pkgid, package );
- appendPackageBaseAttributes( pkgid, package );
-}
-
-void CacheStore::consumeSourcePackage( const data::RecordId & repository_id,
- const data::SrcPackage_Ptr & package )
-{
- RecordId pkgid = appendResolvable( repository_id, ResTraits<SrcPackage>::kind,
- NVRA( package->name, package->edition, package->arch ), package->deps );
- appendResObjectAttributes( pkgid, package );
- appendPackageBaseAttributes( pkgid, package );
-#warning TBD
-}
-
-void CacheStore::consumePatch( const data::RecordId & repository_id,
- const data::Patch_Ptr & patch)
-{
- RecordId id = appendResolvable(
- repository_id, ResTraits<Patch>::kind,
- NVRA( patch->name, patch->edition, patch->arch ), patch->deps );
-
- appendResObjectAttributes( id, patch );
-
- // patch attributes
- appendNumericAttribute( id, "Patch", "timestamp", patch->timestamp );
- appendStringAttribute( id, "Patch", "category", patch->category );
- appendBooleanAttribute( id, "Patch", "rebootNeeded", patch->rebootNeeded );
- appendBooleanAttribute( id, "Patch", "affectsPkgManager", patch->affectsPkgManager );
-
-
- DBG << "got patch " << patch->name << ", atoms: ";
- // cosume atoms
- for (set<data::ResObject_Ptr>::const_iterator p = patch->atoms.begin();
- p != patch->atoms.end(); ++p)
- {
- data::PackageAtom_Ptr atom = dynamic_pointer_cast<data::PackageAtom>(*p);
- if (atom)
- {
- DBG << atom->name << "(atom) ";
- consumePackageAtom(repository_id, atom);
- continue;
- }
-
- data::Script_Ptr script = dynamic_pointer_cast<data::Script>(*p);
- if (script)
- {
- DBG << script->name << "(script) ";
- consumeScript(repository_id, script);
- continue;
- }
-
- data::Message_Ptr message = dynamic_pointer_cast<data::Message>(*p);
- if (message)
- {
- DBG << message->name << "(message) ";
- consumeMessage(repository_id, message);
- continue;
- }
-
- ERR << " ignoring !badatom! ";
- if (*p) ERR << (*p)->name;
- ERR << endl;
- }
-
- DBG << endl;
-}
-
-void CacheStore::consumePackageAtom( const data::RecordId & repository_id,
- const data::PackageAtom_Ptr & atom )
-{
- RecordId id = appendResolvable( repository_id, ResTraits<Atom>::kind,
- NVRA( atom->name, atom->edition, atom->arch ), atom->deps );
- appendResObjectAttributes( id, atom );
- appendPackageBaseAttributes( id, atom );
-
- for (set<data::PatchRpm_Ptr>::const_iterator p = atom->patchRpms.begin();
- p != atom->patchRpms.end(); ++p)
- appendPatchRpm(*p);
-
- for (set<data::DeltaRpm_Ptr>::const_iterator d = atom->deltaRpms.begin();
- d != atom->deltaRpms.end(); ++d)
- appendDeltaRpm(*d);
-}
-
-void CacheStore::consumeMessage( const data::RecordId & repository_id,
- const data::Message_Ptr & message )
-{
- RecordId id = appendResolvable( repository_id, ResTraits<Message>::kind,
- NVRA( message->name, message->edition, message->arch ), message->deps );
- appendResObjectAttributes( id, message );
-
- appendTranslatedStringAttribute( id, "Message", "text", message->text );
-}
-
-void CacheStore::consumeScript( const data::RecordId & repository_id,
- const data::Script_Ptr & script )
-{
- RecordId id = appendResolvable( repository_id, ResTraits<Script>::kind,
- NVRA( script->name, script->edition, script->arch ), script->deps );
- appendResObjectAttributes( id, script );
-
- appendStringAttribute( id, "Script", "doScript", script->doScript );
- appendStringAttribute( id, "Script", "doScriptLocation", script->doScriptLocation.filePath.asString() );
- appendStringAttribute( id, "Script", "doScriptChecksum", script->doScriptLocation.fileChecksum.checksum() );
- appendStringAttribute( id, "Script", "doScriptChecksumType", script->doScriptLocation.fileChecksum.type() );
- appendStringAttribute( id, "Script", "undoScript", script->undoScript );
- appendStringAttribute( id, "Script", "undoScriptLocation", script->undoScriptLocation.filePath.asString() );
- appendStringAttribute( id, "Script", "undoScriptChecksum", script->undoScriptLocation.fileChecksum.checksum() );
- appendStringAttribute( id, "Script", "undoScriptChecksumType", script->undoScriptLocation.fileChecksum.type() );
-}
-
-void CacheStore::consumePattern( const data::RecordId & repository_id,
- const data::Pattern_Ptr & pattern )
-{
- RecordId id = appendResolvable( repository_id, ResTraits<Pattern>::kind,
- NVRA( pattern->name, pattern->edition, pattern->arch ), pattern->deps );
- appendResObjectAttributes( id, pattern );
-
- appendBooleanAttribute( id, "Pattern", "isDefault", pattern->isDefault );
- appendBooleanAttribute( id, "Pattern", "userVisible", pattern->userVisible );
- appendTranslatedStringAttribute( id, "Pattern", "category", pattern->category );
- appendStringAttribute( id, "Pattern", "icon", pattern->icon );
- appendStringAttribute( id, "Pattern", "order", pattern->order );
-}
-
-void CacheStore::consumeProduct( const data::RecordId & repository_id,
- const data::Product_Ptr & product )
-{
- RecordId id = appendResolvable( repository_id, ResTraits<Product>::kind,
- NVRA( product->name, product->edition, product->arch ), product->deps );
- appendResObjectAttributes( id, product );
-
- appendTranslatedStringAttribute( id, "Product", "shortName", product->shortName );
- appendTranslatedStringAttribute( id, "Product", "longName", product->longName );
- appendStringContainerAttribute( id, "Product", "flags", product->flags );
- appendStringAttribute( id, "Pattern", "releasenotesUrl", product->releasenotesUrl.asString() );
- //! \todo figure out how to store list of Urls. A separate method appendUrlContainerAttribute? Or change it to plain string in ResolvableData.h?
-// appendStringContainerAttribute( id, "Product", "updateUrls", product->updateUrls );
-// appendStringContainerAttribute( id, "Product", "extraUrls", product->extraUrls );
-// appendStringContainerAttribute( id, "Product", "optionalUrls", product->optionalUrls );
- appendStringAttribute( id, "Pattern", "distributionName", product->distributionName );
- appendStringAttribute( id, "Pattern", "distributionEdition", product->distributionEdition.asString() );
-}
-
-void CacheStore::consumeChangelog( const data::RecordId & repository_id,
- const data::Resolvable_Ptr & resolvable,
- const Changelog & changelog )
-{
- //! \todo maybe appendChangelog(const data::RecordId & resolvable_id, Changelog changelog) will be needed
- //! for inserting the changelog using in-memory record id of corresponding resolvable.
- //! (first, we'll see how fast is the inserting without remembering those ids)
-}
-
-void CacheStore::consumeFilelist( const data::RecordId & repository_id,
- const data::Resolvable_Ptr & resolvable,
- const data::Filenames & filenames )
-{
- //! \todo maybe consumeFilelist(const data::RecordId & resolvable_id, data::Filenames &) will be needed
-}
-
-RecordId CacheStore::appendResolvable( const RecordId &repository_id,
- const Resolvable::Kind &kind,
- const NVRA &nvra,
- const data::Dependencies &deps )
-{
- _pimpl->append_resolvable_cmd->bind( ":name", nvra.name );
- _pimpl->append_resolvable_cmd->bind( ":version", nvra.edition.version() );
- _pimpl->append_resolvable_cmd->bind( ":release", nvra.edition.release() );
- _pimpl->append_resolvable_cmd->bind( ":epoch", static_cast<int>( nvra.edition.epoch() ) );
- _pimpl->append_resolvable_cmd->bind( ":arch", lookupOrAppendType("arch", nvra.arch.asString()) );
- _pimpl->append_resolvable_cmd->bind( ":kind", lookupOrAppendType("kind", kind.asString()) );
- _pimpl->append_resolvable_cmd->bind( ":repository_id", repository_id );
-
- _pimpl->append_resolvable_cmd->executenonquery();
-
- long long id = _pimpl->con.insertid();
-
- appendDependencies( id, deps );
- /*
- _pimpl->insert_resolvable_in_repository_cmd->bind(":repository_id", repository_id);
- _pimpl->insert_resolvable_in_repository_cmd->bind(":resolvable_id", id);
- _pimpl->insert_resolvable_in_repository_cmd->executenonquery();*/
-
- return static_cast<RecordId>(id);
- return 1;
-}
-
-void CacheStore::appendDependencies( const RecordId &resolvable_id, const data::Dependencies &deps )
-{
- for ( data::Dependencies::const_iterator it = deps.begin(); it != deps.end(); ++it )
- {
- appendDependencyList( resolvable_id, it->first, it->second );
- }
-}
-
-void CacheStore::appendDependencyList( const RecordId &resolvable_id, zypp::Dep deptype, const data::DependencyList &caps )
-{
- for ( data::DependencyList::const_iterator it = caps.begin(); it != caps.end(); ++it )
- {
- appendDependency( resolvable_id, deptype, *it );
- }
-}
-
-void CacheStore::appendDependency( const RecordId &resolvable_id, zypp::Dep deptype, capability::CapabilityImpl::Ptr cap )
-{
- if ( cap == 0 )
- {
- DBG << "invalid capability" << endl;
- return;
- }
-
- if ( capability::isKind<NamedCap>(cap) )
- {
- appendNamedDependency( resolvable_id, deptype, capability::asKind<NamedCap>(cap) );
- }
- else if ( capability::isKind<FileCap>(cap) )
- {
- appendFileDependency( resolvable_id, deptype, capability::asKind<FileCap>(cap) );
- return;
- }
- else if ( capability::isKind<ModaliasCap>(cap) )
- {
- appendModaliasDependency( resolvable_id, deptype, capability::asKind<ModaliasCap>(cap) );
- }
- else if ( capability::isKind<HalCap>(cap) )
- {
- appendHalDependency( resolvable_id, deptype, capability::asKind<HalCap>(cap) );
- }
- else
- {
- appendUnknownDependency( resolvable_id, deptype, cap );
- }
-}
-
-// RecordId CacheStore::lookupOrAppendNamedDependencyEntry( const RecordId name_id, const Edition &edition, const zypp::Rel &rel )
-// {
-// _pimpl->select_named_dependency_cmd->bind( ":name_id", name_id);
-// _pimpl->select_named_dependency_cmd->bind( ":version", edition.version() );
-// _pimpl->select_named_dependency_cmd->bind( ":release", edition.release() );
-// _pimpl->select_named_dependency_cmd->bind( ":epoch", static_cast<int>( edition.epoch() ) );
-// _pimpl->select_named_dependency_cmd->bind( ":relation", zypp_rel2db_rel( rel ) );
-// long long id = 0;
-// try {
-// id = _pimpl->select_named_dependency_cmd->executeint64();
-// }
-// catch ( const sqlite3x::database_error &e )
-// {
-// // does not exist
-// _pimpl->append_named_dependency_entry_cmd->bind( ":name_id", name_id);
-// _pimpl->append_named_dependency_entry_cmd->bind( ":version", edition.version() );
-// _pimpl->append_named_dependency_entry_cmd->bind( ":release", edition.release() );
-// _pimpl->append_named_dependency_entry_cmd->bind( ":epoch", static_cast<int>( edition.epoch() ) );
-// _pimpl->append_named_dependency_entry_cmd->bind( ":relation", zypp_rel2db_rel( rel ) );
-// _pimpl->append_named_dependency_entry_cmd->executenonquery();
-// id = _pimpl->con.insertid();
-// return static_cast<RecordId>(id);
-// }
-// return static_cast<RecordId>(id);
-// }
-
-void CacheStore::appendNamedDependency( const RecordId &resolvable_id, zypp::Dep deptype, capability::NamedCap::Ptr cap )
-{
- if ( !cap )
- ZYPP_THROW(Exception("bad versioned dep"));
- //DBG << "versioned : " << cap << endl;
-
- //RecordId capability_id = appendDependencyEntry( resolvable_id, deptype, cap->refers() );
- RecordId name_id = lookupOrAppendName(cap->name());
-
- _pimpl->append_named_dependency_cmd->bind( ":resolvable_id", resolvable_id );
- _pimpl->append_named_dependency_cmd->bind( ":dependency_type", lookupOrAppendType("deptype", deptype.asString()) );
- _pimpl->append_named_dependency_cmd->bind( ":refers_kind", lookupOrAppendType("kind", cap->refers().asString()) );
-
- //_pimpl->append_named_dependency_cmd->bind( ":capability_id", capability_id);
- _pimpl->append_named_dependency_cmd->bind( ":name_id", name_id);
- _pimpl->append_named_dependency_cmd->bind( ":version", cap->edition().version() );
- _pimpl->append_named_dependency_cmd->bind( ":release", cap->edition().release() );
- _pimpl->append_named_dependency_cmd->bind( ":epoch", static_cast<int>( cap->edition().epoch() ) );
- _pimpl->append_named_dependency_cmd->bind( ":relation", lookupOrAppendType("rel", cap->op().asString()) );
- _pimpl->append_named_dependency_cmd->executenonquery();
-
- //delete cmd;
-}
-
-void CacheStore::appendModaliasDependency( const RecordId &resolvable_id,
- zypp::Dep deptype,
- capability::ModaliasCap::Ptr cap )
-{
- if ( !cap )
- ZYPP_THROW(Exception("Null modalias capability"));
-
- _pimpl->append_modalias_dependency_cmd->bind( ":resolvable_id", resolvable_id );
- _pimpl->append_modalias_dependency_cmd->bind( ":dependency_type", lookupOrAppendType("deptype", deptype.asString()) );
- _pimpl->append_modalias_dependency_cmd->bind( ":refers_kind", lookupOrAppendType("kind", cap->refers().asString()) );
-
- //_pimpl->append_modalias_dependency_cmd->bind( ":capability_id", capability_id);
- _pimpl->append_modalias_dependency_cmd->bind( ":name", cap->name());
- _pimpl->append_modalias_dependency_cmd->bind( ":value", cap->value());
- _pimpl->append_modalias_dependency_cmd->bind( ":relation", lookupOrAppendType("rel", cap->op().asString()) );
-
- _pimpl->append_modalias_dependency_cmd->executenonquery();
- //delete cmd;
-}
-
-void CacheStore::appendHalDependency( const RecordId &resolvable_id,
- zypp::Dep deptype,
- capability::HalCap::Ptr cap )
-{
- if ( !cap )
- ZYPP_THROW(Exception("Null HAL capability"));
-
- _pimpl->append_hal_dependency_cmd->bind( ":resolvable_id", resolvable_id );
- _pimpl->append_hal_dependency_cmd->bind( ":dependency_type", lookupOrAppendType("deptype", deptype.asString()) );
- _pimpl->append_hal_dependency_cmd->bind( ":refers_kind", lookupOrAppendType("kind", cap->refers().asString()) );
-
- //_pimpl->append_hal_dependency_cmd->bind( ":capability_id", capability_id);
- _pimpl->append_hal_dependency_cmd->bind( ":name", cap->name());
- _pimpl->append_hal_dependency_cmd->bind( ":value", cap->value());
- _pimpl->append_hal_dependency_cmd->bind( ":relation", lookupOrAppendType("rel", cap->op().asString()) );
-
- _pimpl->append_hal_dependency_cmd->executenonquery();
- //delete cmd;
-}
-
-void CacheStore::appendFileDependency( const RecordId &resolvable_id, zypp::Dep deptype,
- capability::FileCap::Ptr cap )
-{
- if ( !cap )
- ZYPP_THROW(Exception("Null file capability"));
-
- //RecordId capability_id = appendDependencyEntry( resolvable_id, deptype, cap->refers() );
- RecordId file_id = lookupOrAppendFile(cap->filename());
-
- _pimpl->append_file_dependency_cmd->bind( ":resolvable_id", resolvable_id );
- _pimpl->append_file_dependency_cmd->bind( ":dependency_type", lookupOrAppendType("deptype", deptype.asString()) );
- _pimpl->append_file_dependency_cmd->bind( ":refers_kind", lookupOrAppendType("kind", cap->refers().asString()) );
-
- //_pimpl->append_file_dependency_cmd->bind( ":capability_id", capability_id);
- _pimpl->append_file_dependency_cmd->bind( ":file_id", file_id);
-
- _pimpl->append_file_dependency_cmd->executenonquery();
- //delete cmd;
-}
-
-void CacheStore::appendUnknownDependency( const RecordId &resolvable_id,
- zypp::Dep deptype,
- capability::CapabilityImpl::Ptr cap )
-{
- if ( !cap )
- ZYPP_THROW(Exception("Null unknown capability"));
-
- _pimpl->append_other_dependency_cmd->bind( ":resolvable_id", resolvable_id );
- _pimpl->append_other_dependency_cmd->bind( ":dependency_type", lookupOrAppendType("deptype", deptype.asString()) );
- _pimpl->append_other_dependency_cmd->bind( ":refers_kind", lookupOrAppendType("kind", cap->refers().asString()) );
- _pimpl->append_other_dependency_cmd->bind( ":value", cap->encode());
-
- _pimpl->append_hal_dependency_cmd->executenonquery();
- //delete cmd;
-}
-
-
-/** \todo lookupOrAppend ? */
-RecordId CacheStore::appendPatchRpm(const data::PatchRpm_Ptr & prpm)
-{
- RecordId id;
-
- //! \todo what's this? _pimpl->insert_patchrpm_cmd->bind(":media_nr", ???);
- _pimpl->insert_patchrpm_cmd->bind(":location", prpm->location.filePath.asString());
- _pimpl->insert_patchrpm_cmd->bind(":checksum", prpm->location.fileChecksum.checksum());
- //! \todo checksum type
- _pimpl->insert_patchrpm_cmd->bind(":download_size", static_cast<ByteCount::SizeType>(prpm->location.fileSize));
- _pimpl->insert_patchrpm_cmd->bind(":build_time", prpm->buildTime.asSeconds());
- _pimpl->insert_patchrpm_cmd->executenonquery();
-
- id = _pimpl->con.insertid();
-
- for (set<data::BaseVersion_Ptr>::const_iterator bv = prpm->baseVersions.begin();
- bv != prpm->baseVersions.end(); ++bv)
- {
- _pimpl->append_patch_baseversion_cmd->bind(":patch_package_id", id);
- _pimpl->append_patch_baseversion_cmd->bind(":version", (*bv)->edition.version());
- _pimpl->append_patch_baseversion_cmd->bind(":release", (*bv)->edition.release());
- _pimpl->append_patch_baseversion_cmd->bind(":epoch", (int) (*bv)->edition.epoch());
- _pimpl->append_patch_baseversion_cmd->executenonquery();
- }
-
- return id;
-}
-
-
-/** \todo lookupOrAppend ? */
-RecordId CacheStore::appendDeltaRpm(const data::DeltaRpm_Ptr & drpm)
-{
- RecordId id;
-
- //! \todo what's this? _pimpl->insert_deltarpm_cmd->bind(":media_nr", ???);
- _pimpl->insert_deltarpm_cmd->bind(":location", drpm->location.filePath.asString());
- _pimpl->insert_deltarpm_cmd->bind(":checksum", drpm->location.fileChecksum.checksum());
- //! \todo checksum type
- _pimpl->insert_deltarpm_cmd->bind(":download_size", static_cast<ByteCount::SizeType>(drpm->location.fileSize));
- _pimpl->insert_deltarpm_cmd->bind(":build_time", drpm->buildTime.asSeconds());
-
- _pimpl->insert_deltarpm_cmd->bind(":baseversion_version", drpm->baseVersion.edition.version());
- _pimpl->insert_deltarpm_cmd->bind(":baseversion_release", drpm->baseVersion.edition.release());
- _pimpl->insert_deltarpm_cmd->bind(":baseversion_epoch", (int) drpm->baseVersion.edition.epoch());
- _pimpl->insert_deltarpm_cmd->bind(":baseversion_build_time", drpm->baseVersion.buildTime.asSeconds());
- _pimpl->insert_deltarpm_cmd->bind(":baseversion_checksum", drpm->baseVersion.checkSum.checksum());
- _pimpl->insert_deltarpm_cmd->bind(":baseversion_sequence_info", drpm->baseVersion.sequenceInfo);
-
- _pimpl->insert_deltarpm_cmd->executenonquery();
- id = _pimpl->con.insertid();
-
- return id;
-}
-
-
-// RecordId CacheStore::appendDependencyEntry( const RecordId &resolvable_id, zypp::Dep deptype, const Resolvable::Kind &refers )
-// {
-// //DBG << "rid: " << resolvable_id << " deptype: " << deptype << " " << "refers: " << refers << endl;
-// _pimpl->insert_dependency_entry_cmd->bind( ":resolvable_id", resolvable_id );
-//
-// db::DependencyType dt = zypp_deptype2db_deptype(deptype);
-// if ( dt == db::DEP_TYPE_UNKNOWN )
-// {
-// ZYPP_THROW(Exception("Unknown depenency type"));
-// }
-//
-// _pimpl->insert_dependency_entry_cmd->bind( ":dependency_type", zypp_deptype2db_deptype(deptype) );
-// _pimpl->insert_dependency_entry_cmd->bind( ":refers_kind", zypp_kind2db_kind(refers) );
-//
-// _pimpl->insert_dependency_entry_cmd->executenonquery();
-// //delete cmd;
-// long long id = _pimpl->con.insertid();
-// return static_cast<RecordId>(id);
-// }
-
-RecordId CacheStore::lookupOrAppendFile( const Pathname &path )
-{
- RecordId dir_name_id = lookupOrAppendDirName(path.dirname().asString());
- RecordId file_name_id = lookupOrAppendFileName(path.basename());
-
- _pimpl->select_file_cmd->bind(":dir_name_id", dir_name_id);
- _pimpl->select_file_cmd->bind(":file_name_id", file_name_id);
- long long id = 0;
- try {
- id = _pimpl->select_file_cmd->executeint64();
- }
- catch ( const sqlite3x::database_error &e )
- {
- // does not exist
- _pimpl->insert_file_cmd->bind(":dir_name_id", dir_name_id);
- _pimpl->insert_file_cmd->bind(":file_name_id", file_name_id);
- _pimpl->insert_file_cmd->executenonquery();
- id = _pimpl->con.insertid();
- return static_cast<RecordId>(id);
-
- }
- return static_cast<RecordId>(id);
-}
-
-void CacheStore::updateRepository( const RecordId &id,
- const string &checksum,
- const Date ×tamp )
-{
- _pimpl->update_repository_cmd->bind(":repository_id", id);
- _pimpl->update_repository_cmd->bind(":checksum", checksum);
- _pimpl->update_repository_cmd->bind(":timestamp", static_cast<int>((Date::ValueType) timestamp) );
- _pimpl->insert_repository_cmd->executenonquery();
-}
-
-RecordId CacheStore::lookupOrAppendRepository( const string &alias )
-{
- _pimpl->select_repository_cmd->bind(":alias", alias);
-
- long long id = 0;
- try {
- id = _pimpl->select_repository_cmd->executeint64();
- }
- catch ( const sqlite3x::database_error &e )
- {
- // does not exist
- _pimpl->insert_repository_cmd->bind(":alias", alias);
- _pimpl->insert_repository_cmd->bind(":timestamp", static_cast<int>((Date::ValueType) Date::now()) );
- _pimpl->insert_repository_cmd->executenonquery();
- id = _pimpl->con.insertid();
- return static_cast<RecordId>(id);
-
- }
- return static_cast<RecordId>(id);
-}
-
-void CacheStore::cleanRepository( const data::RecordId &id )
-{
- sqlite3_command cmd( _pimpl->con, "delete from repositories where id=:id");
- cmd.bind(":id", id);
-
- try
- {
- cmd.executenonquery();
- }
- catch ( const sqlite3x::database_error &e )
- {
- ZYPP_THROW(CacheRecordNotFoundException());
- }
-}
-
-void CacheStore::cleanRepository( const std::string &alias )
-{
- cleanRepository(lookupRepository(alias));
-}
-
-RepoStatus CacheStore::repositoryStatus( const data::RecordId &id )
-{
- sqlite3_command cmd( _pimpl->con, "select id,alias,checksum,timestamp from repositories where id=:id");
- cmd.bind(":id", id);
-
- try
- {
- sqlite3_reader reader = cmd.executereader();
- RepoStatus status;
- while ( reader.read() )
- {
- status.setChecksum( reader.getstring(2) );
- status.setTimestamp( reader.getstring(3) );
- }
- return status;
- }
- catch ( const sqlite3x::database_error &e )
- {
- ZYPP_THROW(CacheRecordNotFoundException());
- }
-}
-
-RepoStatus CacheStore::repositoryStatus( const string &alias )
-{
- return repositoryStatus(lookupRepository(alias));
-}
-
-bool CacheStore::isCached( const string &alias )
-{
- try
- {
- lookupRepository(alias);
- }
- catch( const CacheRecordNotFoundException &e )
- {
- return false;
- }
-
- return true;
-}
-
-RecordId CacheStore::lookupRepository( const string &alias )
-{
- sqlite3_command cmd(_pimpl->con, "select id from repositories where alias=:alias;");
- cmd.bind(":alias", alias);
-
- long long id = 0;
- try {
- id = cmd.executeint64();
- }
- catch ( const sqlite3x::database_error &e )
- {
- ZYPP_THROW(CacheRecordNotFoundException());
- }
- return id;
-}
-
-RecordId CacheStore::lookupOrAppendType( const string &klass, const string &name )
-{
- pair<string, string> thetype = make_pair(klass,name);
- if ( _pimpl->type_cache.find(thetype) != _pimpl->type_cache.end() )
- {
- //_pimpl->name_cache_hits++;
- return _pimpl->type_cache[thetype];
- }
-
- _pimpl->select_type_cmd->bind(":class", klass);
- _pimpl->select_type_cmd->bind(":name", name);
- long long id = 0;
- try {
- id = _pimpl->select_type_cmd->executeint64();
- _pimpl->type_cache[thetype] = id;
- }
- catch ( const sqlite3x::database_error &e )
- {
- // does not exist
- _pimpl->insert_type_cmd->bind(":class", klass);
- _pimpl->insert_type_cmd->bind(":name", name);
- _pimpl->insert_type_cmd->executenonquery();
- id = _pimpl->con.insertid();
- return id;
- }
- return id;
-}
-
-RecordId CacheStore::lookupOrAppendName( const string &name )
-{
- if ( _pimpl->name_cache.find(name) != _pimpl->name_cache.end() )
- {
- _pimpl->name_cache_hits++;
- return _pimpl->name_cache[name];
- }
-
- _pimpl->select_name_cmd->bind(":name", name);
- long long id = 0;
- try {
- id = _pimpl->select_name_cmd->executeint64();
- _pimpl->name_cache[name] = id;
- }
- catch ( const sqlite3x::database_error &e )
- {
- // does not exist
- _pimpl->insert_name_cmd->bind(":name", name);
- _pimpl->insert_name_cmd->executenonquery();
- id = _pimpl->con.insertid();
- return static_cast<RecordId>(id);
-
- }
- return static_cast<RecordId>(id);
-}
-
-RecordId CacheStore::lookupOrAppendDirName( const string &name )
-{
- _pimpl->select_dirname_cmd->bind(":name", name);
- long long id = 0;
- try {
- id = _pimpl->select_dirname_cmd->executeint64();
- }
- catch ( const sqlite3x::database_error &e )
- {
- // does not exist
- _pimpl->insert_dirname_cmd->bind(":name", name);
- _pimpl->insert_dirname_cmd->executenonquery();
- id = _pimpl->con.insertid();
- return static_cast<RecordId>(id);
-
- }
- return static_cast<RecordId>(id);
-}
-
-RecordId CacheStore::lookupOrAppendFileName( const string &name )
-{
- _pimpl->select_filename_cmd->bind(":name", name);
- long long id = 0;
- try {
- id = _pimpl->select_filename_cmd->executeint64();
- }
- catch ( const sqlite3x::database_error &e )
- {
- // does not exist
- _pimpl->insert_filename_cmd->bind(":name", name);
- _pimpl->insert_filename_cmd->executenonquery();
- id = _pimpl->con.insertid();
- return static_cast<RecordId>(id);
-
- }
- return static_cast<RecordId>(id);
-}
-
-void CacheStore::setSharedData( const data::RecordId &resolvable_id,
- const data::RecordId &shared_id )
-{
- _pimpl->set_shared_flag_cmd->bind(":resolvable_id", resolvable_id);
-
- if ( shared_id == data::noRecordId )
- _pimpl->set_shared_flag_cmd->bind(":shared_id");
- else
- _pimpl->set_shared_flag_cmd->bind(":shared_id", shared_id);
-
- _pimpl->set_shared_flag_cmd->executenonquery();
-}
-
-void CacheStore::appendBooleanAttribute( const data::RecordId & resolvable_id,
- const std::string & klass,
- const std::string & name,
- bool value)
-{
- RecordId type_id = lookupOrAppendType( klass, name );
- appendNumericAttribute( resolvable_id, type_id, value ? 1 : 0 );
-}
-
-void CacheStore::appendNumericAttribute( const data::RecordId &resolvable_id,
- const std::string &klass,
- const std::string &name,
- int value )
-{
- RecordId type_id = lookupOrAppendType( klass, name );
- appendNumericAttribute( resolvable_id, type_id, value );
-}
-
-void CacheStore::appendNumericAttribute( const RecordId &resolvable_id,
- const RecordId &type_id,
- int value )
-{
- // weak resolvable_id
- _pimpl->append_num_attribute_cmd->bind(":rid", resolvable_id );
- _pimpl->append_num_attribute_cmd->bind(":attr_id", type_id );
-
- _pimpl->append_num_attribute_cmd->bind(":value", value );
-
- _pimpl->append_num_attribute_cmd->executenonquery();
-}
-
-
-void CacheStore::appendTranslatedStringAttribute( const data::RecordId &resolvable_id,
- const std::string &klass,
- const std::string &name,
- const TranslatedText &text )
-{
- set<Locale> locales = text.locales();
- for ( set<Locale>::const_iterator it = locales.begin(); it != locales.end(); ++it )
- {
- appendStringAttributeTranslation( resolvable_id, *it, klass, name, text.text(*it) );
- }
-}
-
-
-void CacheStore::appendStringAttributeTranslation( const data::RecordId &resolvable_id,
- const Locale &locale,
- const std::string &klass,
- const std::string &name,
- const std::string &text )
-{
- // don't bother with writing if the string is empty
- if (text.empty()) return;
-
- RecordId lang_id = lookupOrAppendType("lang",
- locale.code().empty() ? "none" : locale.code() );
- RecordId type_id = lookupOrAppendType( klass, name );
- appendStringAttribute( resolvable_id, lang_id, type_id, text );
-}
-
-void CacheStore::appendStringAttribute( const data::RecordId &resolvable_id,
- const std::string &klass,
- const std::string &name,
- const std::string &value )
-{
- // don't bother with writing if the string is empty
- if (value.empty()) return;
-
- RecordId type_id = lookupOrAppendType(klass, name);
- appendStringAttribute( resolvable_id, type_id, value );
-}
-
-void CacheStore::appendStringAttribute( const RecordId &resolvable_id,
- const RecordId &type_id,
- const std::string &value )
-{
- // don't bother with writing if the string is empty
- if (value.empty()) return;
-
- RecordId lang_id = lookupOrAppendType("lang", "none");
- appendStringAttribute( resolvable_id, lang_id, type_id, value );
-}
-
-void CacheStore::appendStringAttribute( const RecordId &resolvable_id,
- const RecordId &lang_id,
- const RecordId &type_id,
- const string &value )
-{
- // don't bother with writing if the string is empty
- if (value.empty()) return;
-
- // weak resolvable_id
- _pimpl->append_text_attribute_cmd->bind(":rid", resolvable_id );
- _pimpl->append_text_attribute_cmd->bind(":lang_id", lang_id );
- _pimpl->append_text_attribute_cmd->bind(":attr_id", type_id );
-
- _pimpl->append_text_attribute_cmd->bind(":text", value );
-
- _pimpl->append_text_attribute_cmd->executenonquery();
-}
-
-template <class _Container>
-void CacheStore::appendStringContainerAttribute( const data::RecordId &resolvable_id,
- const std::string &klass,
- const std::string &name,
- const _Container &cont )
-{
- // don't bother with writing if the container is empty
- if (cont.empty()) return;
-
- string value = str::join(cont, ZConfig().cacheDBSplitJoinSeparator());
-
- appendStringAttribute( resolvable_id, klass, name, value );
-}
-
-}
-}
-
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#ifndef ZYPP_CacheStore_H
-#define ZYPP_CacheStore_H
-
-#include <iosfwd>
-#include <string>
-
-#include "zypp/base/ReferenceCounted.h"
-#include "zypp/base/NonCopyable.h"
-#include "zypp/base/PtrTypes.h"
-#include "zypp/Pathname.h"
-#include "zypp/NVRA.h"
-#include "zypp/capability/CapabilityImpl.h"
-#include "zypp/capability/Capabilities.h"
-
-#include "zypp/data/ResolvableDataConsumer.h"
-#include "zypp/data/RecordId.h"
-
-#include "zypp/base/PtrTypes.h"
-#include "zypp2/RepoStatus.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace cache
- { /////////////////////////////////////////////////////////////////
-
- /**
- * The cache store caches resolvable data.
- *
- * \code
- * CacheStore store("/path");
- * RecordId repository_id =
- * store.lookupOrAppendRepository("some-alias");
- * store.consumePackage( repository_id, package_ptr );
- * store.commit();
- * \endcode
- *
- * \note Data will not be commited until you explicitely commit.
- */
- class CacheStore : public data::ResolvableDataConsumer
- {
- public:
-
- CacheStore();
- virtual ~CacheStore();
-
- /**
- * Constructor for the CacheStore
- *
- * \note a transaction will be started from the moment the
- * CacheStore is instanciated.
- *
- * The data will be saved in the directory specified in
- * \a dbdir. \a dbdir must exist.
- */
- CacheStore( const Pathname &dbdir );
-
- /**
- * Commit the changes.
- */
- void commit();
-
- /**
- * Implementation of the \ref ResolvableConsumer interface
- *
- * Consume a package, inserting it in the cache, under
- * \param repository_id ownership.
- * \param package Package data
- */
- virtual void consumePackage(const data::RecordId &repository_id,
- const data::Package_Ptr & package);
-
- /**
- * Implementation of the \ref ResolvableConsumer interface
- *
- * Consume a source package, inserting it in the cache, under
- * \param catalog_id ownership.
- * \param srcpackage Source package data
- */
- virtual void consumeSourcePackage(
- const data::RecordId &catalog_id,
- const data::SrcPackage_Ptr & srcpackage );
-
- /**
- * Implementation of the \ref ResolvableConsumer interface
- *
- * Consume a patch, inserting it in the cache, under
- * \param repository_id ownership.
- * \param patch Patch data
- */
- virtual void consumePatch( const data::RecordId &repository_id,
- const data::Patch_Ptr & patch );
-
- /**
- * Implementation of the \ref ResolvableConsumer interface.
- *
- * Consume a package atom, inserting it in the cache, under
- * \a repository_id ownership.
- *
- * \param repository_id record id of repository to which to append the resolvable.
- * \param atom package atom data
- *
- * \note this is somewhat specific to current YUM patch metadata design
- * and may change (to consumeAtom(data::RecordId,data::Atom)).
- */
- virtual void consumePackageAtom( const data::RecordId &repository_id,
- const data::PackageAtom_Ptr & atom );
-
- /**
- * Implementation of the \ref ResolvableConsumer interface
- *
- * Consume a message, inserting it in the cache, under
- * \param repository_id ownership.
- * \param message Message data
- */
- virtual void consumeMessage( const data::RecordId & repository_id,
- const data::Message_Ptr & message);
-
- /**
- * Implementation of the \ref ResolvableConsumer interface
- *
- * Consume a script, inserting it in the cache, under
- * \param repository_id ownership.
- * \param script Script data
- */
- virtual void consumeScript( const data::RecordId & repository_id,
- const data::Script_Ptr & script);
-
- /**
- * Implementation of the \ref ResolvableConsumer interface
- *
- * Consume a pattern, inserting it in the cache, under
- * \param repository_id ownership.
- * \param pattern Pattern data
- */
- virtual void consumePattern( const data::RecordId & repository_id,
- const data::Pattern_Ptr & pattern );
-
- /**
- * Implementation of the \ref ResolvableConsumer interface
- *
- * Consume a product, inserting it in the cache, under
- * \param repository_id ownership.
- * \param pattern Pattern data
- */
- virtual void consumeProduct( const data::RecordId &repository_id,
- const data::Product_Ptr & product );
-
- /**
- * Implementation of the \ref ResolvableConsumer interface
- *
- * Consume changelog of a resolvable, inserting it in the cache.
- * \param repository_id ownership.
- * \param resolvable resolvable for which the changelog data are to be saved
- * \param changelog the changelog
- * \todo see implementation
- */
- virtual void consumeChangelog( const data::RecordId & repository_id,
- const data::Resolvable_Ptr & resolvable,
- const Changelog & changelog );
-
- /**
- * Implementation of the \ref ResolvableConsumer interface
- *
- * Consume filelist of a resolvable, inserting it in the cache.
- * \param repository_id ownership.
- * \param resolvable resolvable for which the filelist is to be saved
- * \param filenames list of filenames the resolvable contains
- * \todo see implementation
- */
- virtual void consumeFilelist( const data::RecordId &repository_id,
- const data::Resolvable_Ptr & resolvable,
- const data::Filenames & filenames );
-
- /**
- * Appends a resolvable to the store.
- *
- * You have to specify with \a kind of resolvable are you inserting
- * and its \c NVRA (name version release and architecture ).
- * Optionaly you can pass a list of \c CapabilityImpl::Ptr
- * as dependencies for the resolvable.
- *
- * You have to specify the RecordId for the repository owning
- * this resolvable. Yuu can obtain it with
- * \ref lookupOrAppendRepository
- *
- * You can create those \a deps using \ref capability::parse
- * functions, or the build methods to create specific types
- * of capabilities:
- * \ref capability::buildVersioned for \c VersionedCap
- * \ref capability::buildNamed for \c NamedCap
- * etc.
- *
- * Once the resolvable is inserted, you will get back the id
- * if it in the store. Which you can use for later adding
- * other properties.
- *
- */
- data::RecordId appendResolvable( const data::RecordId &repository_id,
- const Resolvable::Kind &kind,
- const NVRA &nvra,
- const data::Dependencies &deps );
-
- /**
- * Adds dependencies to the store
- *
- * A map of dependency lists has to be specified. The map contains
- * list of capablities for each dependency type \ref zypp::Dep
- *
- * \a resolvable_id is the resolvable Id in the CacheStore
- * that will own those capabilities.
- *
- * FIXME should it \throw if the resolvable does not exist?
- */
- void appendDependencies( const data::RecordId &resolvable_id,
- const data::Dependencies &dependencies );
-
- /**
- * Adds dependencies to the store
- *
- * A lists of dependencies \a dlist to be specified. Among
- * which type of dependencies \ref zypp::Dep it is as
- * the \a deptype argument.
- *
- * \a resolvable_id is the resolvable Id in the CacheStore
- * that will own those capabilities.
- *
- * FIXME should it \throw if the resolvable does not exist?
- */
- void appendDependencyList( const data::RecordId &resolvable_id,
- zypp::Dep deptype,
- const data::DependencyList &dlist );
-
- /**
- * Adds a dependency to the store.
- *
- * A \ref CapabilityImpl::Ptr argument \a cap has to be specified.
- * Among which type of dependency \ref zypp::Dep it is as
- * the \a deptype argument.
- *
- * \a resolvable_id is the resolvable Id in the CacheStore
- * that will own the capability
- *
- * FIXME should it \throw if the resolvable does not exist?
- */
- void appendDependency( const data::RecordId &resolvable_id,
- zypp::Dep deptype,
- capability::CapabilityImpl::Ptr cap );
-
- /**
- * Adds a Named dependency to the store.
- *
- * A \ref NamedCap::Ptr \a dlist to be specified. Among
- * which type of dependency \ref zypp::Dep it is as
- * the \a deptype argument.
- *
- * \a resolvable_id is the resolvable Id in the CacheStore
- * that will own the capability
- *
- * You can create the named capability using either
- * \ref capability::parse or \ref capability::buildNamed
- *
- * FIXME should it \throw if the resolvable does not exist?
- */
- void appendNamedDependency( const data::RecordId &, zypp::Dep,
- capability::NamedCap::Ptr);
-
- /**
- * Adds a file dependency to the store.
- *
- * A \ref FileCap::Ptr \a dlist to be specified. Among
- * which type of dependency \ref zypp::Dep it is as
- * the \a deptype argument.
- *
- * \a resolvable_id is the resolvable Id in the CacheStore
- * that will own the capability
- *
- * You can create the file capability using either
- * \ref capability::parse or \ref capability::buildFile
- *
- * FIXME should it \throw if the resolvable does not exist?
- */
- void appendFileDependency( const data::RecordId &, zypp::Dep,
- capability::FileCap::Ptr);
-
- /**
- * Adds a Modalias dependency to the store.
- *
- * A \ref ModaliasCap::Ptr \a cap to be specified. Among
- * which type of dependency \ref zypp::Dep it is as
- * the \a deptype argument.
- *
- * \a resolvable_id is the resolvable Id in the CacheStore
- * that will own the capability
- *
- * You can create the modalias capability using either
- * \ref capability::parse or \ref capability::buildModalias
- *
- * FIXME should it \throw if the resolvable does not exist?
- */
- void appendModaliasDependency( const data::RecordId &resolvable_id,
- zypp::Dep deptype,
- capability::ModaliasCap::Ptr cap);
-
- /**
- * Adds a Hal dependency to the store.
- *
- * A \ref HalCap::Ptr \a cap to be specified. Among
- * which type of dependency \ref zypp::Dep it is as
- * the \a deptype argument.
- *
- * \a resolvable_id is the resolvable Id in the CacheStore
- * that will own the capability
- *
- * You can create the modalias capability using either
- * \ref capability::parse or \ref capability::buildHal
- *
- * FIXME should it \throw if the resolvable does not exist?
- */
- void appendHalDependency( const data::RecordId &resolvable_id,
- zypp::Dep deptype,
- capability::HalCap::Ptr cap );
-
- /**
- * Adds a unknown dependency to the store.
- *
- * A \ref Capability::Ptr \a cap to be specified. Among
- * which type of dependency \ref zypp::Dep it is as
- * the \a deptype argument.
- *
- * \a resolvable_id is the resolvable Id in the CacheStore
- * that will own the capability
- *
- * You can create the capability using either
- * \ref capability::parse
- *
- * FIXME should it \throw if the resolvable does not exist?
- */
- void appendUnknownDependency( const data::RecordId &resolvable_id,
- zypp::Dep deptype,
- capability::CapabilityImpl::Ptr cap );
-
- /**
- * Insert patch RPM data into <tt>patch_packages</tt> table.
- *
- * \param prpm The patch RPM object to insert.
- * \return Record ID of the newly inserted record.
- */
- data::RecordId appendPatchRpm( const data::PatchRpm_Ptr & prpm);
-
-
- /**
- * Insert delta RPM data into <tt>delta_packages</tt> table.
- *
- * \param drpm The delta RPM object to insert.
- * \return Record ID of the newly inserted record.
- */
- data::RecordId appendDeltaRpm( const data::DeltaRpm_Ptr & drpm);
-
-
- /**
- * Returns the record id of a type
- *
- * Types are mostly used internally. To give concepts
- * a record id to associate with.
- * Examples could be arch::i386, lang::en_US
- * Packages::summary, rel:>, kind::Package
- *
- * \note If the type entry does not exist, it will
- * be created and the new inserted entry's id will
- * be returned.
- */
- data::RecordId lookupOrAppendType( const std::string &klass,
- const std::string &name );
-
- /**
- * Returns the record id of a repository (Source)
- *
- * \param alias Unique alias for this repo
- *
- * \note If the repository entry does not exist, it will
- * be created and the new inserted entry's id will
- * be returned.
- */
- data::RecordId lookupOrAppendRepository( const std::string &alias );
-
- /**
- * Set the resolvable shared data flag pointing to
- * another resolvable.
- *
- * This is a hint for cache readers. If any attribute
- * of a resolvable is empty, is because it is shared
- * with another resolvable.
- *
- * \param resolvable_id Id of the resolvable. Must exists
- * \param shared_id The resolvable providing the data
- * This one is a weak reference, the reader should just
- * try to look the data there as a hint.
- * use \ref data::noRecordId to reset the value.
- *
- */
- void setSharedData( const data::RecordId &resolvable_id,
- const data::RecordId &shared_id );
-
- /**
- * Append a numeric attribute to a resolvable
- * \param resolvable_id Resovable Id, owner of the attribute
- * \param klass Type class i.e "Package" "lang" "kind"
- * \param name Type name i.e : "size" "media_number"
- * \param value numeric value
- */
- void appendNumericAttribute( const data::RecordId &resolvable_id,
- const std::string &klass,
- const std::string &name,
- int value );
-
- /**
- * Append a translated string value to a resolvable
- * \param resolvable_id Resovable Id, owner of the attribute
- * \param klass Type class i.e "Package" "lang" "kind"
- * \param name Type name i.e : "summary" "none" "Script"
- * \param text Translated text
- */
- void appendTranslatedStringAttribute( const data::RecordId &resolvable_id,
- const std::string &klass,
- const std::string &name,
- const TranslatedText &text );
-
- /**
- * Append a string value to a resolvable
- * \param resolvable_id Resovable Id, owner of the attribute
- * \param locale locale of the text language
- * \param klass Type class i.e "Package" "lang" "kind"
- * \param name Type name i.e : "summary" "none" "Script"
- * \param text text
- */
- void appendStringAttributeTranslation( const data::RecordId &resolvable_id,
- const Locale &locale,
- const std::string &klass,
- const std::string &name,
- const std::string &text );
-
- /**
- * Append a string value to a resolvable
- * \param resolvable_id Resovable Id, owner of the attribute
- * \param klass Type class i.e "Package" "lang" "kind"
- * \param name Type name i.e : "summary" "none" "Script"
- * \param value string value
- */
- void appendStringAttribute( const data::RecordId &resolvable_id,
- const std::string &klass,
- const std::string &name,
- const std::string &value );
-
- /**
- * Append a string value to a resolvable
- * \param resolvable_id Resovable Id, owner of the attribute
- * \param type_id Type id, \see lookupOrAppendType
- * \param value string value
- */
- void appendStringAttribute( const data::RecordId &resolvable_id,
- const data::RecordId &type_id,
- const std::string &value );
-
-
- /**
- * Append strings from _Container to a resolvable.
- * Uses \ref zypp::str::split(_Container, std::string) with
- * \ref ZConfig::cacheDBSplitJoinSeparator() as the second argument
- * (a separator string) of split().
- *
- * \param resolvable_id Resovable Id, owner of the attribute
- * \param klass Type class i.e "Package" "lang" "kind"
- * \param name Type name i.e : "summary" "none" "Script"
- * \param cont The string container.
- */
- template <class _Container>
- void appendStringContainerAttribute( const data::RecordId &resolvable_id,
- const std::string &klass,
- const std::string &name,
- const _Container &cont );
-
- /**
- * Update a known repository checksum and timestamp
- *
- * \note If you don't provide timestamp it defaults
- * to now.
- *
- * It is responsability of the caller to operate with
- * a valid record id. You can get one
- * Using \ref lookupOrAppendRepository
- *
- * If the repository does not exists, nothing will happen
- */
- void updateRepository( const data::RecordId &id,
- const std::string &checksum,
- const Date ×tamp = Date::now() );
-
- /**
- * \short Clean repository from cache
- *
- * \param id repository identifier in cache
- *
- * You can check existence using \ref isCached
- *
- * \throws CacheRecordNotFoundException if the repository
- * id does not refer to a valid repository.
- */
- void cleanRepository( const data::RecordId &id );
-
- /**
- * \short Clean repository from cache
- *
- * \param alias Repository unique alias
- *
- * You can check existence using \ref isCached
- *
- * \throws CacheRecordNotFoundException if the repository
- * alias does not refer to a valid repository.
- */
- void cleanRepository( const std::string &alias );
-
- /**
- * get the status of a cached repository
- *
- * It is responsability of the caller to operate with
- * a valid record id. You can get one
- * Using \ref lookupOrAppendRepository
- *
- * You can check existence using \ref isCached
- *
- * \throws CacheRecordNotFoundException if the repository
- * id does not refer to a valid repository.
- */
- RepoStatus repositoryStatus( const data::RecordId &id );
-
- /**
- * get the status of a cached repository
- *
- * It is responsability of the caller to operate with
- * a valid alias. You can insert one
- * Using \ref lookupOrAppendRepository
- *
- * You can check existence using \ref isCached
- *
- * \throws CacheRecordNotFoundException if the repository
- * alias is unknown
- */
- RepoStatus repositoryStatus( const std::string &alias );
-
- /**
- * \short Does a repository exists in cache?
- *
- * True if the repository is cached
- */
- bool isCached( const std::string &alias );
-
- /**
- * \short looks the id for a repository in cache
- *
- * \param alias Repository unique alias
- *
- * \throws CacheRecordNotFoundException if the repository
- * alias is unknown
- */
- data::RecordId lookupRepository( const std::string &alias );
-
-
- /**
- * Returns the record id of a file entry \a path
- *
- * \note If the file entry does not exist, it will
- * be created and the new inserted entry's id will
- * be returned.
- */
- data::RecordId lookupOrAppendFile( const Pathname &path );
-
- /**
- * Returns the record id of a name entry \a name
- *
- * \note If the name entry does not exist, it will
- * be created and the new inserted entry's id will
- * be returned.
- */
- data::RecordId lookupOrAppendName( const std::string &name );
-
- /**
- * Returns the record id of a directory name entry \a name
- *
- * \note If the directory name entry does not exist, it will
- * be created and the new inserted entry's id will
- * be returned.
- */
- data::RecordId lookupOrAppendDirName( const std::string &name );
-
- /**
- * Returns the record id of a file name entry \a name
- *
- * \note If the file name entry does not exist, it will
- * be created and the new inserted entry's id will
- * be returned.
- */
- data::RecordId lookupOrAppendFileName( const std::string &name );
-
- protected:
- /**
- * Internally used function that appends a entry in
- * the capabilities table for a specific capability
- * entry.
- */
-// data::RecordId appendDependencyEntry( const data::RecordId &,
-// zypp::Dep, const Resolvable::Kind & );
-
- void appendStringAttribute( const data::RecordId &resolvable_id,
- const data::RecordId &lang_id,
- const data::RecordId &type_id,
- const std::string &value );
-
- /**
- * Append a numeric attribute to a resolvable
- * \param resolvable_id Resovable Id, owner of the attribute
- * \param type_id attribute id
- * \param value numeric value
- */
- void appendNumericAttribute( const data::RecordId &resolvable_id,
- const data::RecordId &type_id,
- int value );
-
- /**
- * Append a bool attribute to a resolvable. Will be stored as
- * numeric 1 or 0.
- *
- * \param resolvable_id Resovable Id, owner of the attribute
- * \param type_id attribute id
- * \param value bool value
- */
- void appendBooleanAttribute( const data::RecordId & resolvable_id,
- const std::string & klass,
- const std::string & name,
- bool value);
-
- /** \name Detail Attributes Inserters
- * These functions are used by ResolvableConsumer interface functions
- * to avoid some duplication across types.
- */
- //@{
- void appendResObjectAttributes( const data::RecordId &rid,
- const data::ResObject_Ptr & res );
-
- void appendPackageBaseAttributes(const data::RecordId & pkgid,
- const data::Packagebase_Ptr & package);
- //@}
-
-
- private:
- /** Implementation. */
- class Impl;
- /** Pointer to implementation. */
- RW_pointer<Impl> _pimpl;
- };
- }
-}
-
-#endif
-
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp2/cache/CacheTypes.cc
- *
-*/
-#include <iostream>
-#include "zypp/base/Logger.h"
-#include "zypp/base/Exception.h"
-#include "zypp2/cache/sqlite3x/sqlite3x.hpp"
-#include "zypp/CheckSum.h"
-#include "zypp2/cache/CacheTypes.h"
-
-using namespace std;
-using namespace sqlite3x;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace cache
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : CacheTypes
- //
- ///////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : CacheTypes::CacheTypes
- // METHOD TYPE : Ctor
- //
- CacheTypes::CacheTypes( const Pathname &dbdir )
- : _dbdir(dbdir)
- {
- refreshCache();
- }
-
- void CacheTypes::refreshCache()
- {
- try
- {
- sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
- con.executenonquery("PRAGMA cache_size=8000;");
- con.executenonquery("BEGIN;");
-
- // get all types
- sqlite3_command select_types_cmd( con, "select id,class,name from types;");
- sqlite3_reader reader = select_types_cmd.executereader();
-
- while(reader.read())
- {
- data::RecordId id = reader.getint64(0);
- string klass = reader.getstring(1);
- string name = reader.getstring(2);
- if ( klass == "arch" )
- _arch_cache[id] = Arch(name);
- if ( klass == "rel" )
- _rel_cache[id] = Rel(name);
- if ( klass == "kind" )
- _kind_cache[id] = Resolvable::Kind(name);
- if ( klass == "deptype" )
- _deptype_cache[id] = name;
- }
-
- MIL << "archs: " << _arch_cache.size() << endl;
- MIL << "rel : " << _rel_cache.size() << endl;
- MIL << "kind : " << _kind_cache.size() << endl;
- MIL << "deptype : " << _deptype_cache.size() << endl;
- }
- catch ( std::exception &e )
- {
- ZYPP_THROW(Exception("Error reading types"));
- }
- }
-
- Rel CacheTypes::relationFor( const data::RecordId &id )
- {
- Rel rel;
- std::map<data::RecordId, Rel>::const_iterator it;
- if ( (it = _rel_cache.find(id) ) != _rel_cache.end() )
- rel = it->second;
- else
- ZYPP_THROW(Exception("Inconsistent Rel"));
-
- return rel;
-
- }
-
- Resolvable::Kind CacheTypes::kindFor( const data::RecordId &id )
- {
- Resolvable::Kind kind;
- std::map<data::RecordId, Resolvable::Kind>::const_iterator it;
- if ( (it = _kind_cache.find(id) ) != _kind_cache.end() )
- kind = it->second;
- else
- ZYPP_THROW(Exception("Inconsistent Kind"));
-
- return kind;
- }
-
- Dep CacheTypes::deptypeFor( const data::RecordId &id )
- {
- std::map<data::RecordId, string>::const_iterator it;
- if ( (it = _deptype_cache.find(id) ) != _deptype_cache.end() )
- return Dep(it->second);
- else
- {
- ERR << "deptype: " << id << endl;
- ZYPP_THROW(Exception("Inconsistent deptype"));
- }
- }
-
- Arch CacheTypes::archFor( const data::RecordId &id )
- {
-
- Arch arch;
- std::map<data::RecordId, Arch>::const_iterator it;
- if ( (it = _arch_cache.find(id) ) != _arch_cache.end() )
- arch = it->second;
- else
- ZYPP_THROW(Exception("Inconsistent Arch"));
-
- return arch;
- }
-
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : CacheTypes::~CacheTypes
- // METHOD TYPE : Dtor
- //
- CacheTypes::~CacheTypes()
- {}
-
- /******************************************************************
- **
- ** FUNCTION NAME : operator<<
- ** FUNCTION TYPE : std::ostream &
- */
- std::ostream & operator<<( std::ostream & str, const CacheTypes & obj )
- {
- return str;
- }
-
- /////////////////////////////////////////////////////////////////
- } // namespace cache
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp2
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp2/cache/CacheTypes.h
- *
-*/
-#ifndef ZYPP2_CACHE_CACHETYPES_H
-#define ZYPP2_CACHE_CACHETYPES_H
-
-#include <iosfwd>
-
-#include <map>
-#include <string>
-#include "zypp/Rel.h"
-#include "zypp/Arch.h"
-#include "zypp/ResTraits.h"
-#include "zypp/Dep.h"
-#include "zypp/Resolvable.h"
-#include "zypp/Pathname.h"
-#include "zypp/data/RecordId.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace cache
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : CacheTypes
- //
- /**
- * Cache types is a class that reads the dynamic types
- * from the cache, and keeps them on memory.
- * Then it can by asked for the type for an Id.
- *
- * \see CacheStore::lookupOrAppendType
- */
- class CacheTypes
- {
- friend std::ostream & operator<<( std::ostream & str, const CacheTypes & obj );
- public:
- /**
- * Default ctor
- *
- * \param dbdir Path where the cache is located.
- *
- */
- CacheTypes( const Pathname &dbdir );
-
- /** Dtor */
- ~CacheTypes();
-
- /**
- * Relation for a cache record id.
- *
- * \param id The id you got in a cache query
- *
- * \throws Exception if the id is not a valid type
- */
- Rel relationFor( const data::RecordId &id );
-
- /**
- * Kind for a cache record id.
- *
- * \param id The id you got in a cache query
- *
- * \throws Exception if the id is not a valid type
- */
- Resolvable::Kind kindFor( const data::RecordId &id );
-
- /**
- * Dependency type for a cache record id.
- *
- * \param id The id you got in a cache query
- *
- * \throws Exception if the id is not a valid type
- */
- Dep deptypeFor( const data::RecordId &id );
-
- /**
- * Architecture for a cache record id.
- *
- * \param id The id you got in a cache query
- *
- * \throws Exception if the id is not a valid type
- */
- Arch archFor( const data::RecordId &id );
-
- public:
-
- private:
- void refreshCache();
-
- std::map<data::RecordId, Rel> _rel_cache;
- std::map<data::RecordId, Resolvable::Kind> _kind_cache;
- std::map<data::RecordId, std::string> _deptype_cache;
- std::map<data::RecordId, Arch> _arch_cache;
- Pathname _dbdir;
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates CacheTypes Stream output */
- std::ostream & operator<<( std::ostream & str, const CacheTypes & obj );
-
- /////////////////////////////////////////////////////////////////
- } // namespace cache
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp2
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP2_CACHE_CACHETYPES_H
+++ /dev/null
-
-CACHE WRITE API DESIGN
-dmacvicar@suse.de
-ma@suse.de
-
-Background and problems
-=======================
-
-The biggest problem when designing an API that will be used
-by metadata parsers to fill a database is the fact that all
-the formats read data in different order.
-
-YUM is flawed as it mixes descriptions and user data with
-basic solver data (NVRAD [1]). But it is easy to write to a
-store.
-
-SUSETags is on the other hand has different files for primary
-and user data.
-
-If we consideer a simple API where we have data objects to pass
-to the store:
-
- .------------------.
- | package |
- +------------------+
- | NVRAD |
- +------------------+
- | summary |
- +------------------+
- | other data |
- +------------------+
- | description |
- '------------------'
-
-The SQL table behind the API, has a resolvables table which stores
-
-|-----------------| |-----------------|
-| resolvable | | package_data |
-|-----------------| |-----------------|
-| id | NVRAD | | package_id |
-|-----------------| |-----------------|
- | other data |
- |-----------------|
-
-Inserting a package means, inserting a resolvable entry, getting a new id
-for it, and then insert a new package entry and fill package_id with it.
-
-YUM can insert this data at the same time while parsing as it is available
-at the same time. SUSETags can't, so it has to cache the NVRAD and the id, to
-insert the second block when it becomes available from the translations file.
-
-This causes the design of the data structures to be high dependant on how the metadata
-is read.
-
-Also
-
-We try to look for a solution that works well in the 99% of the cases, giving the flexibility
-in the rest 1%.
-
-Requirements
-============
-
-- Allow parsers to enter metadata as they get it.
-- Be reasonable fast
-
-The first requirement would make us unable to use fixed data transport
-objects to insert data.
-
-If we choose a data object with certains fields, we will be going in favour
-of the design of certain metadata format.
-
-Proposed Solution
-=================
-
-- a basic resolvable NVRAD data object
-- a dynamic fields object:
-
- .------------------------.
- | package_data |
- +------------------+-----+
- | summary | [ ] |
- | description | [ ] |
- | group | [ ] |
- | packager | [ ] |
- | license | [ ] |
- '------------------+-----'
-
-Everytime a package object is inserted in the cache, the resolvable
-entry will be inserted, but also the specific data for the resolvable
-kind will be created in a empty state. The id of the resolvable will be
-returned.
-
-The parser can then write the data passing a structure like the one
-described above, where the first column represents the field and the second
-the field to update. A SQL UPDATE statement will be generated from this
-data object, and adding the fields for first time will be no different as
-UPDATING the fields.
-
-This presents one problem. As the SQL is generated from the data object
-actve fields, we can't precompile those update statements. This is solved easily.
-We can assume if a metadata parser is inserting a combination of fields for
-lot of packages, that it will use the same combination for all packages in most
-of the cases. We can precompile the statements for a combination of fields and
-cache them in a precompiled statement pool. When we will insert another data
-block, we can lookup if a precompiled statement for the combination exists and
-use it. The only cases that will not benefit from it would be updating all the
-time in different orders (which will hit the cache when all field combinations are
-reached). So problem has a easy solution.
-
-Implementation
-==============
-
-The implementation of the data objects is not defined yet. Several alternatives
-come to mind:
-
-struct PackageData
-{
- enum Fields {
- FIELD_DESCRIPTION,
- FIELD_SUMMARY,
- FIELD_GROUP,
- };
-
- string description;
- string summary;
- int size;
-
- int fields_mask;
- // or set<Field> fields
-};
-
-struct PackageData
-{
- pair<bool, string> description;
- pair<bool, string> summary;
- pair<bool, int> size;
-};
-
-In this case, we would need to know the types of the data
-before writing it.
-
-We are investigating the use of boost::any [2] in order to see if
-it is possible to make the api even easier.
-
-
- [1]: Name Version Release Arch Deps
- [2]: http://www.boost.org/doc/html/any.html
\ No newline at end of file
+++ /dev/null
-
-#include "zypp2/cache/CacheTypes.h"
-#include "zypp2/cache/ResolvableQuery.h"
-#include "zypp2/cache/sqlite3x/sqlite3x.hpp"
-
-using namespace sqlite3x;
-using namespace std;
-
-namespace zypp { namespace cache {
-
-
-struct ResolvableQuery::Impl
-{
- Pathname _dbdir;
- string _fields;
- CacheTypes _type_cache;
-
- Impl( const Pathname &dbdir)
- : _dbdir(dbdir)
- , _type_cache(dbdir)
- {
- _fields = "id, name, version, release, epoch, arch, kind, installed_size, archive_size, install_only, build_time, install_time, repository_id";
- }
-
- ~Impl()
- {
- }
-
-
- data::ResObject_Ptr fromRow( sqlite3_reader &reader )
- {
- data::ResObject_Ptr ptr (new data::ResObject);
-
- ptr->name = reader.getstring(1);
- ptr->edition = Edition( reader.getstring(2), reader.getstring(3), reader.getint(4));
- ptr->arch = _type_cache.archFor(reader.getint(5));
-
- // TODO get the rest of the data
-
- return ptr;
- }
-
-
- void query( const data::RecordId &id,
- ProcessResolvable fnc )
- {
- sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
- //con.executenonquery("PRAGMA cache_size=8000;");
- con.executenonquery("BEGIN;");
- sqlite3_command cmd( con, "select " + _fields + " from resolvables where id=:id;");
- cmd.bind(":id", id);
- sqlite3_reader reader = cmd.executereader();
- while(reader.read())
- {
- fnc( id, fromRow(reader) );
- }
- con.executenonquery("COMMIT;");
- }
-
-
- void query( const std::string &s,
- ProcessResolvable fnc )
- {
-
- sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
- //con.executenonquery("PRAGMA cache_size=8000;");
- con.executenonquery("BEGIN;");
- sqlite3_command cmd( con, "select " + _fields + " from resolvables where name like '%:name%';");
- cmd.bind(":name", s);
- sqlite3_reader reader = cmd.executereader();
- while(reader.read())
- {
- fnc( reader.getint64(0), fromRow(reader) );
- }
- con.executenonquery("COMMIT;");
- }
-
-
- std::string queryStringAttribute( const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name )
- {
- sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
- return queryStringAttributeTranslationInternal( con, record_id, Locale(), klass, name);
- }
-
-
- std::string queryStringAttributeTranslation( const data::RecordId &record_id,
- const Locale &locale,
- const std::string &klass,
- const std::string &name )
- {
- sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
- return queryStringAttributeTranslationInternal( con, record_id, locale, klass, name );
- }
-
-
- TranslatedText queryTranslatedStringAttribute( const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name )
- {
- sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
- return queryTranslatedStringAttributeInternal( con, record_id, klass, name );
- }
-
-
- int queryNumericAttribute( const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name )
- {
- sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
- return queryNumericAttributeInternal( con, record_id, klass, name);
- }
-
-private:
-
- int queryNumericAttributeInternal( sqlite3_connection &con,
- const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name )
- {
- con.executenonquery("BEGIN;");
- sqlite3_command cmd( con, "select a.value from numeric_attributes a,types t where a.weak_resolvable_id=:rid and a.attr_id=t.id and t.class=:tclass and t.name=:tname;");
-
- cmd.bind(":rid", record_id);
-
- cmd.bind(":tclass", klass);
- cmd.bind(":tname", name);
-
- return cmd.executeint();
- }
-
- TranslatedText queryTranslatedStringAttributeInternal( sqlite3_connection &con,
- const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name )
- {
- //con.executenonquery("PRAGMA cache_size=8000;");
- con.executenonquery("BEGIN;");
- sqlite3_command cmd( con, "select a.text, l.name from text_attributes a,types l,types t where a.weak_resolvable_id=:rid and a.lang_id=l.id and a.attr_id=t.id and l.class=:lclass and t.class=:tclass and t.name=:tname;");
-
- cmd.bind(":rid", record_id);
- cmd.bind(":lclass", "lang");
-
- cmd.bind(":tclass", klass);
- cmd.bind(":tname", name);
-
- TranslatedText result;
- sqlite3_reader reader = cmd.executereader();
- while(reader.read())
- {
- result.setText( reader.getstring(0), Locale( reader.getstring(1) ) );
- }
- return result;
- }
-
- std::string queryStringAttributeInternal( sqlite3_connection &con,
- const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name )
- {
- return queryStringAttributeTranslationInternal( con, record_id, Locale(), klass, name);
- }
-
- std::string queryStringAttributeTranslationInternal( sqlite3_connection &con,
- const data::RecordId &record_id,
- const Locale &locale,
- const std::string &klass,
- const std::string &name )
- {
- //con.executenonquery("PRAGMA cache_size=8000;");
- con.executenonquery("BEGIN;");
- sqlite3_command cmd( con, "select a.text from text_attributes a,types l,types t where a.weak_resolvable_id=:rid and a.lang_id=l.id and a.attr_id=t.id and l.class=:lclass and l.name=:lname and t.class=:tclass and t.name=:tname;");
-
- cmd.bind(":rid", record_id);
- cmd.bind(":lclass", "lang");
- if (locale == Locale() )
- cmd.bind(":lname", "none");
- else
- cmd.bind(":lname", locale.code());
-
- cmd.bind(":tclass", klass);
- cmd.bind(":tname", name);
-
- return cmd.executestring();
- }
-};
-
-//////////////////////////////////////////////////////////////////////////////
-// FORWARD TO IMPLEMENTATION
-//////////////////////////////////////////////////////////////////////////////
-
-ResolvableQuery::ResolvableQuery( const Pathname &dbdir)
- : _pimpl(new Impl(dbdir))
-{
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-void ResolvableQuery::query( const data::RecordId &id, ProcessResolvable fnc )
-{
- _pimpl->query(id, fnc);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-void ResolvableQuery::query( const std::string &s, ProcessResolvable fnc )
-{
- _pimpl->query(s, fnc);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-int ResolvableQuery::queryNumericAttribute( const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name )
-{
- return _pimpl->queryNumericAttribute(record_id, klass, name);
-}
-
-bool ResolvableQuery::queryBooleanAttribute( const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name )
-{
- return _pimpl->queryNumericAttribute(record_id, klass, name);
-}
-
-
-std::string ResolvableQuery::queryStringAttribute( const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name )
-{
- return _pimpl->queryStringAttribute(record_id, klass, name);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-std::string ResolvableQuery::queryStringAttributeTranslation( const data::RecordId &record_id,
- const Locale &locale,
- const std::string &klass,
- const std::string &name )
-{
- return _pimpl->queryStringAttributeTranslation(record_id, locale, klass, name);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-TranslatedText ResolvableQuery::queryTranslatedStringAttribute( const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name )
-{
- return _pimpl->queryTranslatedStringAttribute(record_id, klass, name);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-} } // namespace zypp::cache
+++ /dev/null
-
-#ifndef ZYPP_CACHE_RESOLVABLE_QUERY_H
-#define ZYPP_CACHE_RESOLVABLE_QUERY_H
-
-#include "zypp/base/Function.h"
-#include "zypp/Pathname.h"
-#include "zypp/data/ResolvableData.h"
-#include "zypp/data/RecordId.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace cache
- { /////////////////////////////////////////////////////////////////
-
- /**
- * The resolvable query class allows you to query for resolvable
- * data and properties from the cache.
- */
- struct ResolvableQuery
- {
- public:
- /**
- * Callback definition
- * first parameter is the resolvable id.
- * second parameter is a \ref data::ResObjectData object with the resource
- */
- typedef function<bool( const data::RecordId &,
- data::ResObject_Ptr )> ProcessResolvable;
-
- /**
- * Constructor
- *
- * \param dbdir Cache location path
- */
- ResolvableQuery( const Pathname &dbdir );
-
- /**
- * Query by record id
- * \param record_id Resolvable id to query
- * \param fnc callback to send the data to. (Will be called once or none)
- */
- void query( const data::RecordId &record_id,
- ProcessResolvable fnc );
-
- /**
- * Query by matching text
- * \param text text to match
- * \param fnc callback to send the data to. (Will be called once per result)
- */
- void query( const std::string &text,
- ProcessResolvable fnc );
-
- /**
- * Queries a specifc attribute for a resolvable
- *
- * \param record_id Resolvable cache id
- * \param klass Attribute Class
- * \param name Attribute Name
- *
- * \return The attribute or 0 if
- * no record is found.
- */
- int queryNumericAttribute( const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name );
-
-
- /**
- * Queries a specifc attribute for a resolvable
- *
- * \param record_id Resolvable cache id
- * \param klass Attribute Class
- * \param name Attribute Name
- *
- * \return The bool value of the attribute or <tt>false</tt>
- * if no record is found.
- */
- bool queryBooleanAttribute( const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name );
-
-
- /**
- * Queries a specifc attribute for a resolvable
- *
- * \param record_id Resolvable cache id
- * \param klass Attribute Class
- * \param name Attribute Name
- *
- * \return The attribute or a empty string if
- * no record is found.
- */
- std::string queryStringAttribute( const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name );
-
- /**
- * Queries a specifc attribute translation
- * for a resolvable.
- *
- * \param record_id Resolvable cache id
- * \param locale Locale of the translation
- * \param klass Attribute Class
- * \param name Attribute Name
- *
- * \return The attribute or a empty string if
- * no record is found.
- */
- std::string queryStringAttributeTranslation( const data::RecordId &record_id,
- const Locale &locale,
- const std::string &klass,
- const std::string &name );
-
- /**
- * Queries all translations for a specific attribute
- * in a resolvable.
- *
- * \param record_id Resolvable cache id
- * \param klass Attribute Class
- * \param name Attribute Name
- *
- * \return all attribute translations or a empty
- * \ref TranslatedString if no record is found.
- */
- TranslatedText queryTranslatedStringAttribute( const data::RecordId &record_id,
- const std::string &klass,
- const std::string &name );
-
- private:
- /** Implementation. */
- class Impl;
- /** Pointer to implementation. */
- RW_pointer<Impl> _pimpl;
- };
-
- } //NS cache
-} //NS zypp
-
-#endif
+++ /dev/null
-
-http://s11n.net/sqlite/wrapper/overview-sqlite3x-sq3-2007.01.25.pdf
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#include <vector>
-
-#include "zypp/base/Logger.h"
-#include "zypp/base/String.h"
-
-#include "zypp2/cache/Utils.h"
-
-using namespace std;
-
-//////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace cache
-{ /////////////////////////////////////////////////////////////////
-
-int tribool_to_int( boost::tribool b )
-{
- if (b)
- return 1;
- else if (!b)
- return 0;
- else
- return 2;
-}
-
-boost::tribool int_to_tribool( int i )
-{
- if (i==1)
- return true;
- else if (i==0)
- return false;
- else
- return boost::indeterminate;
-}
-
-std::string checksum_to_string( const CheckSum &checksum )
-{
- return checksum.type() + ":" + checksum.checksum();
-}
-
-CheckSum string_to_checksum( const std::string &checksum )
-{
- std::vector<std::string> words;
- if ( str::split( checksum, std::back_inserter(words), ":" ) != 2 )
- return CheckSum();
-
- return CheckSum( words[0], words[19]);
-}
-
-}
-}
-
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#ifndef ZYPP_DATA_UTILS_H
-#define ZYPP_DATA_UTILS_H
-
-#include "zypp/base/Logger.h"
-#include "zypp/base/String.h"
-#include "zypp/CheckSum.h"
-#include <boost/logic/tribool.hpp>
-
-//////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace cache
-{ /////////////////////////////////////////////////////////////////
-
- int tribool_to_int( boost::tribool b );
- boost::tribool int_to_tribool( int i );
- std::string checksum_to_string( const CheckSum &checksum );
- CheckSum string_to_checksum( const std::string &checksum );
-
-}
-}
-
-#endif
+++ /dev/null
-
-See:
-http://en.opensuse.org/Libzypp/Refactoring/CacheSchema
\ No newline at end of file
+++ /dev/null
-/*
- * mkarray - make a c array containing the input file.
- *
- * this file is part of the makeutil package:
- * http://sourceforge.net/projects/makeutil/
- * http://www.cybermesa.com/~aisa/makeutil/
- *
- * this file is hereby placed in the public domain.
- * aisa0@users.sourceforge.net, aisa@cybermesa.com
- */
-
-static char rcsid[]="$Id: mkarray.c,v 1.2 2004/12/11 18:21:51 aisa0 Exp $";
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-static
-mkarray(filename, file, ofile, varname)
- char *filename;
- FILE *file;
- FILE *ofile;
- char *varname;
-{
- char buf[BUFSIZ];
- size_t i, rsize, tsize=0;
- int done=0, line=8, status=EXIT_SUCCESS;
-
- fprintf(ofile, "/*\n");
- fprintf(ofile, " * this file is automatically generated\n");
- fprintf(ofile, " */\n");
- fprintf(ofile, "\n");
- fprintf(ofile, "#include <string.h>\n");
- fprintf(ofile, "\n");
- fprintf(ofile, "static char rcsid[]=\"%s\";\n", rcsid);
- fprintf(ofile, "\n");
- fprintf(ofile, "char %s[]=\n{\n", varname);
-
- while(!done) {
- int i, ch;
-
- rsize=fread(&buf[0], sizeof(char), sizeof buf/sizeof buf[0], file);
- tsize+=rsize;
-
- switch(rsize) {
- case 0:
- rsize=1;
- buf[0]='\0';
- done=1;
-
- /* down seems more likely */
-
- default:
- for(i=0;i<rsize;++i) {
- if(8==line) fputc('\t', ofile);
-
- line+=(ch=fprintf(ofile, "0x%02x,", buf[i]&0xff));
-
- if(line+ch>=78) {
- line=8;
- fputc('\n', ofile);
- }
- }
- }
- }
- if(ferror(file)) {
- perror("error: read");
- status|=EXIT_FAILURE;
- }
-
- if(8!=line) fputc('\n', ofile);
- fputs("};\n\n", ofile);
-
- fprintf(ofile, "size_t _%s_size=%d;\n", varname, tsize);
- fprintf(ofile, "size_t *%s_size=&_%s_size;\n", varname, varname);
-
- if(ferror(ofile)) {
- perror("error: write: -: ");
- status|=EXIT_FAILURE;
- }
- if(EOF==fclose(ofile)) {
- perror("error: close: -: ");
- status|=EXIT_FAILURE;
- }
-
- return status;
-}
-
-main(argc, argv)
- char *argv[];
-{
- char *filename, *ofilename, *varname;
- FILE *file;
- int status=EXIT_SUCCESS;
-
- --argc;
- ++argv;
-
- if(argc!=3) {
- fputs("usage: mkarray <input-file> <var-name> <output-file>\n", stderr);
- fprintf( stderr, "You gave %d args\n", argc);
- exit(status|EXIT_FAILURE);
- }
-
- filename=argv[0];
- ofilename=argv[2];
- varname=argv[1];
-
- if(0==strcmp("-", filename)) {
- status|=mkarray(filename, stdin, varname);
- } else {
- FILE *file;
- FILE *ofile;
- if( ( NULL!=(file=fopen(filename, "rb")) ) && ( NULL!=(ofile=fopen(ofilename, "w")) ) )
- {
- status|=mkarray(filename, file, ofile, varname);
- if(EOF==fclose(file)) {
- perror("error: close");
- status|=EXIT_FAILURE;
- }
- }
- else
- {
- perror("error: open");
- status|=EXIT_FAILURE;
- }
- }
-
- exit(status);
-}
-
-/* ..__
- * `' "
- */
+++ /dev/null
-
-------------------------------------------------
--- The cleanup can be generated as:
--- cat schema.sql | grep "^CREATE" | awk '{print "DROP " $2 " IF EXISTS " $3 ";"}' | sort -r
-------------------------------------------------
-
-DROP TRIGGER IF EXISTS remove_resolvables;
-DROP TRIGGER IF EXISTS remove_patch_packages_baseversions;
-DROP TABLE IF EXISTS types;
-DROP TABLE IF EXISTS text_attributes;
-DROP TABLE IF EXISTS split_capabilities;
-DROP TABLE IF EXISTS resolvables_repositories;
-DROP TABLE IF EXISTS resolvables;
-DROP TABLE IF EXISTS patch_packages_baseversions;
-DROP TABLE IF EXISTS patch_packages;
-DROP TABLE IF EXISTS other_capabilities;
-DROP TABLE IF EXISTS numeric_attributes;
-DROP TABLE IF EXISTS names;
-DROP TABLE IF EXISTS named_capabilities;
-DROP TABLE IF EXISTS modalias_capabilities;
-DROP TABLE IF EXISTS locks;
-DROP TABLE IF EXISTS hal_capabilities;
-DROP TABLE IF EXISTS files;
-DROP TABLE IF EXISTS file_names;
-DROP TABLE IF EXISTS file_capabilities;
-DROP TABLE IF EXISTS dir_names;
-DROP TABLE IF EXISTS delta_packages;
-DROP TABLE IF EXISTS db_info;
-DROP TABLE IF EXISTS repositories;
-DROP INDEX IF EXISTS types_class_name_index;
-DROP INDEX IF EXISTS text_attributes_index;
-DROP INDEX IF EXISTS numeric_attributes_index;
-DROP INDEX IF EXISTS named_capabilities_name;
-
-------------------------------------------------
--- version metadata, probably not needed, there
--- is pragma user_version
-------------------------------------------------
-
-CREATE TABLE db_info (
- version INTEGER
-);
-
-------------------------------------------------
--- Basic types like archs, attributes, languages
-------------------------------------------------
-
-CREATE TABLE types (
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , class TEXT NOT NULL
- , name TEXT NOT NULL
-);
-CREATE INDEX types_class_name_index ON types(class, name);
-
-------------------------------------------------
--- Knew repositories. They existed some day.
-------------------------------------------------
-
-CREATE TABLE repositories (
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , alias TEXT NOT NULL UNIQUE
- , checksum TEXT DEFAULT NULL
- , timestamp INTEGER NOT NULL
-);
-CREATE INDEX repo_alias_index ON repositories(alias);
-
-------------------------------------------------
--- Resolvable names
-------------------------------------------------
-
-CREATE TABLE names (
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , name TEXT UNIQUE
-);
-
-------------------------------------------------
--- File names table and normalized sub tables
-------------------------------------------------
-
-CREATE TABLE file_names (
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , name TEXT
-);
-
-CREATE TABLE dir_names (
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , name TEXT
-);
-
-CREATE TABLE files (
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , dir_name_id INTEGER NOT NULL
- , file_name_id INTEGER NOT NULL
- , UNIQUE ( dir_name_id, file_name_id )
-);
-
-------------------------------------------------
--- Resolvables table
-------------------------------------------------
-
--- Resolvables translated strings
-CREATE TABLE text_attributes (
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , weak_resolvable_id INTEGER NOT NULL
- , lang_id INTEGER REFERENCES types(id)
- , attr_id INTEGER REFERENCES types(id)
- , text TEXT
-);
-CREATE INDEX text_attributes_index ON text_attributes(weak_resolvable_id, lang_id, attr_id);
-
--- Resolvables numeric attributes
-CREATE TABLE numeric_attributes (
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , weak_resolvable_id INTEGER NOT NULL
- , attr_id INTEGER REFERENCES types(id)
- , value INTEGER NOT NULL
-);
-CREATE INDEX numeric_attributes_index ON numeric_attributes(weak_resolvable_id, attr_id);
-
-
-CREATE TABLE resolvables (
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , name TEXT
- , version TEXT
- , release TEXT
- , epoch INTEGER
- , arch INTEGER REFERENCES types(id)
- , kind INTEGER REFERENCES types(id)
- , repository_id INTEGER REFERENCES repositories(id)
- , installed_size INTEGER
- , archive_size INTEGER
- , install_only INTEGER
- , build_time INTEGER
- , install_time INTEGER
- , shared_id INTEGER DEFAULT NULL
-);
-CREATE INDEX resolvable_repository_id ON resolvables(repository_id);
-
-------------------------------------------------
--- Do we need those here?
-------------------------------------------------
-
-CREATE TABLE locks (
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , name TEXT
- , version TEXT
- , release TEXT
- , epoch INTEGER
- , arch INTEGER
- , relation INTEGER
- , repository TEXT
- , glob TEXT
- , importance INTEGER
- , importance_gteq INTEGER
-
-);
-
-CREATE TABLE delta_packages (
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , media_nr INTEGER
- , location TEXT
- , checksum TEXT
- , download_size INTEGER
- , build_time INTEGER
- , baseversion_version TEXT
- , baseversion_release TEXT
- , baseversion_epoch INTEGER
- , baseversion_checksum TEXT
- , baseversion_build_time INTEGER
- , baseversion_sequence_info TEXT
-
-);
-
-CREATE TABLE patch_packages (
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , media_nr INTEGER
- , location TEXT
- , checksum TEXT
- , download_size INTEGER
- , build_time INTEGER
-
-);
-
-CREATE TABLE patch_packages_baseversions (
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , patch_package_id INTEGER REFERENCES patch_packages(id)
- , version TEXT
- , release TEXT
- , epoch INTEGER
-
-);
-
-------------------------------------------------
--- Capabilities
-------------------------------------------------
-
-CREATE TABLE named_capabilities (
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , resolvable_id INTEGER REFERENCES resolvables(id)
- , dependency_type INTEGER
- , refers_kind INTEGER
- , name_id INTEGER REFERENCES names(id)
- , version TEXT
- , release TEXT
- , epoch INTEGER
- , relation INTEGER
-);
-CREATE INDEX named_capabilities_name ON named_capabilities(name_id);
-CREATE INDEX named_capabilities_resolvable ON named_capabilities(resolvable_id);
-
-CREATE TABLE modalias_capabilities (
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , resolvable_id INTEGER REFERENCES resolvables(id)
- , dependency_type INTEGER
- , refers_kind INTEGER
- , name TEXT
- , value TEXT
- , relation INTEGER
-);
-CREATE INDEX modalias_capabilities_resolvable ON modalias_capabilities(resolvable_id);
-
-CREATE TABLE hal_capabilities (
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , resolvable_id INTEGER REFERENCES resolvables(id)
- , dependency_type INTEGER
- , refers_kind INTEGER
- , name TEXT
- , value TEXT
- , relation INTEGER
-);
-
-CREATE TABLE file_capabilities (
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , resolvable_id INTEGER REFERENCES resolvables(id)
- , dependency_type INTEGER
- , refers_kind INTEGER
- , file_id INTEGER REFERENCES files(id)
-);
-CREATE INDEX file_capabilities_resolvable ON file_capabilities(resolvable_id);
-
-CREATE TABLE other_capabilities (
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , resolvable_id INTEGER REFERENCES resolvables(id)
- , dependency_type INTEGER
- , refers_kind INTEGER
- , value TEXT
-);
-CREATE INDEX other_capabilities_resolvable ON other_capabilities(resolvable_id);
-
-CREATE TABLE split_capabilities (
- id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL
- , resolvable_id INTEGER REFERENCES resolvables(id)
- , dependency_type INTEGER
- , refers_kind INTEGER
- , name_id INTEGER REFERENCES names(id)
- , file_id INTEGER REFERENCES files(id)
-);
-CREATE INDEX split_capabilities_resolvable ON split_capabilities(resolvable_id);
-
--- Auto clean capabilities
-CREATE TRIGGER remove_resolvables
- AFTER DELETE ON resolvables
- BEGIN
- DELETE FROM named_capabilities WHERE resolvable_id = old.id;
- DELETE FROM modalias_capabilities WHERE resolvable_id = old.id;
- DELETE FROM hal_capabilities WHERE resolvable_id = old.id;
- DELETE FROM file_capabilities WHERE resolvable_id = old.id;
- DELETE FROM split_capabilities WHERE resolvable_id = old.id;
- DELETE FROM other_capabilities WHERE resolvable_id = old.id;
- END;
-
-------------------------------------------------
--- Associate resolvables and repositories
-------------------------------------------------
-
--- FIXME do we want to allow same resolvable to
--- be listed twice in same source but different
--- medias? I think NOT.
-CREATE TABLE resolvables_repositories (
- resolvable_id INTEGER REFERENCES resolvables (id)
- , repository_id INTEGER REFERENCES repositories (id)
- , repository_media_nr INTEGER
- , PRIMARY KEY ( resolvable_id, repository_id )
-);
-
--- Auto clean repositories
-CREATE TRIGGER remove_repositories
- AFTER DELETE ON repositories
- BEGIN
- DELETE FROM resolvables WHERE repository_id = old.id;
- END;
-
-CREATE TRIGGER remove_patch_packages_baseversions
- AFTER DELETE ON patch_packages
- BEGIN
- DELETE FROM patch_packages_baseversions WHERE patch_package_id = old.id;
- END;
-
-
+++ /dev/null
-/*\r
- Copyright (C) 2004-2005 Cory Nelson\r
-\r
- This software is provided 'as-is', without any express or implied\r
- warranty. In no event will the authors be held liable for any damages\r
- arising from the use of this software.\r
-\r
- Permission is granted to anyone to use this software for any purpose,\r
- including commercial applications, and to alter it and redistribute it\r
- freely, subject to the following restrictions:\r
-\r
- 1. The origin of this software must not be misrepresented; you must not\r
- claim that you wrote the original software. If you use this software\r
- in a product, an acknowledgment in the product documentation would be\r
- appreciated but is not required.\r
- 2. Altered source versions must be plainly marked as such, and must not be\r
- misrepresented as being the original software.\r
- 3. This notice may not be removed or altered from any source distribution.\r
-\r
- CVS Info :\r
- $Author: phrostbyte $\r
- $Date: 2005/06/16 20:46:40 $\r
- $Revision: 1.1 $\r
-*/\r
-\r
-#ifndef __SQLITE3X_HPP__\r
-#define __SQLITE3X_HPP__\r
-\r
-#include <string>\r
-#include <exception>\r
-#include <stdexcept>\r
-#include <boost/utility.hpp>\r
-\r
-namespace sqlite3x\r
-{\r
-class sqlite3_connection : boost::noncopyable\r
-{\r
-private:\r
- friend class sqlite3_command;\r
- friend class database_error;\r
-\r
- struct sqlite3 *db;\r
-\r
-public:\r
- sqlite3_connection();\r
- sqlite3_connection(const char *db);\r
- sqlite3_connection(const wchar_t *db);\r
- ~sqlite3_connection();\r
-\r
- void open(const char *db);\r
- void open(const wchar_t *db);\r
- void close();\r
-\r
- long long insertid();\r
- void setbusytimeout(int ms);\r
-\r
- void execute(const std::string &sql);\r
- \r
- void executenonquery(const char *sql);\r
- void executenonquery(const wchar_t *sql);\r
- void executenonquery(const std::string &sql);\r
- void executenonquery(const std::wstring &sql);\r
-\r
- int executeint(const char *sql);\r
- int executeint(const wchar_t *sql);\r
- int executeint(const std::string &sql);\r
- int executeint(const std::wstring &sql);\r
-\r
- long long executeint64(const char *sql);\r
- long long executeint64(const wchar_t *sql);\r
- long long executeint64(const std::string &sql);\r
- long long executeint64(const std::wstring &sql);\r
-\r
- double executedouble(const char *sql);\r
- double executedouble(const wchar_t *sql);\r
- double executedouble(const std::string &sql);\r
- double executedouble(const std::wstring &sql);\r
-\r
- std::string executestring(const char *sql);\r
- std::string executestring(const wchar_t *sql);\r
- std::string executestring(const std::string &sql);\r
- std::string executestring(const std::wstring &sql);\r
-\r
- std::wstring executestring16(const char *sql);\r
- std::wstring executestring16(const wchar_t *sql);\r
- std::wstring executestring16(const std::string &sql);\r
- std::wstring executestring16(const std::wstring &sql);\r
-\r
- std::string executeblob(const char *sql);\r
- std::string executeblob(const wchar_t *sql);\r
- std::string executeblob(const std::string &sql);\r
- std::string executeblob(const std::wstring &sql);\r
-};\r
-\r
-class sqlite3_command;\r
-\r
-class database_error : public std::runtime_error\r
-{\r
-public:\r
- database_error(const char *msg);\r
- database_error(sqlite3_connection &con);\r
-};\r
-\r
-class sqlite3_transaction : boost::noncopyable\r
-{\r
-private:\r
- sqlite3_connection &con;\r
- bool intrans;\r
-\r
-public:\r
- sqlite3_transaction(sqlite3_connection &con, bool start=true);\r
- ~sqlite3_transaction();\r
-\r
- void begin();\r
- void commit();\r
- void rollback();\r
-};\r
-\r
-class sqlite3_reader\r
-{\r
-private:\r
- friend class sqlite3_command;\r
-\r
- sqlite3_command *cmd;\r
-\r
- sqlite3_reader(sqlite3_command *cmd);\r
-\r
-public:\r
- sqlite3_reader();\r
- sqlite3_reader(const sqlite3_reader ©);\r
- ~sqlite3_reader();\r
-\r
- sqlite3_reader& operator=(const sqlite3_reader ©);\r
-\r
- bool read();\r
- void reset();\r
- void close();\r
-\r
- int getint(int index);\r
- long long getint64(int index);\r
- double getdouble(int index);\r
- std::string getstring(int index);\r
- std::wstring getstring16(int index);\r
- std::string getblob(int index);\r
-\r
- std::string getcolname(int index);\r
- std::wstring getcolname16(int index);\r
-};\r
-\r
-class sqlite3_command : boost::noncopyable\r
-{\r
-private:\r
- friend class sqlite3_reader;\r
-\r
- sqlite3_connection &con;\r
- struct sqlite3_stmt *stmt;\r
- unsigned int refs;\r
- int argc;\r
-\r
-public:\r
- sqlite3_command(sqlite3_connection &con, const char *sql);\r
- sqlite3_command(sqlite3_connection &con, const wchar_t *sql);\r
- sqlite3_command(sqlite3_connection &con, const std::string &sql);\r
- sqlite3_command(sqlite3_connection &con, const std::wstring &sql);\r
- ~sqlite3_command();\r
-\r
- void bind(int index);\r
- void bind(int index, int data);\r
- void bind(int index, long long data);\r
- void bind(int index, double data);\r
- void bind(int index, const char *data, int datalen);\r
- void bind(int index, const wchar_t *data, int datalen);\r
- void bind(int index, const void *data, int datalen);\r
- void bind(int index, const std::string &data);\r
- void bind(int index, const std::wstring &data);\r
- \r
- void bind(const std::string ¶m);\r
- void bind(const std::string ¶m, int data);\r
- void bind(const std::string ¶m, long long data);\r
- void bind(const std::string ¶m, double data);\r
- void bind(const std::string ¶m, const char *data, int datalen);\r
- void bind(const std::string ¶m, const wchar_t *data, int datalen);\r
- void bind(const std::string ¶m, const void *data, int datalen);\r
- void bind(const std::string ¶m, const std::string &data);\r
- void bind(const std::string ¶m, const std::wstring &data);\r
-\r
- sqlite3_reader executereader();\r
- void executenonquery();\r
- int executeint();\r
- long long executeint64();\r
- double executedouble();\r
- std::string executestring();\r
- std::wstring executestring16();\r
- std::string executeblob();\r
-};\r
-\r
-}\r
-\r
-#endif\r
+++ /dev/null
-/*\r
- Copyright (C) 2004-2005 Cory Nelson\r
-\r
- This software is provided 'as-is', without any express or implied\r
- warranty. In no event will the authors be held liable for any damages\r
- arising from the use of this software.\r
-\r
- Permission is granted to anyone to use this software for any purpose,\r
- including commercial applications, and to alter it and redistribute it\r
- freely, subject to the following restrictions:\r
-\r
- 1. The origin of this software must not be misrepresented; you must not\r
- claim that you wrote the original software. If you use this software\r
- in a product, an acknowledgment in the product documentation would be\r
- appreciated but is not required.\r
- 2. Altered source versions must be plainly marked as such, and must not be\r
- misrepresented as being the original software.\r
- 3. This notice may not be removed or altered from any source distribution.\r
-\r
- CVS Info :\r
- $Author: phrostbyte $\r
- $Date: 2005/06/16 20:46:40 $\r
- $Revision: 1.1 $\r
-*/\r
-\r
-#include <sqlite3.h>\r
-#include "sqlite3x.hpp"\r
-\r
-namespace sqlite3x\r
-{\r
-\r
-sqlite3_command::sqlite3_command(sqlite3_connection &con, const char *sql) : con(con),refs(0)\r
-{\r
- const char *tail=NULL;\r
- if (sqlite3_prepare(con.db, sql, -1, &this->stmt, &tail)!=SQLITE_OK)\r
- throw database_error(con);\r
-\r
- this->argc=sqlite3_column_count(this->stmt);\r
-}\r
-\r
-sqlite3_command::sqlite3_command(sqlite3_connection &con, const wchar_t *sql) : con(con),refs(0)\r
-{\r
- const wchar_t *tail=NULL;\r
- if (sqlite3_prepare16(con.db, sql, -1, &this->stmt, (const void**)&tail)!=SQLITE_OK)\r
- throw database_error(con);\r
-\r
- this->argc=sqlite3_column_count(this->stmt);\r
-}\r
-\r
-sqlite3_command::sqlite3_command(sqlite3_connection &con, const std::string &sql) : con(con),refs(0)\r
-{\r
- const char *tail=NULL;\r
- if (sqlite3_prepare(con.db, sql.data(), (int)sql.length(), &this->stmt, &tail)!=SQLITE_OK)\r
- throw database_error(con);\r
-\r
- this->argc=sqlite3_column_count(this->stmt);\r
-}\r
-\r
-sqlite3_command::sqlite3_command(sqlite3_connection &con, const std::wstring &sql) : con(con),refs(0)\r
-{\r
- const wchar_t *tail=NULL;\r
- if (sqlite3_prepare16(con.db, sql.data(), (int)sql.length()*2, &this->stmt, (const void**)&tail)!=SQLITE_OK)\r
- throw database_error(con);\r
-\r
- this->argc=sqlite3_column_count(this->stmt);\r
-}\r
-\r
-sqlite3_command::~sqlite3_command()\r
-{\r
- sqlite3_finalize(this->stmt);\r
-}\r
-\r
-void sqlite3_command::bind(int index)\r
-{\r
- if (sqlite3_bind_null(this->stmt, index)!=SQLITE_OK)\r
- throw database_error(this->con);\r
-}\r
-\r
-void sqlite3_command::bind(int index, int data)\r
-{\r
- if (sqlite3_bind_int(this->stmt, index, data)!=SQLITE_OK)\r
- throw database_error(this->con);\r
-}\r
-\r
-void sqlite3_command::bind(int index, long long data)\r
-{\r
- if (sqlite3_bind_int64(this->stmt, index, data)!=SQLITE_OK)\r
- throw database_error(this->con);\r
-}\r
-\r
-void sqlite3_command::bind(int index, double data)\r
-{\r
- if (sqlite3_bind_double(this->stmt, index, data)!=SQLITE_OK)\r
- throw database_error(this->con);\r
-}\r
-\r
-void sqlite3_command::bind(int index, const char *data, int datalen)\r
-{\r
- if (sqlite3_bind_text(this->stmt, index, data, datalen, SQLITE_TRANSIENT)!=SQLITE_OK)\r
- throw database_error(this->con);\r
-}\r
-\r
-void sqlite3_command::bind(int index, const wchar_t *data, int datalen)\r
-{\r
- if (sqlite3_bind_text16(this->stmt, index, data, datalen, SQLITE_TRANSIENT)!=SQLITE_OK)\r
- throw database_error(this->con);\r
-}\r
-\r
-void sqlite3_command::bind(int index, const void *data, int datalen)\r
-{\r
- if (sqlite3_bind_blob(this->stmt, index, data, datalen, SQLITE_TRANSIENT)!=SQLITE_OK)\r
- throw database_error(this->con);\r
-}\r
-\r
-void sqlite3_command::bind(int index, const std::string &data)\r
-{\r
- if (sqlite3_bind_text(this->stmt, index, data.data(), (int)data.length(), SQLITE_TRANSIENT)!=SQLITE_OK)\r
- throw database_error(this->con);\r
-}\r
-\r
-void sqlite3_command::bind(int index, const std::wstring &data)\r
-{\r
- if (sqlite3_bind_text16(this->stmt, index, data.data(), (int)data.length()*2, SQLITE_TRANSIENT)!=SQLITE_OK)\r
- throw database_error(this->con);\r
-}\r
-\r
-// named parameters bind\r
-\r
-void sqlite3_command::bind(const std::string ¶m)\r
-{\r
- if (sqlite3_bind_null(this->stmt, sqlite3_bind_parameter_index( this->stmt, param.c_str() ) )!=SQLITE_OK)\r
- throw database_error(this->con);\r
-}\r
-\r
-void sqlite3_command::bind(const std::string ¶m, int data)\r
-{\r
- if (sqlite3_bind_int(this->stmt, sqlite3_bind_parameter_index( this->stmt, param.c_str() ) , data)!=SQLITE_OK)\r
- throw database_error(this->con);\r
-}\r
-\r
-void sqlite3_command::bind(const std::string ¶m, long long data)\r
-{\r
- if (sqlite3_bind_int64(this->stmt, sqlite3_bind_parameter_index( this->stmt, param.c_str() ) , data)!=SQLITE_OK)\r
- throw database_error(this->con);\r
-}\r
-\r
-void sqlite3_command::bind(const std::string ¶m, double data)\r
-{\r
- if (sqlite3_bind_double(this->stmt, sqlite3_bind_parameter_index( this->stmt, param.c_str() ) , data)!=SQLITE_OK)\r
- throw database_error(this->con);\r
-}\r
-\r
-void sqlite3_command::bind(const std::string ¶m, const char *data, int datalen)\r
-{\r
- if (sqlite3_bind_text(this->stmt, sqlite3_bind_parameter_index( this->stmt, param.c_str() ) , data, datalen, SQLITE_TRANSIENT)!=SQLITE_OK)\r
- throw database_error(this->con);\r
-}\r
-\r
-void sqlite3_command::bind(const std::string ¶m, const wchar_t *data, int datalen)\r
-{\r
- if (sqlite3_bind_text16(this->stmt, sqlite3_bind_parameter_index( this->stmt, param.c_str() ) , data, datalen, SQLITE_TRANSIENT)!=SQLITE_OK)\r
- throw database_error(this->con);\r
-}\r
-\r
-void sqlite3_command::bind(const std::string ¶m, const void *data, int datalen)\r
-{\r
- if (sqlite3_bind_blob(this->stmt, sqlite3_bind_parameter_index( this->stmt, param.c_str() ) , data, datalen, SQLITE_TRANSIENT)!=SQLITE_OK)\r
- throw database_error(this->con);\r
-}\r
-\r
-void sqlite3_command::bind(const std::string ¶m, const std::string &data)\r
-{\r
- if (sqlite3_bind_text(this->stmt, sqlite3_bind_parameter_index( this->stmt, param.c_str() ) , data.data(), (int)data.length(), SQLITE_TRANSIENT)!=SQLITE_OK)\r
- throw database_error(this->con);\r
-}\r
-\r
-void sqlite3_command::bind(const std::string ¶m, const std::wstring &data)\r
-{\r
- if (sqlite3_bind_text16(this->stmt, sqlite3_bind_parameter_index( this->stmt, param.c_str() ) , data.data(), (int)data.length()*2, SQLITE_TRANSIENT)!=SQLITE_OK)\r
- throw database_error(this->con);\r
-}\r
-\r
-\r
-\r
-sqlite3_reader sqlite3_command::executereader()\r
-{\r
- return sqlite3_reader(this);\r
-}\r
-\r
-void sqlite3_command::executenonquery()\r
-{\r
- this->executereader().read();\r
-}\r
-\r
-int sqlite3_command::executeint()\r
-{\r
- sqlite3_reader reader=this->executereader();\r
- if (!reader.read()) throw database_error("nothing to read");\r
- return reader.getint(0);\r
-}\r
-\r
-long long sqlite3_command::executeint64()\r
-{\r
- sqlite3_reader reader=this->executereader();\r
- if (!reader.read()) throw database_error("nothing to read");\r
- return reader.getint64(0);\r
-}\r
-\r
-double sqlite3_command::executedouble()\r
-{\r
- sqlite3_reader reader=this->executereader();\r
- if (!reader.read()) throw database_error("nothing to read");\r
- return reader.getdouble(0);\r
-}\r
-\r
-std::string sqlite3_command::executestring()\r
-{\r
- sqlite3_reader reader=this->executereader();\r
- if (!reader.read()) throw database_error("nothing to read");\r
- return reader.getstring(0);\r
-}\r
-\r
-std::wstring sqlite3_command::executestring16()\r
-{\r
- sqlite3_reader reader=this->executereader();\r
- if (!reader.read()) throw database_error("nothing to read");\r
- return reader.getstring16(0);\r
-}\r
-\r
-std::string sqlite3_command::executeblob()\r
-{\r
- sqlite3_reader reader=this->executereader();\r
- if (!reader.read()) throw database_error("nothing to read");\r
- return reader.getblob(0);\r
-}\r
-\r
-}\r
+++ /dev/null
-/*\r
- Copyright (C) 2004-2005 Cory Nelson\r
-\r
- This software is provided 'as-is', without any express or implied\r
- warranty. In no event will the authors be held liable for any damages\r
- arising from the use of this software.\r
-\r
- Permission is granted to anyone to use this software for any purpose,\r
- including commercial applications, and to alter it and redistribute it\r
- freely, subject to the following restrictions:\r
-\r
- 1. The origin of this software must not be misrepresented; you must not\r
- claim that you wrote the original software. If you use this software\r
- in a product, an acknowledgment in the product documentation would be\r
- appreciated but is not required.\r
- 2. Altered source versions must be plainly marked as such, and must not be\r
- misrepresented as being the original software.\r
- 3. This notice may not be removed or altered from any source distribution.\r
-\r
- CVS Info :\r
- $Author: phrostbyte $\r
- $Date: 2005/06/16 20:46:40 $\r
- $Revision: 1.1 $\r
-*/\r
-\r
-/* \r
- this source contains modifications by Novell Inc.\r
- \r
- Changes:\r
- \r
- * dmacvicar@novell.com\r
- Wrap sqlite3_exec\r
-\r
-*/\r
-\r
-#include <sqlite3.h>\r
-#include "sqlite3x.hpp"\r
-\r
-namespace sqlite3x\r
-{\r
-\r
-sqlite3_connection::sqlite3_connection() : db(NULL)\r
-{}\r
-\r
-sqlite3_connection::sqlite3_connection(const char *db) : db(NULL)\r
-{\r
- this->open(db);\r
-}\r
-\r
-sqlite3_connection::sqlite3_connection(const wchar_t *db) : db(NULL)\r
-{\r
- this->open(db);\r
-}\r
-\r
-sqlite3_connection::~sqlite3_connection()\r
-{\r
- if (this->db) sqlite3_close(this->db);\r
-}\r
-\r
-void sqlite3_connection::open(const char *db)\r
-{\r
- if (sqlite3_open(db, &this->db)!=SQLITE_OK)\r
- throw database_error("unable to open database");\r
-}\r
-\r
-void sqlite3_connection::open(const wchar_t *db)\r
-{\r
- if (sqlite3_open16(db, &this->db)!=SQLITE_OK)\r
- throw database_error("unable to open database");\r
-}\r
-\r
-void sqlite3_connection::close()\r
-{\r
- if (this->db)\r
- {\r
- if (sqlite3_close(this->db)!=SQLITE_OK)\r
- throw database_error(*this);\r
- this->db=NULL;\r
- }\r
-}\r
-\r
-long long sqlite3_connection::insertid()\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_last_insert_rowid(this->db);\r
-}\r
-\r
-void sqlite3_connection::setbusytimeout(int ms)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
-\r
- if (sqlite3_busy_timeout(this->db, ms)!=SQLITE_OK)\r
- throw database_error(*this);\r
-}\r
-\r
-void sqlite3_connection::executenonquery(const char *sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- sqlite3_command(*this, sql).executenonquery();\r
-}\r
-\r
-void sqlite3_connection::executenonquery(const wchar_t *sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- sqlite3_command(*this, sql).executenonquery();\r
-}\r
-\r
-void sqlite3_connection::executenonquery(const std::string &sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- sqlite3_command(*this, sql).executenonquery();\r
-}\r
-\r
-void sqlite3_connection::executenonquery(const std::wstring &sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- sqlite3_command(*this, sql).executenonquery();\r
-}\r
-\r
-int sqlite3_connection::executeint(const char *sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executeint();\r
-}\r
-\r
-int sqlite3_connection::executeint(const wchar_t *sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executeint();\r
-}\r
-\r
-int sqlite3_connection::executeint(const std::string &sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executeint();\r
-}\r
-\r
-int sqlite3_connection::executeint(const std::wstring &sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executeint();\r
-}\r
-\r
-long long sqlite3_connection::executeint64(const char *sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executeint64();\r
-}\r
-\r
-long long sqlite3_connection::executeint64(const wchar_t *sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executeint64();\r
-}\r
-\r
-long long sqlite3_connection::executeint64(const std::string &sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executeint64();\r
-}\r
-\r
-long long sqlite3_connection::executeint64(const std::wstring &sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executeint64();\r
-}\r
-\r
-double sqlite3_connection::executedouble(const char *sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executedouble();\r
-}\r
-\r
-double sqlite3_connection::executedouble(const wchar_t *sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executedouble();\r
-}\r
-\r
-double sqlite3_connection::executedouble(const std::string &sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executedouble();\r
-}\r
-\r
-double sqlite3_connection::executedouble(const std::wstring &sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executedouble();\r
-}\r
-\r
-std::string sqlite3_connection::executestring(const char *sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executestring();\r
-}\r
-\r
-std::string sqlite3_connection::executestring(const wchar_t *sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executestring();\r
-}\r
-\r
-std::string sqlite3_connection::executestring(const std::string &sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executestring();\r
-}\r
-\r
-std::string sqlite3_connection::executestring(const std::wstring &sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executestring();\r
-}\r
-\r
-std::wstring sqlite3_connection::executestring16(const char *sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executestring16();\r
-}\r
-\r
-std::wstring sqlite3_connection::executestring16(const wchar_t *sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executestring16();\r
-}\r
-\r
-std::wstring sqlite3_connection::executestring16(const std::string &sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executestring16();\r
-}\r
-\r
-std::wstring sqlite3_connection::executestring16(const std::wstring &sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executestring16();\r
-}\r
-\r
-std::string sqlite3_connection::executeblob(const char *sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executeblob();\r
-}\r
-\r
-std::string sqlite3_connection::executeblob(const wchar_t *sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executeblob();\r
-}\r
-\r
-std::string sqlite3_connection::executeblob(const std::string &sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executeblob();\r
-}\r
-\r
-std::string sqlite3_connection::executeblob(const std::wstring &sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- return sqlite3_command(*this, sql).executeblob();\r
-}\r
-\r
-void sqlite3_connection::execute(const std::string &sql)\r
-{\r
- if (!this->db) throw database_error("database is not open");\r
- \r
- char *err_msg;\r
- \r
- if ( sqlite3_exec( this->db, sql.c_str(), NULL, NULL, &err_msg ) != SQLITE_OK )\r
- {\r
- std::string err(err_msg);\r
- sqlite3_free(err_msg);\r
- throw database_error(err.c_str());\r
- }\r
-}\r
-\r
-}\r
+++ /dev/null
-/*\r
- Copyright (C) 2004-2005 Cory Nelson\r
-\r
- This software is provided 'as-is', without any express or implied\r
- warranty. In no event will the authors be held liable for any damages\r
- arising from the use of this software.\r
-\r
- Permission is granted to anyone to use this software for any purpose,\r
- including commercial applications, and to alter it and redistribute it\r
- freely, subject to the following restrictions:\r
-\r
- 1. The origin of this software must not be misrepresented; you must not\r
- claim that you wrote the original software. If you use this software\r
- in a product, an acknowledgment in the product documentation would be\r
- appreciated but is not required.\r
- 2. Altered source versions must be plainly marked as such, and must not be\r
- misrepresented as being the original software.\r
- 3. This notice may not be removed or altered from any source distribution.\r
-\r
- CVS Info :\r
- $Author: phrostbyte $\r
- $Date: 2005/06/16 20:46:40 $\r
- $Revision: 1.1 $\r
-*/\r
-\r
-#include <sqlite3.h>\r
-#include "sqlite3x.hpp"\r
-\r
-namespace sqlite3x\r
-{\r
-\r
-database_error::database_error(const char *msg) : runtime_error(msg)\r
-{}\r
-database_error::database_error(sqlite3_connection &con) : runtime_error(sqlite3_errmsg(con.db))\r
-{}\r
-\r
-}\r
+++ /dev/null
-/*\r
- Copyright (C) 2004-2005 Cory Nelson\r
-\r
- This software is provided 'as-is', without any express or implied\r
- warranty. In no event will the authors be held liable for any damages\r
- arising from the use of this software.\r
-\r
- Permission is granted to anyone to use this software for any purpose,\r
- including commercial applications, and to alter it and redistribute it\r
- freely, subject to the following restrictions:\r
-\r
- 1. The origin of this software must not be misrepresented; you must not\r
- claim that you wrote the original software. If you use this software\r
- in a product, an acknowledgment in the product documentation would be\r
- appreciated but is not required.\r
- 2. Altered source versions must be plainly marked as such, and must not be\r
- misrepresented as being the original software.\r
- 3. This notice may not be removed or altered from any source distribution.\r
-\r
- CVS Info :\r
- $Author: phrostbyte $\r
- $Date: 2005/06/16 20:46:40 $\r
- $Revision: 1.1 $\r
-*/\r
-\r
-#include <sqlite3.h>\r
-#include "sqlite3x.hpp"\r
-\r
-namespace sqlite3x\r
-{\r
-\r
-sqlite3_reader::sqlite3_reader() : cmd(NULL)\r
-{}\r
-\r
-sqlite3_reader::sqlite3_reader(const sqlite3_reader ©) : cmd(copy.cmd)\r
-{\r
- if (this->cmd) ++this->cmd->refs;\r
-}\r
-\r
-sqlite3_reader::sqlite3_reader(sqlite3_command *cmd) : cmd(cmd)\r
-{\r
- ++cmd->refs;\r
-}\r
-\r
-sqlite3_reader::~sqlite3_reader()\r
-{\r
- this->close();\r
-}\r
-\r
-sqlite3_reader& sqlite3_reader::operator=(const sqlite3_reader ©)\r
-{\r
- this->close();\r
-\r
- this->cmd=copy.cmd;\r
- if (this->cmd) ++this->cmd->refs;\r
-\r
- return *this;\r
-}\r
-\r
-bool sqlite3_reader::read()\r
-{\r
- if (!this->cmd) throw database_error("reader is closed");\r
-\r
- switch (sqlite3_step(this->cmd->stmt))\r
- {\r
- case SQLITE_ROW:\r
- return true;\r
- case SQLITE_DONE:\r
- return false;\r
- default:\r
- throw database_error(this->cmd->con);\r
- }\r
-}\r
-\r
-void sqlite3_reader::reset()\r
-{\r
- if (!this->cmd) throw database_error("reader is closed");\r
-\r
- if (sqlite3_reset(this->cmd->stmt)!=SQLITE_OK)\r
- throw database_error(this->cmd->con);\r
-}\r
-\r
-void sqlite3_reader::close()\r
-{\r
- if (this->cmd)\r
- {\r
- if (--this->cmd->refs==0) sqlite3_reset(this->cmd->stmt);\r
- this->cmd=NULL;\r
- }\r
-}\r
-\r
-int sqlite3_reader::getint(int index)\r
-{\r
- if (!this->cmd) throw database_error("reader is closed");\r
- if ((index)>(this->cmd->argc-1)) throw std::out_of_range("index out of range");\r
- return sqlite3_column_int(this->cmd->stmt, index);\r
-}\r
-\r
-long long sqlite3_reader::getint64(int index)\r
-{\r
- if (!this->cmd) throw database_error("reader is closed");\r
- if ((index)>(this->cmd->argc-1)) throw std::out_of_range("index out of range");\r
- return sqlite3_column_int64(this->cmd->stmt, index);\r
-}\r
-\r
-double sqlite3_reader::getdouble(int index)\r
-{\r
- if (!this->cmd) throw database_error("reader is closed");\r
- if ((index)>(this->cmd->argc-1)) throw std::out_of_range("index out of range");\r
- return sqlite3_column_double(this->cmd->stmt, index);\r
-}\r
-\r
-std::string sqlite3_reader::getstring(int index)\r
-{\r
- if (!this->cmd) throw database_error("reader is closed");\r
- if ((index)>(this->cmd->argc-1)) throw std::out_of_range("index out of range");\r
- return std::string((const char*)sqlite3_column_text(this->cmd->stmt, index), sqlite3_column_bytes(this->cmd->stmt, index));\r
-}\r
-\r
-std::wstring sqlite3_reader::getstring16(int index)\r
-{\r
- if (!this->cmd) throw database_error("reader is closed");\r
- if ((index)>(this->cmd->argc-1)) throw std::out_of_range("index out of range");\r
- return std::wstring((const wchar_t*)sqlite3_column_text16(this->cmd->stmt, index), sqlite3_column_bytes16(this->cmd->stmt, index)/2);\r
-}\r
-\r
-std::string sqlite3_reader::getblob(int index)\r
-{\r
- if (!this->cmd) throw database_error("reader is closed");\r
- if ((index)>(this->cmd->argc-1)) throw std::out_of_range("index out of range");\r
- return std::string((const char*)sqlite3_column_blob(this->cmd->stmt, index), sqlite3_column_bytes(this->cmd->stmt, index));\r
-}\r
-\r
-std::string sqlite3_reader::getcolname(int index)\r
-{\r
- if (!this->cmd) throw database_error("reader is closed");\r
- if ((index)>(this->cmd->argc-1)) throw std::out_of_range("index out of range");\r
- return sqlite3_column_name(this->cmd->stmt, index);\r
-}\r
-\r
-std::wstring sqlite3_reader::getcolname16(int index)\r
-{\r
- if (!this->cmd) throw database_error("reader is closed");\r
- if ((index)>(this->cmd->argc-1)) throw std::out_of_range("index out of range");\r
- return (const wchar_t*)sqlite3_column_name16(this->cmd->stmt, index);\r
-}\r
-\r
-}\r
+++ /dev/null
-/*\r
- Copyright (C) 2004-2005 Cory Nelson\r
-\r
- This software is provided 'as-is', without any express or implied\r
- warranty. In no event will the authors be held liable for any damages\r
- arising from the use of this software.\r
-\r
- Permission is granted to anyone to use this software for any purpose,\r
- including commercial applications, and to alter it and redistribute it\r
- freely, subject to the following restrictions:\r
-\r
- 1. The origin of this software must not be misrepresented; you must not\r
- claim that you wrote the original software. If you use this software\r
- in a product, an acknowledgment in the product documentation would be\r
- appreciated but is not required.\r
- 2. Altered source versions must be plainly marked as such, and must not be\r
- misrepresented as being the original software.\r
- 3. This notice may not be removed or altered from any source distribution.\r
-\r
- CVS Info :\r
- $Author: phrostbyte $\r
- $Date: 2005/06/16 20:46:40 $\r
- $Revision: 1.1 $\r
-*/\r
-\r
-#include <sqlite3.h>\r
-#include "sqlite3x.hpp"\r
-\r
-namespace sqlite3x\r
-{\r
-\r
-sqlite3_transaction::sqlite3_transaction(sqlite3_connection &con, bool start) : con(con),intrans(false)\r
-{\r
- if (start) begin();\r
-}\r
-\r
-sqlite3_transaction::~sqlite3_transaction()\r
-{\r
- if (intrans)\r
- {\r
- try\r
- {\r
- rollback();\r
- }\r
- catch (...)\r
- {\r
- return;\r
- }\r
- }\r
-}\r
-\r
-void sqlite3_transaction::begin()\r
-{\r
- con.executenonquery("begin;");\r
- intrans=true;\r
-}\r
-\r
-void sqlite3_transaction::commit()\r
-{\r
- con.executenonquery("commit;");\r
- intrans=false;\r
-}\r
-\r
-void sqlite3_transaction::rollback()\r
-{\r
- con.executenonquery("rollback;");\r
- intrans=false;\r
-}\r
-\r
-}\r
+++ /dev/null
-/*
-** Zlib for sqlite3
-**
-** Compile: gcc -o zlib.so -shared zlibext.c -lsqlite3 -lz
-**
-** based on sqaux code from James P. Lyon
-** ported to sqlite3 by Duncan Mac-Vicar
-**
-** The authors disclaims copyright to this source code. In place of
-** a legal notice, here is a blessing:
-**
-** May you do good and not evil.
-** May you find forgiveness for yourself and forgive others.
-** May you share freely, never taking more than you give.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <string.h>
-#include <assert.h>
-
-#include <sqlite3ext.h>
-#include <zlib.h>
-
-#include <sqlite3ext.h>
-SQLITE_EXTENSION_INIT1
-
-/*
-** Compute the maximum size required by sqlite_encode_binary().
-** This doesn't include the NUL byte which terminates the string.
-*/
-int sqaux_encode_maxsize(int datasize)
-{
- int nEncMax = (256*datasize + 1262)/253;
- return nEncMax;
-}
-
-/*
-** Encode a binary buffer "in" of size n bytes so that it contains
-** no instances of characters '\'' or '\000'. The output is
-** null-terminated and can be used as a string value in an INSERT
-** or UPDATE statement. Use sqlite_decode_binary() to convert the
-** string back into its original binary.
-**
-** The result is written into a preallocated output buffer "out".
-** "out" must be able to hold at least 2 +(257*n)/254 bytes.
-** In other words, the output will be expanded by as much as 3
-** bytes for every 254 bytes of input plus 2 bytes of fixed overhead.
-** (This is approximately 2 + 1.0118*n or about a 1.2% size increase.)
-**
-** The return value is the number of characters in the encoded
-** string, excluding the "\000" terminator.
-*/
-int sqlite3_encode_binary(const unsigned char *in, int n, unsigned char *out){
- int i, j, e, m;
- int cnt[256];
- if( n<=0 ){
- out[0] = 'x';
- out[1] = 0;
- return 1;
- }
- memset(cnt, 0, sizeof(cnt));
- for(i=n-1; i>=0; i--){ cnt[in[i]]++; }
- m = n;
- for(i=1; i<256; i++){
- int sum;
- if( i=='\'' ) continue;
- sum = cnt[i] + cnt[(i+1)&0xff] + cnt[(i+'\'')&0xff];
- if( sum<m ){
- m = sum;
- e = i;
- if( m==0 ) break;
- }
- }
- out[0] = e;
- j = 1;
- for(i=0; i<n; i++){
- int c = (in[i] - e)&0xff;
- if( c==0 ){
- out[j++] = 1;
- out[j++] = 1;
- }else if( c==1 ){
- out[j++] = 1;
- out[j++] = 2;
- }else if( c=='\'' ){
- out[j++] = 1;
- out[j++] = 3;
- }else{
- out[j++] = c;
- }
- }
- out[j] = 0;
- return j;
-}
-
-/*
-** Decode the string "in" into binary data and write it into "out".
-** This routine reverses the encoding created by sqlite_encode_binary().
-** The output will always be a few bytes less than the input. The number
-** of bytes of output is returned. If the input is not a well-formed
-** encoding, -1 is returned.
-**
-** The "in" and "out" parameters may point to the same buffer in order
-** to decode a string in place.
-*/
-int sqlite3_decode_binary(const unsigned char *in, unsigned char *out){
- int i, c, e;
- e = *(in++);
- i = 0;
- while( (c = *(in++))!=0 ){
- if( c==1 ){
- c = *(in++);
- if( c==1 ){
- c = 0;
- }else if( c==2 ){
- c = 1;
- }else if( c==3 ){
- c = '\'';
- }else{
- return -1;
- }
- }
- out[i++] = (c + e)&0xff;
- }
- return i;
-}
-
-
-/*
-** Compute the adler32 checksum of a string.
-** This function is exported from the zlib library.
-** Return the checksum as a hex string.
-** THIS IS AN SQLITE USER FUNCTION.
-**
-** argv[0] Data ** encoded data to compute checksum of
-*/
-void FnAdler32(sqlite3_context *context, int argc, sqlite3_value **argv)
-{
- unsigned long checksum;
- char buf[8+1]; /* Buffer to hold 8 hex digits. */
-
- /* Validate arguments. */
- assert(argc == 1 && argv && argv[0]);
-
- checksum = adler32(0L, Z_NULL, 0);
-
- /* Compute the checksum */
- if (argc == 1 && argv && argv[0])
- {
- int len = strlen(sqlite3_value_text(argv[0]));
- checksum = adler32(checksum, (const unsigned char*)argv[0], len);
- }
-
- /* Convert checksum to (upper-case) hexadecimal string. */
- sprintf(buf, "%08X", checksum);
-
- /* 'Return' the string.
- ** -1 means use entire string.
- */
- sqlite3_result_text(context, buf, -1, SQLITE_STATIC);
-}
-
-/*
-** Decode string data stored using ZipString().
-** This undoes sqlite binary encoding and zip compression.
-** <pData> is the NUL-terminated data string stored in the sqlite database.
-** <nSize> is the uncompressed size of the data.
-** If -1 is passed for the size, it will be computed from strlen().
-** <pzErrMsg> points to a string pointer, to allow returning an error message.
-** This argument can be NULL. It should not be freed by the caller.
-** Returns a pointer to dynamically allocated string.
-** Returns NULL on failure.
-*/
-char* UnzipString(const char* pData, long nSize, const char **pzErrMsg)
-{
- long nEncSize, nZipSize;
- long nXmlSize;
- char *pZip, *pXml;
- int zret;
-
- assert(pData); if (!pData) return NULL;
- assert(nSize >= 0); if (nSize < 0) return NULL;
-
- /*
- ** Set up a buffer to hold the unencoded zip data.
- ** This data can contain NUL bytes.
- ** This will always no larger in size than the encoded binary data.
- */
- nEncSize = strlen(pData);
- pZip = (char*)malloc(nEncSize+1);
- if (!pZip)
- {
- if (pzErrMsg)
- *pzErrMsg = "UnzipString: malloc() failure.";
- return NULL;
- }
-
- /*
- ** Decode the sqlite encoding of the zip data.
- ** This returns the actual size of the unencoded [zip] data.
- */
- nZipSize = sqlite3_decode_binary((const unsigned char *)pData, (unsigned char *)pZip);
- if (nZipSize < 0) /* error */
- {
- if (pzErrMsg)
- *pzErrMsg = "UnzipString: sqlite3_decode_binary() failure.";
- free(pZip);
- return NULL;
- }
-
- /*
- ** Set up a buffer to hold the uncompressed data.
- ** This data can contain NUL bytes.
- ** We allocate extra size just to be safe.
- ** NEED to find out how much extra we really need to pad.
- ** This will be generally less than 10kB in size.
- */
- pXml = (char*)malloc(nSize+1);
- if (!pXml)
- {
- if (pzErrMsg)
- *pzErrMsg = "UnzipString: malloc() failure.";
- free(pZip);
- return NULL;
- }
-
- /* Decompress the data into the XML string. */
- nXmlSize = nSize;
- zret = uncompress((unsigned char*)pXml, (unsigned long*)&nXmlSize, (const unsigned char*)pZip, nZipSize);
- if (zret != Z_OK)
- {
- if (pzErrMsg)
- *pzErrMsg = "UnzipString: uncompress() failure.";
- free(pZip);
- free(pXml);
- return NULL;
- }
- assert(nXmlSize == nSize);
-
- /* Terminate the string. */
- pXml[nXmlSize] = 0;
-
- /* Free the zipped data. */
- free(pZip);
-
- return pXml;
-}
-
-/*
-** Compress and encode string data to be stored in an sqlite database.
-** This does zip compression and sqlite binary encoding on the string.
-** <pXml> is the NUL-terminated xml string to be stored in the sqlite Files.Data field.
-** <nSize> is the uncompressed size of the xml string. Can be -1 to cause to compute it.
-** <pzErrMsg> points to a string pointer, to allow returning an error message.
-** This argument can be NULL. It should not be freed.
-** Return pointer to dynamically allocated encoded string.
-** Returns NULL on failure.
-*/
-char* ZipString(const char* pXml, long nXmlSize, const char **pzErrMsg)
-{
- unsigned long nZipSize, nZipMax, nDataSize, nDataMax, i;
- char *pZip, *pData;
- int zret;
-
- assert(pXml); if (!pXml) return NULL;
-
- /* Compute the size if necessary. */
- if (nXmlSize < 0)
- nXmlSize = strlen(pXml);
- assert((unsigned long)nXmlSize == strlen(pXml));
-
- /*
- ** Set up a buffer to hold the unencoded zip data.
- ** This data can contain NUL bytes.
- ** This can be larger than the XML data.
- */
- nZipMax = nXmlSize + nXmlSize/512 + 12;
- pZip = (char*)malloc(nZipMax);
- if (!pZip)
- {
- if (pzErrMsg)
- *pzErrMsg = "ZipString: malloc() failure.";
- return NULL;
- }
-
- /*
- ** Compress the xml data into the zip buffer.
- ** This returns the actual size in <nZipSize>.
- */
- nZipSize = nZipMax;
- zret = compress2((unsigned char*)pZip, &nZipSize, (const unsigned char*)pXml, nXmlSize, Z_BEST_COMPRESSION);
- if (zret != Z_OK)
- {
- if (pzErrMsg)
- *pzErrMsg = "ZipString: compress2() failure.";
- free (pZip);
- return NULL;
- }
- assert(nZipSize <= nZipMax);
-
- /*
- ** Allocate the buffer to hold the encoded binary data.
- ** This data will not contain NUL bytes.
- ** This buffer will generally be larger than the unencoded data.
- ** In general it will be smaller than the size allocated for the zipped data.
- */
- nDataMax = sqaux_encode_maxsize(nZipSize);
- pData = (char*)malloc(nDataMax+1);
- if (!pData)
- {
- if (pzErrMsg)
- *pzErrMsg = "ZipString: realloc() failure.";
- free(pZip);
- return NULL;
- }
-
- /*
- ** Encode the binary data to convert to a form safe to store in sqlite.
- ** This is done in place on the buffer holding the zipped data.
- ** The actual size of the encoded data string will be returned.
- */
- nDataSize = sqlite3_encode_binary((const unsigned char*)pZip, nZipSize, (unsigned char*)pData);
- assert(nDataSize <= nDataMax);
-
- free(pZip);
-
- /* Terminate the Data string. */
- pData[nDataSize] = 0;
-
- /* Return the data string. */
- return pData;
-}
-
-/*
-** Compress and binary encode a data string for storing in an sqlite database.
-** Returns NULL if the argument is NULL.
-** THIS IS AN SQLITE USER FUNCTION.
-**
-** argv[0] = data string
-*/
-void FnZipString( sqlite3_context *context, int argc, sqlite3_value **argv)
-{
- const char *pXml, *zErrMsg;
- char *pEncXml;
- long nSize;
-
- /* TODO: validate arguments. */
- assert(argc == 1 && argv);
-
- pXml = sqlite3_value_text(argv[0]);
-
- /* Handle NULL */
- if (pXml == NULL)
- {
- sqlite3_result_null(context);
- return;
- }
-
- nSize = strlen(pXml);
-
- /*
- ** If an error occurs, buffer[] will hold the error string.
- ** This error message doesn't have to be freed.
- */
- zErrMsg = NULL;
- pEncXml = ZipString(pXml, nSize, &zErrMsg);
- if (pEncXml)
- sqlite3_result_text(context, pEncXml, -1, SQLITE_STATIC);
- else
- sqlite3_result_error(context, zErrMsg, -1);
-
- free(pEncXml);
-}
-
-/*
-** Uncompress and binary decode a string compressed with [Fn]ZipString().
-** Returns NULL if the argument is NULL.
-** THIS IS AN SQLITE USER FUNCTION.
-**
-** argv[0] = compressed data string
-*/
-void FnUnzipString(sqlite3_context *context, int argc, sqlite3_value **argv)
-{
- const char *pZip, *zErrMsg;
- char *pData;
- long nZipSize;
-
- /* TODO: validate arguments. */
- assert(argc == 1 && argv);
-
- pZip = sqlite3_value_text(argv[0]);
-
- /* Handle NULL */
- if (pZip == NULL)
- {
- sqlite3_result_null(context);
- return;
- }
-
- nZipSize = strlen(pZip);
-
- /*
- ** If an error occurs, buffer[] will hold the error string.
- ** This error message doesn't have to be freed.
- */
- zErrMsg = NULL;
- pData = UnzipString(pZip, nZipSize, &zErrMsg);
- if (pData)
- sqlite3_result_text(context, pData, -1, SQLITE_STATIC);
- else
- sqlite3_result_error(context, zErrMsg, -1);
-
- free(pData);
-}
-
-
-/************************************************************************/
-
- /* SQLite invokes this routine once when it loads the extension.
- ** Create new functions, collating sequences, and virtual table
- ** modules here. This is usually the only exported symbol in
- ** the shared library.
- */
- int sqlite3_extension_init(
- sqlite3 *db,
- char **pzErrMsg,
- const sqlite3_api_routines *pApi
- ){
- SQLITE_EXTENSION_INIT2(pApi)
- sqlite3_create_function(db, "unzip", 1, SQLITE_ANY, 0, FnUnzipString, 0, 0);
- sqlite3_create_function(db, "zip", 1, SQLITE_ANY, 0, FnZipString, 0, 0);
- return 0;
- }
-
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/repo/RepoFileReader.cc
- *
-*/
-#include <iostream>
-#include "zypp/base/Logger.h"
-#include "zypp/base/InputStream.h"
-#include "zypp/base/UserRequestException.h"
-
-#include "zypp/parser/IniDict.h"
-#include "zypp2/parser/RepoFileReader.h"
-
-using std::endl;
-using zypp::parser::IniDict;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace parser
- { /////////////////////////////////////////////////////////////////
-
- /**
- * \short List of RepoInfo's from a file.
- * \param file pathname of the file to read.
- */
- static void repositories_in_file( const Pathname &file,
- const RepoFileReader::ProcessRepo &callback,
- const ProgressData::ReceiverFnc &progress )
- {
- InputStream is(file);
- parser::IniDict dict(is);
- for ( parser::IniDict::section_const_iterator its = dict.sectionsBegin();
- its != dict.sectionsEnd();
- ++its )
- {
- MIL << (*its) << endl;
-
- RepoInfo info;
- info.setAlias(*its);
-
- for ( IniDict::entry_const_iterator it = dict.entriesBegin(*its);
- it != dict.entriesEnd(*its);
- ++it )
- {
-
- //MIL << (*it).first << endl;
- if (it->first == "name" )
- info.setName(it-> second);
- else if ( it->first == "enabled" )
- info.setEnabled( it->second == "1" );
- else if ( it->first == "baseurl" )
- info.addBaseUrl( Url(it->second) );
- else if ( it->first == "type" )
- info.setType(repo::RepoType(it->second));
- }
-
- // add it to the list.
- callback(info);
- //if (!progress.tick())
- // ZYPP_THROW(AbortRequestException());
- }
- }
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : RepoFileReader
- //
- ///////////////////////////////////////////////////////////////////
-
- RepoFileReader::RepoFileReader( const Pathname & repo_file,
- const ProcessRepo & callback,
- const ProgressData::ReceiverFnc &progress )
- : _callback(callback)
- {
- repositories_in_file(repo_file, _callback, progress);
- //MIL << "Done" << endl;
- }
-
- RepoFileReader::~RepoFileReader()
- {}
-
- std::ostream & operator<<( std::ostream & str, const RepoFileReader & obj )
- {
- return str;
- }
-
- /////////////////////////////////////////////////////////////////
- } // namespace parser
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp2/repo/RepoFileReader.h
- *
-*/
-#ifndef ZYPP_REPO_REPOFILEREADER_H
-#define ZYPP_REPO_REPOFILEREADER_H
-
-#include <iosfwd>
-
-#include "zypp/base/PtrTypes.h"
-#include "zypp2/RepoInfo.h"
-#include "zypp/ProgressData.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace parser
- { /////////////////////////////////////////////////////////////////
-
- /**
- * \short Read repository data from a .repo file
- *
- * After each repo is read, a \ref RepoInfo is prepared and \ref _callback
- * is called with the object passed in.
- *
- * The \ref _callback is provided on construction.
- *
- * \code
- * RepoFileReader reader(repo_file,
- * bind( &SomeClass::callbackfunc, &SomeClassInstance, _1, _2 ) );
- * \endcode
- */
- class RepoFileReader
- {
- friend std::ostream & operator<<( std::ostream & str, const RepoFileReader & obj );
- public:
-
- /**
- * Callback definition.
- * First parameter is a \ref RepoInfo object with the resource
- * second parameter is the resource type.
- *
- * Return false from the callback to get a \ref AbortRequestException
- * to be thrown and the processing to be cancelled.
- */
- typedef function< bool( const RepoInfo & )> ProcessRepo;
-
- /** Implementation */
- class Impl;
-
- public:
- /**
- * \short Constructor. Creates the reader and start reading.
- *
- * \param repo_file A valid .repo file
- * \param callback Callback that will be called for each repository.
- * \param progress Optional progress function. \see ProgressData
- *
- * \throws AbortRequestException If the callback returns false
- * \throws Exception If a error occurs at reading / parsing
- *
- */
- RepoFileReader( const Pathname & repo_file,
- const ProcessRepo & callback,
- const ProgressData::ReceiverFnc &progress = ProgressData::ReceiverFnc() );
-
- /**
- * Dtor
- */
- ~RepoFileReader();
- private:
- ProcessRepo _callback;
- };
- ///////////////////////////////////////////////////////////////////
-
- /** \relates RepoFileReader Stream output */
- std::ostream & operator<<( std::ostream & str, const RepoFileReader & obj );
-
- /////////////////////////////////////////////////////////////////
- } // namespace parser
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_REPO_REPOFILEREADER_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp2/parser/susetags/RepoParser.cc
- *
-*/
-#include <iostream>
-#include "zypp/base/Logger.h"
-#include "zypp/base/Iterator.h"
-#include "zypp/base/String.h"
-
-#include "zypp2/parser/susetags/RepoParser.h"
-#include "zypp/parser/susetags/ContentFileReader.h"
-#include "zypp/parser/susetags/PackagesFileReader.h"
-#include "zypp/parser/susetags/PackagesLangFileReader.h"
-#include "zypp/parser/susetags/PatternFileReader.h"
-#include "zypp/parser/susetags/RepoIndex.h"
-#include "zypp/parser/ParseException.h"
-
-#include "zypp/ZConfig.h"
-
-using std::endl;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace parser
- { /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace susetags
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : RepoParser::Impl
- //
- /** RepoParser implementation.
- * \todo Clean data on exeption.
- */
- class RepoParser::Impl
- {
- public:
- Impl( const data::RecordId & repositoryId_r,
- data::ResolvableDataConsumer & consumer_r,
- const ProgressData::ReceiverFnc & fnc_r )
- : _repositoryId( repositoryId_r )
- , _consumer( consumer_r )
- {
- _ticks.sendTo( fnc_r );
- }
-
- /** Main entry to parser. */
- void parse( const Pathname & reporoot_r );
-
- /** \name FileReader callbacks delivering data. */
- //@{
- void consumeIndex( const RepoIndex_Ptr & data_r )
- {
- SEC << "[Index]" << data_r << endl;
- _repoIndex = data_r;
- }
-
- void consumeProd( const data::Product_Ptr & data_r )
- {
- SEC << "[Prod]" << data_r << endl;
- _prodData = data_r;
- _consumer.consumeProduct( _repositoryId, data_r );
- }
-
- void consumePkg( const data::Package_Ptr & data_r )
- {
- SEC << "[Package]" << data_r << endl;
- _consumer.consumePackage( _repositoryId, data_r );
- }
-
- void consumeSrcPkg( const data::SrcPackage_Ptr & data_r )
- {
- SEC << "[SrcPackage]" << data_r << endl;
- _consumer.consumeSourcePackage( _repositoryId, data_r );
- }
-
- void consumePat( const data::Pattern_Ptr & data_r )
- {
- SEC << "[Pattern]" << data_r << endl;
- _consumer.consumePattern( _repositoryId, data_r );
- }
- //@}
-
- public:
-
- bool isPatternFile( const std::string & name_r ) const
- {
- return( name_r.size() > 4 && name_r.substr( name_r.size() - 4 ) == ".pat" );
- }
-
- /** Test for \c packages.lang in \ref _repoIndex.*/
- bool haveLocale( const Locale & locale_r ) const
- {
- std::string searchFor( "packages." + locale_r.code() );
- for ( RepoIndex::FileChecksumMap::const_iterator it = _repoIndex->metaFileChecksums.begin();
- it != _repoIndex->metaFileChecksums.end(); ++it )
- {
- if ( it->first == searchFor )
- return true; // got it
- }
- return false; // not found
- }
-
- /** Take care translations for \a locale_r or an appropriate
- * fallback were parsed.
- */
- void parseLocaleIf( const Locale & locale_r )
- {
- Locale toParse( locale_r );
- bool alreadyParsed = false;
-
- while ( toParse != Locale::noCode )
- {
- alreadyParsed = ( _parsedLocales.find( toParse ) != _parsedLocales.end() );
- if ( alreadyParsed || haveLocale( toParse ) )
- break; // no return because we want to log in case of a fallback
- toParse = toParse.fallback();
- }
-
- if ( toParse != locale_r )
- {
- WAR << "Using fallback locale " << toParse << " for " << locale_r << endl;
- }
-
- if ( alreadyParsed )
- {
- return; // now return...
- }
-
- // ...or parse
- _parsedLocales.insert( toParse ); // don't try again.
-
- PackagesLangFileReader reader;
- reader.setLocale( toParse );
- reader.setPkgConsumer( bind( &Impl::consumePkg, this, _1 ) );
- reader.setSrcPkgConsumer( bind( &Impl::consumeSrcPkg, this, _1 ) );
- reader.parse( _descrdir / ("packages." + toParse.code()) );
-
- if ( ! _ticks.incr() )
- ZYPP_THROW( AbortRequestException() );
- }
-
- private:
- data::RecordId _repositoryId;
- data::ResolvableDataConsumer & _consumer;
- ProgressData _ticks;
-
- private: // these (and _ticks) are actually scoped per parse() run.
- RepoIndex_Ptr _repoIndex;
- data::Product_Ptr _prodData;
- Pathname _descrdir; // full path
- Pathname _datadir; // full path
-
- /** Translations processed by \ref parseLocaleIf so far.*/
- std::set<Locale> _parsedLocales;
- };
- ///////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : RepoParser::Impl::parse
- // METHOD TYPE : void
- //
- void RepoParser::Impl::parse( const Pathname & reporoot_r )
- {
- _prodData = 0;
- _repoIndex = 0;
- _descrdir = _datadir = Pathname();
- _parsedLocales.clear();
-
- // Content file first to get the repoindex
- {
- ContentFileReader content;
- content.setProductConsumer( bind( &Impl::consumeProd, this, _1 ) );
- content.setRepoIndexConsumer( bind( &Impl::consumeIndex, this, _1 ) );
- content.parse( reporoot_r / "content" );
- }
- if ( ! _repoIndex )
- {
- ZYPP_THROW( ParseException( reporoot_r.asString() + ": " + "No reository index in content file." ) );
- }
- DBG << _repoIndex << endl;
-
- // Prepare parsing
- _descrdir = reporoot_r / _repoIndex->descrdir;
- _datadir = reporoot_r / _repoIndex->datadir;
-
- _ticks.name( "Parsing susetags repo at " + reporoot_r.asString() );
- _ticks.range( _repoIndex->metaFileChecksums.size() );
- if ( ! _ticks.toMin() )
- ZYPP_THROW( AbortRequestException() );
-
- // Start with packages
- {
- PackagesFileReader reader;
- reader.setPkgConsumer( bind( &Impl::consumePkg, this, _1 ) );
- reader.setSrcPkgConsumer( bind( &Impl::consumeSrcPkg, this, _1 ) );
- reader.parse( _descrdir / "packages" );
- }
- if ( ! _ticks.incr() )
- ZYPP_THROW( AbortRequestException() );
-
- // Now process packages.lang
- // Always parse 'en'. For each wanted locale at least
- // some fallback, if locale is not present.
- parseLocaleIf( Locale("en") );
- parseLocaleIf( Locale("de_DE") );
- parseLocaleIf( ZConfig().defaultTextLocale() );
-
- // Now process the rest of RepoIndex
- for ( RepoIndex::FileChecksumMap::const_iterator it = _repoIndex->metaFileChecksums.begin();
- it != _repoIndex->metaFileChecksums.end(); ++it )
- {
- if ( isPatternFile( it->first ) )
- {
- PatternFileReader reader;
- reader.setConsumer( bind( &Impl::consumePat, this, _1 ) );
- reader.parse( _descrdir / it->first );
- }
-
- if ( ! _ticks.incr() )
- ZYPP_THROW( AbortRequestException() );
- }
-
- // Done
- if ( ! _ticks.toMax() )
- ZYPP_THROW( AbortRequestException() );
- }
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : RepoParser
- //
- ///////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : RepoParser::RepoParser
- // METHOD TYPE : Ctor
- //
- RepoParser::RepoParser( const data::RecordId & repositoryId_r,
- data::ResolvableDataConsumer & consumer_r,
- const ProgressData::ReceiverFnc & fnc_r )
- : _pimpl( new Impl( repositoryId_r, consumer_r, fnc_r ) )
- {}
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : RepoParser::~RepoParser
- // METHOD TYPE : Dtor
- //
- RepoParser::~RepoParser()
- {}
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : RepoParser::parse
- // METHOD TYPE : void
- //
- void RepoParser::parse( const Pathname & reporoot_r )
- {
- _pimpl->parse( reporoot_r );
- }
-
- /////////////////////////////////////////////////////////////////
- } // namespace susetags
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
- } // namespace parser
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp2/parser/susetags/RepoParser.h
- *
-*/
-#ifndef ZYPP2_PARSER_SUSETAGS_REPOPARSER_H
-#define ZYPP2_PARSER_SUSETAGS_REPOPARSER_H
-
-#include <iosfwd>
-
-#include "zypp/base/PtrTypes.h"
-#include "zypp/base/NonCopyable.h"
-
-#include "zypp/data/RecordId.h"
-#include "zypp/data/ResolvableDataConsumer.h"
-
-#include "zypp/ProgressData.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace parser
- { /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace susetags
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : RepoParser
- //
- /** SuseTags metadata parser.
- *
- * Reads a \c content file to get the \ref data::Product and a \Ref RepoIndex.
- * Then parses the remaining files and feeds them to a \ref data::ResolvableDataConsumer
- * (typically to store them in a database).
- *
- * \see \ref ContentFileReader and \ref FileReaderBase
- *
- * \code
- * Pathname dbdir( "store" );
- * Pathname reporoot( "lmd" );
- *
- * cache::CacheStore store( dbdir );
- * data::RecordId catalogId = store.lookupOrAppendRepository( Url("dir:///somewhere"), "/" );
- *
- * parser::susetags::RepoParser repo( catalogId, store );
- * repo.parse( reporoot );
- *
- * store.commit();
- * \endcode
- *
- * \todo Improve selection of Languages to parse
- * \todo Improve feeding of translations into Cachestore. Add specialized consumer, for Du too.
- * \todo DiskUsage filereader and parsing
- * \todo more doc and Exception specification
- */
- class RepoParser : private base::NonCopyable
- {
- public:
- /** Ctor.
- *
- * \param repositoryId_r repository identifier
- * \param consumer_r consumer of parsed data
- * \param fnc_r progress reporting function
- */
- RepoParser( const data::RecordId & repositoryId_r,
- data::ResolvableDataConsumer & consumer_r,
- const ProgressData::ReceiverFnc & fnc_r = ProgressData::ReceiverFnc() );
- /** Dtor */
- ~RepoParser();
-
- /** Parse a local repository located at \a reporoot_r.
- *
- * \param reporoot_r The local repositories root directory.
- * \throw Exception on errors.
- */
- void parse( const Pathname & reporoot_r );
-
- public:
- class Impl;
- private:
- RW_pointer<Impl,rw_pointer::Scoped<Impl> > _pimpl;
- };
- ///////////////////////////////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////
- } // namespace susetags
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
- } // namespace parser
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP2_PARSER_SUSETAGS_REPOPARSER_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/repo/RepoException.cc
- *
-*/
-#include <iostream>
-//#include "zypp/base/Logger.h"
-#include "zypp2/repo/RepoException.h"
-
-using std::endl;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace repo
- { /////////////////////////////////////////////////////////////////
-
- RepoException::RepoException()
- : Exception( "Repo exception" )
- {}
-
- RepoException::RepoException( const std::string & msg_r )
- : Exception( msg_r )
- {}
-
- RepoException::~RepoException() throw()
- {}
-
- RepoNotCachedException::RepoNotCachedException()
- : RepoException( "Repository not Cached" )
- {}
-
- RepoNotCachedException::RepoNotCachedException( const std::string & msg_r )
- : RepoException( msg_r )
- {}
-
- RepoNotCachedException::~RepoNotCachedException() throw()
- {}
-
-
- std::ostream & RepoException::dumpOn( std::ostream & str ) const
- {
- return Exception::dumpOn( str );
- }
-
- /////////////////////////////////////////////////////////////////
- } // namespace repo
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/parser/tagfile/RepoException.h
- *
-*/
-#ifndef ZYPP_REPO_REPOEXCEPTION_H
-#define ZYPP_REPO_REPOEXCEPTION_H
-
-#include <iosfwd>
-#include <string>
-
-#include "zypp/base/Exception.h"
-#include "zypp/base/UserRequestException.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace repo
- { /////////////////////////////////////////////////////////////////
-
- /**
- * \short Exception for repository handling.
- */
- class RepoException : public Exception
- {
- public:
- /** Default ctor */
- RepoException();
- /** Ctor */
- RepoException( const std::string & msg_r );
- /** Dtor */
- virtual ~RepoException() throw();
- protected:
- virtual std::ostream & dumpOn( std::ostream & str ) const;
- };
- ///////////////////////////////////////////////////////////////////
-
- /**
- * The repository cache is not built yet
- * so you can't create the repostories from
- * the cache.
- */
- class RepoNotCachedException : public RepoException
- {
- public:
- RepoNotCachedException();
- RepoNotCachedException( const std::string & msg_r );
- virtual ~RepoNotCachedException() throw();
- };
-
- /**
- * thrown when it was impossible to
- * determine one url for this repo.
- */
- class RepoNoUrlException : public RepoException
- {
-
- };
-
- /**
- * thrown when it was impossible to
- * determine an alias for this repo.
- */
- class RepoNoAliasException : public RepoException
- {
-
- };
-
- /**
- * thrown when it was impossible to
- * match a repository
- */
- class RepoNotFoundException : public RepoException
- {
-
- };
-
- /**
- * Repository already exists and some unique
- * attribute can't be duplicated.
- */
- class RepoAlreadyExistsException : public RepoException
- {
-
- };
-
- /**
- * thrown when it was impossible to
- * determine an alias for this repo.
- */
- class RepoUnknownTypeException : public RepoException
- {
-
- };
-
- /////////////////////////////////////////////////////////////////
- } // namespace parser
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_PARSER_TAGFILE_PARSEEXCEPTION_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#include <map>
-#include "zypp/base/Exception.h"
-#include "RepoType.h"
-
-namespace zypp
-{
-namespace repo
-{
-
- static std::map<std::string,RepoType::Type> _table;
-
- const RepoType RepoType::RPMMD(RepoType::RPMMD_e);
- const RepoType RepoType::YAST2(RepoType::YAST2_e);
- //const RepoType RepoType::NONE(RepoType::NONE_e);
-
- RepoType::RepoType(const std::string & strval_r)
- : _type(parse(strval_r))
- {}
-
- RepoType::Type RepoType::parse(const std::string & strval_r)
- {
- if (_table.empty())
- {
- // initialize it
- _table["repomd"] = RepoType::RPMMD_e;
- _table["rpmmd"] = RepoType::RPMMD_e;
- _table["rpm-md"] = RepoType::RPMMD_e;
- _table["yum"] = RepoType::RPMMD_e;
- _table["susetags"] = RepoType::YAST2_e;
- _table["yast"] = RepoType::YAST2_e;
- _table["yast2"] = RepoType::YAST2_e;
- _table["NONE"] = _table["none"] = RepoType::NONE_e;
- }
-
- std::map<std::string,RepoType::Type>::const_iterator it
- = _table.find(strval_r);
- if (it == _table.end())
- {
- ZYPP_THROW(Exception(
- "RepoType parse: illegal string value '" + strval_r + "'"));
- }
- return it->second;
- }
-
-
- const std::string & RepoType::asString() const
- {
- static std::map<Type, std::string> _table;
- if ( _table.empty() )
- {
- // initialize it
- _table[RPMMD_e] = "rpm-md";
- _table[YAST2_e] = "yast2";
- _table[NONE_e] = "NONE";
- }
- return _table[_type];
- }
-
-
- } // ns repo
-} // ns zypp
-
-// vim: set ts=2 sts=2 sw=2 et ai:
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#ifndef ZYPP_REPO_TYPE_H_
-#define ZYPP_REPO_TYPE_H_
-
-#include <iosfwd>
-#include<string>
-
-namespace zypp
-{
- namespace repo
- {
-
- /**
- * \short Repository type enumeration
- *
- * Repositories can be from varous types
- * ...
- */
- struct RepoType
- {
- static const RepoType RPMMD;
- static const RepoType YAST2;
- //static const RepoType NONE;
-
- enum Type
- {
- NONE_e,
- RPMMD_e,
- YAST2_e
- };
-
- RepoType(Type type) : _type(type) {}
-
- explicit RepoType(const std::string & strval_r);
-
- const Type toEnum() const { return _type; }
-
- RepoType::Type parse(const std::string & strval_r);
-
- const std::string & asString() const;
-
- Type _type;
- };
-
-
- inline std::ostream & operator<<( std::ostream & str, const RepoType & obj )
- { return str << obj.asString(); }
-
- inline bool operator==(const RepoType & obj1, const RepoType & obj2)
- { return obj1._type == obj2._type; }
-
-
- } // ns repo
-} // ns zypp
-
-#endif
-
-// vim: set ts=2 sts=2 sw=2 et ai:
+++ /dev/null
-
-#include "zypp2/repo/RepositoryImpl.h"
-
-namespace zypp { namespace repo {
-
-IMPL_PTR_TYPE(RepositoryImpl)
-
-RepositoryImpl::RepositoryImpl( const RepoInfo &info )
- : _info(info)
-{
-
-}
-
-const RepoInfo RepositoryImpl::info() const
-{
- return _info;
-}
-
-RepositoryImpl::~RepositoryImpl()
-{
-
-}
-
-RepositoryImpl::RepositoryImpl( const null & )
- : base::ProvideNumericId<RepositoryImpl,Repository::NumericId>( NULL )
-{}
-
-
-const ResStore & RepositoryImpl::resolvables() const
-{
- return _store;
-}
-
-} } // ns
-
+++ /dev/null
-
-
-#ifndef ZYPP_REPOSITORY_IMPL_h
-#define ZYPP_REPOSITORY_IMPL_h
-
-#include <iosfwd>
-#include <string>
-
-#include "zypp/base/ReferenceCounted.h"
-#include "zypp/base/NonCopyable.h"
-#include "zypp/base/PtrTypes.h"
-#include "zypp/base/ProvideNumericId.h"
-#include "zypp/ResStore.h"
-#include "zypp2/Repository.h"
-#include "zypp2/RepoInfo.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace repo
- { /////////////////////////////////////////////////////////////////
-
- DEFINE_PTR_TYPE(RepositoryImpl);
-
- class RepositoryImpl : public base::ReferenceCounted,
- public base::ProvideNumericId<RepositoryImpl,Repository::NumericId>,
- private base::NonCopyable
- {
- friend std::ostream & operator<<( std::ostream & str, const RepositoryImpl & obj );
- public:
-
- /**
- * \short Ctor.
- * \param info What is known about this source at construction time.
- *
- */
- RepositoryImpl( const RepoInfo &info = RepoInfo() );
-
- /**
- * \short Information about this repository
- * You can't change this information after creation.
- * Use \ref RepoManager for that.
- */
- const RepoInfo info() const;
-
- /**
- * \short Dtor
- */
- ~RepositoryImpl();
-
- const ResStore & resolvables() const;
-
- struct null {};
- public:
- /** Offer default Impl. */
- static RepositoryImpl_Ptr nullimpl()
- {
- static RepositoryImpl_Ptr _nullimpl( new RepositoryImpl( null() ) );
- return _nullimpl;
- }
-
- RepositoryImpl( const null & );
-
- Repository selfRepository()
- { return Repository( this ); }
- protected:
- RepoInfo _info;
-
- ResStore _store;
- };
- }
-}
-
-#endif
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zmd/backend/dbrepository/PackageImpl.h
- *
-*/
-
-#include "zypp/TranslatedText.h"
-#include "zypp/base/String.h"
-#include "zypp/base/Logger.h"
-#include "zypp2/repo/RepositoryImpl.h"
-#include "PackageImpl.h"
-
-
-using namespace std;
-using namespace zypp::detail;
-using namespace::zypp::repo;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp { namespace repo { namespace cached {
-
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : PackageImpl
-//
-///////////////////////////////////////////////////////////////////
-
-/** Default ctor
-*/
-PackageImpl::PackageImpl (const data::RecordId &id, cached::RepoImpl::Ptr repository_r)
- : _repository (repository_r)
- , _install_only(false)
- , _size_installed(0)
- , _size_archive(0)
- , _data_loaded(false)
- , _id(id)
-{}
-
-Repository
-PackageImpl::repository() const
-{
- return _repository->selfRepository();
-}
-
-/** Package summary */
-TranslatedText PackageImpl::summary() const
-{
- return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "summary" );
-}
-
-/** Package description */
-TranslatedText PackageImpl::description() const
-{
- return _repository->resolvableQuery().queryTranslatedStringAttribute( _id, "ResObject", "description" );
-}
-
-PackageGroup PackageImpl::group() const
-{
- return _repository->resolvableQuery().queryStringAttribute( _id, "Package", "group" );
-}
-
-Pathname PackageImpl::location() const
-{
- return _repository->resolvableQuery().queryStringAttribute( _id, "Package", "group" );
-}
-
-ByteCount PackageImpl::size() const
-{
- return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "size" );
-}
-
-/** */
-ByteCount PackageImpl::archivesize() const
-{
- return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "archivesize" );
-}
-
-bool PackageImpl::installOnly() const
-{
- return _repository->resolvableQuery().queryBooleanAttribute( _id, "ResObject", "installOnly" );
-}
-
-unsigned PackageImpl::repositoryMediaNr() const
-{
- return _repository->resolvableQuery().queryNumericAttribute( _id, "ResObject", "repositoryMediaNr" );
-}
-
-Vendor PackageImpl::vendor() const
-{
- return "suse";
-}
-
-/////////////////////////////////////////////////////////////////
-} } } // namespace zypp::repo::cached
-///////////////////////////////////////////////////////////////////
-
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#ifndef zypp_repo_cached_PackageImpl_H
-#define zypp_repo_cached_PackageImpl_H
-
-#include "zypp/detail/PackageImpl.h"
-#include "zypp2/repo/cached/RepoImpl.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-namespace repo
-{ /////////////////////////////////////////////////////////////////
-namespace cached
-{ /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : PackageImpl
- //
- class PackageImpl : public detail::PackageImplIf
- {
- public:
-
- PackageImpl( const data::RecordId &id, repo::cached::RepoImpl::Ptr repository_r );
-
- virtual TranslatedText summary() const;
- virtual TranslatedText description() const;
- virtual ByteCount size() const;
- virtual PackageGroup group() const;
- virtual ByteCount archivesize() const;
- virtual Pathname location() const;
- virtual bool installOnly() const;
- virtual Repository repository() const;
- virtual unsigned repositoryMediaNr() const;
- virtual Vendor vendor() const;
-
- protected:
- repo::cached::RepoImpl::Ptr _repository;
- TranslatedText _summary;
- TranslatedText _description;
- PackageGroup _group;
- Pathname _location;
- bool _install_only;
- unsigned _media_nr;
-
- ByteCount _size_installed;
- ByteCount _size_archive;
-
- bool _data_loaded;
- data::RecordId _id;
- };
- /////////////////////////////////////////////////////////////////
-} // namespace cached
-} // namespace repository
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZMD_BACKEND_DBSOURCE_DBPACKAGEIMPL_H
-
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#include <iostream>
-#include <map>
-
-#include "zypp/base/Logger.h"
-#include "zypp/base/Measure.h"
-#include "zypp/capability/Capabilities.h"
-#include "zypp2/cache/ResolvableQuery.h"
-#include "zypp/detail/ResImplTraits.h"
-#include "zypp/CapFactory.h"
-
-#include "zypp2/repo/cached/RepoImpl.h"
-#include "zypp2/repo/cached/PackageImpl.h"
-
-
-using namespace zypp::detail;
-using namespace zypp::cache;
-using namespace std;
-using namespace sqlite3x;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace repo
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
-namespace cached
-{ /////////////////////////////////////////////////////////////////
-
-RepoImpl::RepoImpl( const RepoInfo &repoinfo, const Pathname &dbdir, const data::RecordId &repository_id )
- : RepositoryImpl(repoinfo),
- _dbdir(dbdir),
- _type_cache(dbdir),
- _repository_id(repository_id),
- _rquery(dbdir)
-{
-
-}
-
-RepoImpl::~RepoImpl()
-{
-
-}
-
-
-void RepoImpl::factoryInit()
-{
- MIL << "Plaindir repository initialized." << std::endl;
-}
-
-void read_capabilities( sqlite3_connection &con, map<data::RecordId, NVRAD> &nvras );
-
-
-void RepoImpl::createResolvables()
-{
- debug::Measure m("create resolvables");
- CapFactory capfactory;
- try
- {
- sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
- con.executenonquery("PRAGMA cache_size=8000;");
- con.executenonquery("BEGIN;");
-
- sqlite3_command cmd( con, "select id,name,version,release,epoch,arch,kind from resolvables where repository_id=:repository_id;");
- cmd.bind(":repository_id", _repository_id);
- map<data::RecordId, NVRAD> nvras;
-
- sqlite3_reader reader = cmd.executereader();
- while(reader.read())
- {
- long long id = reader.getint64(0);
- Dependencies deps;
-
- // Collect basic Resolvable data
- nvras[id] = NVRAD( reader.getstring(1),
- Edition( reader.getstring(2), reader.getstring(3), reader.getint(4) ),
- _type_cache.archFor(reader.getint(5)),
- deps
- );
- }
-
- MIL << "Done reading resolvables nvra" << endl;
-
- read_capabilities( con, nvras);
-
- for ( map<data::RecordId, NVRAD>::const_iterator it = nvras.begin(); it != nvras.end(); ++it )
- {
- ResImplTraits<cached::PackageImpl>::Ptr impl = new cached::PackageImpl(it->first, this);
- Package::Ptr package = detail::makeResolvableFromImpl( it->second, impl );
- _store.insert (package);
- }
- con.executenonquery("COMMIT;");
- }
- catch(exception &ex) {
- cerr << "Exception Occured: " << ex.what() << endl;
- }
- //extract_packages_from_directory( _store, thePath, selfRepositoryRef(), true );
-
-}
-
-
-ResolvableQuery RepoImpl::resolvableQuery()
-{
- return _rquery;
-}
-
-void RepoImpl::read_capabilities( sqlite3_connection &con, map<data::RecordId, NVRAD> &nvras )
-{
- CapFactory capfactory;
-
-
- // precompile statements
-
-
-
-// map<data::RecordId, capability::CapabilityImpl::Ptr> named_caps;
-// sqlite3_command select_named_cmd( con, "select v.id, c.refers_kind, n.name, v.version, v.release, v.epoch, v.relation named_capabilities v, capabilities c, names n where v.name_id=n.id and c.id=ncc.capability_id and ncc.named_capability_id=v.id;");
-// {
-// debug::Measure mnc("read named capabilities");
-// sqlite3_reader reader = select_named_cmd.executereader();
-// while ( reader.read() )
-// {
-//
-// }
-// }
- sqlite3_command select_named_cmd( con, "select v.refers_kind, n.name, v.version, v.release, v.epoch, v.relation, v.dependency_type, v.resolvable_id from named_capabilities v, names n where v.name_id=n.id;");
- sqlite3_command select_file_cmd( con, "select fc.refers_kind, dn.name, fn.name, fc.dependency_type, fc.resolvable_id from file_capabilities fc, files f, dir_names dn, file_names fn where f.id=fc.file_id and f.dir_name_id=dn.id and f.file_name_id=fn.id;");
-
- {
- debug::Measure mnc("read named capabilities");
- sqlite3_reader reader = select_named_cmd.executereader();
- while ( reader.read() )
- {
-
- Resolvable::Kind refer = _type_cache.kindFor(reader.getint(0));
- Rel rel = _type_cache.relationFor(reader.getint(5));
-
- data::RecordId rid = reader.getint64(7);
-
- if ( rel == zypp::Rel::NONE )
- {
- capability::NamedCap *ncap = new capability::NamedCap( refer, reader.getstring(1) );
- zypp::Dep deptype = _type_cache.deptypeFor(reader.getint(6));
- nvras[rid][deptype].insert( capfactory.fromImpl( capability::CapabilityImpl::Ptr(ncap) ) );
- }
- else
- {
- capability::VersionedCap *vcap = new capability::VersionedCap( refer, reader.getstring(1), /* rel */ rel, Edition( reader.getstring(2), reader.getstring(3), reader.getint(4) ) );
- zypp::Dep deptype = _type_cache.deptypeFor(reader.getint(6));
- nvras[rid][deptype].insert( capfactory.fromImpl( capability::CapabilityImpl::Ptr(vcap) ) );
- }
- }
- }
-
- {
- debug::Measure mnf("read file capabilities");
- sqlite3_reader reader = select_file_cmd.executereader();
- while ( reader.read() )
- {
- Resolvable::Kind refer = _type_cache.kindFor(reader.getint(0));
- capability::FileCap *fcap = new capability::FileCap( refer, reader.getstring(1) + "/" + reader.getstring(2) );
- zypp::Dep deptype = _type_cache.deptypeFor(reader.getint(3));
- data::RecordId rid = reader.getint64(4);
- nvras[rid][deptype].insert( capfactory.fromImpl( capability::CapabilityImpl::Ptr(fcap) ) );
- }
- }
-
- MIL << nvras.size() << " capabilities" << endl;
-}
-
-
-/////////////////////////////////////////////////////////////////
-} // namespace plaindir
-///////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-} // namespace repository
-///////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#ifndef ZYPP_RepoImpl_H
-#define ZYPP_RepoImpl_H
-
-#include <iosfwd>
-#include <map>
-#include "zypp/Arch.h"
-#include "zypp/Rel.h"
-#include "zypp/Pathname.h"
-#include "zypp/data/RecordId.h"
-#include "zypp2/repo/RepositoryImpl.h"
-#include "zypp/ResStore.h"
-#include "zypp2/cache/sqlite3x/sqlite3x.hpp"
-#include "zypp2/cache/CacheTypes.h"
-#include "zypp2/cache/ResolvableQuery.h"
-#include "zypp2/RepoInfo.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace repo
- { /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace cached
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : RepoImpl
- //
- /** */
- class RepoImpl : public repo::RepositoryImpl
- {
- public:
- typedef intrusive_ptr<RepoImpl> Ptr;
- typedef intrusive_ptr<const RepoImpl> constPtr;
-
- public:
- /** Default ctor */
- RepoImpl( const RepoInfo &repoinfo, const Pathname &dbdir, const data::RecordId &repository_id );
- /** Dtor */
- ~RepoImpl();
- void factoryInit();
- public:
-
- cache::ResolvableQuery resolvableQuery();
- void createResolvables();
-
- protected:
- void read_capabilities( sqlite3x::sqlite3_connection &con, std::map<data::RecordId, NVRAD> &nvras );
- Pathname _dbdir;
- cache::CacheTypes _type_cache;
- data::RecordId _repository_id;
-
- cache::ResolvableQuery _rquery;
- };
- ///////////////////////////////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////
- } // namespace cached
- ///////////////////////////////////////////////////////////////////
-
- using cached::RepoImpl;
-
- /////////////////////////////////////////////////////////////////
- } // namespace source
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOURCE_PLAINDIR_PLAINDIRIMPL_H
-
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zmd/backend/dbsource/SrcPackageImpl.h
- *
-*/
-
-#include "SrcPackageImpl.h"
-#include "zypp/source/SourceImpl.h"
-#include "zypp/TranslatedText.h"
-#include "zypp/base/String.h"
-#include "zypp/base/Logger.h"
-
-using namespace std;
-using namespace zypp::detail;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp { namespace repo { namespace cached {
-
-///////////////////////////////////////////////////////////////////
-//
-// CLASS NAME : SrcPackageImpl
-//
-///////////////////////////////////////////////////////////////////
-
-/** Default ctor
-*/
-SrcPackageImpl::SrcPackageImpl (Source_Ref source_r)
- : _source (source_r)
- , _install_only(false)
- , _size_installed(0)
- , _size_archive(0)
- , _data_loaded(false)
-{}
-
-Source_Ref
-SrcPackageImpl::source() const
-{
- return _source;
-}
-
-/** Package summary */
-TranslatedText SrcPackageImpl::summary() const
-{
- return _summary;
-}
-
-/** Package description */
-TranslatedText SrcPackageImpl::description() const
-{
- return _description;
-}
-
-PackageGroup SrcPackageImpl::group() const
-{
- return _group;
-}
-
-Pathname SrcPackageImpl::location() const
-{
- return _location;
-}
-
-ByteCount SrcPackageImpl::size() const
-{
- return _size_installed;
-}
-
-/** */
-ByteCount SrcPackageImpl::archivesize() const
-{
- return _size_archive;
-}
-
-bool SrcPackageImpl::installOnly() const
-{
- return _install_only;
-}
-
-unsigned SrcPackageImpl::sourceMediaNr() const
-{
- return _media_nr;
-}
-
-Vendor SrcPackageImpl::vendor() const
-{
- return "suse";
-}
-
-/////////////////////////////////////////////////////////////////
-} } } // namespace zypp.repo.cached
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-
-#ifndef CachedRepoSrcPackageImpl_H
-#define CachedRepoSrcPackageImpl_H
-
-#include "zypp/detail/PackageImpl.h"
-#include "zypp/Source.h"
-//#include <sqlite3.h>
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-namespace repo
-{
-namespace cached
-{
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : CachedSourcePackageImpl
- //
- class SrcPackageImpl : public detail::SrcPackageImplIf
- {
- public:
-
- SrcPackageImpl( Source_Ref source_r );
-
- virtual TranslatedText summary() const;
- virtual TranslatedText description() const;
- virtual ByteCount size() const;
- virtual PackageGroup group() const;
- virtual ByteCount archivesize() const;
- virtual Pathname location() const;
- virtual bool installOnly() const;
- virtual Source_Ref source() const;
- virtual unsigned sourceMediaNr() const;
- virtual Vendor vendor() const;
-
- protected:
- Source_Ref _source;
- TranslatedText _summary;
- TranslatedText _description;
- PackageGroup _group;
- Pathname _location;
- bool _install_only;
- unsigned _media_nr;
-
- ByteCount _size_installed;
- ByteCount _size_archive;
-
- bool _data_loaded;
- };
- /////////////////////////////////////////////////////////////////
-} // ns cached
-} // ns repo
-} // namespace zypp
-
-///////////////////////////////////////////////////////////////////
-#endif // ZMD_BACKEND_DBSOURCE_DBPACKAGEIMPL_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/repo/memory/PackageImpl.cc
- *
-*/
-
-#include "zypp2/repo/memory/PackageImpl.h"
-
-using namespace std;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace repo
-{ /////////////////////////////////////////////////////////////////
-namespace memory
-{ /////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-//
-// METHOD NAME : PackageImpl::PackageImpl
-// METHOD TYPE : Ctor
-//
-PackageImpl::PackageImpl(data::Package_Ptr ptr)
- :
- _summary(ptr->summary),
- _description(ptr->description),
- _insnotify(ptr->insnotify),
- _delnotify(ptr->delnotify),
- _license_to_confirm(ptr->licenseToConfirm),
- _group(ptr->group),
- _keywords(),
- _authors(ptr->authors),
- _size(ptr->installedSize),
- _archivesize(ptr->repositoryLocation.fileSize),
- _vendor(ptr->vendor),
- _license(ptr->license),
- _buildtime(ptr->buildTime),
- _media_number(ptr->repositoryLocation.mediaNr),
- _location(ptr->repositoryLocation.filePath),
- _diskusage(),
- _checksum(ptr->repositoryLocation.fileChecksum)
-{
-}
-
-///////////////////////////////////////////////////////////////////
-//
-// METHOD NAME : PackageImpl::~PackageImpl
-// METHOD TYPE : Dtor
-//
-PackageImpl::~PackageImpl()
-{}
-
-TranslatedText PackageImpl::summary() const
-{
- return _summary;
-}
-
-TranslatedText PackageImpl::description() const
-{
- return _description;
-}
-
-TranslatedText PackageImpl::insnotify() const
-{
- return _insnotify;
-}
-
-TranslatedText PackageImpl::delnotify() const
-{
- return _delnotify;
-}
-
-TranslatedText PackageImpl::licenseToConfirm() const
-{
- return _license_to_confirm;
-}
-
-Source_Ref PackageImpl::source() const
-{
- return Source_Ref::noSource;
-}
-
-unsigned PackageImpl::sourceMediaNr() const
-{
- return _media_number;
-}
-
-CheckSum PackageImpl::checksum() const
-{
- return _checksum;
-}
-
-Date PackageImpl::buildtime() const
-{
- return _buildtime;
-}
-
-string PackageImpl::buildhost() const
-{
- return string();
-}
-
-Date PackageImpl::installtime() const
-{
- return Date();
-} // it was never installed
-
-string PackageImpl::distribution() const
-{
- return string();
-}
-
-Vendor PackageImpl::vendor() const
-{
- return string();
-}
-
-Label PackageImpl::license() const
-{
- return _license;
-}
-
-string PackageImpl::packager() const
-{
- return string();
-}
-
-PackageGroup PackageImpl::group() const
-{
- return _group;
-}
-
-PackageImpl::Keywords PackageImpl::keywords() const
-{
- return _keywords;
-}
-
-Changelog PackageImpl::changelog() const
-{
- return Changelog();
-}
-
-Pathname PackageImpl::location() const
-{
- return _location;
-}
-
-string PackageImpl::url() const
-{
- return string();
-}
-
-string PackageImpl::os() const
-{
- return string();
-}
-
-Text PackageImpl::prein() const
-{
- return Text();
-}
-
-Text PackageImpl::postin() const
-{
- return Text();
-}
-
-Text PackageImpl::preun() const
-{
- return Text();
-}
-
-Text PackageImpl::postun() const
-{
- return Text();
-}
-
-ByteCount PackageImpl::size() const
-{
- return _size;
-}
-
-ByteCount PackageImpl::sourcesize() const
-// FIXME
-{
- return 0;
-}
-
-ByteCount PackageImpl::archivesize() const
-{
- return _archivesize;
-}
-
-DiskUsage PackageImpl::diskusage() const
-{
- return _diskusage;
-}
-
-list<string> PackageImpl::authors() const
-{
- return list<string>();
-}
-
-list<string> PackageImpl::filenames() const
-{
- return list<string>();
-}
-
-list<detail::PackageImplIf::DeltaRpm> PackageImpl::deltaRpms() const
-{
- return detail::PackageImplIf::deltaRpms();
-}
-
-list<detail::PackageImplIf::PatchRpm> PackageImpl::patchRpms() const
-{
- return detail::PackageImplIf::patchRpms();
-}
-
-bool PackageImpl::installOnly() const
-{
- return false;
-}
-
-/////////////////////////////////////////////////////////////////
-} // namespace memory
-///////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-} // namespace
-///////////////////////////////////////////////////////////////////
-
-/////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp/repo/memory/PackageImpl.h
- *
-*/
-#ifndef ZYPP_SOURCE_MEMORYPACKAGEIMPL_H
-#define ZYPP_SOURCE_MEMORYPACKAGEIMPL_H
-
-#include "zypp/detail/PackageImplIf.h"
-#include "zypp/Source.h"
-#include "zypp/data/ResolvableData.h"
-#include "zypp/DiskUsage.h"
-#include "zypp/CheckSum.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace repo
- { /////////////////////////////////////////////////////////////////
- namespace memory
- { /////////////////////////////////////////////////////////////////
-
- DEFINE_PTR_TYPE(DImpl);
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : PackageImpl
- //
- /**
- */
- struct PackageImpl : public zypp::detail::PackageImplIf
- {
- PackageImpl( data::Package_Ptr ptr );
- virtual ~PackageImpl();
-
- /** \name ResObject attributes. */
- //@{
- virtual TranslatedText summary() const;
- virtual TranslatedText description() const;
- virtual TranslatedText insnotify() const;
- virtual TranslatedText delnotify() const;
- virtual TranslatedText licenseToConfirm() const;
- virtual Source_Ref source() const;
- virtual unsigned sourceMediaNr() const;
- //@}
-
- virtual CheckSum checksum() const;
- virtual Date buildtime() const;
- virtual std::string buildhost() const;
- virtual Date installtime() const;
- virtual std::string distribution() const;
- virtual Vendor vendor() const;
- virtual Label license() const;
- virtual std::string packager() const;
- virtual PackageGroup group() const;
- virtual Keywords keywords() const;
- virtual Changelog changelog() const;
- virtual Pathname location() const;
- virtual std::string url() const;
- virtual std::string os() const;
- virtual Text prein() const;
- virtual Text postin() const;
- virtual Text preun() const;
- virtual Text postun() const;
- virtual ByteCount size() const;
- virtual ByteCount sourcesize() const;
- virtual ByteCount archivesize() const;
- virtual DiskUsage diskusage() const;
- virtual std::list<std::string> authors() const;
- virtual std::list<std::string> filenames() const;
- virtual std::list<DeltaRpm> deltaRpms() const;
- virtual std::list<PatchRpm> patchRpms() const;
- virtual bool installOnly() const;
-
- TranslatedText _summary;
- TranslatedText _description;
- TranslatedText _insnotify;
- TranslatedText _delnotify;
- TranslatedText _license_to_confirm;
-
- PackageGroup _group;
- Keywords _keywords;
- std::list<std::string> _authors;
- ByteCount _size;
- ByteCount _archivesize;
- Vendor _vendor;
- Label _license;
- Date _buildtime;
- unsigned _media_number;
- Pathname _location;
- DiskUsage _diskusage;
- CheckSum _checksum;
-private:
- };
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
- } // namespace memory
- /////////////////////////////////////////////////////////////////
- } // namespace repository
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_DETAIL_PACKAGEIMPL_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp2/repository/memory/PatternImpl.cc
- *
-*/
-#include "zypp2/repo/memory/PatternImpl.h"
-
-using namespace std;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace repo
-{ /////////////////////////////////////////////////////////////////
-namespace memory
-{
-///////////////////////////////////////////////////////////////////
-//
-// METHOD NAME : PatternImpl::PatternImpl
-// METHOD TYPE : Ctor
-//
-PatternImpl::PatternImpl(data::Pattern_Ptr ptr)
-{}
-
-///////////////////////////////////////////////////////////////////
-//
-// METHOD NAME : PatternImpl::~PatternImpl
-// METHOD TYPE : Dtor
-//
-PatternImpl::~PatternImpl()
-{}
-
-Source_Ref PatternImpl::source() const
-{
- return Source_Ref::noSource;
-}
-
-TranslatedText PatternImpl::summary() const
-{
- return _summary;
-}
-
-TranslatedText PatternImpl::description() const
-{
- return _description;
-}
-
-TranslatedText PatternImpl::category() const
-{
- return _category;
-}
-
-bool PatternImpl::userVisible() const
-{
- return _visible;
-}
-
-Label PatternImpl::order() const
-{
- return _order;
-}
-
-Pathname PatternImpl::icon() const
-{
- return _icon;
-}
-
-/////////////////////////////////////////////////////////////////
-} // namespace detail
-///////////////////////////////////////////////////////////////////
-}
-/////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp2/repository/memory/PatternImpl.h
- *
-*/
-#ifndef ZYPP_DETAIL_MEMORY_PATTERNIMPL_H
-#define ZYPP_DETAIL_MEMORY_PATTERNIMPL_H
-
-#include "zypp/detail/PatternImplIf.h"
-#include "zypp/data/ResolvableData.h"
-#include "zypp/Source.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace repo
- { /////////////////////////////////////////////////////////////////
- namespace memory
- {
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : PatternImpl
- //
- /**
- */
- struct PatternImpl : public zypp::detail::PatternImplIf
- {
-public:
- PatternImpl(data::Pattern_Ptr ptr);
- virtual ~PatternImpl();
-
- virtual TranslatedText summary() const;
- virtual TranslatedText description() const;
- virtual TranslatedText category() const;
- virtual bool userVisible() const;
- virtual Label order() const;
- virtual Pathname icon() const;
- virtual Source_Ref source() const;
-
- TranslatedText _summary;
- TranslatedText _description;
- TranslatedText _category;
- bool _visible;
- std::string _order;
- Pathname _icon;
- };
- ///////////////////////////////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////
- } // namespace memory
- ///////////////////////////////////////////////////////////////////
- } // namespace repository
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_DETAIL_PATTERNIMPL_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp2/repo/memory/ProductImpl.cc
- *
-*/
-#include "zypp2/repo/memory/ProductImpl.h"
-
-using namespace std;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace repo
- { /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace memory
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : ProductImpl::ProductImpl
- // METHOD TYPE : Ctor
- //
- ProductImpl::ProductImpl(data::Product_Ptr ptr)
- {}
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : ProductImpl::~ProductImpl
- // METHOD TYPE : Dtor
- //
- ProductImpl::~ProductImpl()
- {}
-
-
- std::string ProductImpl::category() const
- {
- return _category;
- }
-
- Label ProductImpl::vendor() const
- {
- return _vendor;
- }
-
- TranslatedText ProductImpl::summary() const
- {
- return _summary;
- }
-
- Source_Ref ProductImpl::source() const
- {
- return Source_Ref::noSource;
- }
-
- Url ProductImpl::releaseNotesUrl() const
- {
- return _release_notes_url;
- }
-
- std::list<Url> ProductImpl::updateUrls() const
- {
- return _update_urls;
- }
-
- std::list<Url> ProductImpl::extraUrls() const
- {
- return _extra_urls;
- }
-
- std::list<Url> ProductImpl::optionalUrls() const
- {
- return _optional_urls;
- }
-
- std::list<std::string> ProductImpl::flags() const
- {
- return _flags;
- }
-
- TranslatedText ProductImpl::shortName() const
- {
- return TranslatedText(_shortlabel);
- }
-
- std::string ProductImpl::distributionName() const
- {
- return _dist_name;
- }
-
- Edition ProductImpl::distributionEdition() const
- {
- return _dist_version;
- }
-
- /////////////////////////////////////////////////////////////////
- } // namespace memory
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
- } // namespace repository
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp2/repo/memory/ProductImpl.h
- *
-*/
-#ifndef ZYPP_DETAIL_MEMORY_PRODUCTIMPL_H
-#define ZYPP_DETAIL_MEMORY_PRODUCTIMPL_H
-
-#include <map>
-
-#include "zypp/CheckSum.h"
-#include "zypp/CapSet.h"
-#include "zypp/detail/ProductImplIf.h"
-#include "zypp/Source.h"
-#include "zypp/data/ResolvableData.h"
-#include "zypp/TranslatedText.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace repo
- { /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace memory
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : ProductImpl
- //
- /**
- */
- struct ProductImpl : public zypp::detail::ProductImplIf
- {
- public:
- ProductImpl(data::Product_Ptr ptr);
- virtual ~ProductImpl();
-
- virtual std::string category() const;
- virtual Label vendor() const;
- virtual TranslatedText summary() const;
- virtual Source_Ref source() const;
- virtual Url releaseNotesUrl() const;
-
- virtual std::list<Url> updateUrls() const;
- virtual std::list<Url> extraUrls() const;
- virtual std::list<Url> optionalUrls() const;
-
- virtual std::list<std::string> flags() const;
- virtual TranslatedText shortName() const;
- virtual std::string distributionName() const;
- virtual Edition distributionEdition() const;
-
- std::string _category;
-
- std::string _name;
- std::string _version;
- std::string _dist_name;
- Edition _dist_version;
-
- std::string _base_product;
- std::string _base_version;
- std::string _you_type;
- std::string _shortlabel;
- std::string _vendor;
- Url _release_notes_url;
-
- std::list<Url> _update_urls;
- std::list<Url> _extra_urls;
- std::list<Url> _optional_urls;
-
- std::map< std::string, std::list<std::string> > _arch; // map of 'arch : "arch1 arch2 arch3"', arch1 being 'best', arch3 being 'noarch' (ususally)
- std::string _default_base;
- Dependencies _deps;
- std::list<std::string> _languages;
- TranslatedText _summary;
- std::string _description_dir;
- std::string _data_dir;
- std::list<std::string> _flags;
- std::string _language;
- std::string _timezone;
-
- std::map<std::string, CheckSum> _descr_files_checksums;
- std::map<std::string, CheckSum> _signing_keys;
- };
- ///////////////////////////////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////
- } // namespace memory
- ///////////////////////////////////////////////////////////////////
- } // namespace repository
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_DETAIL_PRODUCTIMPL_H
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp2/repo/memory/SrcPackageImpl.cc
- *
-*/
-#include "zypp2/repo/memory/SrcPackageImpl.h"
-
-using namespace std;
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////////////
-namespace repo
-{ /////////////////////////////////////////////////////////////////
-namespace memory
-{ /////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////
-//
-// METHOD NAME : SrcPackageImpl::SrcPackageImpl
-// METHOD TYPE : Ctor
-//
-SrcPackageImpl::SrcPackageImpl(data::SrcPackage_Ptr ptr)
- : _media_number( 1 )
-{}
-
-///////////////////////////////////////////////////////////////////
-//
-// METHOD NAME : SrcPackageImpl::~SrcPackageImpl
-// METHOD TYPE : Dtor
-//
-SrcPackageImpl::~SrcPackageImpl()
-{}
-
-
-Pathname SrcPackageImpl::location() const
-{
- return _location;
-}
-
-ByteCount SrcPackageImpl::archivesize() const
-{
- return _archivesize;
-}
-
-DiskUsage SrcPackageImpl::diskusage() const
-{
- return _diskusage;
-}
-
-Source_Ref SrcPackageImpl::source() const
-{
- return Source_Ref::noSource;
-}
-
-unsigned SrcPackageImpl::sourceMediaNr() const
-{
- return _media_number;
-}
-
-/////////////////////////////////////////////////////////////////
-} // namespace memory
-///////////////////////////////////////////////////////////////////
-/////////////////////////////////////////////////////////////////
-} // namespace
-///////////////////////////////////////////////////////////////////
-
-/////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
+++ /dev/null
-/*---------------------------------------------------------------------\
-| ____ _ __ __ ___ |
-| |__ / \ / / . \ . \ |
-| / / \ V /| _/ _/ |
-| / /__ | | | | | | |
-| /_____||_| |_| |_| |
-| |
-\---------------------------------------------------------------------*/
-/** \file zypp2/repository/memory/SrcPackageImpl.h
- *
-*/
-#ifndef ZYPP_SOURCE_MEMORYSRCPackageIMPL_H
-#define ZYPP_SOURCE_MEMORYSRCPackageIMPL_H
-
-#include "zypp/detail/SrcPackageImplIf.h"
-#include "zypp/Source.h"
-#include "zypp/DiskUsage.h"
-#include "zypp/data/ResolvableData.h"
-
-///////////////////////////////////////////////////////////////////
-namespace zypp
-{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace repo
- { /////////////////////////////////////////////////////////////////
- namespace memory
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // CLASS NAME : SrcPackageImpl
- //
- /**
- */
- struct SrcPackageImpl : public zypp::detail::SrcPackageImplIf
- {
- SrcPackageImpl(data::SrcPackage_Ptr ptr);
- virtual ~SrcPackageImpl();
-
- /** */
- virtual Pathname location() const;
- /** */
- virtual ByteCount archivesize() const;
- /** */
- virtual DiskUsage diskusage() const;
- /** */
- virtual unsigned sourceMediaNr() const;
-
-private:
- ByteCount _archivesize;
- unsigned _media_number;
- Pathname _location;
- DiskUsage _diskusage;
-public:
- Source_Ref source() const;
- };
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
- } // namespace memory
- /////////////////////////////////////////////////////////////////
- } // namespace repository
- ///////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////
-} // namespace zypp
-///////////////////////////////////////////////////////////////////
-#endif // ZYPP_SOURCE_MEMORY_SRCPACKAGEIMPL_H