summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-10-04 03:10:33 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2016-10-04 03:10:33 +0100
commit19605c98462dd904d05854fed12df95b81337a1a (patch)
tree05fae995e016149b49d1e8146724eae9290689c1
parentAdd methods for getting repo details (diff)
downloadgentoobrowse-api-19605c98462dd904d05854fed12df95b81337a1a.tar.bz2
gentoobrowse-api-19605c98462dd904d05854fed12df95b81337a1a.tar.xz
gentoobrowse-api-19605c98462dd904d05854fed12df95b81337a1a.zip
Add method for getting package use flag options
-rw-r--r--gentoobrowse-api/api/portage.ice1
-rw-r--r--gentoobrowse-api/domain/extended-models.ice10
-rw-r--r--gentoobrowse-api/service/portageimpl.cpp7
-rw-r--r--gentoobrowse-api/service/portageimpl.h1
-rw-r--r--gentoobrowse-api/service/sql/portage/getPackageUses.sql19
-rw-r--r--gentoobrowse-api/unittests/testPortage.cpp15
6 files changed, 53 insertions, 0 deletions
diff --git a/gentoobrowse-api/api/portage.ice b/gentoobrowse-api/api/portage.ice
index 1f211fd..fee89f4 100644
--- a/gentoobrowse-api/api/portage.ice
+++ b/gentoobrowse-api/api/portage.ice
@@ -28,6 +28,7 @@ module Gentoo {
idempotent PackageDependencyPackages getPackageRuntimeDependencies(int id);
idempotent PackageDependencyPackages getPackagesDepending(int id);
idempotent PackageMasks getPackageMasks(int id);
+ idempotent PackageUses getPackageUses(int id);
idempotent Bug getBug(int id) throws Slicer::NoRowsReturned;
idempotent Bugs getPackageBugs(int packageId);
diff --git a/gentoobrowse-api/domain/extended-models.ice b/gentoobrowse-api/domain/extended-models.ice
index aee4af1..1d37342 100644
--- a/gentoobrowse-api/domain/extended-models.ice
+++ b/gentoobrowse-api/domain/extended-models.ice
@@ -32,6 +32,14 @@ module Gentoo {
IntList ebuildids;
};
+ class PackageUse {
+ string use;
+ bool islocal;
+ optional(0) string group;
+ string name;
+ string description;
+ };
+
[ "slicer:element:package" ]
sequence<SearchResultPackage> SearchResultPackages;
[ "slicer:element:bug" ]
@@ -46,6 +54,8 @@ module Gentoo {
sequence<PackageDependencyPackage> PackageDependencyPackages;
[ "slicer:element:mask" ]
sequence<PackageMask> PackageMasks;
+ [ "slicer:element:use" ]
+ sequence<PackageUse> PackageUses;
};
#endif
diff --git a/gentoobrowse-api/service/portageimpl.cpp b/gentoobrowse-api/service/portageimpl.cpp
index a12c8d7..198a893 100644
--- a/gentoobrowse-api/service/portageimpl.cpp
+++ b/gentoobrowse-api/service/portageimpl.cpp
@@ -21,6 +21,7 @@
#include <sql/portage/getPackageRuntimeDependencies.sql.h>
#include <sql/portage/getPackagesDepending.sql.h>
#include <sql/portage/getPackageMasks.sql.h>
+#include <sql/portage/getPackageUses.sql.h>
#include <sql/portage/getSyncs.sql.h>
#include <sql/portage/getBug.sql.h>
#include <sql/portage/getPackageBugs.sql.h>
@@ -182,6 +183,12 @@ Portage::getPackageMasks(Ice::Int id, const Ice::Current &)
return fetchCache<Gentoo::PackageMasks>(sql::portage::getPackageMasks, 30, id);
}
+Gentoo::PackageUses
+Portage::getPackageUses(Ice::Int id, const Ice::Current &)
+{
+ return fetchCache<Gentoo::PackageUses>(sql::portage::getPackageUses, 30, id);
+}
+
Gentoo::BugPtr
Portage::getBug(Ice::Int id, const Ice::Current &)
{
diff --git a/gentoobrowse-api/service/portageimpl.h b/gentoobrowse-api/service/portageimpl.h
index 42d57e4..ea6ad5f 100644
--- a/gentoobrowse-api/service/portageimpl.h
+++ b/gentoobrowse-api/service/portageimpl.h
@@ -35,6 +35,7 @@ class DLL_PUBLIC Portage : public Gentoo::Portage, IceTray::AbstractCachingDatab
Gentoo::PackageDependencyPackages getPackageRuntimeDependencies(Ice::Int id, const Ice::Current &) override;
Gentoo::PackageDependencyPackages getPackagesDepending(Ice::Int id, const Ice::Current &) override;
Gentoo::PackageMasks getPackageMasks(Ice::Int id, const Ice::Current &) override;
+ Gentoo::PackageUses getPackageUses(Ice::Int id, const Ice::Current &) override;
Gentoo::BugPtr getBug(Ice::Int id, const Ice::Current &) override;
Gentoo::Bugs getPackageBugs(Ice::Int packageId, const Ice::Current &) override;
diff --git a/gentoobrowse-api/service/sql/portage/getPackageUses.sql b/gentoobrowse-api/service/sql/portage/getPackageUses.sql
new file mode 100644
index 0000000..50d6c0a
--- /dev/null
+++ b/gentoobrowse-api/service/sql/portage/getPackageUses.sql
@@ -0,0 +1,19 @@
+SELECT eu.use, ul.use IS NOT NULL islocal, ugg.name AS group, LTRIM(COALESCE(ugg.use, eu.use), '+') AS name,
+ COALESCE(ul.description, ugg.description, ug.description) description
+FROM gentoobrowse.ebuilds e
+ JOIN gentoobrowse.ebuild_uses eu
+ ON e.ebuildid = eu.ebuildid
+ LEFT OUTER JOIN gentoobrowse.use_global ug
+ ON LTRIM(eu.use, '+') = ug.use
+ LEFT OUTER JOIN gentoobrowse.use_local ul
+ ON LTRIM(eu.use, '+') = ul.use
+ AND ul.packageid = e.packageid
+ LEFT OUTER JOIN (
+ SELECT ugs.usegroupid, ugs.name, ugg.use, ugg.description
+ FROM gentoobrowse.use_group ugg, gentoobrowse.use_groups ugs
+ WHERE ugs.usegroupid = ugg.usegroupid) ugg
+ ON REVERSE(SPLIT_PART(REVERSE(eu.use), '_', 1)) = ugg.use
+ AND LEFT(eu.use, LENGTH(eu.use) - LENGTH(SPLIT_PART(REVERSE(eu.use), '_', 1)) - 1) = ugg.name
+WHERE e.packageid = ?
+GROUP BY eu.use, ul.use, ul.packageid, ug.use, ugg.name, ugg.usegroupid, ugg.use, ugg.description
+ORDER BY ugg.name nulls first, eu.use
diff --git a/gentoobrowse-api/unittests/testPortage.cpp b/gentoobrowse-api/unittests/testPortage.cpp
index c408a83..ab0f466 100644
--- a/gentoobrowse-api/unittests/testPortage.cpp
+++ b/gentoobrowse-api/unittests/testPortage.cpp
@@ -298,6 +298,21 @@ BOOST_AUTO_TEST_CASE( getPackageMasks )
BOOST_REQUIRE_EQUAL(629114, ms.front()->ebuildids.back());
}
+BOOST_AUTO_TEST_CASE( getPackageUses )
+{
+ auto us = p->getPackageUses(46436);
+ BOOST_REQUIRE_EQUAL(19, us.size());
+ BOOST_REQUIRE_EQUAL("+keyutils", us.front()->use);
+ BOOST_REQUIRE_EQUAL("keyutils", us.front()->name);
+ BOOST_REQUIRE_EQUAL(true, us.front()->islocal);
+ BOOST_REQUIRE(!us[0]->group);
+ BOOST_REQUIRE(us[9]->group);
+ BOOST_REQUIRE_EQUAL("abi_mips", *us[9]->group);
+ BOOST_REQUIRE_EQUAL("Enable for the keyring ccache using keyutils.", us[0]->description);
+ BOOST_REQUIRE_EQUAL("selinux", us[6]->use);
+ BOOST_REQUIRE_EQUAL(false, us[2]->islocal);
+}
+
BOOST_AUTO_TEST_CASE( getBugMissing )
{
BOOST_REQUIRE_THROW(p->getBug(10), Slicer::NoRowsReturned);