Mailinglist Archive: zypp-commit (266 mails)

< Previous Next >
[zypp-commit] r11601 - /trunk/libzypp/zypp/target/TargetImpl.cc
  • From: mlandres@xxxxxxxxxxxxxxxx
  • Date: Thu, 06 Nov 2008 16:40:53 -0000
  • Message-id: <20081106164053.9BB1033907@xxxxxxxxxxxxxxxx>
Author: mlandres
Date: Thu Nov 6 17:40:53 2008
New Revision: 11601

URL: http://svn.opensuse.org/viewcvs/zypp?rev=11601&view=rev
Log:
remove superfluous calls to rpmdb2solv

Modified:
trunk/libzypp/zypp/target/TargetImpl.cc

Modified: trunk/libzypp/zypp/target/TargetImpl.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/target/TargetImpl.cc?rev=11601&r1=11600&r2=11601&view=diff
==============================================================================
--- trunk/libzypp/zypp/target/TargetImpl.cc (original)
+++ trunk/libzypp/zypp/target/TargetImpl.cc Thu Nov 6 17:40:53 2008
@@ -44,6 +44,8 @@
#include "zypp/target/rpm/librpmDb.h"
#include "zypp/target/CommitPackageCache.h"

+#include "zypp/parser/ProductFileReader.h"
+
#include "zypp/pool/GetResolvablesToInsDel.h"
#include "zypp/solver/detail/Helper.h"

@@ -978,32 +980,6 @@

///////////////////////////////////////////////////////////////////

- namespace
- {
- std::string rpmdb2solvAttr( const std::string & attr_r, const Pathname &
root_r )
- {
- std::ostringstream cmd;
- cmd << "rpmdb2solv";
- cmd << " -n";
- if ( ! root_r.empty() )
- cmd << " -r '" << root_r << "'";
- cmd << " -p '" << Pathname::assertprefix( root_r, "/etc/products.d" )
<< "'";
- cmd << " -a " << attr_r;
-
- MIL << "Executing: " << cmd << endl;
- ExternalProgram prog( cmd.str(), ExternalProgram::Discard_Stderr );
- for ( std::string output( prog.receiveLine() ); output.length();
output = prog.receiveLine() )
- {
- return str::trim(output);
- }
-
- int ret = prog.close();
- WAR << "Got no output from rpmdb2solv (returned " << ret << ")." <<
endl;
-
- return std::string();
- }
- }
-
Product::constPtr TargetImpl::baseProduct() const
{
ResPool pool(ResPool::instance());
@@ -1016,17 +992,38 @@
return 0L;
}

+ namespace
+ {
+ parser::ProductFileData baseproductdata( const Pathname & root_r )
+ {
+ PathInfo baseproduct( Pathname::assertprefix( root_r,
"/etc/products.d/baseproduct" ) );
+ if ( baseproduct.isFile() )
+ {
+ try
+ {
+ return parser::ProductFileReader::scanFile( baseproduct.path() );
+ }
+ catch ( const Exception & excpt )
+ {
+ ZYPP_CAUGHT( excpt );
+ }
+ }
+ return parser::ProductFileData();
+ }
+
+ }
+
std::string TargetImpl::targetDistribution() const
- { return rpmdb2solvAttr( "register.target", _root ); }
+ { return baseproductdata( _root ).registerTarget(); }

std::string TargetImpl::targetDistributionRelease() const
- { return rpmdb2solvAttr( "register.release", _root ); }
+ { return baseproductdata( _root ).registerRelease(); }

std::string TargetImpl::distributionVersion() const
{
if ( _distributionVersion.empty() )
{
- _distributionVersion = rpmdb2solvAttr( "releasever", _root );
+ _distributionVersion = baseproductdata( _root ).edition().version();
if ( !_distributionVersion.empty() )
MIL << "Remember distributionVersion = '" << _distributionVersion <<
"'" << endl;
}

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages