Author: dmacvicar
Date: Sat Oct 11 13:01:31 2008
New Revision: 11296
URL: http://svn.opensuse.org/viewcvs/zypp?rev=11296&view=rev
Log:
implement distver variable
Added:
trunk/libzypp/tests/zypp/Resolvable_test.cc
Modified:
trunk/libzypp/tests/repo/RepoVariables_test.cc
trunk/libzypp/tests/zypp/Target_test.cc
trunk/libzypp/zypp/Target.cc
trunk/libzypp/zypp/Target.h
trunk/libzypp/zypp/repo/RepoVariables.cc
trunk/libzypp/zypp/target/TargetImpl.cc
trunk/libzypp/zypp/target/TargetImpl.h
trunk/sat-solver/tools/repo_products.c
Modified: trunk/libzypp/tests/repo/RepoVariables_test.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/repo/RepoVariables_test.cc?rev=11296&r1=11295&r2=11296&view=diff
==============================================================================
--- trunk/libzypp/tests/repo/RepoVariables_test.cc (original)
+++ trunk/libzypp/tests/repo/RepoVariables_test.cc Sat Oct 11 13:01:31 2008
@@ -46,6 +46,30 @@
BOOST_CHECK_EQUAL(replacer2(Url("http://site.org/update/?arch=$arch")).asCompleteString(),
"http://site.org/update/?arch=i686");
+
+ // no target activated yet, there should be no replacement of
+ // $distver
+ BOOST_CHECK_EQUAL(replacer2(Url("http://site.org/update/$distver/?arch=$arch")).asCompleteString(),
+ "http://site.org/update/$distver/?arch=i686");
+
+ // now we initialize the target
+ filesystem::TmpDir tmp;
+
+ ZYpp::Ptr z = getZYpp();
+
+ // create the products.d directory
+ assert_dir(tmp.path() / "/etc/products.d" );
+ BOOST_CHECK( copy( Pathname(TESTS_SRC_DIR) / "/zypp/data/Target/product.prod", tmp.path() / "/etc/products.d/product.prod") == 0 );
+ // make it the base product
+ BOOST_CHECK( symlink(tmp.path() / "/etc/products.d/product.prod", tmp.path() / "/etc/products.d/baseproduct" ) == 0 );
+
+
+ z->initializeTarget( tmp.path() );
+ // target activated, there should be replacement of
+ // $distver
+ BOOST_CHECK_EQUAL(replacer2(Url("http://site.org/update/$distver/?arch=$arch")).asCompleteString(),
+ "http://site.org/update/10/?arch=i686");
+
}
// vim: set ts=2 sts=2 sw=2 ai et:
Added: trunk/libzypp/tests/zypp/Resolvable_test.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/Resolvable_test.cc?rev=11296&view=auto
==============================================================================
--- trunk/libzypp/tests/zypp/Resolvable_test.cc (added)
+++ trunk/libzypp/tests/zypp/Resolvable_test.cc Sat Oct 11 13:01:31 2008
@@ -0,0 +1,39 @@
+
+#include <iostream>
+#include <list>
+#include <string>
+
+// Boost.Test
+#include
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/Exception.h"
+#include "zypp/ZYppFactory.h"
+#include "zypp/ZYpp.h"
+#include "zypp/Pattern.h"
+
+#include "TestSetup.h"
+
+using boost::unit_test::test_case;
+using namespace std;
+using namespace zypp;
+
+
+BOOST_AUTO_TEST_CASE(resolvable_test)
+{
+ TestSetup test( Arch_x86_64 );
+ // test.loadTarget(); // initialize and load target
+ test.loadRepo( TESTS_SRC_DIR"/data/openSUSE-11.1" );
+
+ int pattern_count = 0;
+ for_( pitem, test.pool().begin(), test.pool().end() )
+ {
+ if ( isKind<Pattern>(pitem->resolvable()) )
+ {
+ //BOOST_CHECK( ! asKind<Pattern>(pitem->resolvable())->contents().empty() );
+ MIL << asKind<Pattern>(pitem->resolvable()) << endl;
+ pattern_count++;
+ }
+ }
+ BOOST_CHECK(pattern_count > 0);
+}
Modified: trunk/libzypp/tests/zypp/Target_test.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/Target_test.cc?rev=11296&r1=11295&r2=11296&view=diff
==============================================================================
--- trunk/libzypp/tests/zypp/Target_test.cc (original)
+++ trunk/libzypp/tests/zypp/Target_test.cc Sat Oct 11 13:01:31 2008
@@ -16,7 +16,7 @@
using boost::unit_test::test_case;
using namespace std;
using namespace zypp;
-
+using namespace zypp::filesystem;
BOOST_AUTO_TEST_CASE(target_test)
{
@@ -24,9 +24,23 @@
filesystem::TmpDir tmp;
ZYpp::Ptr z = getZYpp();
+
+ // create the products.d directory
+ assert_dir(tmp.path() / "/etc/products.d" );
+ BOOST_CHECK( copy( Pathname(TESTS_SRC_DIR) / "/zypp/data/Target/product.prod", tmp.path() / "/etc/products.d/product.prod") == 0 );
+
+ // make it the base product
+ BOOST_CHECK( symlink(tmp.path() / "/etc/products.d/product.prod", tmp.path() / "/etc/products.d/baseproduct" ) == 0 );
+
z->initializeTarget( tmp.path() );
BOOST_CHECK( ! z->target()->anonymousUniqueId().empty() );
BOOST_CHECK( PathInfo( tmp.path() / "/var/lib/zypp/AnonymousUniqueId").isExist() );
BOOST_CHECK( PathInfo( tmp.path() / "/var/lib/zypp/AnonymousUniqueId").size() > 0 );
+
+ // now check the base product
+ BOOST_CHECK_EQUAL( z->target()->targetDistribution(), "sle-10-i586");
+ BOOST_CHECK_EQUAL( z->target()->targetDistributionRelease(), "special_edition");
+ BOOST_CHECK_EQUAL( z->target()->distributionVersion(), "10");
+
}
Modified: trunk/libzypp/zypp/Target.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Target.cc?rev=11296&r1=11295&r2=11296&view=diff
==============================================================================
--- trunk/libzypp/zypp/Target.cc (original)
+++ trunk/libzypp/zypp/Target.cc Sat Oct 11 13:01:31 2008
@@ -106,6 +106,9 @@
std::string Target::anonymousUniqueId() const
{ return _pimpl->anonymousUniqueId(); }
+ std::string Target::distributionVersion() const
+ { return _pimpl->distributionVersion(); }
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
Modified: trunk/libzypp/zypp/Target.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Target.h?rev=11296&r1=11295&r2=11296&view=diff
==============================================================================
--- trunk/libzypp/zypp/Target.h (original)
+++ trunk/libzypp/zypp/Target.h Sat Oct 11 13:01:31 2008
@@ -125,6 +125,14 @@
std::string targetDistributionRelease() const;
//@}
+ /** This is \c version attribute of the installed base product.
+ * For example http://download.opensue.org/update/11.0
+ * The 11.0 corresponds to the base product version.
+ */
+ std::string distributionVersion() const;
+ //@}
+
+
/**
* anonymous unique id
*
Modified: trunk/libzypp/zypp/repo/RepoVariables.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/RepoVariables.cc?rev=11296&r1=11295&r2=11296&view=diff
==============================================================================
--- trunk/libzypp/zypp/repo/RepoVariables.cc (original)
+++ trunk/libzypp/zypp/repo/RepoVariables.cc Sat Oct 11 13:01:31 2008
@@ -13,6 +13,7 @@
#include "zypp/base/String.h"
#include "zypp/repo/RepoException.h"
#include "zypp/ZConfig.h"
+#include "zypp/ZYppFactory.h"
#include "RepoVariables.h"
using namespace std;
@@ -53,6 +54,16 @@
newvalue = str::gsub( newvalue,
"$basearch",
basearch.asString() );
+
+ // only replace $distver if the target is
+ // initialized
+ if ( getZYpp()->getTarget() )
+ {
+ newvalue = str::gsub( newvalue,
+ "$distver",
+ getZYpp()->target()->distributionVersion() );
+ }
+
return newvalue;
}
Modified: trunk/libzypp/zypp/target/TargetImpl.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/TargetImpl.cc?rev=11296&r1=11295&r2=11296&view=diff
==============================================================================
--- trunk/libzypp/zypp/target/TargetImpl.cc (original)
+++ trunk/libzypp/zypp/target/TargetImpl.cc Sat Oct 11 13:01:31 2008
@@ -911,6 +911,9 @@
std::string TargetImpl::targetDistributionRelease() const
{ return rpmdb2solvAttr( "register.release", _root ); }
+ std::string TargetImpl::distributionVersion() const
+ { return rpmdb2solvAttr( "distver", _root ); }
+
///////////////////////////////////////////////////////////////////
std::string TargetImpl::anonymousUniqueId() const
Modified: trunk/libzypp/zypp/target/TargetImpl.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/TargetImpl.h?rev=11296&r1=11295&r2=11296&view=diff
==============================================================================
--- trunk/libzypp/zypp/target/TargetImpl.h (original)
+++ trunk/libzypp/zypp/target/TargetImpl.h Sat Oct 11 13:01:31 2008
@@ -146,6 +146,9 @@
/** \copydoc Target::targetDistributionRelease()*/
std::string targetDistributionRelease() const;
+
+ /** \copydoc Target::distributionVersion()*/
+ std::string distributionVersion() const;
protected:
/** Path to the target */
Modified: trunk/sat-solver/tools/repo_products.c
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_products.c?rev=11296&r1=11295&r2=11296&view=diff
==============================================================================
--- trunk/sat-solver/tools/repo_products.c (original)
+++ trunk/sat-solver/tools/repo_products.c Sat Oct 11 13:01:31 2008
@@ -273,6 +273,15 @@
if (pd->currentproduct == pd->baseproduct)
repodata_set_str(pd->data, pd->handle, PRODUCT_TYPE, "base");
+ // output distver if requested, only if the product is
+ // a base product
+ if (pd->currentproduct == pd->baseproduct
+ && pd->attribute
+ && !strcmp(pd->attribute, "distver"))
+ {
+ printf("%s\n", pd->tmpvers);
+ }
+
if (pd->tmprel)
{
if (pd->tmpvers)
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org