From c28758a9327efc0f3bfc2f3c14d12b533750d94b Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 8 Jul 2019 21:27:53 +0300 Subject: Add support for marking internal repository as non-buildable --- libbrep/build-extra.sql | 3 ++- libbrep/build-package.hxx | 15 ++++++--------- libbrep/build.hxx | 41 ++++++++++++++++++++++------------------- libbrep/build.xml | 2 ++ libbrep/common.hxx | 2 +- libbrep/package.cxx | 17 ++++++++++------- libbrep/package.hxx | 31 ++++++++++++++++++++++++++++--- libbrep/package.xml | 9 +++++++++ 8 files changed, 80 insertions(+), 40 deletions(-) (limited to 'libbrep') diff --git a/libbrep/build-extra.sql b/libbrep/build-extra.sql index 1ada713..9ecbcb1 100644 --- a/libbrep/build-extra.sql +++ b/libbrep/build-extra.sql @@ -48,7 +48,8 @@ CREATE FOREIGN TABLE build_package ( version_upstream TEXT NOT NULL, version_release TEXT NULL, internal_repository_tenant TEXT NULL, - internal_repository_canonical_name TEXT NULL) + internal_repository_canonical_name TEXT NULL, + buildable BOOLEAN NOT NULL) SERVER package_server OPTIONS (table_name 'package'); -- The foreign table for the build_package object builds member (that is of a diff --git a/libbrep/build-package.hxx b/libbrep/build-package.hxx index 3f15012..c491b9e 100644 --- a/libbrep/build-package.hxx +++ b/libbrep/build-package.hxx @@ -78,6 +78,7 @@ namespace brep package_id id; upstream_version version; lazy_shared_ptr internal_repository; + bool buildable; // Mapped to the package object builds member using the PostgreSQL foreign // table mechanism. @@ -101,7 +102,7 @@ namespace brep build_package () = default; }; - // Packages that can potentially be built (internal non-stub). + // Packages that can potentially be built. // // Note that ADL can't find the equal operator, so we use the function call // notation. @@ -109,11 +110,9 @@ namespace brep #pragma db view \ object(build_package) \ object(build_repository inner: \ + build_package::buildable && \ brep::operator== (build_package::internal_repository, \ - build_repository::id) && \ - brep::compare_version_ne (build_package::id.version, \ - brep::wildcard_version, \ - false)) \ + build_repository::id)) \ object(build_tenant: build_package::id.tenant == build_tenant::id) struct buildable_package { @@ -128,11 +127,9 @@ namespace brep #pragma db view \ object(build_package) \ object(build_repository inner: \ + build_package::buildable && \ brep::operator== (build_package::internal_repository, \ - build_repository::id) && \ - brep::compare_version_ne (build_package::id.version, \ - brep::wildcard_version, \ - false)) \ + build_repository::id)) \ object(build_tenant: build_package::id.tenant == build_tenant::id) struct buildable_package_count { diff --git a/libbrep/build.hxx b/libbrep/build.hxx index 9fbf983..ea51c00 100644 --- a/libbrep/build.hxx +++ b/libbrep/build.hxx @@ -26,7 +26,7 @@ // #define LIBBREP_BUILD_SCHEMA_VERSION_BASE 7 -#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 7, closed) +#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 8, closed) // 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 @@ -262,10 +262,16 @@ namespace brep } }; - #pragma db view object(build) \ - object(build_package inner: \ - brep::operator== (build::id.package, build_package::id) && \ - build_package::internal_repository.canonical_name.is_not_null ()) \ + // Note that ADL can't find the equal operator in join conditions, so we use + // the function call notation for them. + // + + // Toolchains of existing buildable package builds. + // + #pragma db view object(build) \ + object(build_package inner: \ + brep::operator== (build::id.package, build_package::id) && \ + build_package::buildable) \ query(distinct) struct toolchain { @@ -303,27 +309,24 @@ namespace brep canonical_version version_; }; - // Build of an existing internal package. - // - // Note that ADL can't find the equal operator, so we use the function call - // notation. + // Build of an existing buildable package. // - #pragma db view \ - object(build) \ - object(build_package inner: \ - brep::operator== (build::id.package, build_package::id) && \ - build_package::internal_repository.canonical_name.is_not_null ()) \ + #pragma db view \ + object(build) \ + object(build_package inner: \ + brep::operator== (build::id.package, build_package::id) && \ + build_package::buildable) \ object(build_tenant: build_package::id.tenant == build_tenant::id) struct package_build { shared_ptr build; }; - #pragma db view \ - object(build) \ - object(build_package inner: \ - brep::operator== (build::id.package, build_package::id) && \ - build_package::internal_repository.canonical_name.is_not_null ()) \ + #pragma db view \ + object(build) \ + object(build_package inner: \ + brep::operator== (build::id.package, build_package::id) && \ + build_package::buildable) \ object(build_tenant: build_package::id.tenant == build_tenant::id) struct package_build_count { diff --git a/libbrep/build.xml b/libbrep/build.xml index 2f8a8a9..032fd38 100644 --- a/libbrep/build.xml +++ b/libbrep/build.xml @@ -1,4 +1,6 @@ + + diff --git a/libbrep/common.hxx b/libbrep/common.hxx index db7e045..052aae1 100644 --- a/libbrep/common.hxx +++ b/libbrep/common.hxx @@ -151,7 +151,7 @@ namespace brep // // The default collation for UTF8-encoded TEXT columns in PostgreSQL is // UCA-compliant. This makes the statement 'a' < '~' to be false, which - // in turn makes the statement 2.1.alpha < 2.1 to be false as well. + // in turn makes the statement 2.1-alpha < 2.1 to be false as well. // // Unicode Collation Algorithm (UCA): http://unicode.org/reports/tr10/ // diff --git a/libbrep/package.cxx b/libbrep/package.cxx index 6c6a565..b17dcc1 100644 --- a/libbrep/package.cxx +++ b/libbrep/package.cxx @@ -105,13 +105,12 @@ namespace brep dependencies (move (dp)), requirements (move (rq)), builds (move (bs)), - build_constraints (version.compare (wildcard_version, true) != 0 - ? move (bc) - : build_constraints_type ()), + build_constraints (!stub () ? move (bc) : build_constraints_type ()), internal_repository (move (rp)), location (move (lc)), fragment (move (fr)), - sha256sum (move (sh)) + sha256sum (move (sh)), + buildable (!stub () && internal_repository->buildable) { assert (internal_repository->internal); } @@ -123,7 +122,8 @@ namespace brep : id (rp->tenant, move (nm), vr), tenant (id.tenant), name (id.name), - version (move (vr)) + version (move (vr)), + buildable (false) { assert (!rp->internal); other_repositories.emplace_back (move (rp)); @@ -192,6 +192,7 @@ namespace brep string d, repository_location h, optional c, + bool b, uint16_t r) : id (move (t), l.canonical_name ()), tenant (id.tenant), @@ -201,7 +202,8 @@ namespace brep priority (r), cache_location (move (h)), certificate (move (c)), - internal (true) + internal (true), + buildable (b) { } @@ -212,7 +214,8 @@ namespace brep canonical_name (id.canonical_name), location (move (l)), priority (0), - internal (false) + internal (false), + buildable (false) { } } diff --git a/libbrep/package.hxx b/libbrep/package.hxx index 86a1922..5e1bebd 100644 --- a/libbrep/package.hxx +++ b/libbrep/package.hxx @@ -21,7 +21,7 @@ // #define LIBBREP_PACKAGE_SCHEMA_VERSION_BASE 14 -#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 14, closed) +#pragma db model version(LIBBREP_PACKAGE_SCHEMA_VERSION_BASE, 15, closed) namespace brep { @@ -245,6 +245,7 @@ namespace brep string display_name, repository_location cache_location, optional, + bool buildable, uint16_t priority); // Create external repository. @@ -259,8 +260,8 @@ namespace brep repository_location location; // Note: foreign-mapped in build. string display_name; - // The order in the internal repositories configuration file, starting from - // 1. 0 for external repositories. + // The order in the internal repositories configuration file, starting + // from 1. 0 for external repositories. // uint16_t priority; @@ -291,6 +292,12 @@ namespace brep timestamp repositories_timestamp; bool internal; + + // Whether repository packages are buildable by the build bot controller + // service. Can only be true for internal repositories. + // + bool buildable; + vector> complements; vector> prerequisites; @@ -401,6 +408,13 @@ namespace brep bool internal () const noexcept {return internal_repository != nullptr;} + bool + stub () const noexcept + { + return version.compare (wildcard_version, + true /* ignore_revision */) == 0; + } + // Manifest data. // package_id id; @@ -459,6 +473,17 @@ namespace brep vector> other_repositories; + // Whether the package is buildable by the build bot controller service. + // Can only be true for non-stubs that belong to at least one buildable + // (internal) repository. + // + // While we could potentially calculate this flag on the fly, that would + // complicate the database queries significantly. + // + // Note: foreign-mapped in build. + // + bool buildable; + // Database mapping. // #pragma db member(id) id column("") diff --git a/libbrep/package.xml b/libbrep/package.xml index ad0a888..4af583e 100644 --- a/libbrep/package.xml +++ b/libbrep/package.xml @@ -1,4 +1,13 @@ + + + + + + + + +
-- cgit v1.1