Author: mlandres Date: Wed Apr 16 12:57:30 2008 New Revision: 9664 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9664&view=rev Log: - initializeTarget now takes an additional option, telling whether to rebuild an existing rpm database before using it. Default is false. Modified: trunk/libzypp/VERSION.cmake trunk/libzypp/devel/devel.ma/NewPool.cc trunk/libzypp/package/libzypp.changes trunk/libzypp/zypp/Target.cc trunk/libzypp/zypp/Target.h trunk/libzypp/zypp/ZYpp.cc trunk/libzypp/zypp/ZYpp.h trunk/libzypp/zypp/target/TargetImpl.cc trunk/libzypp/zypp/target/TargetImpl.h trunk/libzypp/zypp/target/rpm/RpmDb.cc trunk/libzypp/zypp/target/rpm/RpmDb.h trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc trunk/libzypp/zypp/zypp_detail/ZYppImpl.h Modified: trunk/libzypp/VERSION.cmake URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/VERSION.cmake?rev=9664&r1=9663&r2=9664&view=diff ============================================================================== --- trunk/libzypp/VERSION.cmake (original) +++ trunk/libzypp/VERSION.cmake Wed Apr 16 12:57:30 2008 @@ -45,6 +45,6 @@ # SET(LIBZYPP_MAJOR "4") -SET(LIBZYPP_MINOR "12") -SET(LIBZYPP_COMPATMINOR "12") -SET(LIBZYPP_PATCH "1") +SET(LIBZYPP_MINOR "13") +SET(LIBZYPP_COMPATMINOR "13") +SET(LIBZYPP_PATCH "0") Modified: trunk/libzypp/devel/devel.ma/NewPool.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/NewPool.cc?rev=9664&r1=9663&r2=9664&view=diff ============================================================================== --- trunk/libzypp/devel/devel.ma/NewPool.cc (original) +++ trunk/libzypp/devel/devel.ma/NewPool.cc Wed Apr 16 12:57:30 2008 @@ -619,7 +619,7 @@ { Measure x( "INIT TARGET" ); { - getZYpp()->initializeTarget( sysRoot ); + getZYpp()->initializeTarget( sysRoot, true ); getZYpp()->target()->load(); } } @@ -661,6 +661,8 @@ } } + SEC << zypp::getZYpp()->diskUsage() << endl; + if ( 1 ) { PoolItem pi ( getPi<Package>("amarok") ); @@ -675,6 +677,9 @@ } } + + SEC << zypp::getZYpp()->diskUsage() << endl; + //vdumpPoolStats( USR << "Pool:"<< endl, pool.begin(), pool.end() ) << endl; //waitForInput(); Modified: trunk/libzypp/package/libzypp.changes URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=9664&r1=9663&r2=9664&view=diff ============================================================================== --- trunk/libzypp/package/libzypp.changes (original) +++ trunk/libzypp/package/libzypp.changes Wed Apr 16 12:57:30 2008 @@ -1,4 +1,13 @@ ------------------------------------------------------------------- +Wed Apr 16 12:50:09 CEST 2008 - ma@suse.de + +- initializeTarget now takes an additional option, telling whether to + rebuild an existing rpm database before using it. Default is false. + (#308352) +- version 4.13.0 +- revision 9664 + +------------------------------------------------------------------- Tue Apr 15 12:57:42 CEST 2008 - jreidinger@suse.cz - save do nothing if no locks added/removed Modified: trunk/libzypp/zypp/Target.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Target.cc?rev=9664&r1=9663&r2=9664&view=diff ============================================================================== --- trunk/libzypp/zypp/Target.cc (original) +++ trunk/libzypp/zypp/Target.cc Wed Apr 16 12:57:30 2008 @@ -29,8 +29,8 @@ // METHOD NAME : Target::Target // METHOD TYPE : Ctor // - Target::Target( const Pathname & root ) - : _pimpl( new Impl(root) ) + Target::Target( const Pathname & root, bool doRebuild_r ) + : _pimpl( new Impl(root,doRebuild_r) ) { } Modified: trunk/libzypp/zypp/Target.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Target.h?rev=9664&r1=9663&r2=9664&view=diff ============================================================================== --- trunk/libzypp/zypp/Target.h (original) +++ trunk/libzypp/zypp/Target.h Wed Apr 16 12:57:30 2008 @@ -99,9 +99,11 @@ Date timestamp() const; public: - /** Ctor */ + /** Ctor. If \c doRebuild_r is \c true, an already existing + * database is rebuilt (rpm --rebuilddb ). + */ explicit - Target( const Pathname & root = "/" ); + Target( const Pathname & root = "/", bool doRebuild_r = false ); /** Ctor */ explicit Target( const Impl_Ptr & impl_r ); Modified: trunk/libzypp/zypp/ZYpp.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZYpp.cc?rev=9664&r1=9663&r2=9664&view=diff ============================================================================== --- trunk/libzypp/zypp/ZYpp.cc (original) +++ trunk/libzypp/zypp/ZYpp.cc Wed Apr 16 12:57:30 2008 @@ -85,8 +85,8 @@ Target_Ptr ZYpp::target() const { return _pimpl->target(); } - void ZYpp::initializeTarget(const Pathname & root) - { _pimpl->initializeTarget(root); } + void ZYpp::initializeTarget( const Pathname & root, bool doRebuild_r ) + { _pimpl->initializeTarget( root, doRebuild_r ); } void ZYpp::finishTarget() { _pimpl->finishTarget(); } Modified: trunk/libzypp/zypp/ZYpp.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZYpp.h?rev=9664&r1=9663&r2=9664&view=diff ============================================================================== --- trunk/libzypp/zypp/ZYpp.h (original) +++ trunk/libzypp/zypp/ZYpp.h Wed Apr 16 12:57:30 2008 @@ -86,9 +86,11 @@ /** * \throws Exception - * just init the target, dont populate store or pool + * Just init the target, dont populate store or pool. + * If \c doRebuild_r is \c true, an already existing + * database is rebuilt (rpm --rebuilddb ). */ - void initializeTarget(const Pathname & root); + void initializeTarget(const Pathname & root, bool doRebuild_r = false); /** * \throws Exception Modified: trunk/libzypp/zypp/target/TargetImpl.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/TargetImpl.cc?rev=9664&r1=9663&r2=9664&view=diff ============================================================================== --- trunk/libzypp/zypp/target/TargetImpl.cc (original) +++ trunk/libzypp/zypp/target/TargetImpl.cc Wed Apr 16 12:57:30 2008 @@ -68,10 +68,10 @@ /////////////////////////////////////////////////////////////////// namespace { ///////////////////////////////////////////////////////////////// - + // Execute file (passed as pi_t) as script // report against report_r - // + // void ExecuteScript( const Pathname & pn_r, callback::SendReport<ScriptResolvableReport> * report) { @@ -110,22 +110,22 @@ } return; } - + // Check for (and run) update script // path: directory where to look // name,version,release: Script name must match 'name-version.release-' prefix - // + // void RunUpdateScript(Pathname path, std::string name, std::string version, std::string release) { // open the scripts directory - + DIR *dir = opendir(path.asString().c_str()); if (!dir) { WAR << "Cannot access directory " << path << endl; return; } - + // compute the name-version.release- prefix std::string prefix = name + "-" + version + "." + release + "-"; size_t pfx_size = prefix.length(); @@ -134,7 +134,7 @@ ERR << "Prefix size (" << pfx_size << ") larger than supported (255)" << endl; pfx_size = 255; } - + // scan directory for match const char *found = NULL; struct dirent *dentry; @@ -152,12 +152,12 @@ closedir(dir); return; } - + // Fetch and execute remote script // access_r: remote access handle // script_r: script (resolvable) handle // do_r: true for 'do', false for 'undo' - // + // void ExecuteScriptHelper( repo::RepoMediaAccess & access_r, Script::constPtr script_r, bool do_r ) @@ -186,7 +186,7 @@ ExecuteScript( localfile, &report ); report->finish(); - + return; } @@ -276,11 +276,11 @@ // METHOD NAME : TargetImpl::TargetImpl // METHOD TYPE : Ctor // - TargetImpl::TargetImpl(const Pathname & root_r) - : _root(root_r) + TargetImpl::TargetImpl( const Pathname & root_r, bool doRebuild_r ) + : _root( root_r ) , _requestedLocalesFile( home() / "RequestedLocales" ) { - _rpm.initDatabase(root_r); + _rpm.initDatabase( root_r, Pathname(), doRebuild_r ); MIL << "Initialized target on " << _root << endl; } @@ -393,7 +393,7 @@ Repository system( satpool.systemRepo() ); system.eraseFromPool(); } - + void TargetImpl::load() { Modified: trunk/libzypp/zypp/target/TargetImpl.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/TargetImpl.h?rev=9664&r1=9663&r2=9664&view=diff ============================================================================== --- trunk/libzypp/zypp/target/TargetImpl.h (original) +++ trunk/libzypp/zypp/target/TargetImpl.h Wed Apr 16 12:57:30 2008 @@ -61,7 +61,7 @@ public: /** Ctor. */ - TargetImpl(const Pathname & root_r = "/"); + TargetImpl(const Pathname & root_r = "/", bool doRebuild_r = false ); /** Dtor. */ virtual ~TargetImpl(); Modified: trunk/libzypp/zypp/target/rpm/RpmDb.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/rpm/RpmDb.cc?rev=9664&r1=9663&r2=9664&view=diff ============================================================================== --- trunk/libzypp/zypp/target/rpm/RpmDb.cc (original) +++ trunk/libzypp/zypp/target/rpm/RpmDb.cc Wed Apr 16 12:57:30 2008 @@ -370,7 +370,7 @@ // METHOD NAME : RpmDb::initDatabase // METHOD TYPE : PMError // -void RpmDb::initDatabase( Pathname root_r, Pathname dbPath_r ) +void RpmDb::initDatabase( Pathname root_r, Pathname dbPath_r, bool doRebuild_r ) { /////////////////////////////////////////////////////////////////// // Check arguments @@ -387,7 +387,8 @@ ZYPP_THROW(RpmInvalidRootException(root_r, dbPath_r)); } - MIL << "Calling initDatabase: " << stringPath( root_r, dbPath_r ) << endl; + MIL << "Calling initDatabase: " << stringPath( root_r, dbPath_r ) + << ( doRebuild_r ? " (rebuilddb)" : "" ) << endl; /////////////////////////////////////////////////////////////////// // Check whether already initialized @@ -450,17 +451,15 @@ _dbPath = dbPath_r; _dbStateInfo = info; -#warning Add rebuild database once have the info about context -#if 0 - if ( ! ( Y2PM::runningFromSystem() ) ) + if ( doRebuild_r ) { + INT << "ping" << dbsi_has( info, DbSI_HAVE_V4 ) << dbsi_has( info, DbSI_MADE_V4 ) << endl; if ( dbsi_has( info, DbSI_HAVE_V4 ) - && ! dbsi_has( info, DbSI_MADE_V4 ) ) + && ! dbsi_has( info, DbSI_MADE_V4 ) ) { - err = rebuildDatabase(); + rebuildDatabase(); } } -#endif MIL << "Syncronizing keys with zypp keyring" << endl; // we do this one by one now. @@ -586,11 +585,6 @@ { WAR << "Non empty rpm3 and rpm4 database found: using rpm4" << endl; -#warning EXCEPTION: nonempty rpm4 and rpm3 database found. - //ConvertDbReport::Send report( RpmDbCallbacks::convertDbReport ); - //report->start( dbInfo.dbV3().path() ); - //report->stop( some error ); - // set DbSI_MODIFIED_V4 as it's not a temporary which can be removed. dbsi_set( info_r, DbSI_MODIFIED_V4 ); @@ -871,7 +865,12 @@ if ( newMaster() ) { // file is removed at the end of rebuild. // current size should be upper limit for new db - report->progress( (100 * newMaster.size()) / dbMaster.size(), root() + dbPath()); + if ( ! report->progress( (100 * newMaster.size()) / dbMaster.size(), root() + dbPath()) ) + { + WAR << "User requested abort." << endl; + systemKill(); + filesystem::recursive_rmdir( newMaster.path().dirname() ); + } } if ( line.compare( 0, 2, "D:" ) ) Modified: trunk/libzypp/zypp/target/rpm/RpmDb.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/rpm/RpmDb.h?rev=9664&r1=9663&r2=9664&view=diff ============================================================================== --- trunk/libzypp/zypp/target/rpm/RpmDb.h (original) +++ trunk/libzypp/zypp/target/rpm/RpmDb.h Wed Apr 16 12:57:30 2008 @@ -187,11 +187,15 @@ * (no packages were installed or deleted). Otherwise the new database * is kept, and the old one is removed. * + * If the database alredy exists and \c doRebuild_r is true, \ref rebuildDatabase + * is called. + * * \throws RpmException * **/ void initDatabase( Pathname root_r = Pathname(), - Pathname dbPath_r = Pathname() ); + Pathname dbPath_r = Pathname(), + bool doRebuild_r = false ); /** * Block further access to the rpm database and go back to uninitialized @@ -406,7 +410,7 @@ * The exit code of the rpm process, or -1 if not yet known. */ int exit_code; - + /** * Error message from running rpm as external program. * Use only if something fail. Modified: trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc?rev=9664&r1=9663&r2=9664&view=diff ============================================================================== --- trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc (original) +++ trunk/libzypp/zypp/zypp_detail/ZYppImpl.cc Wed Apr 16 12:57:30 2008 @@ -34,7 +34,7 @@ { ///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// namespace zypp_detail - { ///////////////////////////////////////////////////////////////// + { ///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// // @@ -94,9 +94,9 @@ return _target; } - void ZYppImpl::initializeTarget(const Pathname & root) + void ZYppImpl::initializeTarget( const Pathname & root, bool doRebuild_r ) { - MIL << "initTarget( " << root << endl; + MIL << "initTarget( " << root << (doRebuild_r?", rebuilddb":"") << ")" << endl; if (_target) { if (_target->root() == root) { MIL << "Repeated call to initializeTarget()" << endl; @@ -104,9 +104,9 @@ } _target->unload(); - + } - _target = new Target( root ); + _target = new Target( root, doRebuild_r ); _target->buildCache(); } @@ -114,7 +114,7 @@ { if (_target) _target->unload(); - + _target = 0; } @@ -139,9 +139,9 @@ if (! policy_r.dryRun() ) { DBG << "unloading " << sat::Pool::instance().systemRepoName() << " repo from pool" << endl; - + _target->unload(); - + if ( policy_r.syncPoolAfterCommit() ) { // reload new status from target Modified: trunk/libzypp/zypp/zypp_detail/ZYppImpl.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/zypp_detail/ZYppImpl.h?rev=9664&r1=9663&r2=9664&view=diff ============================================================================== --- trunk/libzypp/zypp/zypp_detail/ZYppImpl.h (original) +++ trunk/libzypp/zypp/zypp_detail/ZYppImpl.h Wed Apr 16 12:57:30 2008 @@ -73,7 +73,7 @@ * \throws Exception * true, just init the target, dont populate store or pool */ - void initializeTarget(const Pathname & root); + void initializeTarget( const Pathname & root, bool doRebuild_r ); /** * \throws Exception -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org