From 62ef4e518442722ab7c488e5d12e88d3a98e1545 Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Thu, 16 Mar 2006 16:28:31 +0000 Subject: [PATCH] - move yum schemas to /usr/libzypp/schema/yum - add schemas for storage, at least patterns validate. - fix storage to not insert the right architectures in patterns --- configure.ac | 11 +- zypp/parser/xmlstore/Makefile.am | 2 +- zypp/parser/xmlstore/XMLPatternParser.cc | 9 +- zypp/parser/xmlstore/schema/Makefile.am | 3 + zypp/parser/xmlstore/schema/pattern.rnc | 18 +++ zypp/parser/xmlstore/schema/pattern.rng | 42 +++++++ zypp/parser/xmlstore/schema/resolvable.rnc | 86 ++++++++++++++ zypp/parser/xmlstore/schema/resolvable.rng | 173 +++++++++++++++++++++++++++++ zypp/parser/xmlstore/schema/rnc2rng | 2 + zypp/parser/xmlstore/schemanames.h | 16 +-- zypp/parser/yum/schema/Makefile.am | 2 +- zypp/parser/yum/schemanames.h | 2 +- zypp/target/store/XMLFilesBackend.cc | 34 ++---- zypp/target/store/serialize.cc | 23 ++-- 14 files changed, 364 insertions(+), 59 deletions(-) create mode 100644 zypp/parser/xmlstore/schema/Makefile.am create mode 100644 zypp/parser/xmlstore/schema/pattern.rnc create mode 100644 zypp/parser/xmlstore/schema/pattern.rng create mode 100644 zypp/parser/xmlstore/schema/resolvable.rnc create mode 100644 zypp/parser/xmlstore/schema/resolvable.rng create mode 100755 zypp/parser/xmlstore/schema/rnc2rng diff --git a/configure.ac b/configure.ac index 30c2ef8..43b7a3d 100644 --- a/configure.ac +++ b/configure.ac @@ -68,11 +68,13 @@ AC_SUBST(pkgdocdir) zyppdir=${prefix}/share/$PACKAGE localedir=${prefix}/share/locale -schemadir=${zyppdir}/schema +yumschemadir=${zyppdir}/schema/yum +xmlstoreschemadir=${zyppdir}/schema/xmlstore AC_SUBST(zyppdir) AC_SUBST(localedir) -AC_SUBST(schemadir) +AC_SUBST(yumschemadir) +AC_SUBST(xmlstoreschemadir) AH_TEMPLATE([LOCALEDIR],[gettext localedir]) AC_DEFINE_UNQUOTED([LOCALEDIR], ["${localedir}"]) @@ -212,9 +214,10 @@ AC_OUTPUT( po/Makefile.in\ zypp/capability/Makefile \ zypp/parser/Makefile \ zypp/parser/yum/Makefile \ - zypp/parser/yum/schema/Makefile \ - zypp/parser/tagfile/Makefile \ + zypp/parser/yum/schema/Makefile \ + zypp/parser/tagfile/Makefile \ zypp/parser/xmlstore/Makefile \ + zypp/parser/xmlstore/schema/Makefile \ zypp/pool/Makefile \ zypp/solver/Makefile \ zypp/solver/detail/Makefile \ diff --git a/zypp/parser/xmlstore/Makefile.am b/zypp/parser/xmlstore/Makefile.am index 83e2e37..b18c224 100644 --- a/zypp/parser/xmlstore/Makefile.am +++ b/zypp/parser/xmlstore/Makefile.am @@ -1,7 +1,7 @@ ## Process this file with automake to produce Makefile.in ## ################################################## -#SUBDIRS = schema +SUBDIRS = schema INCLUDES = -I$(oldincludedir)/libxml2 -I.. \ -DZYPP_BASE_LOGGER_LOGGROUP=\"parser-xml\" diff --git a/zypp/parser/xmlstore/XMLPatternParser.cc b/zypp/parser/xmlstore/XMLPatternParser.cc index ab9350b..71a77cf 100644 --- a/zypp/parser/xmlstore/XMLPatternParser.cc +++ b/zypp/parser/xmlstore/XMLPatternParser.cc @@ -63,6 +63,14 @@ namespace zypp { if (name == "name") { dataPtr->name = _helper.content(child); } + else if (name == "arch") { + dataPtr->arch = _helper.content(child); + } + else if (name == "version") { + dataPtr->epoch = _helper.attribute(child,"epoch"); + dataPtr->ver = _helper.attribute(child,"ver"); + dataPtr->rel = _helper.attribute(child,"rel"); + } else if (name == "summary") { dataPtr->summary.setText(_helper.content(child), Locale(_helper.attribute(child,"lang"))); } @@ -76,7 +84,6 @@ namespace zypp { dataPtr->description.setText(_helper.content(child), Locale(_helper.attribute(child,"lang"))); } else if (name == "category") { - #warning FIXME pattern category is translatable dataPtr->category.setText(_helper.content(child)); } else if (name == "icon") { diff --git a/zypp/parser/xmlstore/schema/Makefile.am b/zypp/parser/xmlstore/schema/Makefile.am new file mode 100644 index 0000000..67f094f --- /dev/null +++ b/zypp/parser/xmlstore/schema/Makefile.am @@ -0,0 +1,3 @@ +schemafilesdir = ${xmlstoreschemadir} +schemafiles_DATA = $(wildcard *.rng *.rnc) +EXTRA_DIST = $(schemafiles_DATA) diff --git a/zypp/parser/xmlstore/schema/pattern.rnc b/zypp/parser/xmlstore/schema/pattern.rnc new file mode 100644 index 0000000..494760c --- /dev/null +++ b/zypp/parser/xmlstore/schema/pattern.rnc @@ -0,0 +1,18 @@ +default namespace = "http://www.novell.com/metadata/zypp/xml-store" + +include "resolvable.rnc" + +start = element-pattern + +element-pattern = + element pattern { pattern } + +pattern = + resolvable-data?, + element-summary+, + element-description+, + element default { boolean }?, + element uservisible { boolean }, + element category { text }, + element icon { text }?, + element script { text } \ No newline at end of file diff --git a/zypp/parser/xmlstore/schema/pattern.rng b/zypp/parser/xmlstore/schema/pattern.rng new file mode 100644 index 0000000..0563781 --- /dev/null +++ b/zypp/parser/xmlstore/schema/pattern.rng @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/zypp/parser/xmlstore/schema/resolvable.rnc b/zypp/parser/xmlstore/schema/resolvable.rnc new file mode 100644 index 0000000..b2e09bb --- /dev/null +++ b/zypp/parser/xmlstore/schema/resolvable.rnc @@ -0,0 +1,86 @@ +default namespace = "http://www.novell.com/metadata/zypp/xml-store" + +boolean = "true" | "false" + +attribute-kind = + attribute kind { "pattern" | "package" | "patch" | "script" | "message" | "product" | "atom" } + +arch = + "noarch" + | "athlon" + | "i386" + | "i486" + | "i586" + | "i686" + | "ia64" + | "ppc" + | "ppc64" + | "s390" + | "s390x" + | "x86_64" + | "src" + +element-version = + element version { version } + +translated-text = + attribute lang { text }?, + text + +version = + attribute ver { text }, + attribute rel { text }, + attribute epoch { xsd:nonNegativeInteger }?, + empty + +element-summary = + element summary { translated-text } + +element-description = + element description { translated-text } + +capability = + element capability { attribute-kind, + text } + +capability-set = + capability* + +provides = + element provides { capability-set } +requires = + element requires { capability-set } +prerequires = + element prerequires { capability-set } +conflicts = + element conflicts { capability-set } +suggests = + element suggests { capability-set } +freshens = + element freshens { capability-set } +supplements = + element supplements { capability-set } +enhances = + element enhances { capability-set } +recommends = + element recommends { capability-set } +obsoletes = + element obsoletes { capability-set } + +dependencies = + provides?, + prerequires?, + conflicts?, + obsoletes?, + freshens?, + requires?, + recommends?, + enhances?, + supplements?, + suggests? + +resolvable-data = + element name { text }, + element-version, + element arch { arch }, + dependencies diff --git a/zypp/parser/xmlstore/schema/resolvable.rng b/zypp/parser/xmlstore/schema/resolvable.rng new file mode 100644 index 0000000..015f68c --- /dev/null +++ b/zypp/parser/xmlstore/schema/resolvable.rng @@ -0,0 +1,173 @@ + + + + + true + false + + + + + + pattern + package + patch + script + message + product + atom + + + + + + noarch + athlon + i386 + i486 + i586 + i686 + ia64 + ppc + ppc64 + s390 + s390x + x86_64 + src + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/zypp/parser/xmlstore/schema/rnc2rng b/zypp/parser/xmlstore/schema/rnc2rng new file mode 100755 index 0000000..84897ec --- /dev/null +++ b/zypp/parser/xmlstore/schema/rnc2rng @@ -0,0 +1,2 @@ +#!/bin/bash +for i in *.rnc; do trang -I rnc -O rng $i ${i%.rnc}.rng; done diff --git a/zypp/parser/xmlstore/schemanames.h b/zypp/parser/xmlstore/schemanames.h index b73fa46..9f5e328 100644 --- a/zypp/parser/xmlstore/schemanames.h +++ b/zypp/parser/xmlstore/schemanames.h @@ -6,7 +6,7 @@ | /_____||_| |_| |_| | | | \---------------------------------------------------------------------*/ -/** \file zypp/parser/yum/schemanames.h +/** \file zypp/parser/xmltore/schemanames.h * */ @@ -18,26 +18,16 @@ namespace zypp { namespace parser { namespace xmlstore { /* FIXME: How do I do this properly? */ - //#define SCHEMABASE "/usr/share/zypp/schema/" +#define SCHEMABASE "/usr/share/zypp/schema/xmlstore/" //#define REPOMDSCHEMA (SCHEMABASE "repomd.rng") //#define PRIMARYSCHEMA (SCHEMABASE "suse-primary.rng") //#define GROUPSCHEMA (SCHEMABASE "groups.rng") - //#define PATTERNSCHEMA (SCHEMABASE "patterns.rng") + #define PATTERNSCHEMA (SCHEMABASE "pattern.rng") //#define FILELISTSCHEMA (SCHEMABASE "filelists.rng") //#define OTHERSCHEMA (SCHEMABASE "other.rng") //#define PATCHSCHEMA (SCHEMABASE "patch.rng") //#define PATCHESSCHEMA (SCHEMABASE "patches.rng") //#define PRODUCTSCHEMA (SCHEMABASE "product.rng") - - #define REPOMDSCHEMA "" - #define PRIMARYSCHEMA "" - #define GROUPSCHEMA "" - #define PATTERNSCHEMA "" - #define FILELISTSCHEMA "" - #define OTHERSCHEMA "" - #define PATCHSCHEMA "" - #define PATCHESSCHEMA "" - #define PRODUCTSCHEMA "" } // namespace xmlstore } // namespace parser } // namespace zypp diff --git a/zypp/parser/yum/schema/Makefile.am b/zypp/parser/yum/schema/Makefile.am index 363e037..5ba1112 100644 --- a/zypp/parser/yum/schema/Makefile.am +++ b/zypp/parser/yum/schema/Makefile.am @@ -1,3 +1,3 @@ -schemafilesdir = ${schemadir} +schemafilesdir = ${yumschemadir} schemafiles_DATA = $(wildcard *.rng *.rnc) EXTRA_DIST = $(schemafiles_DATA) diff --git a/zypp/parser/yum/schemanames.h b/zypp/parser/yum/schemanames.h index b729968..40e8582 100644 --- a/zypp/parser/yum/schemanames.h +++ b/zypp/parser/yum/schemanames.h @@ -18,7 +18,7 @@ namespace zypp { namespace parser { namespace yum { /* FIXME: How do I do this properly? */ - #define SCHEMABASE "/usr/share/zypp/schema/" + #define SCHEMABASE "/usr/share/zypp/schema/yum/" #define REPOMDSCHEMA (SCHEMABASE "repomd.rng") #define PRIMARYSCHEMA (SCHEMABASE "suse-primary.rng") #define GROUPSCHEMA (SCHEMABASE "groups.rng") diff --git a/zypp/target/store/XMLFilesBackend.cc b/zypp/target/store/XMLFilesBackend.cc index b8cd50a..3f5b192 100644 --- a/zypp/target/store/XMLFilesBackend.cc +++ b/zypp/target/store/XMLFilesBackend.cc @@ -771,16 +771,6 @@ XMLFilesBackend::createScript(const zypp::parser::xmlstore::XMLPatchScriptData & } } -/* - std::string groupId; - std::list name; - std::string default_; - std::string userVisible; - std::list description; - std::list grouplist; - std::list package_list; -*/ - Product::Ptr XMLFilesBackend::createProduct( const zypp::parser::xmlstore::XMLProductData & parsed ) const { @@ -799,22 +789,12 @@ XMLFilesBackend::createProduct( const zypp::parser::xmlstore::XMLProductData & p else impl->_release_notes_url = Url(); - //unsigned int sourceid = str::strtonum(parsed.sourceid); - /* - std::string sourceid = parsed.sourceid; - try - { - impl->_source = SourceManager::sourceManager()->findSource(sourceid); - } - catch (const Exception & excpt_r) - { - ZYPP_CAUGHT(excpt_r); - impl->_source = Source_Ref::noSource; - } - */ + Arch arch; + if (!parsed.arch.empty()) + arch = Arch(parsed.arch); // Collect basic Resolvable data - NVRAD dataCollect( parsed.name, Edition( parsed.ver, parsed.rel, parsed.epoch ), Arch_noarch, createDependencies(parsed, ResTraits::kind) ); + NVRAD dataCollect( parsed.name, Edition( parsed.ver, parsed.rel, parsed.epoch ), arch, createDependencies(parsed, ResTraits::kind) ); Product::Ptr product = detail::makeResolvableFromImpl( dataCollect, impl ); return product; } @@ -840,8 +820,12 @@ XMLFilesBackend::createPattern( const zypp::parser::xmlstore::XMLPatternData & p impl->_icon = parsed.icon; impl->_script = parsed.script; + Arch arch; + if (!parsed.arch.empty()) + arch = Arch(parsed.arch); + // Collect basic Resolvable data - NVRAD dataCollect( parsed.name, Edition::noedition, Arch_noarch, createDependencies( parsed, ResTraits::kind)); + NVRAD dataCollect( parsed.name, Edition( parsed.ver, parsed.rel, parsed.epoch ), arch, createDependencies( parsed, ResTraits::kind)); Pattern::Ptr pattern = detail::makeResolvableFromImpl( dataCollect, impl ); return pattern; } diff --git a/zypp/target/store/serialize.cc b/zypp/target/store/serialize.cc index f3b9274..201f029 100644 --- a/zypp/target/store/serialize.cc +++ b/zypp/target/store/serialize.cc @@ -228,20 +228,18 @@ std::string toXML( const Selection::constPtr &obj ) { stringstream out; out << "" << std::endl; - out << "" << std::endl; - //out << " " << xml_escape(obj->name()) << "" << std::endl; - + out << "" << std::endl; + out << toXML(static_cast(obj)) << std::endl; // access implementation detail::ResImplTraits::constPtr sipp( detail::ImplConnect::resimpl( obj ) ); out << translatedTextToXML(sipp->summary(), "summary"); - + out << translatedTextToXML(sipp->description(), "description"); //out << " " << (obj->isDefault() ? "true" : "false" ) << "" << std::endl; out << " " << (obj->visible() ? "true" : "false" ) << "" << std::endl; out << " " << xml_escape(obj->category()) << "" << std::endl; - out << " null" << std::endl; - out << translatedTextToXML(sipp->description(), "description"); + out << " " << std::endl; out << "" << std::endl; return out.str(); } @@ -264,21 +262,20 @@ std::string toXML( const Pattern::constPtr &obj ) { stringstream out; out << "" << std::endl; - out << "" << std::endl; - out << " " << xml_escape(obj->name()) << "" << std::endl; + out << "" << std::endl; out << toXML(static_cast(obj)) << std::endl; // access implementation detail::ResImplTraits::constPtr pipp( detail::ImplConnect::resimpl( obj ) ); out << translatedTextToXML(pipp->summary(), "summary"); - + out << translatedTextToXML(pipp->description(), "description"); + out << " " << (obj->isDefault() ? "true" : "false" ) << "" << std::endl; out << " " << (obj->userVisible() ? "true" : "false" ) << "" << std::endl; out << " " << xml_escape(obj->category()) << "" << std::endl; out << " " << xml_escape(obj->icon().asString()) << "" << std::endl; out << " " << std::endl; - out << translatedTextToXML(pipp->description(), "description"); out << "" << std::endl; return out.str(); } @@ -288,7 +285,7 @@ std::string toXML( const Product::constPtr &obj ) { stringstream out; out << "" << std::endl; - out << "category()) << "\">" << std::endl; + out << "category()) << "\">" << std::endl; out << " " << xml_escape(obj->vendor()) << "" << std::endl; out << " " << xml_escape(obj->source().alias()) << "" << std::endl; out << toXML(static_cast(obj)) << std::endl; @@ -357,7 +354,7 @@ std::string toXML( const Patch::constPtr &obj ) { stringstream out; out << "" << std::endl; - out << "id()) << "\"" << std::endl; out << " timestamp=\"" << obj->timestamp().asSeconds() << "\"" << std::endl; out << " engine=\"1.0\">" << std::endl; @@ -383,7 +380,7 @@ std::string toXML( const PersistentStorage::SourceData &obj ) { stringstream out; out << "" << std::endl; - out << "" << std::endl; + out << ">" << std::endl; out << " " << (obj.enabled ? "true" : "false" ) << "" << std::endl; out << " " << ( obj.autorefresh ? "true" : "false" ) << "" << std::endl; out << " " << xml_escape(obj.product_dir) << "" << std::endl; -- 2.7.4