Author: dmacvicar Date: Wed Jul 4 14:01:53 2007 New Revision: 5875 URL: http://svn.opensuse.org/viewcvs/zypp?rev=5875&view=rev Log: - rename setter methods to setSomething. Please stick to this convention. - Add MediaProducts class Added: branches/REFACTORING-10_3/libzypp/zypp/MediaProducts.cc branches/REFACTORING-10_3/libzypp/zypp/MediaProducts.h Modified: branches/REFACTORING-10_3/libzypp/zypp/CMakeLists.txt branches/REFACTORING-10_3/libzypp/zypp/OnMediaLocation.h branches/REFACTORING-10_3/libzypp/zypp/parser/yum/PatchesFileReader.cc branches/REFACTORING-10_3/libzypp/zypp/parser/yum/RepoParser.cc branches/REFACTORING-10_3/libzypp/zypp/parser/yum/RepomdFileReader.cc branches/REFACTORING-10_3/libzypp/zypp/repo/PackageDelta.h branches/REFACTORING-10_3/libzypp/zypp/repo/PackageProvider.cc branches/REFACTORING-10_3/libzypp/zypp/repo/cached/RepoImpl.cc branches/REFACTORING-10_3/libzypp/zypp/repo/susetags/Downloader.cc branches/REFACTORING-10_3/libzypp/zypp/repo/yum/Downloader.cc Modified: branches/REFACTORING-10_3/libzypp/zypp/CMakeLists.txt URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/CMakeLists.txt?rev=5875&r1=5874&r2=5875&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/CMakeLists.txt (original) +++ branches/REFACTORING-10_3/libzypp/zypp/CMakeLists.txt Wed Jul 4 14:01:53 2007 @@ -86,6 +86,7 @@ RepoInfo.cc RepoStatus.cc RepoManager.cc + MediaProducts.cc ) SET( zypp_HEADERS @@ -182,6 +183,7 @@ RepoInfo.h RepoStatus.h RepoManager.h + MediaProducts.h ) INSTALL( FILES ${zypp_HEADERS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/zypp" ) Added: branches/REFACTORING-10_3/libzypp/zypp/MediaProducts.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/MediaProducts.cc?rev=5875&view=auto ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/MediaProducts.cc (added) +++ branches/REFACTORING-10_3/libzypp/zypp/MediaProducts.cc Wed Jul 4 14:01:53 2007 @@ -0,0 +1,75 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ + +#include <iostream> +#include <fstream> +#include "zypp/ZConfig.h" +#include "zypp/base/Logger.h" +#include "zypp/media/MediaManager.h" +#include "zypp/base/UserRequestException.h" + +#include "zypp/MediaProducts.h" + +#undef ZYPP_BASE_LOGGER_LOGGROUP +#define ZYPP_BASE_LOGGER_LOGGROUP "zypp" + +using namespace std; + +namespace zypp +{ + +template <class _OutputIterator> +static void scanProductsFile( const Pathname & file_r, _OutputIterator result ) +{ + std::ifstream pfile( file_r.asString().c_str() ); + while ( pfile.good() ) { + + std::string value = str::getline( pfile, str::TRIM ); + if ( pfile.bad() ) { + ERR << "Error parsing " << file_r << endl; + ZYPP_THROW(Exception("Error parsing " + file_r.asString())); + } + if ( pfile.fail() ) { + break; // no data on last line + } + std::string tag = str::stripFirstWord( value, true ); + + if ( tag.size() ) { + *result = MediaProductEntry( tag, value ); + } + } +} + +template<class _OutputIterator> +void productsInMedia( const Url & url_r, _OutputIterator result ) +{ + if (! url_r.isValid()) + ZYPP_THROW( Exception("Empty URL passed to SourceFactory") ); + + media::MediaManager media_mgr; + // open the media + media::MediaId id = media_mgr.open(url_r); + media_mgr.attach(id); + Pathname products_file = Pathname("media.1/products"); + + try { + media_mgr.provideFile (id, products_file); + products_file = media_mgr.localPath (id, products_file); + scanProductsFile (products_file, result); + } + catch ( const Exception & excpt ) { + ZYPP_CAUGHT(excpt); + MIL << "No products description found on the Url" << endl; + } + media_mgr.release(id); +} + +} // ns zypp + +// vim: set ts=2 sts=2 sw=2 et ai: Added: branches/REFACTORING-10_3/libzypp/zypp/MediaProducts.h URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/MediaProducts.h?rev=5875&view=auto ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/MediaProducts.h (added) +++ branches/REFACTORING-10_3/libzypp/zypp/MediaProducts.h Wed Jul 4 14:01:53 2007 @@ -0,0 +1,56 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/MediaProducts.h + * Functions to find out products in media + */ +#ifndef ZYPP_MEDIAPRODUCTS_H_ +#define ZYPP_MEDIAPRODUCTS_H_ + +#include "zypp/ProgressData.h" + +namespace zypp +{ + /** + * \short Represents an available product in media + */ + struct MediaProductEntry + { + Pathname _dir; + std::string _name; + + /** + * \short Ctor + */ + MediaProductEntry( const Pathname & dir_r = "/", const std::string & name_r = std::string() ) + : _dir(dir_r), _name(name_r) + { + } + }; + + /** + * A set of available products in media + */ + typedef std::set<MediaProductEntry> MediaProductSet; + + /** + * \short Available products in a url location + * + * \param url_r url to inspect + * \param result output iterator where \ref MediaProductEntry + * items will be inserted. + * \throws MediaException If accessng the media fails + */ + template <class _OutputIterator> + void productsInMedia( const Url & url_r, _OutputIterator result ); + +} // ns zypp + +#endif + +// vim: set ts=2 sts=2 sw=2 et ai: Modified: branches/REFACTORING-10_3/libzypp/zypp/OnMediaLocation.h URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/OnMediaLocation.h?rev=5875&r1=5874&r2=5875&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/OnMediaLocation.h (original) +++ branches/REFACTORING-10_3/libzypp/zypp/OnMediaLocation.h Wed Jul 4 14:01:53 2007 @@ -49,10 +49,10 @@ const ByteCount & downloadsize() const { return _downloadsize; } public: - OnMediaLocation & medianr( unsigned val_r ) { _medianr = val_r; return *this; } - OnMediaLocation & filename( const Pathname & val_r ) { _filename = val_r; return *this; } - OnMediaLocation & checksum( const CheckSum & val_r ) { _checksum = val_r; return *this; } - OnMediaLocation & downloadsize( const ByteCount & val_r ) { _downloadsize = val_r; return *this; } + OnMediaLocation & setMedianr( unsigned val_r ) { _medianr = val_r; return *this; } + OnMediaLocation & setFilename( const Pathname & val_r ) { _filename = val_r; return *this; } + OnMediaLocation & setChecksum( const CheckSum & val_r ) { _checksum = val_r; return *this; } + OnMediaLocation & setDownloadsize( const ByteCount & val_r ) { _downloadsize = val_r; return *this; } private: unsigned _medianr; Modified: branches/REFACTORING-10_3/libzypp/zypp/parser/yum/PatchesFileReader.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/parser/yum/PatchesFileReader.cc?rev=5875&r1=5874&r2=5875&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/parser/yum/PatchesFileReader.cc (original) +++ branches/REFACTORING-10_3/libzypp/zypp/parser/yum/PatchesFileReader.cc Wed Jul 4 14:01:53 2007 @@ -103,7 +103,7 @@ if ( reader_r->name() == "location" ) { _tag = tag_Location; - _location.filename( reader_r->getAttribute("href").asString() ); + _location.setFilename( reader_r->getAttribute("href").asString() ); return true; } if ( reader_r->name() == "checksum" ) @@ -111,7 +111,7 @@ _tag = tag_CheckSum; string checksum_type = reader_r->getAttribute("type").asString() ; string checksum_vaue = reader_r.nodeText().asString(); - _location.checksum( CheckSum( checksum_type, checksum_vaue ) ); + _location.setChecksum( CheckSum( checksum_type, checksum_vaue ) ); return true; } if ( reader_r->name() == "timestamp" ) Modified: branches/REFACTORING-10_3/libzypp/zypp/parser/yum/RepoParser.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/parser/yum/RepoParser.cc?rev=5875&r1=5874&r2=5875&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/parser/yum/RepoParser.cc (original) +++ branches/REFACTORING-10_3/libzypp/zypp/parser/yum/RepoParser.cc Wed Jul 4 14:01:53 2007 @@ -192,7 +192,7 @@ : _repository_id(repository_id), _consumer(consumer), _options(options) { - _ticks.name("RepoParser"); + _ticks.name("YUM RepoParser"); _ticks.sendTo(progress); } @@ -316,10 +316,17 @@ cache_dir + "/repodata/repomd.xml", bind(&RepoParser::Impl::repomd_CB, this, _1, _2)); +// long long totalsize = 0 +// for(list<RepoParserJob>::const_iterator it = _jobs.begin(); +// it != _jobs.end(); ++it) +// { +// RepoParserJob job = *it; +// totalsize += PathInfo(cache_dir + job.filename()).size(); +// } - _ticks.range(_jobs.size()); + //_ticks.range(totalsize); _ticks.toMin(); - + doJobs(cache_dir); _ticks.toMax(); Modified: branches/REFACTORING-10_3/libzypp/zypp/parser/yum/RepomdFileReader.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/parser/yum/RepomdFileReader.cc?rev=5875&r1=5874&r2=5875&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/parser/yum/RepomdFileReader.cc (original) +++ branches/REFACTORING-10_3/libzypp/zypp/parser/yum/RepomdFileReader.cc Wed Jul 4 14:01:53 2007 @@ -137,7 +137,7 @@ if ( reader_r->name() == "location" ) { _tag = tag_Location; - _location.filename( reader_r->getAttribute("href").asString() ); + _location.setFilename( reader_r->getAttribute("href").asString() ); // ignoring attribute xml:base return true; } @@ -148,7 +148,7 @@ _tag = tag_CheckSum; string checksum_type = reader_r->getAttribute("type").asString() ; string checksum_vaue = reader_r.nodeText().asString(); - _location.checksum( CheckSum( checksum_type, checksum_vaue ) ); + _location.setChecksum( CheckSum( checksum_type, checksum_vaue ) ); return true; } Modified: branches/REFACTORING-10_3/libzypp/zypp/repo/PackageDelta.h URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/repo/PackageDelta.h?rev=5875&r1=5874&r2=5875&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/repo/PackageDelta.h (original) +++ branches/REFACTORING-10_3/libzypp/zypp/repo/PackageDelta.h Wed Jul 4 14:01:53 2007 @@ -45,10 +45,10 @@ const Date & buildtime() const { return _buildtime;} public: - PatchRpm & location( const OnMediaLocation & val_r ) { _location = val_r; return *this; } - PatchRpm & baseversions( const BaseVersions & val_r ) { _baseversions = val_r; return *this; } - PatchRpm & baseversion( const BaseVersion & val_r ) { _baseversions.push_back( val_r ); return *this; } - PatchRpm & buildtime( const Date & val_r ) { _buildtime = val_r; return *this; } + PatchRpm & setLocation( const OnMediaLocation & val_r ) { _location = val_r; return *this; } + PatchRpm & setBaseversions( const BaseVersions & val_r ) { _baseversions = val_r; return *this; } + PatchRpm & addBaseversion( const BaseVersion & val_r ) { _baseversions.push_back( val_r ); return *this; } + PatchRpm & setBuildtime( const Date & val_r ) { _buildtime = val_r; return *this; } private: OnMediaLocation _location; @@ -77,10 +77,10 @@ const std::string & sequenceinfo() const { return _sequenceinfo; } public: - BaseVersion & edition( const Edition & val_r ) { _edition = val_r; return *this; } - BaseVersion & buildtime( const Date & val_r ) { _buildtime = val_r; return *this; } - BaseVersion & checksum( const CheckSum & val_r ) { _checksum = val_r; return *this; } - BaseVersion & sequenceinfo( const std::string & val_r ) { _sequenceinfo = val_r; return *this; } + BaseVersion & setEdition( const Edition & val_r ) { _edition = val_r; return *this; } + BaseVersion & setBuildtime( const Date & val_r ) { _buildtime = val_r; return *this; } + BaseVersion & setChecksum( const CheckSum & val_r ) { _checksum = val_r; return *this; } + BaseVersion & setSequenceinfo( const std::string & val_r ) { _sequenceinfo = val_r; return *this; } private: Edition _edition; @@ -101,9 +101,9 @@ const Date & buildtime() const { return _buildtime;} public: - DeltaRpm & location( const OnMediaLocation & val_r ) { _location = val_r; return *this; } - DeltaRpm & baseversion( const BaseVersion & val_r ) { _baseversion = val_r; return *this; } - DeltaRpm & buildtime( const Date & val_r ) { _buildtime = val_r; return *this; } + DeltaRpm & setLocation( const OnMediaLocation & val_r ) { _location = val_r; return *this; } + DeltaRpm & setBaseversion( const BaseVersion & val_r ) { _baseversion = val_r; return *this; } + DeltaRpm & setBuildtime( const Date & val_r ) { _buildtime = val_r; return *this; } private: OnMediaLocation _location; Modified: branches/REFACTORING-10_3/libzypp/zypp/repo/PackageProvider.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/repo/PackageProvider.cc?rev=5875&r1=5874&r2=5875&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/repo/PackageProvider.cc (original) +++ branches/REFACTORING-10_3/libzypp/zypp/repo/PackageProvider.cc Wed Jul 4 14:01:53 2007 @@ -182,10 +182,10 @@ // no patch/delta -> provide full package ManagedFile ret; OnMediaLocation loc; - loc.medianr( _package->mediaNr() ) - .filename( _package->location() ) - .checksum( _package->checksum() ) - .downloadsize( _package->archivesize() ); + loc.setMedianr( _package->mediaNr() ) + .setFilename( _package->location() ) + .setChecksum( _package->checksum() ) + .setDownloadsize( _package->archivesize() ); ProvideFilePolicy policy; policy.progressCB( bind( &PackageProvider::progressPackageDownload, this, _1 ) ); Modified: branches/REFACTORING-10_3/libzypp/zypp/repo/cached/RepoImpl.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/repo/cached/RepoImpl.cc?rev=5875&r1=5874&r2=5875&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/repo/cached/RepoImpl.cc (original) +++ branches/REFACTORING-10_3/libzypp/zypp/repo/cached/RepoImpl.cc Wed Jul 4 14:01:53 2007 @@ -211,8 +211,8 @@ while ( reader.read() ) { zypp::OnMediaLocation on_media; - on_media.medianr(reader.getint(1)); - on_media.filename(reader.getstring(2)); + on_media.setMedianr(reader.getint(1)); + on_media.setFilename(reader.getstring(2)); string checksum_string(reader.getstring(3)); CheckSum checksum = encoded_string_to_checksum(checksum_string); @@ -221,11 +221,11 @@ ERR << "Wrong checksum for delta, skipping..." << endl; continue; } - on_media.checksum(checksum); - on_media.downloadsize(reader.getint(4)); + on_media.setChecksum(checksum); + on_media.setDownloadsize(reader.getint(4)); packagedelta::DeltaRpm::BaseVersion baseversion; - baseversion.edition( Edition(reader.getstring(6), reader.getstring(7), reader.getstring(8) ) ); + baseversion.setEdition( Edition(reader.getstring(6), reader.getstring(7), reader.getstring(8) ) ); checksum_string = reader.getstring(9); checksum = encoded_string_to_checksum(checksum_string); @@ -234,14 +234,14 @@ ERR << "Wrong checksum for delta, skipping..." << endl; continue; } - baseversion.checksum(checksum); - baseversion.buildtime(reader.getint(10)); - baseversion.sequenceinfo(reader.getstring(11)); + baseversion.setChecksum(checksum); + baseversion.setBuildtime(reader.getint(10)); + baseversion.setSequenceinfo(reader.getstring(11)); zypp::packagedelta::DeltaRpm delta; - delta.location( on_media ); - delta.baseversion( baseversion ); - delta.buildtime(reader.getint(5)); + delta.setLocation( on_media ); + delta.setBaseversion( baseversion ); + delta.setBuildtime(reader.getint(5)); //impl->addDeltaRpm(delta); } @@ -259,8 +259,8 @@ long long patch_package_id = reader.getint64(0); zypp::OnMediaLocation on_media; - on_media.medianr( reader.getint(1) ); - on_media.filename( reader.getstring(2) ); + on_media.setMedianr( reader.getint(1) ); + on_media.setFilename( reader.getstring(2) ); string checksum_string(reader.getstring(3)); CheckSum checksum = encoded_string_to_checksum(checksum_string); @@ -269,12 +269,12 @@ ERR << "Wrong checksum for delta, skipping..." << endl; continue; } - on_media.checksum(checksum); - on_media.downloadsize(reader.getint(4)); + on_media.setChecksum(checksum); + on_media.setDownloadsize(reader.getint(4)); zypp::packagedelta::PatchRpm patch; - patch.location( on_media ); - patch.buildtime(reader.getint(5)); + patch.setLocation( on_media ); + patch.setBuildtime(reader.getint(5)); pp_bv_cmd.bind( ":patch_package_id", patch_package_id ); @@ -282,7 +282,7 @@ while (bv_reader.read()) { packagedelta::PatchRpm::BaseVersion baseversion = packagedelta::PatchRpm::BaseVersion( bv_reader.getstring(0) , bv_reader.getstring(1), bv_reader.getint(2) ); - patch.baseversion(baseversion); + patch.addBaseversion(baseversion); } //impl->addPatchRpm(patch); Modified: branches/REFACTORING-10_3/libzypp/zypp/repo/susetags/Downloader.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/repo/susetags/Downloader.cc?rev=5875&r1=5874&r2=5875&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/repo/susetags/Downloader.cc (original) +++ branches/REFACTORING-10_3/libzypp/zypp/repo/susetags/Downloader.cc Wed Jul 4 14:01:53 2007 @@ -35,7 +35,7 @@ { MediaSetAccess media(_url, _path); Fetcher fetcher; - fetcher.enqueue( OnMediaLocation().filename("/content") ); + fetcher.enqueue( OnMediaLocation().setFilename("/content") ); fetcher.start( dest_dir, media ); fetcher.reset(); @@ -67,7 +67,7 @@ ZYPP_THROW(Exception("bad DESCR line")); } OnMediaLocation location; - location.filename( descr_dir + words[3]).checksum( CheckSum( words[1], words[2] ) ); + location.setFilename( descr_dir + words[3]).setChecksum( CheckSum( words[1], words[2] ) ); fetcher.enqueue(location); } } Modified: branches/REFACTORING-10_3/libzypp/zypp/repo/yum/Downloader.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/repo/yum/Downloader.cc?rev=5875&r1=5874&r2=5875&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/repo/yum/Downloader.cc (original) +++ branches/REFACTORING-10_3/libzypp/zypp/repo/yum/Downloader.cc Wed Jul 4 14:01:53 2007 @@ -88,10 +88,10 @@ _dest_dir = dest_dir; if ( _media.doesFileExist(keypath) ) - _fetcher.enqueue( OnMediaLocation().filename(keypath) ); + _fetcher.enqueue( OnMediaLocation().setFilename(keypath) ); if ( _media.doesFileExist(sigpath) ) - _fetcher.enqueue( OnMediaLocation().filename(sigpath) ); + _fetcher.enqueue( OnMediaLocation().setFilename(sigpath) ); _fetcher.start( dest_dir, _media ); @@ -106,7 +106,7 @@ if ( PathInfo( dest_dir + keypath ).isExist() ) sigchecker.addPublicKey(dest_dir + keypath ); - _fetcher.enqueue( OnMediaLocation().filename(repomdpath), sigchecker ); + _fetcher.enqueue( OnMediaLocation().setFilename(repomdpath), sigchecker ); _fetcher.start( dest_dir, _media); if ( ! progress.tick() ) -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org