#include "zypp/cache/CacheAttributes.h"
#include "satsolver/repo.h"
-#include "satsolver/solvable.h"
+#include "satsolver/attr_store.h"
using namespace std;
using namespace zypp;
using zypp::debug::Measure;
+
+
/** Append OnMediaLocation attributes to resolvable with ID.
* \code
* appendOnMediaLocation( pkgid, attrPackageLocation, package->repositoryLocation );
Impl( const Pathname &solvdir )
: name_cache_hits(0)
, dir_cache_hits(0)
- , _last_repoid(0)
, _cachedir(solvdir)
{
_pool = pool_create();
-
+ _attr = new_store(_pool);
+
+ _attr_package_authors = str2id(_pool, "package:authors", 1);
+ _attr_package_description = str2id(_pool, "package:description", 1);
+ _attr_package_diskusage = str2id(_pool, "package:diskusage", 1);
+ _attr_package_downloadsize = str2id(_pool, "package:downloadsize", 1);
+ _attr_package_eula = str2id(_pool, "package:eula", 1);
+ _attr_package_group = str2id(_pool, "package:group", 1);
+ _attr_package_installsize = str2id(_pool, "package:authors", 1);
+ _attr_package_keywords = str2id(_pool, "package:keywords", 1);
+ _attr_package_license = str2id(_pool, "package:license", 1);
+ _attr_package_messagedel = str2id(_pool, "package:messagedel", 1);
+ _attr_package_messageins = str2id(_pool, "package:messageins", 1);
+ _attr_package_mediadir = str2id(_pool, "package:mediadir", 1);
+ _attr_package_mediafile = str2id(_pool, "package:mediafile", 1);
+ _attr_package_medianr = str2id(_pool, "package:medianr", 1);
+ _attr_package_nosource = str2id(_pool, "package:nosource", 1);
+ _attr_package_source = str2id(_pool, "package:source", 1);
+ _attr_package_sourceid = str2id(_pool, "package:sourceid", 1);
+ _attr_package_summary = str2id(_pool, "package:summary", 1);
+ _attr_package_time = str2id(_pool, "package:time", 1);
}
Impl()
_Pool *_pool;
- map<RecordId,Repo*> _id2repo;
- map<string, RecordId> _name2repoid;
- RecordId _last_repoid;
+ map<string,Repo*> _repoid2repo;
+
Pathname _cachedir;
+ Attrstore *_attr;
+
+ Id _attr_package_authors;
+ Id _attr_package_description;
+ Id _attr_package_diskusage;
+ Id _attr_package_downloadsize;
+ Id _attr_package_eula;
+ Id _attr_package_group;
+ Id _attr_package_installsize;
+ Id _attr_package_keywords;
+ Id _attr_package_license;
+ Id _attr_package_messagedel;
+ Id _attr_package_messageins;
+ Id _attr_package_mediadir;
+ Id _attr_package_mediafile;
+ Id _attr_package_medianr;
+ Id _attr_package_nosource;
+ Id _attr_package_source;
+ Id _attr_package_sourceid;
+ Id _attr_package_summary;
+ Id _attr_package_time;
};
void SolvStore::appendResObjectAttributes( const data::RecordId &rid,
const data::ResObject_Ptr & res )
{
- appendTranslatedStringAttribute( rid, attrResObjectDescription(), res->description );
- appendTranslatedStringAttribute( rid, attrResObjectSummary(), res->summary );
- appendNumericAttribute( rid, attrResObjectInstalledSize(), res->installedSize );
- appendNumericAttribute( rid, attrResObjectBuildTime(), res->buildTime );
- appendBooleanAttribute( rid, attrResObjectInstallOnly(), res->installOnly );
- appendStringAttribute( rid, attrResObjectVendor(), res->vendor );
- appendTranslatedStringAttribute( rid, attrResObjectLicenseToConfirm(), res->licenseToConfirm );
- appendTranslatedStringAttribute( rid, attrResObjectInsnotify(), res->insnotify );
- appendTranslatedStringAttribute( rid, attrResObjectDelnotify(), res->delnotify );
+
+// appendTranslatedStringAttribute( rid, attrResObjectDescription(), res->description );
+// appendTranslatedStringAttribute( rid, attrResObjectSummary(), res->summary );
+// appendNumericAttribute( rid, attrResObjectInstalledSize(), res->installedSize );
+// appendNumericAttribute( rid, attrResObjectBuildTime(), res->buildTime );
+// appendBooleanAttribute( rid, attrResObjectInstallOnly(), res->installOnly );
+// appendStringAttribute( rid, attrResObjectVendor(), res->vendor );
+// appendTranslatedStringAttribute( rid, attrResObjectLicenseToConfirm(), res->licenseToConfirm );
+// appendTranslatedStringAttribute( rid, attrResObjectInsnotify(), res->insnotify );
+// appendTranslatedStringAttribute( rid, attrResObjectDelnotify(), res->delnotify );
}
void SolvStore::appendPackageBaseAttributes( const RecordId & pkgid,
const data::Packagebase_Ptr & package )
{
- appendStringAttribute( pkgid, attrPackageBuildhost(), package->buildhost );
- appendStringAttribute( pkgid, attrPackageDistribution(), package->distribution );
- appendStringAttribute( pkgid, attrPackageLicense(), package->license );
- appendStringAttribute( pkgid, attrPackageGroup(), package->group );
- appendStringAttribute( pkgid, attrPackagePackager(), package->packager );
- appendStringAttribute( pkgid, attrPackageUrl(), package->url );
- appendStringAttribute( pkgid, attrPackageOperatingSystem(), package->operatingSystem );
- appendStringAttribute( pkgid, attrPackagePrein(), package->prein );
- appendStringAttribute( pkgid, attrPackagePostin(), package->postin );
- appendStringAttribute( pkgid, attrPackagePreun(), package->preun );
- appendStringAttribute( pkgid, attrPackagePostun(), package->postun );
- appendStringContainerAttribute( pkgid, attrPackageKeywords(), package->keywords.begin(), package->keywords.end() );
- appendStringContainerAttribute( pkgid, attrPackageAuthors(), package->authors.begin(), package->authors.end() );
-
- appendOnMediaLocation( pkgid, attrPackageLocation, package->repositoryLocation );
-}
-
-RecordId SolvStore::consumePackage( const RecordId & repository_id,
+
+// appendStringAttribute( pkgid, attrPackageBuildhost(), package->buildhost );
+// appendStringAttribute( pkgid, attrPackageDistribution(), package->distribution );
+// appendStringAttribute( pkgid, attrPackageLicense(), package->license );
+// appendStringAttribute( pkgid, attrPackageGroup(), package->group );
+// appendStringAttribute( pkgid, attrPackagePackager(), package->packager );
+// appendStringAttribute( pkgid, attrPackageUrl(), package->url );
+// appendStringAttribute( pkgid, attrPackageOperatingSystem(), package->operatingSystem );
+// appendStringAttribute( pkgid, attrPackagePrein(), package->prein );
+// appendStringAttribute( pkgid, attrPackagePostin(), package->postin );
+// appendStringAttribute( pkgid, attrPackagePreun(), package->preun );
+// appendStringAttribute( pkgid, attrPackagePostun(), package->postun );
+// appendStringContainerAttribute( pkgid, attrPackageKeywords(), package->keywords.begin(), package->keywords.end() );
+// appendStringContainerAttribute( pkgid, attrPackageAuthors(), package->authors.begin(), package->authors.end() );
+//
+// appendOnMediaLocation( pkgid, attrPackageLocation, package->repositoryLocation );
+}
+
+RecordId SolvStore::consumePackage( const std::string & repository_id,
const data::Package_Ptr & package )
{
- RecordId id = appendResolvable( repository_id, ResTraits<Package>::kind,
- NVRA( package->name, package->edition, package->arch ), package->deps, package->shareDataWith );
- appendResObjectAttributes( id, package );
- appendPackageBaseAttributes( id, package );
-
- if ( ! package->srcPackageIdent.name.empty() )
- {
- appendStringAttribute( id, attrPackageSourcePkgName(), package->srcPackageIdent.name );
- appendStringAttribute( id, attrPackageSourcePkgEdition(), package->srcPackageIdent.edition.asString() );
- }
-
- return id;
+// RecordId id = appendResolvable( repository_id, ResTraits<Package>::kind,
+// NVRA( package->name, package->edition, package->arch ), package->deps, package->shareDataWith );
+// appendResObjectAttributes( id, package );
+// appendPackageBaseAttributes( id, package );
+//
+// if ( ! package->srcPackageIdent.name.empty() )
+// {
+// appendStringAttribute( id, attrPackageSourcePkgName(), package->srcPackageIdent.name );
+// appendStringAttribute( id, attrPackageSourcePkgEdition(), package->srcPackageIdent.edition.asString() );
+// }
+
+ //return id;
+ return 0;
}
-RecordId SolvStore::consumeSourcePackage( const data::RecordId & repository_id,
+RecordId SolvStore::consumeSourcePackage( const std::string & repository_id,
const data::SrcPackage_Ptr & package )
{
- RecordId id = appendResolvable( repository_id, ResTraits<SrcPackage>::kind,
- NVRA( package->name, package->edition, package->arch ), package->deps, package->shareDataWith );
- appendResObjectAttributes( id, package );
-
- appendOnMediaLocation( id, attrSrcPackageLocation, package->repositoryLocation );
- return id;
+// RecordId id = appendResolvable( repository_id, ResTraits<SrcPackage>::kind,
+// NVRA( package->name, package->edition, package->arch ), package->deps, package->shareDataWith );
+// appendResObjectAttributes( id, package );
+//
+// appendOnMediaLocation( id, attrSrcPackageLocation, package->repositoryLocation );
+ //return id;
+ return 0;
}
-RecordId SolvStore::consumePatch( const data::RecordId & repository_id,
+RecordId SolvStore::consumePatch( const std::string & 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, attrPatchTimestamp(), patch->timestamp );
- appendStringAttribute( id, attrPatchCategory(), patch->category );
- appendStringAttribute( id, attrPatchId(), patch->id );
- appendBooleanAttribute( id, attrPatchRebootNeeded(), patch->rebootNeeded );
- appendBooleanAttribute( id, attrPatchAffectsPkgManager(), 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;
- return id;
+ NVRA( patch->name, patch->edition, patch->arch ), patch->deps );*/
+
+// appendResObjectAttributes( id, patch );
+//
+// // patch attributes
+// appendNumericAttribute( id, attrPatchTimestamp(), patch->timestamp );
+// appendStringAttribute( id, attrPatchCategory(), patch->category );
+// appendStringAttribute( id, attrPatchId(), patch->id );
+// appendBooleanAttribute( id, attrPatchRebootNeeded(), patch->rebootNeeded );
+// appendBooleanAttribute( id, attrPatchAffectsPkgManager(), 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;
+ //return id;
+ return 0;
}
-RecordId SolvStore::consumePackageAtom( const data::RecordId & repository_id,
+RecordId SolvStore::consumePackageAtom( const std::string & 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(repository_id, *p);
-
- for (set<data::DeltaRpm_Ptr>::const_iterator d = atom->deltaRpms.begin();
- d != atom->deltaRpms.end(); ++d)
- appendDeltaRpm(repository_id, *d);
- return id;
+// 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(repository_id, *p);
+//
+// for (set<data::DeltaRpm_Ptr>::const_iterator d = atom->deltaRpms.begin();
+// d != atom->deltaRpms.end(); ++d)
+// appendDeltaRpm(repository_id, *d);
+ //7return id;
+ return 0;
}
-RecordId SolvStore::consumeMessage( const data::RecordId & repository_id,
+RecordId SolvStore::consumeMessage( const std::string & 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, attrMessageText(), message->text );
- return id;
+// RecordId id = appendResolvable( repository_id, ResTraits<Message>::kind,
+// NVRA( message->name, message->edition, message->arch ), message->deps );
+// appendResObjectAttributes( id, message );
+//
+// appendTranslatedStringAttribute( id, attrMessageText(), message->text );
+ //7return id;
+ return 0;
}
-RecordId SolvStore::consumeScript( const data::RecordId & repository_id,
+RecordId SolvStore::consumeScript( const std::string & 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, attrScriptDoScript(), script->doScript );
- appendOnMediaLocation( id, attrScriptDoScriptLocation, script->doScriptLocation );
- appendStringAttribute( id, attrScriptUndoScript(), script->undoScript );
- appendOnMediaLocation( id, attrScriptUndoScriptLocation, script->undoScriptLocation );
- return id;
+ //RecordId id = appendResolvable( repository_id, ResTraits<Script>::kind,
+ //NVRA( script->name, script->edition, script->arch ), script->deps );
+// appendResObjectAttributes( id, script );
+//
+// appendStringAttribute( id, attrScriptDoScript(), script->doScript );
+// appendOnMediaLocation( id, attrScriptDoScriptLocation, script->doScriptLocation );
+// appendStringAttribute( id, attrScriptUndoScript(), script->undoScript );
+// appendOnMediaLocation( id, attrScriptUndoScriptLocation, script->undoScriptLocation );
+ //return id;
+ return 0;
}
-RecordId SolvStore::consumePattern( const data::RecordId & repository_id,
+RecordId SolvStore::consumePattern( const std::string & 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, attrPatternIsDefault(), pattern->isDefault );
- appendBooleanAttribute( id, attrPatternUserVisible(), pattern->userVisible );
- appendTranslatedStringAttribute( id, attrPatternCategory(), pattern->category );
- appendStringAttribute( id, attrPatternIcon(), pattern->icon );
- appendStringAttribute( id, attrPatternOrder(), pattern->order );
+// RecordId id = appendResolvable( repository_id, ResTraits<Pattern>::kind,
+// NVRA( pattern->name, pattern->edition, pattern->arch ), pattern->deps );
+// appendResObjectAttributes( id, pattern );
+//
+// appendBooleanAttribute( id, attrPatternIsDefault(), pattern->isDefault );
+// appendBooleanAttribute( id, attrPatternUserVisible(), pattern->userVisible );
+// appendTranslatedStringAttribute( id, attrPatternCategory(), pattern->category );
+// appendStringAttribute( id, attrPatternIcon(), pattern->icon );
+// appendStringAttribute( id, attrPatternOrder(), pattern->order );
// We store them as string. They are
// (sometimes) evaluated by the YaST UI.
- appendStringContainerAttribute( id, attrPatternUiIncludes(), pattern->includes.begin(), pattern->includes.end() );
- appendStringContainerAttribute( id, attrPatternUiExtends(), pattern->extends.begin(), pattern->extends.end() );
+// appendStringContainerAttribute( id, attrPatternUiIncludes(), pattern->includes.begin(), pattern->includes.end() );
+// appendStringContainerAttribute( id, attrPatternUiExtends(), pattern->extends.begin(), pattern->extends.end() );
- return id;
+ //return id;
+ return 0;
}
-RecordId SolvStore::consumeProduct( const data::RecordId & repository_id,
+RecordId SolvStore::consumeProduct( const std::string & 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 );
-
- appendStringAttribute( id, attrProductType(), product->type );
- appendTranslatedStringAttribute( id, attrProductShortName(), product->shortName );
- appendTranslatedStringAttribute( id, attrProductLongName(), product->longName );
- appendStringContainerAttribute( id, attrProductFlags(), product->flags.begin(), product->flags.end() );
- appendStringAttribute( id, attrProductReleasenotesUrl(), product->releasenotesUrl.asString() );
- appendStringContainerAttribute( id, attrProductUpdateUrls(), product->updateUrls );
- appendStringContainerAttribute( id, attrProductExtraUrls(), product->extraUrls );
- appendStringContainerAttribute( id, attrProductOptionalUrls(), product->optionalUrls );
- appendStringAttribute( id, attrProductDistributionName(), product->distributionName );
- appendStringAttribute( id, attrProductDistributionEdition(), product->distributionEdition.asString() );
- return id;
+// RecordId id = appendResolvable( repository_id, ResTraits<Product>::kind,
+// NVRA( product->name, product->edition, product->arch ), product->deps );
+// appendResObjectAttributes( id, product );
+//
+// appendStringAttribute( id, attrProductType(), product->type );
+// appendTranslatedStringAttribute( id, attrProductShortName(), product->shortName );
+// appendTranslatedStringAttribute( id, attrProductLongName(), product->longName );
+// appendStringContainerAttribute( id, attrProductFlags(), product->flags.begin(), product->flags.end() );
+// appendStringAttribute( id, attrProductReleasenotesUrl(), product->releasenotesUrl.asString() );
+// appendStringContainerAttribute( id, attrProductUpdateUrls(), product->updateUrls );
+// appendStringContainerAttribute( id, attrProductExtraUrls(), product->extraUrls );
+// appendStringContainerAttribute( id, attrProductOptionalUrls(), product->optionalUrls );
+// appendStringAttribute( id, attrProductDistributionName(), product->distributionName );
+// appendStringAttribute( id, attrProductDistributionEdition(), product->distributionEdition.asString() );
+ //return id;
+ return 0;
}
RecordId SolvStore::consumeChangelog( const data::RecordId &resolvable_id,
void SolvStore::updatePackageLang( const data::RecordId & resolvable_id,
const data::Packagebase_Ptr & data_r )
{
- appendTranslatedStringAttribute( resolvable_id, attrResObjectSummary(), data_r->summary );
- appendTranslatedStringAttribute( resolvable_id, attrResObjectDescription(), data_r->description );
- appendTranslatedStringAttribute( resolvable_id, attrResObjectLicenseToConfirm(), data_r->licenseToConfirm );
- appendTranslatedStringAttribute( resolvable_id, attrResObjectInsnotify(), data_r->insnotify );
- appendTranslatedStringAttribute( resolvable_id, attrResObjectDelnotify(), data_r->delnotify );
+// appendTranslatedStringAttribute( resolvable_id, attrResObjectSummary(), data_r->summary );
+// appendTranslatedStringAttribute( resolvable_id, attrResObjectDescription(), data_r->description );
+// appendTranslatedStringAttribute( resolvable_id, attrResObjectLicenseToConfirm(), data_r->licenseToConfirm );
+// appendTranslatedStringAttribute( resolvable_id, attrResObjectInsnotify(), data_r->insnotify );
+// appendTranslatedStringAttribute( resolvable_id, attrResObjectDelnotify(), data_r->delnotify );
}
-::_Solvable* SolvStore::appendResolvable( const data::RecordId &repository_id,
+_Solvable* SolvStore::appendResolvable( const std::string & repository_id,
const data::Resolvable_Ptr &res )
{
Repo *repo;
- map<RecordId, Repo*>::const_iterator it = _pimpl->_id2repo.find(repository_id);
- if ( it == _pimpl->_id2repo.end() )
+ map<string, Repo*>::const_iterator it = _pimpl->_repoid2repo.find(repository_id);
+ if ( it == _pimpl->_repoid2repo.end() )
{
// throw
}
repo = it->second;
- Solvable *s = pool_id2solvable(_pimpl->_pool, repo_add_solvable(repo));
+ //Id
+ _Solvable *s = pool_id2solvable(_pimpl->_pool, repo_add_solvable(repo));
s->evr = str2id(_pimpl->_pool, res->edition.c_str(), 1);
// s->provides = adddep(pool, pd, s->provides, atts, 0);
//
}
-RecordId SolvStore::appendResolvable( const RecordId &repository_id,
- const Resolvable::Kind &kind,
- const NVRA &nvra,
- const data::Dependencies &deps )
-{
- return appendResolvable( repository_id,
- kind,
- nvra,
- deps,
- data::noRecordId );
-}
-
-data::RecordId
- SolvStore::appendResolvable( const data::RecordId &repository_id,
- const Resolvable::Kind &kind,
- const NVRA &nvra,
- const data::Dependencies &deps,
- const data::RecordId &shared_id )
-{
-
-// Solvable *s = pool_id2solvable(pool, repo_add_solvable(pd->repo));
-// s->evr = makeevr_atts(pool, pd, atts);
-// s->provides = adddep(pool, pd, s->provides, atts, 0);
-//
-// s->name = str2id(pool, nvra.name.c_str(), 1);
-// s->arch = str2id(pool, nvra.arch.c_str(), 1);
-// s->vendor = str2id(pool, nvra.vendor.c_str(), 1);
-//
-// if (!s->arch)
-// s->arch = ARCH_NOARCH;
-//
-// if (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
-// s->provides = repo_addid_dep(pd->repo, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
-//
-// s->supplements = repo_fix_legacy(pd->repo, s->provides, s->supplements);
-
- // file
- //id = str2id(pool, pd->content, 1);
- //s->provides = repo_addid(pd->repo, s->provides, id);
-
-
-// long long id = _pimpl->con.insertid();
-//
-// appendDependencies( id, deps );
-
- return 0;
-}
-
-void SolvStore::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 SolvStore::appendDependencyList( const RecordId &resolvable_id, Dep deptype, const data::DependencyList &caps )
-{
- for ( data::DependencyList::const_iterator it = caps.begin(); it != caps.end(); ++it )
- {
- appendDependency( resolvable_id, deptype, *it );
- }
-}
-
-void SolvStore::appendDependency( const RecordId &resolvable_id, Dep deptype, Capability cap )
-{
-#warning MIGRATE TO SAT
- // create capability from data
-}
-
-
/** \todo lookupOrAppend ? */
-RecordId SolvStore::appendPatchRpm(const zypp::data::RecordId &repository_id, const data::PatchRpm_Ptr & prpm)
+RecordId SolvStore::appendPatchRpm( const std::string & repository_id, const data::PatchRpm_Ptr & prpm)
{
RecordId id;
return id;
/** \todo lookupOrAppend ? */
-RecordId SolvStore::appendDeltaRpm(const zypp::data::RecordId &repository_id, const data::DeltaRpm_Ptr & drpm)
+RecordId SolvStore::appendDeltaRpm( const std::string & repository_id, const data::DeltaRpm_Ptr & drpm)
{
RecordId id;
return id;
}
-RecordId SolvStore::lookupOrAppendFile( const Pathname &path )
-{
- long long id = 0;
- return id;
-}
-
-void SolvStore::updateRepositoryStatus( const RecordId &id,
- const RepoStatus &status )
-{
- // NO OP for now
-}
-
-RecordId SolvStore::lookupOrAppendRepository( const string &alias )
-{
- map<string,RecordId>::const_iterator it = _pimpl->_name2repoid.find(alias);
- if (it == _pimpl->_name2repoid.end())
- {
- _pimpl->_name2repoid[alias] = ++_pimpl->_last_repoid;
- //_pimpl->_id2repo[_pimpl->_last_repoid] = ::repo_create(_pimpl->_pool, alias.c_str());
- }
- return _pimpl->_name2repoid[alias];
-}
-
-void SolvStore::cleanRepository( const data::RecordId &id,
- const ProgressData::ReceiverFnc & progressrcv )
-{
- // just delete the solv file
- //cleanupRepository(lookupRepository(
-}
-
void SolvStore::cleanRepository( const std::string &alias,
const ProgressData::ReceiverFnc & progressrcv )
{
bool SolvStore::isCached( const string &alias )
{
- return _pimpl->_name2repoid.find(alias) != _pimpl->_name2repoid.end();
-}
-
-RecordId SolvStore::lookupRepository( const string &alias )
-{
- map<string,RecordId>::const_iterator it = _pimpl->_name2repoid.find(alias);
- if (it == _pimpl->_name2repoid.end())
- ZYPP_THROW(CacheRecordNotFoundException());
-
- return _pimpl->_name2repoid[alias];
-}
-
-RecordId SolvStore::lookupOrAppendType( const string &klass, const string &name )
-{
- long long id = 0;
- return id;
-}
-
-RecordId SolvStore::lookupOrAppendName( const string &name )
-{
- long long id = 0;
- return id;
-}
-
-RecordId SolvStore::lookupOrAppendDirName( const string &name )
-{
- long long id = 0;
- return id;
-}
-
-RecordId SolvStore::lookupOrAppendFileName( const string &name )
-{
- long long id = 0;
- return id;
-}
-
-void SolvStore::setSharedData( const data::RecordId &resolvable_id,
- const data::RecordId &shared_id )
-{
-}
-
-void SolvStore::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 SolvStore::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 SolvStore::appendNumericAttribute( const RecordId &resolvable_id,
- const RecordId &type_id,
- int value )
-{
- // weak resolvable_id
-}
-
-
-void SolvStore::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 SolvStore::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;
-}
-
-void SolvStore::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;
-}
-
-void SolvStore::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;
-}
-
-void SolvStore::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;
+ return _pimpl->_repoid2repo.find(alias) != _pimpl->_repoid2repo.end();
}
}
#include "zypp/ProgressData.h"
#include "zypp/cache/Attribute.h"
+#include "satsolver/solvable.h"
+
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
* The data will be saved in the directory specified in
* \a dbdir. \a dbdir must exist.
*/
- SolvStore( const Pathname &dbdir );
+ SolvStore( const Pathname &solvdir );
/**
* Commit the changes.
* \param repository_id ownership.
* \param package Package data
*/
- virtual data::RecordId consumePackage(const data::RecordId &repository_id,
+ virtual data::RecordId consumePackage(const std::string &repo_id,
const data::Package_Ptr & package);
/**
* \param catalog_id ownership.
* \param srcpackage Source package data
*/
- virtual data::RecordId consumeSourcePackage( const data::RecordId &catalog_id,
+ virtual data::RecordId consumeSourcePackage( const std::string &repo_id,
const data::SrcPackage_Ptr & srcpackage );
/**
* \param repository_id ownership.
* \param patch Patch data
*/
- virtual data::RecordId consumePatch( const data::RecordId &repository_id,
+ virtual data::RecordId consumePatch( const std::string &repo_id,
const data::Patch_Ptr & patch );
/**
* \note this is somewhat specific to current YUM patch metadata design
* and may change (to consumeAtom(data::RecordId,data::Atom)).
*/
- virtual data::RecordId consumePackageAtom( const data::RecordId &repository_id,
+ virtual data::RecordId consumePackageAtom( const std::string &repo_id,
const data::PackageAtom_Ptr & atom );
/**
* \param repository_id ownership.
* \param message Message data
*/
- virtual data::RecordId consumeMessage( const data::RecordId & repository_id,
+ virtual data::RecordId consumeMessage( const std::string &repo_id,
const data::Message_Ptr & message);
/**
* \param repository_id ownership.
* \param script Script data
*/
- virtual data::RecordId consumeScript( const data::RecordId & repository_id,
+ virtual data::RecordId consumeScript( const std::string & repo_id,
const data::Script_Ptr & script);
/**
* \param repository_id ownership.
* \param pattern Pattern data
*/
- virtual data::RecordId consumePattern( const data::RecordId & repository_id,
+ virtual data::RecordId consumePattern( const std::string & repo_id,
const data::Pattern_Ptr & pattern );
/**
* \param repository_id ownership.
* \param pattern Pattern data
*/
- virtual data::RecordId consumeProduct( const data::RecordId &repository_id,
+ virtual data::RecordId consumeProduct( const std::string &repo_id,
const data::Product_Ptr & product );
/**
* other properties.
*
*/
- data::RecordId appendResolvable( const data::RecordId &repository_id,
- const Resolvable::Kind &kind,
- const NVRA &nvra,
- const data::Dependencies &deps );
-
- /**
- * \short Appends a resolvable, and sets shared data with another one
- *
- * \see appendResolvable
- * \param shared_id Resolvable that provides data in case
- * this one does not provide an attribute
- *
- * \note Not all attributes can be shared. \ref shared_id is just
- * a hint for the queries.
- */
- data::RecordId appendResolvable( const data::RecordId &repository_id,
- const Resolvable::Kind &kind,
- const NVRA &nvra,
- const data::Dependencies &deps,
- const data::RecordId &shared_id );
- /**
- * 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 SolvStore
- * 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 SolvStore
- * that will own those capabilities.
- *
- * FIXME should it \throw if the resolvable does not exist?
- */
- void appendDependencyList( const data::RecordId &resolvable_id,
- 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 SolvStore
- * that will own the capability
- *
- * FIXME should it \throw if the resolvable does not exist?
- */
- void appendDependency( const data::RecordId &resolvable_id,
- Dep deptype,
- Capability cap );
+ _Solvable* appendResolvable( const std::string &repo_id,
+ const data::Resolvable_Ptr &res );
/**
* 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::RecordId &repo_id,
+ data::RecordId appendPatchRpm( const std::string &repo_id,
const data::PatchRpm_Ptr & prpm);
* \param drpm The delta RPM object to insert.
* \return Record ID of the newly inserted record.
*/
- data::RecordId appendDeltaRpm( const data::RecordId &repo_id,
+ data::RecordId appendDeltaRpm( const std::string &repo_id,
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 );
- /** \overload */
- data::RecordId lookupOrAppendType( const Attribute &attr )
- { return lookupOrAppendType( attr.klass, attr.name ); }
-
/**
* Returns the record id of a repository (Source)
*
*/
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 );
- /** \overload */
- void appendNumericAttribute( const data::RecordId &resolvable_id,
- const Attribute& attr,
- int value )
- { appendNumericAttribute( resolvable_id, attr.klass, attr.name, 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 );
- /** \overload */
- void appendTranslatedStringAttribute( const data::RecordId &resolvable_id,
- const Attribute& attr,
- const TranslatedText &text )
- { appendTranslatedStringAttribute( resolvable_id, attr.klass, attr.name, 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 );
- /** \overload */
- void appendStringAttributeTranslation( const data::RecordId &resolvable_id,
- const Locale &locale,
- const Attribute& attr,
- const std::string &text )
- { appendStringAttributeTranslation( resolvable_id, locale, attr.klass, attr.name, 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 );
- /** \overload */
- void appendStringAttribute( const data::RecordId &resolvable_id,
- const Attribute& attr,
- const std::string &value )
- { appendStringAttribute( resolvable_id, attr.klass, attr.name, 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 _Iterator to a resolvable.
- *
- * Uses \ref zypp::str::split(_Iterator,_Iterator, std::string) with
- * \ref ZConfig::cacheDBSplitJoinSeparator() as the second argument
- * (a separator string) of split().
- *
- * Any container of any class providing asString() can be used.
- *
- * \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 begin begin Iterator to the container
- * \param end end Iterator to the container
- */
- template <class _Iterator>
- void appendStringContainerAttribute( const data::RecordId &resolvable_id,
- const std::string &klass,
- const std::string &name,
- _Iterator begin,
- _Iterator end )
- {
- std::string value = str::join(begin, end, ZConfig::instance().cacheDBSplitJoinSeparator());
- appendStringAttribute( resolvable_id, klass, name, value );
- }
- /** \overload */
- template <class _Iterator>
- void appendStringContainerAttribute( const data::RecordId &resolvable_id,
- const Attribute& attr,
- _Iterator begin,
- _Iterator end )
- { appendStringContainerAttribute( resolvable_id, attr.klass, attr.name, begin, end ); }
-
- /**
- * Append strings from a _Container to a resolvable.
- *
- * Convenience method taking the container instead of it's
- * begin/end iterators as argument.
- *
- * \see appendStringContainerAttribute
- */
- template <class _Container>
- void appendStringContainerAttribute( const data::RecordId &resolvable_id,
- const std::string &klass,
- const std::string &name,
- const _Container & container )
- { appendStringContainerAttribute( resolvable_id, klass, name, container.begin(), container.end() ); }
- /** \overload */
- template <class _Container>
- void appendStringContainerAttribute( const data::RecordId &resolvable_id,
- const Attribute& attr,
- const _Container & container )
- { appendStringContainerAttribute( resolvable_id, attr.klass, attr.name, container ); }
-
- /**
- * 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 updateRepositoryStatus( const data::RecordId &id,
- const RepoStatus &status );
-
- /**
- * \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,
- const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
-
- /**
- * \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,
- const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
-
- /**
- * 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:
-
- /**
- * Appends a solvable 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.
- *
- */
- ::_Solvable* appendResolvable( const data::RecordId &repository_id,
- const data::Resolvable_Ptr &res );
-
- 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);
- /** \overload */
- void appendBooleanAttribute( const data::RecordId & resolvable_id,
- const Attribute& attr,
- bool value)
- { appendBooleanAttribute( resolvable_id, attr.klass, attr.name, value ); }
-
-
/** \name Detail Attributes Inserters
* These functions are used by ResolvableConsumer interface functions
* to avoid some duplication across types.
const data::Packagebase_Ptr & package);
//@}
+ void cleanRepository( const std::string &alias,
+ const ProgressData::ReceiverFnc & progressrcv );
+
+ RepoStatus repositoryStatus( const std::string &alias );
+
+ bool isCached( const std::string &alias );
private:
/** Implementation. */