Author: mlandres
Date: Wed May 23 08:30:13 2007
New Revision: 5596
URL: http://svn.opensuse.org/viewcvs/zypp?rev=5596&view=rev
Log:
finished ContentFileReader
Modified:
trunk/libzypp/zypp/parser/susetags/ContentFileReader.cc
trunk/libzypp/zypp/parser/susetags/ContentFileReader.h
trunk/libzypp/zypp/parser/susetags/PackagesFileReader.h
trunk/libzypp/zypp/parser/susetags/PackagesLangFileReader.h
trunk/libzypp/zypp/parser/susetags/PatternFileReader.h
trunk/libzypp/zypp/parser/susetags/RepoIndex.h
Modified: trunk/libzypp/zypp/parser/susetags/ContentFileReader.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/ContentFileReader.cc?rev=5596&r1=5595&r2=5596&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/susetags/ContentFileReader.cc (original)
+++ trunk/libzypp/zypp/parser/susetags/ContentFileReader.cc Wed May 23 08:30:13 2007
@@ -121,7 +121,7 @@
return errors;
}
- void setDependencies( data::DependencyList & deplist_r,const std::string & value ) const
+ void setDependencies( data::DependencyList & deplist_r, const std::string & value ) const
{
std::liststd::string words;
str::split( value, std::back_inserter( words ) );
@@ -174,6 +174,21 @@
}
}
+ bool setFileCheckSum( std::map & map_r, const std::string & value ) const
+ {
+ bool error = false;
+ std::vectorstd::string words;
+ if ( str::split( value, std::back_inserter( words ) ) == 3 )
+ {
+ map_r[words[2]] = CheckSum( words[0], words[1] );
+ }
+ else
+ {
+ error = true;
+ }
+ return error;
+ }
+
public:
std::string _inputname;
@@ -282,6 +297,8 @@
if ( ! ticks.toMin() )
userRequestedAbort( 0 );
+ Arch sysarch( ZConfig().systemArchitecture() );
+
iostr::EachLine line( input_r );
for( ; line; line.next() )
{
@@ -303,6 +320,9 @@
key.erase( pos );
}
+ //
+ // Product related data:
+ //
if ( key == "PRODUCT" )
{
std::replace( value.begin(), value.end(), ' ', '_' );
@@ -312,6 +332,18 @@
{
_pimpl->product().edition = value;
}
+ else if ( key == "ARCH" )
+ {
+ // Default product arch is noarch. We update, if the
+ // ARCH.xxx tag is better than the current product arch
+ // and still compatible with the sysarch.
+ Arch carch( modifier );
+ if ( Arch::compare( _pimpl->product().arch, carch ) < 0
+ && carch.compatibleWith( sysarch ) )
+ {
+ _pimpl->product().arch = carch;
+ }
+ }
else if ( key == "DISTPRODUCT" )
{
_pimpl->product().distributionName = value;
@@ -324,6 +356,10 @@
{
_pimpl->product().vendor = value;
}
+ else if ( key == "LABEL" )
+ {
+ _pimpl->product().summary.setText( value, Locale(modifier) );
+ }
else if ( key == "SHORTLABEL" )
{
_pimpl->product().shortName.setText( value, Locale(modifier) );
@@ -366,14 +402,6 @@
WAR << errPrefix( line.lineNo(), "Ignored malformed URL(s)", *line ) << endl;
}
}
- else if ( key == "ARCH" )
- {
- /*unused ?*/;
- }
- else if ( key == "DEFAULTBASE" )
- {
- /*unused ?*/;
- }
else if ( key == "PREREQUIRES" )
{
_pimpl->setDependencies( _pimpl->product().deps[Dep::PREREQUIRES], value );
@@ -410,45 +438,55 @@
{
_pimpl->setDependencies( _pimpl->product().deps[Dep::ENHANCES], value );
}
- else if ( key == "LINGUAS" )
- {
- /*unused ?*/;
- }
- else if ( key == "LABEL" )
+ //
+ // ReppoIndex related data:
+ //
+ else if ( key == "DEFAULTBASE" )
{
- _pimpl->product().summary.setText( value, Locale(modifier) );
+ _pimpl->repoindex().defaultBase = Arch(value);
}
else if ( key == "DESCRDIR" )
{
- /*unused ?*/;
+ _pimpl->repoindex().descrdir = value;
}
else if ( key == "DATADIR" )
{
- /*unused ?*/;
+ _pimpl->repoindex().datadir = value;
}
else if ( key == "FLAGS" )
{
- /*unused ?*/;
+ str::split( value, std::back_inserter( _pimpl->repoindex().flags ) );
}
- else if ( key == "LANGUAGE" )
+ else if ( key == "KEY" )
{
- /*unused ?*/;
+ if ( _pimpl->setFileCheckSum( _pimpl->repoindex().signingKeys, value ) )
+ {
+ ZYPP_THROW( ParseException( errPrefix( line.lineNo(), "Expected [algorithm checksum filename]", *line ) ) );
+ }
}
- else if ( key == "TIMEZONE" )
+ else if ( key == "LANGUAGE" )
{
- /*unused ?*/;
+ _pimpl->repoindex().language;
}
- else if ( key == "META" )
+ else if ( key == "LINGUAS" )
{
- /*unused ?*/;
+ std::setstd::string strval;
+ str::split( value, std::inserter( strval, strval.end() ) );
+ for ( std::setstd::string::const_iterator it = strval.begin(); it != strval.end(); ++it )
+ {
+ _pimpl->repoindex().languages.push_back( Locale(*it) );
+ }
}
- else if ( key == "KEY" )
+ else if ( key == "META" )
{
- /*unused ?*/;
+ if ( _pimpl->setFileCheckSum( _pimpl->repoindex().metaFileChecksums, value ) )
+ {
+ ZYPP_THROW( ParseException( errPrefix( line.lineNo(), "Expected [algorithm checksum filename]", *line ) ) );
+ }
}
- else if ( key == "VOLATILE_CONTENT" )
+ else if ( key == "TIMEZONE" )
{
- /*unused ? add to FLAGS*/;
+ _pimpl->repoindex().timezone = value;
}
else
{ WAR << errPrefix( line.lineNo(), "Unknown tag", *line ) << endl; }
@@ -458,6 +496,21 @@
userRequestedAbort( line.lineNo() );
}
+ //
+ // post processing
+ //
+ if ( _pimpl->hasProduct() )
+ {
+ // Insert a "Provides" _dist_name" == _dist_version"
+ if ( ! _pimpl->product().distributionName.empty() )
+ {
+ _pimpl->product().deps[Dep::PROVIDES].insert(
+ capability::parse( ResTraits<Product>::kind,
+ _pimpl->product().distributionName,
+ Rel::EQ,
+ _pimpl->product().distributionEdition ) );
+ }
+ }
if ( ! ticks.toMax() )
userRequestedAbort( line.lineNo() );
Modified: trunk/libzypp/zypp/parser/susetags/ContentFileReader.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/ContentFileReader.h?rev=5596&r1=5595&r2=5596&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/susetags/ContentFileReader.h (original)
+++ trunk/libzypp/zypp/parser/susetags/ContentFileReader.h Wed May 23 08:30:13 2007
@@ -15,6 +15,7 @@
#include <iosfwd>
#include "zypp/base/PtrTypes.h"
+#include "zypp/base/NonCopyable.h"
#include "zypp/base/Function.h"
#include "zypp/base/InputStream.h"
@@ -48,7 +49,7 @@
// CLASS NAME : ContentFileReader
//
/** */
- class ContentFileReader
+ class ContentFileReader : private base::NonCopyable
{
public:
typedef function ProductConsumer;
@@ -60,8 +61,8 @@
/** Dtor */
virtual ~ContentFileReader();
/** Parse the stream.
- * \throw ParseExcetion on errors.
- * \throws AbortRequestException on user request.
+ * \throw ParseException on errors.
+ * \throw AbortRequestException on user request.
* Invokes \ref consume for each tag. \ref consume might throw
* other exceptions as well.
*/
@@ -97,7 +98,7 @@
private:
class Impl;
- scoped_ptr<Impl> _pimpl;
+ RW_pointer _pimpl;
ProductConsumer _productConsumer;
RepoIndexConsumer _repoIndexConsumer;
};
Modified: trunk/libzypp/zypp/parser/susetags/PackagesFileReader.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/PackagesFileReader.h?rev=5596&r1=5595&r2=5596&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/susetags/PackagesFileReader.h (original)
+++ trunk/libzypp/zypp/parser/susetags/PackagesFileReader.h Wed May 23 08:30:13 2007
@@ -76,7 +76,7 @@
private:
class Impl;
- scoped_ptr<Impl> _pimpl;
+ RW_pointer _pimpl;
PkgConsumer _pkgConsumer;
SrcPkgConsumer _srcPkgConsumer;
};
Modified: trunk/libzypp/zypp/parser/susetags/PackagesLangFileReader.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/PackagesLangFileReader.h?rev=5596&r1=5595&r2=5596&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/susetags/PackagesLangFileReader.h (original)
+++ trunk/libzypp/zypp/parser/susetags/PackagesLangFileReader.h Wed May 23 08:30:13 2007
@@ -81,7 +81,7 @@
private:
class Impl;
- scoped_ptr<Impl> _pimpl;
+ RW_pointer _pimpl;
Locale _locale;
PkgConsumer _pkgConsumer;
SrcPkgConsumer _srcPkgConsumer;
Modified: trunk/libzypp/zypp/parser/susetags/PatternFileReader.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/PatternFileReader.h?rev=5596&r1=5595&r2=5596&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/susetags/PatternFileReader.h (original)
+++ trunk/libzypp/zypp/parser/susetags/PatternFileReader.h Wed May 23 08:30:13 2007
@@ -69,7 +69,8 @@
private:
class Impl;
- scoped_ptr<Impl> _pimpl;
+ RW_pointer _pimpl;
+
Consumer _consumer;
};
///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/parser/susetags/RepoIndex.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/susetags/RepoIndex.h?rev=5596&r1=5595&r2=5596&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/susetags/RepoIndex.h (original)
+++ trunk/libzypp/zypp/parser/susetags/RepoIndex.h Wed May 23 08:30:13 2007
@@ -13,11 +13,18 @@
#define ZYPP_PARSER_SUSETAGS_REPOINDEX_H
#include <iosfwd>
+#include <list>
+#include <map>
#include "zypp/base/ReferenceCounted.h"
#include "zypp/base/NonCopyable.h"
#include "zypp/base/PtrTypes.h"
+#include "zypp/Arch.h"
+#include "zypp/CheckSum.h"
+#include "zypp/Pathname.h"
+#include "zypp/Locale.h"
+
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
@@ -41,6 +48,18 @@
{
public:
+ Locale language;
+ std::string timezone;
+ Arch defaultBase;
+ std::list<Locale> languages;
+ std::liststd::string flags;
+
+ Pathname descrdir;
+ Pathname datadir;
+
+ std::map metaFileChecksums;
+ std::map signingKeys;
+
protected:
/** Overload to realize std::ostream & operator\<\<. */
//virtual std::ostream & dumpOn( std::ostream & str ) const;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org