Skip to content

Commit

Permalink
changed FindBaseProduct() to RememberBaseProduct()
Browse files Browse the repository at this point in the history
to share some code
  • Loading branch information
lslezak committed Apr 22, 2014
1 parent 1e2e5b6 commit 8c12322
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/PkgFunctions.h
Expand Up @@ -161,7 +161,7 @@ class PkgFunctions

bool aliasExists(const std::string &alias, const std::list<zypp::RepoInfo> &reps) const;

zypp::Product::constPtr FindBaseProduct(const std::string &alias) const;
void RememberBaseProduct(const std::string &alias);

zypp::RepoManager* CreateRepoManager();

Expand Down
59 changes: 18 additions & 41 deletions src/Source_Create.cc
Expand Up @@ -674,14 +674,7 @@ PkgFunctions::SourceCreateEx (const YCPString& media, const YCPString& pd, bool
if (base && !base_product)
{
y2milestone("Searching a base product...");
zypp::Product::constPtr zypp_product = FindBaseProduct(repo->repoInfo().alias());

base_product = new BaseProduct(
zypp_product->name(),
zypp_product->edition(),
zypp_product->arch(),
repo->repoInfo().alias()
);
RememberBaseProduct(repo->repoInfo().alias());
}
}
catch ( const zypp::Exception& excpt)
Expand Down Expand Up @@ -716,14 +709,7 @@ PkgFunctions::SourceCreateEx (const YCPString& media, const YCPString& pd, bool
if (base && !base_product)
{
y2milestone("Searching the base product...");
zypp::Product::constPtr zypp_product = FindBaseProduct(repo->repoInfo().alias());

base_product = new BaseProduct(
zypp_product->name(),
zypp_product->edition(),
zypp_product->arch(),
repo->repoInfo().alias()
);
RememberBaseProduct(repo->repoInfo().alias());
}
}
}
Expand Down Expand Up @@ -886,10 +872,8 @@ YCPValue PkgFunctions::RepositoryScan(const YCPString& url)
return ret;
}

zypp::Product::constPtr PkgFunctions::FindBaseProduct(const std::string &alias) const
void PkgFunctions::RememberBaseProduct(const std::string &alias)
{
zypp::Product::constPtr product = NULL;

// access to the Pool of Selectables
zypp::ResPoolProxy selectablePool(zypp::ResPool::instance().proxy());

Expand All @@ -905,35 +889,28 @@ zypp::Product::constPtr PkgFunctions::FindBaseProduct(const std::string &alias)
// check the repository
if (res && res->repoInfo().alias() == alias)
{
product = boost::dynamic_pointer_cast<const zypp::Product>(res);
zypp::Product::constPtr product = boost::dynamic_pointer_cast<const zypp::Product>(res);

if (product)
{
break;
y2milestone("Found base product: %s-%s-%s (%s)",
product->name().c_str(),
product->edition().asString().c_str(),
product->arch().asString().c_str(),
product->summary().c_str()
);

base_product = new BaseProduct(
product->name(),
product->edition(),
product->arch(),
alias
);
}
}
}

if (product)
{
break;
}
}

// no product in the pool
if (!product)
{
y2error("No base product has been found");
}
else
{
y2milestone("Found base product: %s %s (%s-%s)",
product->summary().c_str(),
product->edition().asString().c_str(),
product->name().c_str(),
product->edition().asString().c_str()
);
}

return product;
y2error("No base product has been found");
}

0 comments on commit 8c12322

Please sign in to comment.