aboutsummaryrefslogtreecommitdiff
path: root/libbrep
diff options
context:
space:
mode:
Diffstat (limited to 'libbrep')
-rw-r--r--libbrep/build-extra.sql18
-rw-r--r--libbrep/build-package.hxx42
-rw-r--r--libbrep/package.cxx5
-rw-r--r--libbrep/package.hxx29
-rw-r--r--libbrep/package.xml38
5 files changed, 125 insertions, 7 deletions
diff --git a/libbrep/build-extra.sql b/libbrep/build-extra.sql
index 6a222a7..4da75e5 100644
--- a/libbrep/build-extra.sql
+++ b/libbrep/build-extra.sql
@@ -3,6 +3,8 @@
-- file for details.
--
+DROP FOREIGN TABLE IF EXISTS build_package_constraints;
+
DROP FOREIGN TABLE IF EXISTS build_package;
DROP FOREIGN TABLE IF EXISTS build_repository;
@@ -29,3 +31,19 @@ CREATE FOREIGN TABLE build_package (
version_release TEXT NULL,
internal_repository TEXT NULL)
SERVER package_server OPTIONS (table_name 'package');
+
+-- The foreign table for the build_package object constraints member (that is
+-- of a container type).
+--
+--
+CREATE FOREIGN TABLE build_package_constraints (
+ name TEXT NOT NULL,
+ version_epoch INTEGER NOT NULL,
+ version_canonical_upstream TEXT NOT NULL,
+ version_canonical_release TEXT NOT NULL COLLATE "C",
+ version_revision INTEGER NOT NULL,
+ index BIGINT NOT NULL,
+ exclusion BOOLEAN NOT NULL,
+ config TEXT NOT NULL,
+ target TEXT NULL)
+SERVER package_server OPTIONS (table_name 'package_build_constraints');
diff --git a/libbrep/build-package.hxx b/libbrep/build-package.hxx
index 8bc703a..324303d 100644
--- a/libbrep/build-package.hxx
+++ b/libbrep/build-package.hxx
@@ -23,7 +23,7 @@ namespace brep
// The mapping is established in build-extra.sql. We also explicitly mark
// non-primary key foreign-mapped members in the source object.
//
- // Foreign object that is mapped to the subset of repository object.
+ // Foreign object that is mapped to a subset of repository object.
//
#pragma db object table("build_repository") pointer(shared_ptr) readonly
class build_repository
@@ -46,7 +46,18 @@ namespace brep
build_repository () = default;
};
- // Foreign object that is mapped to the subset of package object.
+ // "Foreign" value type that is mapped to a subset of the build_constraint
+ // value type (see libbpkg/manifest.hxx for details).
+ //
+ #pragma db value
+ struct build_constraint_subset
+ {
+ bool exclusion;
+ string config;
+ optional<string> target;
+ };
+
+ // Foreign object that is mapped to a subset of package object.
//
#pragma db object table("build_package") pointer(shared_ptr) readonly
class build_package
@@ -56,10 +67,16 @@ namespace brep
upstream_version version;
lazy_shared_ptr<build_repository> internal_repository;
+ // Mapped to a subset of the package object build_constraints member
+ // using the PostgreSQL foreign table mechanism.
+ //
+ vector<build_constraint_subset> constraints;
+
// Database mapping.
//
#pragma db member(id) id column("")
#pragma db member(version) set(this.version.init (this.id.version, (?)))
+ #pragma db member(constraints) id_column("") value_column("")
private:
friend class odb::access;
@@ -102,6 +119,27 @@ namespace brep
//
#pragma db member(result) column("count(" + build_package::id.name + ")")
};
+
+ // Packages that have the build constraints. Note that only buildable
+ // (internal and non-stub) packages can have such constraints, so there is
+ // no need for additional checks.
+ //
+ #pragma db view \
+ table("build_package_constraints" = "c") \
+ object(build_package = package inner: \
+ "c.exclusion AND " \
+ "c.name = " + package::id.name + "AND" + \
+ "c.version_epoch = " + package::id.version.epoch + "AND" + \
+ "c.version_canonical_upstream = " + \
+ package::id.version.canonical_upstream + "AND" + \
+ "c.version_canonical_release = " + \
+ package::id.version.canonical_release + "AND" + \
+ "c.version_revision = " + package::id.version.revision) \
+ query(distinct)
+ struct build_constrained_package
+ {
+ shared_ptr<build_package> package;
+ };
}
#endif // LIBBREP_BUILD_PACKAGE_HXX
diff --git a/libbrep/package.cxx b/libbrep/package.cxx
index 20be387..e14b15a 100644
--- a/libbrep/package.cxx
+++ b/libbrep/package.cxx
@@ -62,6 +62,7 @@ namespace brep
optional<email_type> be,
dependencies_type dp,
requirements_type rq,
+ build_constraints_type bc,
optional<path> lc,
optional<string> sh,
shared_ptr<repository_type> rp)
@@ -80,6 +81,10 @@ namespace brep
build_email (move (be)),
dependencies (move (dp)),
requirements (move (rq)),
+ build_constraints (
+ version.compare (wildcard_version, true) != 0
+ ? move (bc)
+ : build_constraints_type ()),
internal_repository (move (rp)),
location (move (lc)),
sha256sum (move (sh))
diff --git a/libbrep/package.hxx b/libbrep/package.hxx
index 5a159ae..d3e3e00 100644
--- a/libbrep/package.hxx
+++ b/libbrep/package.hxx
@@ -9,6 +9,7 @@
#include <chrono>
#include <odb/core.hxx>
+#include <odb/section.hxx>
#include <odb/nested-container.hxx>
#include <libbrep/types.hxx>
@@ -18,9 +19,9 @@
// Used by the data migration entries.
//
-#define LIBBREP_PACKAGE_SCHEMA_VERSION_BASE 4
+#define LIBBREP_PACKAGE_SCHEMA_VERSION_BASE 5
-#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 4, closed)
+#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 5, open)
namespace brep
{
@@ -164,6 +165,13 @@ namespace brep
#pragma db value(requirement_alternatives) definition
+ // build_constraints
+ //
+ using bpkg::build_constraint;
+ using build_constraints = vector<build_constraint>;
+
+ #pragma db value(build_constraint) definition
+
#pragma db value
class certificate
{
@@ -285,8 +293,10 @@ namespace brep
using email_type = brep::email;
using dependencies_type = brep::dependencies;
using requirements_type = brep::requirements;
+ using build_constraints_type = brep::build_constraints;
- // Create internal package object.
+ // Create internal package object. Note that for stubs the build
+ // constraints are meaningless, and so not saved.
//
package (string name,
version_type,
@@ -303,6 +313,7 @@ namespace brep
optional<email_type> build_email,
dependencies_type,
requirements_type,
+ build_constraints_type,
optional<path> location,
optional<string> sha256sum,
shared_ptr<repository_type>);
@@ -337,6 +348,9 @@ namespace brep
dependencies_type dependencies;
requirements_type requirements;
+ build_constraints_type build_constraints; // Note: foreign-mapped in build.
+ odb::section build_section;
+
// Note that it is foreign-mapped in build.
//
lazy_shared_ptr<repository_type> internal_repository;
@@ -413,9 +427,16 @@ namespace brep
set(odb::nested_set (this.requirements, std::move (?))) \
id_column("") key_column("") value_column("id")
+ // build_constraints
+ //
+ #pragma db member(build_constraints) id_column("") value_column("") \
+ section(build_section)
+
+ #pragma db member(build_section) load(lazy) update(always)
+
// other_repositories
//
- #pragma db member(other_repositories) \
+ #pragma db member(other_repositories) \
id_column("") value_column("repository") value_not_null
// search_index
diff --git a/libbrep/package.xml b/libbrep/package.xml
index 657c2fc..0947d6f 100644
--- a/libbrep/package.xml
+++ b/libbrep/package.xml
@@ -1,5 +1,5 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="package" version="1">
- <model version="4">
+ <model version="5">
<table name="repository" kind="object">
<column name="name" type="TEXT" null="false"/>
<column name="location" type="TEXT" null="false"/>
@@ -374,6 +374,42 @@
<column name="version_revision"/>
</index>
</table>
+ <table name="package_build_constraints" kind="container">
+ <column name="name" type="TEXT" null="false"/>
+ <column name="version_epoch" type="INTEGER" null="false"/>
+ <column name="version_canonical_upstream" type="TEXT" null="false"/>
+ <column name="version_canonical_release" type="TEXT" null="false" options="COLLATE &quot;C&quot;"/>
+ <column name="version_revision" type="INTEGER" null="false"/>
+ <column name="index" type="BIGINT" null="false"/>
+ <column name="exclusion" type="BOOLEAN" null="false"/>
+ <column name="config" type="TEXT" null="false"/>
+ <column name="target" type="TEXT" null="true"/>
+ <column name="comment" type="TEXT" null="false"/>
+ <foreign-key name="object_id_fk" on-delete="CASCADE">
+ <column name="name"/>
+ <column name="version_epoch"/>
+ <column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
+ <column name="version_revision"/>
+ <references table="package">
+ <column name="name"/>
+ <column name="version_epoch"/>
+ <column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
+ <column name="version_revision"/>
+ </references>
+ </foreign-key>
+ <index name="package_build_constraints_object_id_i">
+ <column name="name"/>
+ <column name="version_epoch"/>
+ <column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
+ <column name="version_revision"/>
+ </index>
+ <index name="package_build_constraints_index_i">
+ <column name="index"/>
+ </index>
+ </table>
<table name="package_other_repositories" kind="container">
<column name="name" type="TEXT" null="false"/>
<column name="version_epoch" type="INTEGER" null="false"/>