aboutsummaryrefslogtreecommitdiff
path: root/libbrep
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-11-17 23:41:25 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-11-29 20:53:58 +0300
commit22059500a799d788c09171e31b668ab8259ec057 (patch)
treeb6b6d31884a2f4d4226a7299c9decd388a426044 /libbrep
parent2667fad8bf6e7ef6ef1894ab49a3bdc5cc858607 (diff)
Add support for builds manifest value
Diffstat (limited to 'libbrep')
-rw-r--r--libbrep/build-extra.sql21
-rw-r--r--libbrep/build-package.hxx46
-rw-r--r--libbrep/build.hxx2
-rw-r--r--libbrep/build.xml2
-rw-r--r--libbrep/common.hxx21
-rw-r--r--libbrep/package.cxx2
-rw-r--r--libbrep/package.hxx16
-rw-r--r--libbrep/package.xml47
8 files changed, 110 insertions, 47 deletions
diff --git a/libbrep/build-extra.sql b/libbrep/build-extra.sql
index 6c0d6ef..1ada713 100644
--- a/libbrep/build-extra.sql
+++ b/libbrep/build-extra.sql
@@ -8,6 +8,8 @@
DROP FOREIGN TABLE IF EXISTS build_package_constraints;
+DROP FOREIGN TABLE IF EXISTS build_package_builds;
+
DROP FOREIGN TABLE IF EXISTS build_package;
DROP FOREIGN TABLE IF EXISTS build_repository;
@@ -49,6 +51,22 @@ CREATE FOREIGN TABLE build_package (
internal_repository_canonical_name TEXT NULL)
SERVER package_server OPTIONS (table_name 'package');
+-- The foreign table for the build_package object builds member (that is of a
+-- container type).
+--
+--
+CREATE FOREIGN TABLE build_package_builds (
+ tenant TEXT NOT NULL,
+ name CITEXT 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,
+ expression TEXT NOT NULL,
+ comment TEXT NOT NULL)
+SERVER package_server OPTIONS (table_name 'package_builds');
+
-- The foreign table for the build_package object constraints member (that is
-- of a container type).
--
@@ -63,5 +81,6 @@ CREATE FOREIGN TABLE build_package_constraints (
index BIGINT NOT NULL,
exclusion BOOLEAN NOT NULL,
config TEXT NOT NULL,
- target TEXT NULL)
+ target TEXT NULL,
+ comment TEXT NOT NULL)
SERVER package_server OPTIONS (table_name 'package_build_constraints');
diff --git a/libbrep/build-package.hxx b/libbrep/build-package.hxx
index 0d6b5bf..4294106 100644
--- a/libbrep/build-package.hxx
+++ b/libbrep/build-package.hxx
@@ -69,17 +69,6 @@ namespace brep
build_repository (): canonical_name (id.canonical_name) {}
};
- // "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 the package object.
//
#pragma db object table("build_package") pointer(shared_ptr) readonly
@@ -90,15 +79,21 @@ 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.
+ // Mapped to the package object builds member using the PostgreSQL foreign
+ // table mechanism.
+ //
+ build_class_exprs builds;
+
+ // Mapped to the package object build_constraints member using the
+ // PostgreSQL foreign table mechanism.
//
- vector<build_constraint_subset> constraints;
+ build_constraints constraints;
// Database mapping.
//
#pragma db member(id) id column("")
#pragma db member(version) set(this.version.init (this.id.version, (?)))
+ #pragma db member(builds) id_column("") value_column("")
#pragma db member(constraints) id_column("") value_column("")
private:
@@ -149,29 +144,6 @@ 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 inner: \
- "c.exclusion AND " \
- "c.tenant = " + build_package::id.tenant + "AND" + \
- "c.name = " + build_package::id.name + "AND" + \
- "c.version_epoch = " + build_package::id.version.epoch + "AND" + \
- "c.version_canonical_upstream = " + \
- build_package::id.version.canonical_upstream + "AND" + \
- "c.version_canonical_release = " + \
- build_package::id.version.canonical_release + "AND" + \
- "c.version_revision = " + build_package::id.version.revision) \
- object(build_tenant: build_package::id.tenant == build_tenant::id) \
- query(distinct)
- struct build_constrained_package
- {
- shared_ptr<build_package> package;
- };
}
#endif // LIBBREP_BUILD_PACKAGE_HXX
diff --git a/libbrep/build.hxx b/libbrep/build.hxx
index 279c1d7..03807fa 100644
--- a/libbrep/build.hxx
+++ b/libbrep/build.hxx
@@ -26,7 +26,7 @@
//
#define LIBBREP_BUILD_SCHEMA_VERSION_BASE 4
-#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 5, open)
+#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 6, open)
// We have to keep these mappings at the global scope instead of inside
// the brep namespace because they need to be also effective in the
diff --git a/libbrep/build.xml b/libbrep/build.xml
index 13b47a6..434eac2 100644
--- a/libbrep/build.xml
+++ b/libbrep/build.xml
@@ -1,4 +1,6 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="build" version="1">
+ <changeset version="6"/>
+
<changeset version="5"/>
<model version="4">
diff --git a/libbrep/common.hxx b/libbrep/common.hxx
index b9adee8..b2e2052 100644
--- a/libbrep/common.hxx
+++ b/libbrep/common.hxx
@@ -267,6 +267,27 @@ namespace brep
: tenant (move (t)), canonical_name (move (n)) {}
};
+ // build_class_expr
+ //
+ using bpkg::build_class_expr;
+ using build_class_exprs = vector<build_class_expr>;
+
+ #pragma db value(build_class_expr) definition
+
+ #pragma db member(build_class_expr::expr) transient
+ #pragma db member(build_class_expr::underlying_classes) transient
+
+ #pragma db member(build_class_expr::expression) virtual(string) before \
+ get(this.string ()) \
+ set(this = brep::build_class_expr ((?), "" /* comment */))
+
+ // build_constraints
+ //
+ using bpkg::build_constraint;
+ using build_constraints = vector<build_constraint>;
+
+ #pragma db value(build_constraint) definition
+
// Version comparison operators.
//
// They allow comparing objects that have epoch, canonical_upstream,
diff --git a/libbrep/package.cxx b/libbrep/package.cxx
index 0a711ba..5b7c716 100644
--- a/libbrep/package.cxx
+++ b/libbrep/package.cxx
@@ -70,6 +70,7 @@ namespace brep
optional<email_type> bee,
dependencies_type dp,
requirements_type rq,
+ build_class_exprs bs,
build_constraints_type bc,
optional<path> lc,
optional<string> fr,
@@ -97,6 +98,7 @@ namespace brep
build_error_email (move (bee)),
dependencies (move (dp)),
requirements (move (rq)),
+ builds (move (bs)),
build_constraints (version.compare (wildcard_version, true) != 0
? move (bc)
: build_constraints_type ()),
diff --git a/libbrep/package.hxx b/libbrep/package.hxx
index 97ea864..73dfd14 100644
--- a/libbrep/package.hxx
+++ b/libbrep/package.hxx
@@ -21,7 +21,7 @@
//
#define LIBBREP_PACKAGE_SCHEMA_VERSION_BASE 7
-#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 10, open)
+#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 11, open)
namespace brep
{
@@ -164,13 +164,6 @@ 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
-
// certificate
//
#pragma db value
@@ -376,6 +369,7 @@ namespace brep
optional<email_type> build_error_email,
dependencies_type,
requirements_type,
+ build_class_exprs,
build_constraints_type,
optional<path> location,
optional<string> fragment,
@@ -425,6 +419,7 @@ namespace brep
dependencies_type dependencies;
requirements_type requirements;
+ build_class_exprs builds; // Note: foreign-mapped in build.
build_constraints_type build_constraints; // Note: foreign-mapped in build.
odb::section build_section;
@@ -511,6 +506,11 @@ namespace brep
set(odb::nested_set (this.requirements, std::move (?))) \
id_column("") key_column("") value_column("id")
+ // builds
+ //
+ #pragma db member(builds) id_column("") value_column("") \
+ section(build_section)
+
// build_constraints
//
#pragma db member(build_constraints) id_column("") value_column("") \
diff --git a/libbrep/package.xml b/libbrep/package.xml
index dff6a47..e90a3a1 100644
--- a/libbrep/package.xml
+++ b/libbrep/package.xml
@@ -1,4 +1,51 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="package" version="1">
+ <changeset version="11">
+ <add-table name="package_builds" kind="container">
+ <column name="tenant" type="TEXT" null="false"/>
+ <column name="name" type="CITEXT" 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="expression" type="TEXT" null="false"/>
+ <column name="comment" type="TEXT" null="false"/>
+ <foreign-key name="tenant_fk" deferrable="DEFERRED">
+ <column name="tenant"/>
+ <references table="tenant">
+ <column name="id"/>
+ </references>
+ </foreign-key>
+ <foreign-key name="object_id_fk" on-delete="CASCADE">
+ <column name="tenant"/>
+ <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="tenant"/>
+ <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_builds_object_id_i">
+ <column name="tenant"/>
+ <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_builds_index_i">
+ <column name="index"/>
+ </index>
+ </add-table>
+ </changeset>
+
<changeset version="10">
<alter-table name="package">
<add-column name="build_warning_email" type="TEXT" null="true"/>