From 4b9be1cb87c4759ca08aa89acd9e9fd7ba5b18be Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 6 Jul 2017 20:28:22 +0300 Subject: Add support for build include/exclude manifest values --- libbrep/build-extra.sql | 18 ++++++++++++++++++ libbrep/build-package.hxx | 42 ++++++++++++++++++++++++++++++++++++++++-- libbrep/package.cxx | 5 +++++ libbrep/package.hxx | 29 +++++++++++++++++++++++++---- libbrep/package.xml | 38 +++++++++++++++++++++++++++++++++++++- 5 files changed, 125 insertions(+), 7 deletions(-) (limited to 'libbrep') 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 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 internal_repository; + // Mapped to a subset of the package object build_constraints member + // using the PostgreSQL foreign table mechanism. + // + vector 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 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 be, dependencies_type dp, requirements_type rq, + build_constraints_type bc, optional lc, optional sh, shared_ptr 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 #include +#include #include #include @@ -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; + + #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 build_email, dependencies_type, requirements_type, + build_constraints_type, optional location, optional sha256sum, shared_ptr); @@ -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 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 @@ - + @@ -374,6 +374,42 @@
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
-- cgit v1.1