summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-10-03 18:43:20 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2016-10-03 18:43:20 +0100
commitaf55d929088e25204b4626486c4e19070f9cefdd (patch)
tree186edd3199b1fb2a86cdf8106d152e7be0f71d21
parentTemplate PqArray (diff)
downloadgentoobrowse-api-af55d929088e25204b4626486c4e19070f9cefdd.tar.bz2
gentoobrowse-api-af55d929088e25204b4626486c4e19070f9cefdd.tar.xz
gentoobrowse-api-af55d929088e25204b4626486c4e19070f9cefdd.zip
Add methods for getting dependencies and masks
-rw-r--r--gentoobrowse-api/api/portage.ice4
-rw-r--r--gentoobrowse-api/domain/converters.cpp2
-rw-r--r--gentoobrowse-api/domain/extended-models.ice11
-rw-r--r--gentoobrowse-api/domain/portage-models.ice13
-rw-r--r--gentoobrowse-api/service/portageimpl.cpp28
-rw-r--r--gentoobrowse-api/service/portageimpl.h4
-rw-r--r--gentoobrowse-api/service/sql/portage/getPackageDependencies.sql6
-rw-r--r--gentoobrowse-api/service/sql/portage/getPackageMasks.sql7
-rw-r--r--gentoobrowse-api/service/sql/portage/getPackageRuntimeDependencies.sql7
-rw-r--r--gentoobrowse-api/service/sql/portage/getPackagesDepending.sql11
-rw-r--r--gentoobrowse-api/unittests/fixtures/masksets.dat2
-rw-r--r--gentoobrowse-api/unittests/testPortage.cpp45
12 files changed, 139 insertions, 1 deletions
diff --git a/gentoobrowse-api/api/portage.ice b/gentoobrowse-api/api/portage.ice
index aed2293..98b39fe 100644
--- a/gentoobrowse-api/api/portage.ice
+++ b/gentoobrowse-api/api/portage.ice
@@ -24,6 +24,10 @@ module Gentoo {
idempotent Packages getPackagesWithRecentAdditions(int syncs);
idempotent Categories getCategoriesWithRecentAdditions(int syncs);
idempotent Packages getTopTrackedPackages(int n);
+ idempotent PackageDependencyPackages getPackageDependencies(int id);
+ idempotent PackageDependencyPackages getPackageRuntimeDependencies(int id);
+ idempotent PackageDependencyPackages getPackagesDepending(int id);
+ idempotent PackageMasks getPackageMasks(int id);
idempotent Bug getBug(int id) throws Slicer::NoRowsReturned;
idempotent Bugs getPackageBugs(int packageId);
diff --git a/gentoobrowse-api/domain/converters.cpp b/gentoobrowse-api/domain/converters.cpp
index 6cedbcd..33a479f 100644
--- a/gentoobrowse-api/domain/converters.cpp
+++ b/gentoobrowse-api/domain/converters.cpp
@@ -64,6 +64,8 @@ namespace Slicer {
s->get("{" + boost::algorithm::join(l2, ",") + "}");
}
+ template class PqArray<Ice::Int>;
+
::Gentoo::StringList
unpackPqTextArray(const std::string & s)
{
diff --git a/gentoobrowse-api/domain/extended-models.ice b/gentoobrowse-api/domain/extended-models.ice
index fabf0f3..de9e514 100644
--- a/gentoobrowse-api/domain/extended-models.ice
+++ b/gentoobrowse-api/domain/extended-models.ice
@@ -23,11 +23,22 @@ module Gentoo {
StringList archs;
};
+ class PackageDependencyPackage extends Package {
+ IntList ebuildids;
+ bool block;
+ };
+
+ class PackageMask extends Mask {
+ IntList ebuildids;
+ };
+
sequence<SearchResultPackage> SearchResultPackages;
sequence<SearchResultBug> SearchResultBugs;
sequence<OverviewCategory> OverviewCategories;
sequence<EbuildDetail> EbuildDetails;
dictionary<string, OverviewCategories> OverviewCategoriesBySuper;
+ sequence<PackageDependencyPackage> PackageDependencyPackages;
+ sequence<PackageMask> PackageMasks;
};
#endif
diff --git a/gentoobrowse-api/domain/portage-models.ice b/gentoobrowse-api/domain/portage-models.ice
index 28083e8..42eb0c0 100644
--- a/gentoobrowse-api/domain/portage-models.ice
+++ b/gentoobrowse-api/domain/portage-models.ice
@@ -7,6 +7,8 @@ module Gentoo {
sequence<byte> Image;
[ "slicer:custommodelpart:PqArray<std::string>" ]
sequence<string> StringList;
+ [ "slicer:custommodelpart:PqArray<Ice::Int>" ]
+ sequence<int> IntList;
class Category {
["slicer:db:pkey"]
@@ -89,6 +91,16 @@ module Gentoo {
StringList use;
};
+ class Mask {
+ int setno;
+ optional(0) string person;
+ string email;
+ [ "slicer:conversion:boost.posix_time.ptime:posixTimeToShortDate:shortDateToPosixTime" ]
+ string dateadded;
+ string message;
+ StringList atomspec;
+ };
+
struct Sync {
[ "slicer:conversion:boost.posix_time.ptime:boost.posix_time.to_iso_extended_string:boost.posix_time.time_from_string:nodeclare" ]
string timestamp;
@@ -102,6 +114,7 @@ module Gentoo {
sequence<ChangeLogEntry> ChangeLog;
sequence<NewsItem> News;
sequence<Sync> Syncs;
+ sequence<Mask> Masks;
};
#endif
diff --git a/gentoobrowse-api/service/portageimpl.cpp b/gentoobrowse-api/service/portageimpl.cpp
index 9854230..689b173 100644
--- a/gentoobrowse-api/service/portageimpl.cpp
+++ b/gentoobrowse-api/service/portageimpl.cpp
@@ -17,6 +17,10 @@
#include <sql/portage/getPackagesWithRecentAdditions.sql.h>
#include <sql/portage/getTopTrackedPackages.sql.h>
#include <sql/portage/getRecentAdditions.sql.h>
+#include <sql/portage/getPackageDependencies.sql.h>
+#include <sql/portage/getPackageRuntimeDependencies.sql.h>
+#include <sql/portage/getPackagesDepending.sql.h>
+#include <sql/portage/getPackageMasks.sql.h>
#include <sql/portage/getSyncs.sql.h>
#include <sql/portage/getBug.sql.h>
#include <sql/portage/getPackageBugs.sql.h>
@@ -152,6 +156,30 @@ Portage::getCategoriesWithRecentAdditions(Ice::Int syncs, const Ice::Current &)
return fetchCache<Gentoo::Categories>(sql::portage::getCategoriesWithRecentAdditions, 30, syncs);
}
+Gentoo::PackageDependencyPackages
+Portage::getPackageDependencies(Ice::Int id, const Ice::Current &)
+{
+ return fetchCache<Gentoo::PackageDependencyPackages>(sql::portage::getPackageDependencies, 30, id);
+}
+
+Gentoo::PackageDependencyPackages
+Portage::getPackageRuntimeDependencies(Ice::Int id, const Ice::Current &)
+{
+ return fetchCache<Gentoo::PackageDependencyPackages>(sql::portage::getPackageRuntimeDependencies, 30, id);
+}
+
+Gentoo::PackageDependencyPackages
+Portage::getPackagesDepending(Ice::Int id, const Ice::Current &)
+{
+ return fetchCache<Gentoo::PackageDependencyPackages>(sql::portage::getPackagesDepending, 30, id);
+}
+
+Gentoo::PackageMasks
+Portage::getPackageMasks(Ice::Int id, const Ice::Current &)
+{
+ return fetchCache<Gentoo::PackageMasks>(sql::portage::getPackageMasks, 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 86608d5..8810068 100644
--- a/gentoobrowse-api/service/portageimpl.h
+++ b/gentoobrowse-api/service/portageimpl.h
@@ -31,6 +31,10 @@ class DLL_PUBLIC Portage : public Gentoo::Portage, IceTray::AbstractCachingDatab
Gentoo::Packages getPackagesWithRecentAdditions(Ice::Int syncs, const Ice::Current &) override;
Gentoo::Categories getCategoriesWithRecentAdditions(Ice::Int syncs, const Ice::Current &) override;
Gentoo::Packages getTopTrackedPackages(Ice::Int n, const Ice::Current &) override;
+ Gentoo::PackageDependencyPackages getPackageDependencies(Ice::Int id, const Ice::Current &) override;
+ 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::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/getPackageDependencies.sql b/gentoobrowse-api/service/sql/portage/getPackageDependencies.sql
new file mode 100644
index 0000000..5a6b6c9
--- /dev/null
+++ b/gentoobrowse-api/service/sql/portage/getPackageDependencies.sql
@@ -0,0 +1,6 @@
+SELECT p.packageid, p.categoryid, p.name, p.description, p.summary, p.firstseen, p.maintainer, p.maintainername, p.herd, array_agg(e.ebuildid order by e.ebuildid) ebuildids, position('!' in d.op) > 0 block
+FROM gentoobrowse.packages p, gentoobrowse.ebuilds e, gentoobrowse.ebuild_deps d
+WHERE e.packageid = ?
+AND e.ebuildid = d.ebuildid
+AND p.packageid = d.packageid
+GROUP BY p.packageid, block
diff --git a/gentoobrowse-api/service/sql/portage/getPackageMasks.sql b/gentoobrowse-api/service/sql/portage/getPackageMasks.sql
new file mode 100644
index 0000000..bc05f4b
--- /dev/null
+++ b/gentoobrowse-api/service/sql/portage/getPackageMasks.sql
@@ -0,0 +1,7 @@
+SELECT ms.setno, ms.person, ms.email, ms.dateadded, ms.message, ms.atomspec, ms.n, ARRAY_AGG(e.ebuildid ORDER BY e.ebuildid) ebuildids
+FROM gentoobrowse.ebuild_masks em, gentoobrowse.masksets ms, gentoobrowse.ebuilds e
+WHERE em.setno = ms.setno
+AND em.ebuildid = e.ebuildid
+AND e.packageid = ?
+GROUP BY ms.setno
+ORDER BY dateadded
diff --git a/gentoobrowse-api/service/sql/portage/getPackageRuntimeDependencies.sql b/gentoobrowse-api/service/sql/portage/getPackageRuntimeDependencies.sql
new file mode 100644
index 0000000..e74d0d0
--- /dev/null
+++ b/gentoobrowse-api/service/sql/portage/getPackageRuntimeDependencies.sql
@@ -0,0 +1,7 @@
+SELECT p.packageid, p.categoryid, p.name, p.description, p.summary, p.firstseen, p.maintainer, p.maintainername, p.herd, array_agg(e.ebuildid order by e.ebuildid) ebuildids, position('!' in d.op) > 0 block
+FROM gentoobrowse.packages p, gentoobrowse.ebuilds e, gentoobrowse.ebuild_rdeps d
+WHERE e.packageid = ?
+AND e.ebuildid = d.ebuildid
+AND p.packageid = d.packageid
+GROUP BY p.packageid, block
+
diff --git a/gentoobrowse-api/service/sql/portage/getPackagesDepending.sql b/gentoobrowse-api/service/sql/portage/getPackagesDepending.sql
new file mode 100644
index 0000000..c86d1f9
--- /dev/null
+++ b/gentoobrowse-api/service/sql/portage/getPackagesDepending.sql
@@ -0,0 +1,11 @@
+SELECT p.packageid, p.categoryid, p.name, p.description, p.summary, p.firstseen, p.maintainer, p.maintainername, p.herd, array_agg(e.ebuildid order by e.ebuildid) ebuildids, position('!' in d.op) > 0 block
+FROM gentoobrowse.packages p, gentoobrowse.ebuilds e, (
+ SELECT d.ebuildid, d.packageid, d.op
+ FROM gentoobrowse.ebuild_rdeps d
+ UNION ALL
+ SELECT d.ebuildid, d.packageid, d.op
+ FROM gentoobrowse.ebuild_deps d) d
+WHERE d.packageid = ?
+AND e.ebuildid = d.ebuildid
+AND p.packageid = e.packageid
+GROUP BY p.packageid, block
diff --git a/gentoobrowse-api/unittests/fixtures/masksets.dat b/gentoobrowse-api/unittests/fixtures/masksets.dat
index d73443e..c523a3a 100644
--- a/gentoobrowse-api/unittests/fixtures/masksets.dat
+++ b/gentoobrowse-api/unittests/fixtures/masksets.dat
@@ -1,4 +1,4 @@
-3 Robin H. Johnson robbat2@gentoo.org 2006-02-11 zlib interaction is badly broken. See bug #124733. 1 {}
+3 Robin H. Johnson robbat2@gentoo.org 2006-02-11 zlib interaction is badly broken. See bug #124733. 1 {<dev-vcs/cvs-1.12.10}
4 Tavis Ormandy taviso@gentoo.org 2006-03-21 masked pending unresolved security issues #125902 1 {}
5 Tavis Ormandy taviso@gentoo.org 2006-03-21 masked pending unresolved security issues #127167 2 {}
6 MATSUU Takuto matsuu@gentoo.org 2007-04-05 to be tested, seems unstable 1 {}
diff --git a/gentoobrowse-api/unittests/testPortage.cpp b/gentoobrowse-api/unittests/testPortage.cpp
index 263c707..135ae7f 100644
--- a/gentoobrowse-api/unittests/testPortage.cpp
+++ b/gentoobrowse-api/unittests/testPortage.cpp
@@ -253,6 +253,51 @@ BOOST_AUTO_TEST_CASE( getRecentAdditions )
BOOST_REQUIRE_EQUAL("GPL-2", es.front()->license);
}
+BOOST_AUTO_TEST_CASE( getPackageDependencies )
+{
+ auto d = p->getPackageDependencies(54144);
+ BOOST_REQUIRE_EQUAL(2, d.size());
+ BOOST_REQUIRE_EQUAL("gnupg", d.front()->name);
+ // This is right... git-9999 requires a version of itself
+ BOOST_REQUIRE_EQUAL("git", d.back()->name);
+ BOOST_REQUIRE_EQUAL(4, d.back()->ebuildids.size());
+ BOOST_REQUIRE_EQUAL(628953, d.back()->ebuildids.front());
+ BOOST_REQUIRE_EQUAL(629007, d.back()->ebuildids.back());
+}
+
+BOOST_AUTO_TEST_CASE( getPackageRuntimeDependencies )
+{
+ auto d = p->getPackageRuntimeDependencies(54144);
+ BOOST_REQUIRE_EQUAL(3, d.size());
+ BOOST_REQUIRE_EQUAL("gnupg", d[0]->name);
+ BOOST_REQUIRE_EQUAL("cvsps", d[1]->name);
+ BOOST_REQUIRE_EQUAL("subversion", d[2]->name);
+}
+
+BOOST_AUTO_TEST_CASE( getPackagesDepending )
+{
+ auto d = p->getPackagesDepending(55923);
+ BOOST_REQUIRE_EQUAL(6, d.size());
+ BOOST_REQUIRE_EQUAL("statcvs", d.front()->name);
+ BOOST_REQUIRE_EQUAL("tkcvs", d.back()->name);
+}
+
+BOOST_AUTO_TEST_CASE( getPackageMasks )
+{
+ auto ms = p->getPackageMasks(55923);
+ BOOST_REQUIRE_EQUAL(1, ms.size());
+ BOOST_REQUIRE_EQUAL(3, ms.front()->setno);
+ BOOST_REQUIRE_EQUAL("robbat2@gentoo.org", ms.front()->email);
+ BOOST_REQUIRE_EQUAL("Robin H. Johnson", ms.front()->person);
+ BOOST_REQUIRE_EQUAL("2006-02-11", ms.front()->dateadded);
+ BOOST_REQUIRE_EQUAL("zlib interaction is badly broken. See bug #124733.", ms.front()->message);
+ BOOST_REQUIRE_EQUAL(1, ms.front()->atomspec.size());
+ BOOST_REQUIRE_EQUAL("<dev-vcs/cvs-1.12.10", ms.front()->atomspec.front());
+ BOOST_REQUIRE_EQUAL(5, ms.front()->ebuildids.size());
+ BOOST_REQUIRE_EQUAL(628951, ms.front()->ebuildids.front());
+ BOOST_REQUIRE_EQUAL(629114, ms.front()->ebuildids.back());
+}
+
BOOST_AUTO_TEST_CASE( getBugMissing )
{
BOOST_REQUIRE_THROW(p->getBug(10), Slicer::NoRowsReturned);