From 1a180ab4204fa23c64b3628c4114f056b7f75c22 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Wed, 29 Aug 2007 12:03:00 +0000 Subject: [PATCH] - Fixed PlainDir repositories to provide real disk usage data. For repomd and others that do not provide any detailed disk usage info, assume the packgage size is required below "/". Peviously they were treated as being empy. --- VERSION.cmake | 4 +-- devel/devel.ma/Parse.cc | 70 ++++++++++++++++++++++++++++++-------- devel/devel.ma/Tools.h | 10 ++++++ package/libzypp.changes | 25 +++++++++----- zypp/DiskUsage.h | 12 ++++--- zypp/capability/CapabilityImpl.cc | 10 ++++++ zypp/capability/CapabilityImpl.h | 7 ++++ zypp/capability/FileCap.h | 10 ++++-- zypp/parser/plaindir/RepoParser.cc | 62 +++++++-------------------------- zypp/repo/cached/PackageImpl.cc | 11 ++++++ zypp/repo/cached/SrcPackageImpl.cc | 6 ++++ zypp/target/rpm/RpmDb.cc | 6 +--- 12 files changed, 147 insertions(+), 86 deletions(-) diff --git a/VERSION.cmake b/VERSION.cmake index 454a4a0..3169500 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -46,5 +46,5 @@ SET(LIBZYPP_MAJOR "3") SET(LIBZYPP_MINOR "19") -SET(LIBZYPP_COMPATMINOR "0") -SET(LIBZYPP_PATCH "1") +SET(LIBZYPP_COMPATMINOR "19") +SET(LIBZYPP_PATCH "2") diff --git a/devel/devel.ma/Parse.cc b/devel/devel.ma/Parse.cc index b782b79..5cf9f15 100644 --- a/devel/devel.ma/Parse.cc +++ b/devel/devel.ma/Parse.cc @@ -17,6 +17,7 @@ #include "zypp/Package.h" #include "zypp/Pattern.h" #include "zypp/Language.h" +#include "zypp/Digest.h" #include "zypp/PackageKeyword.h" #include "zypp/NameKindProxy.h" #include "zypp/pool/GetResolvablesToInsDel.h" @@ -48,9 +49,9 @@ struct Xprint { bool operator()( const PoolItem & obj_r ) { - //handle( asKind( obj_r ) ); + handle( asKind( obj_r ) ); //handle( asKind( obj_r ) ); - handle( asKind( obj_r ) ); + //handle( asKind( obj_r ) ); return true; } @@ -59,7 +60,7 @@ struct Xprint if ( !p ) return; - MIL << p->mediaNr() << endl; + MIL << p->diskusage() << endl; } void handle( const Pattern_constPtr & p ) @@ -209,6 +210,52 @@ struct ConvertDbReceive : public callback::ReceiveReport +{ + DigestReceive() + { + connect(); + } + + virtual bool askUserToAcceptNoDigest( const zypp::Pathname &file ) + { + USR << endl; + return false; + } + virtual bool askUserToAccepUnknownDigest( const Pathname &file, const std::string &name ) + { + USR << endl; + return false; + } + virtual bool askUserToAcceptWrongDigest( const Pathname &file, const std::string &requested, const std::string &found ) + { + USR << "fle " << PathInfo(file) << endl; + USR << "req " << requested << endl; + USR << "fnd " << found << endl; + + waitForInput(); + + return false; + } +}; + +struct KeyRingSignalsReceive : public callback::ReceiveReport +{ + KeyRingSignalsReceive() + { + connect(); + } + virtual void trustedKeyAdded( const PublicKey &/*key*/ ) + { + USR << endl; + } + virtual void trustedKeyRemoved( const PublicKey &/*key*/ ) + { + USR << endl; + } +}; /////////////////////////////////////////////////////////////////// @@ -284,6 +331,9 @@ int main( int argc, char * argv[] ) //zypp::base::LogControl::instance().logfile( "log.restrict" ); INT << "===[START]==========================================" << endl; + DigestReceive foo; + KeyRingSignalsReceive baa; + RepoManager repoManager( makeRepoManager( "/Local/ROOT" ) ); RepoInfoList repos = repoManager.knownRepositories(); SEC << repos << endl; @@ -296,7 +346,7 @@ int main( int argc, char * argv[] ) .setName( "Test Repo for factory." ) .setEnabled( true ) .setAutorefresh( false ) - .addBaseUrl( Url("ftp://dist.suse.de/install/stable-x86/") ); + .addBaseUrl( Url("http://dist.suse.de/install/stable-x86/") ); repoManager.addRepository( nrepo ); SEC << "refreshMetadat" << endl; @@ -318,7 +368,7 @@ int main( int argc, char * argv[] ) if ( ! nrepo.enabled() ) continue; - if ( ! repoManager.isCached( nrepo ) || 1 ) + if ( ! repoManager.isCached( nrepo ) || 0 ) { if ( repoManager.isCached( nrepo ) ) { @@ -326,7 +376,7 @@ int main( int argc, char * argv[] ) repoManager.cleanCache( nrepo ); } SEC << "refreshMetadata" << endl; - repoManager.refreshMetadata( nrepo ); + repoManager.refreshMetadata( nrepo, RepoManager::RefreshForced ); SEC << "buildCache" << endl; repoManager.buildCache( nrepo ); } @@ -352,14 +402,6 @@ int main( int argc, char * argv[] ) MIL << "Added target: " << pool << endl; } - Capability _cap( CapFactory().parse( "de" ) ); - SEC << "F" << endl; - forEachMatchIn( pool, Dep::FRESHENS, _cap, Print() ); - SEC << "S" << endl; - forEachMatchIn( pool, Dep::SUPPLEMENTS, _cap, Print() ); - SEC << "P" << endl; - forEachMatchIn( pool, Dep::PROVIDES, _cap, Print() ); - SEC << endl; std::for_each( pool.begin(), pool.end(), Xprint() ); diff --git a/devel/devel.ma/Tools.h b/devel/devel.ma/Tools.h index 206f729..3cc868a 100644 --- a/devel/devel.ma/Tools.h +++ b/devel/devel.ma/Tools.h @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -27,6 +28,15 @@ using std::endl; /////////////////////////////////////////////////////////////////// // +void waitForInput() +{ + int i; + USR << "WAITING FOR INPUT!" << endl; + std::cin >> i; +} + +/////////////////////////////////////////////////////////////////// +// template struct SetTrue { diff --git a/package/libzypp.changes b/package/libzypp.changes index 585f72a..c9356ba 100644 --- a/package/libzypp.changes +++ b/package/libzypp.changes @@ -1,10 +1,19 @@ ------------------------------------------------------------------- +Wed Aug 29 13:55:28 CEST 2007 - ma@suse.de + +- Fixed PlainDir repositories to provide real disk usage data. For + repomd and others that do not provide any detailed disk usage info, + assume the packgage size is required below "/". Peviously they were + treated as being empy. +- version 3.19.2 + +------------------------------------------------------------------- Wed Aug 29 13:36:42 CEST 2007 - schubi@suse.de - Add a new solver solution in the case of running in a timeout: - ProblemSolutionDoubleTimeout.h - #Bug 302496 - -r 6970 + ProblemSolutionDoubleTimeout.h + #Bug 302496 +- revision 6970 ------------------------------------------------------------------- Wed Aug 29 11:23:26 CEST 2007 - dmacvicar@suse.de @@ -33,7 +42,7 @@ Tue Aug 28 17:30:30 CEST 2007 - kkaempf@suse.de ------------------------------------------------------------------- Tue Aug 28 11:27:53 CEST 2007 - dmacvicar@suse.de -- real fix for reading signature ids. (#390535). +- real fix for reading signature ids. (#390535). - delete metadata when removing repo (#301037). ------------------------------------------------------------------- @@ -69,7 +78,7 @@ Mon Aug 27 15:53:52 CEST 2007 - schubi@suse.de * Changing of filesystem whithin a workflow, cause the solver results will be reset if the filesystem dependencies have been changed Bug 271912 -- r 6901 +- r 6901 ------------------------------------------------------------------- Sun Aug 26 15:49:27 CEST 2007 - kkaempf@suse.de @@ -90,15 +99,15 @@ Fri Aug 24 11:52:27 CEST 2007 - dmacvicar@suse.de intsys mode (#297136) - signature and checksum verification fixes. Still pending problem ZYpp getting no output from gpg when running from zypper. - (#302059) + (#302059) ------------------------------------------------------------------- Thu Aug 23 13:51:41 CEST 2007 - schubi@suse.de -- Do not strip resolvables which have the same name but different kind +- Do not strip resolvables which have the same name but different kind (ResolverInfo*) - Flag info NEEDEDBY correctly if it will be used by freshen/supplement -- r 6830 +- r 6830 ------------------------------------------------------------------- Wed Aug 22 18:58:44 CEST 2007 - mvidner@suse.cz diff --git a/zypp/DiskUsage.h b/zypp/DiskUsage.h index 72fa82f..c1501c9 100644 --- a/zypp/DiskUsage.h +++ b/zypp/DiskUsage.h @@ -62,7 +62,7 @@ namespace zypp } /** - * + * **/ const Entry & operator=( const Entry & rhs ) const { return rhs; @@ -106,6 +106,10 @@ namespace zypp add( Entry( dirname_r, size_r, files_r ) ); } /** + * Whether there is no entry available. + */ + bool empty() const { return _dirs.empty(); } + /** * Number of entries **/ unsigned size() const { return _dirs.size(); } @@ -123,7 +127,7 @@ namespace zypp typedef EntrySet::iterator iterator; typedef EntrySet::reverse_iterator reverse_iterator; - + /** * Forward iterator pointing to the first entry (if any) **/ @@ -140,10 +144,10 @@ namespace zypp * Reverse iterator pointing before the first entry. **/ reverse_iterator rend() { return _dirs.rend(); } - + typedef EntrySet::const_iterator const_iterator; typedef EntrySet::const_reverse_iterator const_reverse_iterator; - + /** * Forward const iterator pointing to the first entry (if any) **/ diff --git a/zypp/capability/CapabilityImpl.cc b/zypp/capability/CapabilityImpl.cc index 1214ac0..544c80f 100644 --- a/zypp/capability/CapabilityImpl.cc +++ b/zypp/capability/CapabilityImpl.cc @@ -99,6 +99,16 @@ namespace zypp return *name_r.c_str() == '/'; } + bool isInterestingFileSpec( const std::string & name_r ) + { + static str::smatch what; + static const str::regex filenameRegex( + "/(s?bin|lib(64)?|etc)/|^/usr/(games/|share/(dict/words|magic\\.mime)$)|^/opt/gnome/games/", + str::regex::optimize|str::regex::nosubs ); + + return str::regex_match( name_r, what, filenameRegex ); + } + bool isSplitSpec( const std::string & name_r ) { return name_r.find( ":/" ) != std::string::npos; diff --git a/zypp/capability/CapabilityImpl.h b/zypp/capability/CapabilityImpl.h index 0fe01c6..01020dc 100644 --- a/zypp/capability/CapabilityImpl.h +++ b/zypp/capability/CapabilityImpl.h @@ -173,6 +173,13 @@ namespace zypp /** Test for a FileCap. \a name_r starts with \c "/". */ bool isFileSpec( const std::string & name_r ); + /** Test for a FileCap that is likely being REQUIRED. + * Files below \c /bin , \c /sbin , \c /lib etc. Scanning a + * packages filelist, an \e interesting FileCap might be worth + * being remembered in PROVIDES. + */ + bool isInterestingFileSpec( const std::string & name_r ); + /** Test for a SplitCap. \a name_r constains \c ":/". */ bool isSplitSpec( const std::string & name_r ); diff --git a/zypp/capability/FileCap.h b/zypp/capability/FileCap.h index b38fc70..f5a3f33 100644 --- a/zypp/capability/FileCap.h +++ b/zypp/capability/FileCap.h @@ -22,13 +22,17 @@ namespace zypp { ///////////////////////////////////////////////////////////////// DEFINE_PTR_TYPE(FileCap) - + /////////////////////////////////////////////////////////////////// // // CLASS NAME : FileCap // /** A \c filename matching if some Resolvable provides it. * + * \see \ref capability::isInterestingFileSpec to test whether some + * filename is likely targeted by some requires, thus worth being + * provided. + * * \todo Check whether we have to look into the Resolable filelist as well. */ class FileCap : public CapabilityImpl @@ -37,7 +41,7 @@ namespace zypp typedef FileCap Self; typedef FileCap_Ptr Ptr; typedef FileCap_constPtr constPtr; - + /** Ctor */ FileCap( const Resolvable::Kind & refers_r, const std::string & fname_r ) : CapabilityImpl( refers_r ) @@ -47,7 +51,7 @@ namespace zypp public: std::string filename() const { return _fname; } - + /** */ virtual const Kind & kind() const; diff --git a/zypp/parser/plaindir/RepoParser.cc b/zypp/parser/plaindir/RepoParser.cc index 61b0b97..dc6e31d 100644 --- a/zypp/parser/plaindir/RepoParser.cc +++ b/zypp/parser/plaindir/RepoParser.cc @@ -45,10 +45,10 @@ static time_t recursive_timestamp( const Pathname &dir ) ERR << "readdir " << dir << " failed" << endl; return 0; } - + for (std::list::const_iterator it = dircontent.begin(); it != dircontent.end(); - ++it) + ++it) { Pathname dir_path = dir + *it; if ( PathInfo(dir_path).isDir()) @@ -69,7 +69,7 @@ RepoStatus dirStatus( const Pathname &dir ) status.setChecksum(str::numstring(t)); return status; } - + data::Package_Ptr makePackageDataFromHeader( const RpmHeader::constPtr header, set * filerequires, const Pathname & location, data::RecordId &repoid ) @@ -81,15 +81,10 @@ data::Package_Ptr makePackageDataFromHeader( const RpmHeader::constPtr header, WAR << "Can't make Package from SourcePackage header" << endl; return 0; } - + data::Package_Ptr pkg = new data::Package; - -// typedef std::set DependencyList; -// typedef std::map Dependencies; + pkg->name = header->tag_name(); -// impl->setRepository( repo ); -// if (!location.empty()) -// impl->setLocation( location ); try { pkg->edition = Edition( header->tag_version(), @@ -114,7 +109,7 @@ data::Package_Ptr makePackageDataFromHeader( const RpmHeader::constPtr header, WAR << "Package " << pkg->name << " has bad architecture '" << header->tag_arch() << "'"; return 0; } - + pkg->deps[Dep::REQUIRES] = header->tag_requires( filerequires ); pkg->deps[Dep::PREREQUIRES] = header->tag_prerequires( filerequires ); pkg->deps[Dep::CONFLICTS] = header->tag_conflicts( filerequires ); @@ -128,51 +123,18 @@ data::Package_Ptr makePackageDataFromHeader( const RpmHeader::constPtr header, pkg->description = (TranslatedText)header->tag_description(); pkg->licenseToConfirm = (TranslatedText)header->tag_license(); -// Dependencies deps; - -// RecordId shareDataWith; -// std::string vendor; -// ByteCount installedSize; -// Date buildTime; -// DefaultIntegral installOnly; -// TranslatedText summary; -// TranslatedText description; -// TranslatedText licenseToConfirm; -// TranslatedText insnotify; -// TranslatedText delnotify; -// RecordId repository; - -// Location repositoryLocation; - - pkg->repositoryLocation = location; - -// std::string group; -// std::set keywords; -// Changelog changelog; -// std::list authors; -// std::string buildhost; -// std::string distribution; -// std::string license; -// std::string packager; -// std::string url; -// std::string operatingSystem; -// std::string prein; -// std::string postin; -// std::string preun; -// std::string postun; -// + pkg->repositoryLocation = location; + + header->tag_du( pkg->diskusage ); list filenames = header->tag_filenames(); pkg->deps[Dep::PROVIDES] = header->tag_provides ( filerequires ); - static str::smatch what; - static const str::regex filenameRegex( "/(s?bin|lib(64)?|etc)/|^/usr/(games/|share/(dict/words|magic\\.mime)$)|^/opt/gnome/games/", - str::regex::optimize|str::regex::nosubs ); for (list::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) { - if ( str::regex_match( *filename, what, filenameRegex ) ) + if ( capability::isInterestingFileSpec( *filename ) ) { try { pkg->deps[Dep::PROVIDES].insert(capability::buildFile( ResTraits::kind, *filename )); @@ -188,7 +150,7 @@ data::Package_Ptr makePackageDataFromHeader( const RpmHeader::constPtr header, return pkg; } - + /** RepoParser implementation. * \todo Clean data on exeption. */ @@ -216,7 +178,7 @@ class RepoParser::Impl private: // these (and _ticks) are actually scoped per parse() run. }; -/////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// // diff --git a/zypp/repo/cached/PackageImpl.cc b/zypp/repo/cached/PackageImpl.cc index 6c696de..c5392b3 100644 --- a/zypp/repo/cached/PackageImpl.cc +++ b/zypp/repo/cached/PackageImpl.cc @@ -197,6 +197,17 @@ const DiskUsage & PackageImpl::diskusage() const // lazy init _diskusage.reset( new DiskUsage ); _repository->resolvableQuery().queryDiskUsage( _id, *_diskusage ); + if ( _diskusage->empty() ) + { + // No info: Creating a faked entry distributing the + // total package size in assumed 200 files to "/ZYPP_NO_DU_INFO" + // + // Note: Less likely that some system has a mountpoint named + // ZYPP_NO_DU_INFO, so the size will be accounted to '/'. + // but adding a faked mountpoint entry an application is able + // to spot and handle these faked data in a different manner. + _diskusage->add( "/ZYPP_NO_DU_INFO", size(), 200 ); + } } return *_diskusage; } diff --git a/zypp/repo/cached/SrcPackageImpl.cc b/zypp/repo/cached/SrcPackageImpl.cc index a0ceb61..054fa45 100644 --- a/zypp/repo/cached/SrcPackageImpl.cc +++ b/zypp/repo/cached/SrcPackageImpl.cc @@ -118,6 +118,12 @@ const DiskUsage & SrcPackageImpl::diskusage() const // lazy init _diskusage.reset( new DiskUsage ); _repository->resolvableQuery().queryDiskUsage( _id, *_diskusage ); + if ( _diskusage->empty() ) + { + // No info: Creating a faked entry distributing the + // total source package size in assumed 20 files to "/usr/src/packages" + _diskusage->add( "/usr/src/packages", size(), 20 ); + } } return *_diskusage; } diff --git a/zypp/target/rpm/RpmDb.cc b/zypp/target/rpm/RpmDb.cc index bfe186c..197f1ff 100644 --- a/zypp/target/rpm/RpmDb.cc +++ b/zypp/target/rpm/RpmDb.cc @@ -1215,15 +1215,11 @@ Package::Ptr RpmDb::makePackageFromHeader( const RpmHeader::constPtr header, CapFactory capfactory; insertCaps( dataCollect[Dep::PROVIDES], header->tag_provides( filerequires ), capfactory ); - static str::smatch what; - static const str::regex filenameRegex( "/(s?bin|lib(64)?|etc)/|^/usr/(games/|share/(dict/words|magic\\.mime)$)|^/opt/gnome/games/", - str::regex::optimize|str::regex::nosubs ); - for (list::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) { - if ( str::regex_match( *filename, what, filenameRegex ) ) + if ( capability::isInterestingFileSpec( *filename ) ) { try { -- 2.7.4