Author: mlandres Date: Tue Mar 4 18:21:33 2008 New Revision: 9008 URL: http://svn.opensuse.org/viewcvs/zypp?rev=9008&view=rev Log: - Try to rebuild broken solv files in RepoManager::loadFromCache. - Fix RepoStatus::operator&& and RepoStatus testsuite. Modified: trunk/libzypp/devel/devel.ma/NewPool.cc trunk/libzypp/package/libzypp.changes trunk/libzypp/tests/zypp/CMakeLists.txt trunk/libzypp/tests/zypp/CheckSum_test.cc trunk/libzypp/tests/zypp/RepoStatus_test.cc trunk/libzypp/tests/zypp/Vendor_test.cc trunk/libzypp/tests/zypp/data/Vendor/zypp2.conf trunk/libzypp/zypp/RepoManager.cc trunk/libzypp/zypp/RepoStatus.cc trunk/libzypp/zypp/target/TargetImpl.cc Modified: trunk/libzypp/devel/devel.ma/NewPool.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/devel/devel.ma/NewPool.cc?rev=9008&r1=9007&r2=9008&view=diff ============================================================================== --- trunk/libzypp/devel/devel.ma/NewPool.cc (original) +++ trunk/libzypp/devel/devel.ma/NewPool.cc Tue Mar 4 18:21:33 2008 @@ -508,10 +508,7 @@ } } - satpool.addRequestedLocale( Locale("de_DE") ); - satpool.addRequestedLocale( Locale("pt_BR") ); - - if ( 1 ) + if ( 0 ) { Measure x( "INIT TARGET" ); { @@ -524,9 +521,6 @@ /////////////////////////////////////////////////////////////////// - MIL << "pool: " << pool.getRequestedLocales() << endl; - install(); - if ( 0 ) { Measure x( "Upgrade" ); Modified: trunk/libzypp/package/libzypp.changes URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=9008&r1=9007&r2=9008&view=diff ============================================================================== --- trunk/libzypp/package/libzypp.changes (original) +++ trunk/libzypp/package/libzypp.changes Tue Mar 4 18:21:33 2008 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Tue Mar 4 18:17:41 CET 2008 - ma@suse.de + +- Try to rebuild broken solv files in RepoManager::loadFromCache. +- Fix RepoStatus::operator&& and RepoStatus testsuite. +- revision 9008 + +------------------------------------------------------------------- Tue Mar 4 16:09:14 CET 2008 - schubi@suse.de - improved problem description while a vendor change Modified: trunk/libzypp/tests/zypp/CMakeLists.txt URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/CMakeLists.txt?rev=9008&r1=9007&r2=9008&view=diff ============================================================================== --- trunk/libzypp/tests/zypp/CMakeLists.txt (original) +++ trunk/libzypp/tests/zypp/CMakeLists.txt Tue Mar 4 18:21:33 2008 @@ -2,3 +2,4 @@ ADD_TESTS(RWPtr Vendor TranslatedText PoolQuery KeyRing MediaSetAccess ResKind Arch Url Edition Capabilities CheckSum PublicKey PathInfo Digest Fetcher FileChecker RepoManager RepoInfo RepoStatus ProgressData ) +EXEC_PROGRAM( ln ARGS -sf "${CMAKE_CURRENT_SOURCE_DIR}/data" "${CMAKE_CURRENT_BINARY_DIR}/data" ) Modified: trunk/libzypp/tests/zypp/CheckSum_test.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/CheckSum_test.cc?rev=9008&r1=9007&r2=9008&view=diff ============================================================================== --- trunk/libzypp/tests/zypp/CheckSum_test.cc (original) +++ trunk/libzypp/tests/zypp/CheckSum_test.cc Tue Mar 4 18:21:33 2008 @@ -22,7 +22,4 @@ BOOST_CHECK_THROW( CheckSum( "sha1", "dsdsads" ), Exception ); // wrong size BOOST_CHECK_THROW( CheckSum( "sha256", "dsdsads" ), Exception ); // wrong size BOOST_CHECK_THROW( CheckSum( "md5", "dsdsads" ), Exception ); // wrong size - BOOST_CHECK_THROW( CheckSum( "md4", "dsdsads" ), Exception ); // wrong size - BOOST_CHECK_THROW( CheckSum( "md2", "dsdsads" ), Exception ); // wrong size - } Modified: trunk/libzypp/tests/zypp/RepoStatus_test.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/RepoStatus_test.cc?rev=9008&r1=9007&r2=9008&view=diff ============================================================================== --- trunk/libzypp/tests/zypp/RepoStatus_test.cc (original) +++ trunk/libzypp/tests/zypp/RepoStatus_test.cc Tue Mar 4 18:21:33 2008 @@ -16,6 +16,18 @@ BOOST_AUTO_TEST_CASE(repostatus_test) { - TmpDir tmpPath; + TmpFile tmpPath; + TmpFile tmpPath2; RepoStatus status; + RepoStatus fstatus( tmpPath ); + RepoStatus fstatus2( tmpPath2 ); + BOOST_CHECK_EQUAL( status.empty(), true ); + BOOST_CHECK_EQUAL( (status&&status).empty(), true ); + + BOOST_CHECK_EQUAL( fstatus.empty(), false ); + BOOST_CHECK_EQUAL( (fstatus&&status).empty(), false ); + + BOOST_CHECK_EQUAL( (fstatus&&status).checksum(), (status&&fstatus).checksum() ); + BOOST_CHECK_EQUAL( (fstatus&&fstatus2).checksum(), (fstatus2&&fstatus).checksum() ); + } Modified: trunk/libzypp/tests/zypp/Vendor_test.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/Vendor_test.cc?rev=9008&r1=9007&r2=9008&view=diff ============================================================================== --- trunk/libzypp/tests/zypp/Vendor_test.cc (original) +++ trunk/libzypp/tests/zypp/Vendor_test.cc Tue Mar 4 18:21:33 2008 @@ -16,16 +16,21 @@ using namespace std; using namespace zypp; +namespace zypp +{ + void reconfigureZConfig( const Pathname & ); +} + #define DATADIR (Pathname(TESTS_SRC_DIR) + "/zypp/data/Vendor") BOOST_AUTO_TEST_CASE(vendor_test1) { - setenv("ZYPP_CONF", (DATADIR + "zypp1.conf").c_str(), 1 ); + reconfigureZConfig( DATADIR / "zypp1.conf" ); // No vendor definition files has been readed. So only suse,opensuse vendors are // equivalent BOOST_REQUIRE( VendorAttr::instance().equivalent("suse", "suse") ); BOOST_REQUIRE( VendorAttr::instance().equivalent("equal", "equal") ); - BOOST_REQUIRE( VendorAttr::instance().equivalent("suse", "SuSE") ); + BOOST_REQUIRE( VendorAttr::instance().equivalent("suse", "SuSE") ); BOOST_REQUIRE( VendorAttr::instance().equivalent("opensuse", "SuSE") ); BOOST_REQUIRE( !VendorAttr::instance().equivalent("open", "SuSE") ); BOOST_REQUIRE( !VendorAttr::instance().equivalent("nothing", "SuSE") ); @@ -33,20 +38,20 @@ BOOST_AUTO_TEST_CASE(vendor_test2) { - setenv("ZYPP_CONF", (DATADIR + "zypp2.conf").c_str(), 1 ); + reconfigureZConfig( DATADIR / "zypp2.conf" ); // No vendor definition files has been readed. So only suse,opensuse vendors are // equivalent BOOST_REQUIRE( VendorAttr::instance().equivalent("suse", "suse") ); BOOST_REQUIRE( VendorAttr::instance().equivalent("equal", "equal") ); - BOOST_REQUIRE( VendorAttr::instance().equivalent("suse", "SuSE") ); - BOOST_REQUIRE( VendorAttr::instance().equivalent("opensuse", "SuSE") ); + BOOST_REQUIRE( VendorAttr::instance().equivalent("suse", "SuSE") ); + BOOST_REQUIRE( !VendorAttr::instance().equivalent("opensuse", "SuSE") ); BOOST_REQUIRE( !VendorAttr::instance().equivalent("open", "SuSE") ); BOOST_REQUIRE( !VendorAttr::instance().equivalent("nothing", "SuSE") ); BOOST_REQUIRE( VendorAttr::instance().equivalent("nvidia", "SuSE") ); - BOOST_REQUIRE( VendorAttr::instance().equivalent("nvidia_new_new", "SuSE") ); - BOOST_REQUIRE( VendorAttr::instance().equivalent("nvidia", "opensuse") ); + BOOST_REQUIRE( VendorAttr::instance().equivalent("nvidia_new_new", "SuSE") ); + BOOST_REQUIRE( !VendorAttr::instance().equivalent("nvidia", "opensuse") ); BOOST_REQUIRE( !VendorAttr::instance().equivalent("ati", "SuSE") ); BOOST_REQUIRE( !VendorAttr::instance().equivalent("ati", "nvidia") ); - BOOST_REQUIRE( VendorAttr::instance().equivalent("ati_new", "ati") ); + BOOST_REQUIRE( VendorAttr::instance().equivalent("ati_new", "ati") ); } Modified: trunk/libzypp/tests/zypp/data/Vendor/zypp2.conf URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/data/Vendor/zypp2.conf?rev=9008&r1=9007&r2=9008&view=diff ============================================================================== --- trunk/libzypp/tests/zypp/data/Vendor/zypp2.conf (original) +++ trunk/libzypp/tests/zypp/data/Vendor/zypp2.conf Tue Mar 4 18:21:33 2008 @@ -122,5 +122,6 @@ ## Valid values: A directory ## Default value: /etc/zypp/vondors.d ## -vendordir = ./../../tests/zypp/data/Vendor/vendors.d +#vendordir = ./../../tests/zypp/data/Vendor/vendors.d +vendordir = ./data/Vendor/vendors.d Modified: trunk/libzypp/zypp/RepoManager.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoManager.cc?rev=9008&r1=9007&r2=9008&view=diff ============================================================================== --- trunk/libzypp/zypp/RepoManager.cc (original) +++ trunk/libzypp/zypp/RepoManager.cc Tue Mar 4 18:21:33 2008 @@ -670,7 +670,6 @@ Pathname base = _pimpl->options.repoCachePath + info.escaped_alias(); Pathname solvfile = base.extend(".solv"); - //cache::SolvStore store(_pimpl->options.repoCachePath); RepoStatus raw_metadata_status = metadataStatus(info); if ( raw_metadata_status.empty() ) @@ -679,6 +678,7 @@ in case this is the first time - if it's !autorefresh, we may still refresh */ refreshMetadata(info, RefreshIfNeeded, progressrcv ); + raw_metadata_status = metadataStatus(info); } bool needs_cleaning = false; @@ -701,12 +701,6 @@ needs_cleaning = true; } - else { - /* if there is no cache at this point, we refresh the raw - in case this is the first time - if it's !autorefresh, - we may still refresh */ - refreshMetadata(info, RefreshIfNeeded, progressrcv ); - } ProgressData progress(100); callback::SendReport<ProgressReport> report; @@ -716,18 +710,10 @@ if (needs_cleaning) { -// Pathname name = _pimpl->options.repoCachePath; -// //data::RecordId id = store.lookupRepository(info.alias()); -// ostringstream os; -// os << id.get(); -// name += os.str() + ".solv"; -// unlink (name); -// cleanCacheInternal( store, info); cleanCache(info); } MIL << info.alias() << " building cache..." << endl; - //data::RecordId id = store.lookupOrAppendRepository(info.alias()); // do we have type? repo::RepoType repokind = info.type(); @@ -910,19 +896,29 @@ status.saveToCookieFile(cookiefile); } - void RepoManager::loadFromCache( const RepoInfo &info, + void RepoManager::loadFromCache( const RepoInfo & info, const ProgressData::ReceiverFnc & progressrcv ) { assert_alias(info); - sat::Pool satpool( sat::Pool::instance() ); string alias = info.escaped_alias(); - - Pathname solvfile = (_pimpl->options.repoCachePath + alias).extend(".solv"); + Pathname solvfile = (_pimpl->options.repoCachePath / alias).extend(".solv"); if ( ! PathInfo(solvfile).isExist() ) ZYPP_THROW(RepoNotCachedException()); - Repository repo = satpool.addRepoSolv(solvfile, info); + try + { + sat::Pool::instance().addRepoSolv( solvfile, info ); + } + catch ( const Exception & exp ) + { + ZYPP_CAUGHT( exp ); + MIL << "Try to handle exception by rebuilding the solv-file" << endl; + cleanCache( info, progressrcv ); + buildCache( info, BuildIfNeeded, progressrcv ); + + sat::Pool::instance().addRepoSolv( solvfile, info ); + } } //////////////////////////////////////////////////////////////////////////// Modified: trunk/libzypp/zypp/RepoStatus.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoStatus.cc?rev=9008&r1=9007&r2=9008&view=diff ============================================================================== --- trunk/libzypp/zypp/RepoStatus.cc (original) +++ trunk/libzypp/zypp/RepoStatus.cc Tue Mar 4 18:21:33 2008 @@ -34,10 +34,10 @@ { public: - + string checksum; Date timestamp; - + /** Offer default Impl. */ static shared_ptr<Impl> nullimpl() { @@ -85,7 +85,7 @@ RepoStatus RepoStatus::fromCookieFile( const Pathname &cookiefile ) { RepoStatus status; - + std::ifstream file(cookiefile.c_str()); if (!file) { ZYPP_THROW (Exception( "Can't open " + cookiefile.asString() ) ); @@ -119,7 +119,7 @@ _pimpl->timestamp = Date(info.mtime()); } } - + bool RepoStatus::empty() const { return _pimpl->checksum.empty(); @@ -136,23 +136,28 @@ _pimpl->timestamp = timestamp; return *this; } - + string RepoStatus::checksum() const { return _pimpl->checksum; } Date RepoStatus::timestamp() const { return _pimpl->timestamp; } - - RepoStatus operator&&( const RepoStatus &lhs, const RepoStatus &rhs ) + + RepoStatus operator&&( const RepoStatus & lhs, const RepoStatus & rhs ) { + if ( lhs.empty() ) + return rhs; + if ( rhs.empty() ) + return lhs; + + std::string lchk( lhs.checksum() ); + std::string rchk( rhs.checksum() ); + // order strings to assert && is kommutativ + stringstream ss( lchk < rchk ? lchk+rchk : rchk+lchk ); + RepoStatus result; - string combinedcs = (lhs.checksum() + rhs.checksum()); - stringstream ss(combinedcs); - CheckSum newcs(CheckSum::sha1(ss)); - result.setChecksum(newcs.checksum()); - result.setTimestamp(lhs.timestamp()); - if ( rhs.timestamp() > lhs.timestamp() ) - result.setTimestamp(rhs.timestamp()); + result.setChecksum( CheckSum::sha1(ss).checksum() ); + result.setTimestamp( lhs.timestamp() < rhs.timestamp() ? rhs.timestamp() : lhs.timestamp() ); return result; } Modified: trunk/libzypp/zypp/target/TargetImpl.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/TargetImpl.cc?rev=9008&r1=9007&r2=9008&view=diff ============================================================================== --- trunk/libzypp/zypp/target/TargetImpl.cc (original) +++ trunk/libzypp/zypp/target/TargetImpl.cc Tue Mar 4 18:21:33 2008 @@ -381,7 +381,7 @@ Pathname rpmsolv( Pathname::assertprefix( _root, ZConfig::instance().repoCachePath() + system.name() ).extend(".solv") ); MIL << "adding " << rpmsolv << " to pool(" << system.name() << ")"; #warning PROBABLY CLEAR NONEMTY SYSTEM REPO - system.addSolv(rpmsolv); + system.addSolv( rpmsolv ); // (Re)Load the requested locales. // If the requested locales are empty, we leave the pool untouched -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org