Author: mlandres Date: Fri Jul 13 13:15:12 2007 New Revision: 6002 URL: http://svn.opensuse.org/viewcvs/zypp?rev=6002&view=rev Log: use product vendor if package vendor is not specified Modified: branches/REFACTORING-10_3/libzypp/zypp/parser/susetags/RepoParser.cc Modified: branches/REFACTORING-10_3/libzypp/zypp/parser/susetags/RepoParser.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/... ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/parser/susetags/RepoParser.cc (original) +++ branches/REFACTORING-10_3/libzypp/zypp/parser/susetags/RepoParser.cc Fri Jul 13 13:15:12 2007 @@ -66,31 +66,29 @@ /** \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 ) { MIL << "[Product] " << data_r << endl; ++_stats.prod; _prodData = data_r; + _defaultVendor = data_r->vendor; _consumer.consumeProduct( _repositoryId, data_r ); } + /////////////////////////////////////////////////////////////////// void consumePkg( const data::Package_Ptr & data_r ) { - // prepend location with 'datadir' - Pathname tofix( data_r->repositoryLocation.filename() ); - data_r->repositoryLocation.setFilename( _datadir / tofix ); - - // resolve shared data tag - if ( ! data_r->sharedDataTag.empty() ) - { - data_r->shareDataWith = idMapGet( data_r->sharedDataTag ); - } + fixVendor( data_r ); + fixLocationPath( data_r ); + resolveSharedDataTag( data_r ); ++_stats.pack; data::RecordId newid = _consumer.consumePackage( _repositoryId, data_r ); @@ -103,17 +101,13 @@ newid ); } + /////////////////////////////////////////////////////////////////// void consumeSrcPkg( const data::SrcPackage_Ptr & data_r ) { - // prepend location with 'datadir' - Pathname tofix( data_r->repositoryLocation.filename() ); - data_r->repositoryLocation.setFilename( _datadir / tofix ); + fixVendor( data_r ); + fixLocationPath( data_r ); + resolveSharedDataTag( data_r ); - // resolve shared data tag - if ( ! data_r->sharedDataTag.empty() ) - { - data_r->shareDataWith = idMapGet( data_r->sharedDataTag ); - } ++_stats.srcp; data::RecordId newid = _consumer.consumeSourcePackage( _repositoryId, data_r ); @@ -125,6 +119,7 @@ newid ); } + /////////////////////////////////////////////////////////////////// void consumePkgLang( const data::Package_Ptr & data_r ) { data::RecordId id = idMapGet( makeSharedIdent( ResTraits<Package>::kind, @@ -137,6 +132,7 @@ } } + /////////////////////////////////////////////////////////////////// void consumeSrcPkgLang( const data::SrcPackage_Ptr & data_r ) { data::RecordId id = idMapGet( makeSharedIdent( ResTraits<SrcPackage>::kind, @@ -149,16 +145,46 @@ } } + /////////////////////////////////////////////////////////////////// void consumePat( const data::Pattern_Ptr & data_r ) { //SEC << "[Pattern]" << data_r << endl; + fixVendor( data_r ); ++_stats.patt; _consumer.consumePattern( _repositoryId, data_r ); } //@} - public: + public: + /** Use products vendor if vendor was not specified. */ + void fixVendor( const data::ResObject_Ptr & data_r ) + { + if ( data_r->vendor.empty() && ! _defaultVendor.empty() ) + { + data_r->vendor = _defaultVendor; + } + } + + /** Prepend location with 'datadir'. */ + void fixLocationPath( const data::Packagebase_Ptr & data_r ) + { + Pathname tofix( data_r->repositoryLocation.filename() ); + data_r->repositoryLocation.setFilename( _datadir / tofix ); + } + + /** Resolve shared data tag. */ + void resolveSharedDataTag( const data::Packagebase_Ptr & data_r ) + { + if ( ! data_r->sharedDataTag.empty() ) + { + data_r->shareDataWith = idMapGet( data_r->sharedDataTag ); + } + } + public: + /** Throw \ref ParseException if a required file is not + * available below \ref _reporoot on disk. + */ Pathname assertMandatoryFile( const Pathname & file_r ) const { PathInfo inputfile( _reporoot / file_r ); @@ -169,6 +195,9 @@ return inputfile.path(); } + /** Print a warning if an optional file is not + * available below \ref _reporoot on disk. + */ Pathname getOptionalFile( const Pathname & file_r ) const { PathInfo inputfile( _reporoot / file_r ); @@ -244,9 +273,9 @@ reader.setSrcPkgConsumer( bind( &Impl::consumeSrcPkgLang, this, _1 ) ); reader.parse( inputfile ); } - + if ( ! _ticks.incr( PathInfo(inputfile).size() ) ) - ZYPP_THROW( AbortRequestException() ); + ZYPP_THROW( AbortRequestException() ); } private: @@ -278,6 +307,7 @@ private: // these (and _ticks) are actually scoped per parse() run. RepoIndex_Ptr _repoIndex; data::Product_Ptr _prodData; + std::string _defaultVendor; Pathname _reporoot; // full path Pathname _descrdir; // path below reporoot Pathname _datadir; // path below reporoot @@ -307,6 +337,7 @@ { _prodData = 0; _repoIndex = 0; + _defaultVendor.clear(); _reporoot = reporoot_r; _descrdir = _datadir = Pathname(); _parsedLocales.clear(); @@ -330,19 +361,19 @@ _datadir = _repoIndex->datadir; // path below reporoot _ticks.name( "Parsing susetags repo at " + reporoot_r.asString() ); - + // calculate progress range based on file sizes to parse int jobssize = 0; for ( RepoIndex::FileChecksumMap::const_iterator it = _repoIndex->metaFileChecksums.begin(); it != _repoIndex->metaFileChecksums.end(); ++it ) { jobssize += PathInfo(getOptionalFile(_descrdir / it->first)).size(); - + } MIL << "Total job size: " << jobssize << endl; - + _ticks.range(jobssize); - + if ( ! _ticks.toMin() ) ZYPP_THROW( AbortRequestException() ); @@ -352,11 +383,11 @@ PackagesFileReader reader; reader.setPkgConsumer( bind( &Impl::consumePkg, this, _1 ) ); reader.setSrcPkgConsumer( bind( &Impl::consumeSrcPkg, this, _1 ) ); - + CombinedProgressData packageprogress( _ticks, PathInfo(inputfile).size() ); reader.parse( inputfile, packageprogress ); } - + // Now process packages.lang. Always parse 'en'. // At least packages.en is mandatory, because the file might // contain license texts. -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org