# to find the KeyRingTest receiver
INCLUDE_DIRECTORIES( ${LIBZYPP_SOURCE_DIR}/tests/zypp )
-ADD_TESTS(RepoVariables OutdatedMetadata)
+ADD_TESTS(RepoVariables ExtendedMetadata)
--- /dev/null
+#include <iostream>
+#include <sstream>
+#include <fstream>
+#include <list>
+#include <string>
+
+#include <boost/test/auto_unit_test.hpp>
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/Exception.h"
+#include "zypp/PathInfo.h"
+#include "zypp/TmpPath.h"
+#include "zypp/RepoManager.h"
+#include "zypp/sat/Pool.h"
+#include "KeyRingTestReceiver.h"
+
+#include "TestSetup.h"
+
+using boost::unit_test::test_case;
+
+using namespace std;
+using namespace zypp;
+using namespace zypp::repo;
+using namespace zypp::filesystem;
+
+#define TEST_DIR TESTS_SRC_DIR "/repo/yum/data/extensions"
+
+BOOST_AUTO_TEST_CASE(extended_metadata)
+{
+ KeyRingTestReceiver rec;
+ //rec.answerAcceptUnknownKey(true);
+ rec.answerAcceptUnsignedFile(true);
+
+
+// rec.answerImportKey(true);
+ Pathname repodir(TEST_DIR );
+
+ sat::Pool pool(sat::Pool::instance());
+
+ TestSetup test( Arch_x86_64 );
+ test.loadRepo(Url(string("dir:") + repodir.absolutename().asString()), "updates");
+
+ Repository repo = pool.reposFind("updates");
+
+ BOOST_CHECK_EQUAL( repo.generatedTimestamp(), Date(1227279057) );
+ BOOST_CHECK_EQUAL( repo.suggestedExpirationTimestamp(), Date(1227279057 + 3600) );
+
+ // check that the attributes of product compatibility are ok
+ int count = 0;
+ vector<string> cpeids;
+ vector<string> labels;
+
+ for_( it,
+ repo.compatibleWithProductBegin(),
+ repo.compatibleWithProductEnd() )
+ {
+ cpeids.push_back(it.cpeId());
+ labels.push_back(it.label());
+ count++;
+ }
+
+ // there were 2 compatible products
+ BOOST_CHECK_EQUAL( count, 2 );
+ BOOST_CHECK_EQUAL( cpeids[0], "cpe://o:opensuse" );
+ BOOST_CHECK_EQUAL( cpeids[1], "cpe://o:sle" );
+
+ BOOST_CHECK_EQUAL( labels[0], "openSUSE 11.0" );
+ BOOST_CHECK_EQUAL( labels[1], "SLE 11.0" );
+
+ cpeids.clear();
+ labels.clear();
+ count = 0;
+
+ for_( it,
+ repo.updatesProductBegin(),
+ repo.updatesProductEnd() )
+ {
+ cpeids.push_back(it.cpeId());
+ labels.push_back(it.label());
+ count++;
+ }
+
+ // the repo updates one product
+ BOOST_CHECK_EQUAL( count, 1 );
+ BOOST_CHECK_EQUAL( cpeids[0], "cpe://o:sle" );
+ BOOST_CHECK_EQUAL( labels[0], "SLE 11.0" );
+
+ // because this product updates something, it _is_ an update repo
+ BOOST_CHECK( repo.isUpdateRepo() );
+
+ BOOST_CHECK( repo.providesUpdatesFor("cpe://o:sle") );
+ BOOST_CHECK( ! repo.providesUpdatesFor("cpe://o:windows") );
+
+}
+++ /dev/null
-#include <iostream>
-#include <sstream>
-#include <fstream>
-#include <list>
-#include <string>
-
-#include <boost/test/auto_unit_test.hpp>
-
-#include "zypp/base/Logger.h"
-#include "zypp/base/Exception.h"
-#include "zypp/PathInfo.h"
-#include "zypp/TmpPath.h"
-#include "zypp/RepoManager.h"
-#include "zypp/sat/Pool.h"
-#include "KeyRingTestReceiver.h"
-
-#include "TestSetup.h"
-
-using boost::unit_test::test_case;
-
-using namespace std;
-using namespace zypp;
-using namespace zypp::repo;
-using namespace zypp::filesystem;
-
-#define TEST_DIR TESTS_SRC_DIR "/repo/yum/data/extensions"
-
-BOOST_AUTO_TEST_CASE(extensions)
-{
- KeyRingTestReceiver rec;
- //rec.answerAcceptUnknownKey(true);
- rec.answerAcceptUnsignedFile(true);
-
-
-// rec.answerImportKey(true);
- Pathname repodir(TEST_DIR );
-
- sat::Pool pool(sat::Pool::instance());
-
- TestSetup test( Arch_x86_64 );
- test.loadRepo(Url(string("dir:") + repodir.absolutename().asString()), "updates");
-
- Repository repo = pool.reposFind("updates");
-
- BOOST_CHECK_EQUAL( repo.generatedTimestamp(), Date(1222083131) );
- BOOST_CHECK_EQUAL( repo.suggestedExpirationTimestamp(), Date(1222083131 + 3600) );
-}
<timestamp>1215823454</timestamp>
<open-checksum type="sha">c6bd3c6099de74d97ed045163235be10ffa8a85f</open-checksum>
</data>
+
+
<data type="suseinfo">
<location href="repodata/suseinfo.xml.gz"/>
- <checksum type="sha">a9cf8892e8bb47ed09f05f40e42c390a943e61f5</checksum>
- <timestamp>1222083131</timestamp>
- <open-checksum type="sha">a3011438085ac55f06c68053201ea3ded17ee85c</open-checksum>
+ <checksum type="sha">e0b9149c1b7f48c952e9b3ea996669d8d0d9e1e8</checksum>
+ <timestamp>1227279057.0</timestamp>
+ <open-checksum type="sha">b17c055bef95bca397faffdf028cfa91dd1b24bc</open-checksum>
</data>
</repomd>
bool Repository::providesUpdatesFor( const std::string &key ) const
{
NO_REPOSITORY_RETURN( false );
+
+ for_( it,
+ updatesProductBegin(),
+ updatesProductEnd() )
+ {
+ // FIXME implement real CPE matching here
+ // someday
+ if ( key == it.cpeId() )
+ return true;
+ }
+
return false;
}
bool Repository::isUpdateRepo() const
{
NO_REPOSITORY_RETURN( false );
- return false;
+ return ( updatesProductBegin() != updatesProductEnd() );
}
bool Repository::solvablesEmpty() const
* The suggested expiration date of this repository
* already passed
*
+ * rpm-md repositories can provide this tag using the
+ * expire extension tag:
+ * \see http://en.opensuse.org/Standards/Rpm_Metadata#SUSE_repository_info_.28suseinfo.xml.29.2C_extensions_to_repomd.xml
*/
bool maybeOutdated() const;
* if the repository claims to update something then
* it is an update repository
*
- * This is implemented by looking at an "update" keyword
- * on the repository tags
+ * This is implemented by looking at the repository updates
+ * tag.
+ * \see http://en.opensuse.org/Standards/Rpm_Metadata#SUSE_repository_info_.28suseinfo.xml.29.2C_extensions_to_repomd.xml
*/
bool isUpdateRepo() const;
/**
* wether the repository claims to update something \ref prod
- * with key \ref cpename
+ * with key \ref cpeid
*
- * See http://cpe.mitre.org/ for more information on CPE
+ * \see zypp::Product::cpeId()
+ *
+ * See http://cpe.mitre.org/ for more information on the
+ * Common Platform Enumearation.
*/
- bool providesUpdatesFor( const std::string &cpename ) const;
+ bool providesUpdatesFor( const std::string &cpeid ) const;
/** Whether \ref Repository contains solvables. */
bool solvablesEmpty() const;
/**
* Get an iterator to the beginning of the repository
* compatible distros.
+ * \note This is only a hint. There is no guarantee that
+ * the repository is built for that product.
* \see Repository::ProductInfoIterator
*/
ProductInfoIterator compatibleWithProductBegin() const;