aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am1
-rw-r--r--guix-data-service/jobs/load-new-guix-revision.scm12
-rw-r--r--guix-data-service/model/channel-instance.scm52
-rw-r--r--sqitch/deploy/channel_instance_derivations.sql13
-rw-r--r--sqitch/revert/channel_instance_derivations.sql7
-rw-r--r--sqitch/sqitch.plan1
-rw-r--r--sqitch/verify/channel_instance_derivations.sql7
-rw-r--r--tests/jobs-load-new-guix-revision.scm30
8 files changed, 111 insertions, 12 deletions
diff --git a/Makefile.am b/Makefile.am
index 5f1ed30..1f05b9c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -76,6 +76,7 @@ SOURCES = \
guix-data-service/model/build-server-token-seed.scm \
guix-data-service/model/build-status.scm \
guix-data-service/model/build.scm \
+ guix-data-service/model/channel-instance.scm \
guix-data-service/model/channel-news.scm \
guix-data-service/model/derivation.scm \
guix-data-service/model/git-branch.scm \
diff --git a/guix-data-service/jobs/load-new-guix-revision.scm b/guix-data-service/jobs/load-new-guix-revision.scm
index efc2417..13668d8 100644
--- a/guix-data-service/jobs/load-new-guix-revision.scm
+++ b/guix-data-service/jobs/load-new-guix-revision.scm
@@ -35,6 +35,7 @@
#:use-module (guix-data-service config)
#:use-module (guix-data-service database)
#:use-module (guix-data-service model build)
+ #:use-module (guix-data-service model channel-instance)
#:use-module (guix-data-service model channel-news)
#:use-module (guix-data-service model package)
#:use-module (guix-data-service model package-derivation-by-guix-revision-range)
@@ -1206,6 +1207,17 @@ ORDER BY packages.name, packages.version"
guix-revision-id
(extract-information-from conn guix-revision-id
commit store-item)
+ (insert-channel-instances conn
+ guix-revision-id
+ (filter-map
+ (match-lambda
+ ((system . derivations)
+ (and=>
+ (assoc-ref derivations
+ 'manifest-entry-item)
+ (lambda (drv)
+ (cons system drv)))))
+ channel-derivations-by-system))
(if (defined? 'channel-news-for-commit
(resolve-module '(guix channels)))
(log-time
diff --git a/guix-data-service/model/channel-instance.scm b/guix-data-service/model/channel-instance.scm
new file mode 100644
index 0000000..9df2722
--- /dev/null
+++ b/guix-data-service/model/channel-instance.scm
@@ -0,0 +1,52 @@
+;;; Guix Data Service -- Information about Guix over time
+;;; Copyright © 2020 Christopher Baines <mail@cbaines.net>
+;;;
+;;; This program is free software: you can redistribute it and/or
+;;; modify it under the terms of the GNU Affero General Public License
+;;; as published by the Free Software Foundation, either version 3 of
+;;; the License, or (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; Affero General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU Affero General Public
+;;; License along with this program. If not, see
+;;; <http://www.gnu.org/licenses/>.
+
+(define-module (guix-data-service model channel-instance)
+ #:use-module (srfi srfi-1)
+ #:use-module (ice-9 match)
+ #:use-module (squee)
+ #:use-module (json)
+ #:use-module (guix utils)
+ #:use-module (guix-data-service model utils)
+ #:use-module (guix-data-service model derivation)
+ #:export (insert-channel-instances))
+
+(define (insert-channel-instances conn
+ guix-revision-id
+ derivations-by-system)
+ (let ((derivation-ids
+ (derivation-file-names->derivation-ids
+ conn
+ (map cdr derivations-by-system))))
+
+ (exec-query
+ conn
+ (string-append
+ "
+INSERT INTO channel_instances
+ (guix_revision_id, system, derivation_id)
+VALUES "
+ (string-join
+ (map (lambda (system derivation-id)
+ (simple-format #f "(~A, '~A', ~A)"
+ guix-revision-id
+ system
+ derivation-id))
+ (map car derivations-by-system)
+ derivation-ids)
+ ", "))))
+ #t)
diff --git a/sqitch/deploy/channel_instance_derivations.sql b/sqitch/deploy/channel_instance_derivations.sql
new file mode 100644
index 0000000..bb8e6e3
--- /dev/null
+++ b/sqitch/deploy/channel_instance_derivations.sql
@@ -0,0 +1,13 @@
+-- Deploy guix-data-service:channel_instance_derivations to pg
+
+BEGIN;
+
+CREATE TABLE channel_instances (
+ guix_revision_id integer NOT NULL REFERENCES guix_revisions(id),
+ system varchar NOT NULL,
+ derivation_id integer NOT NULL REFERENCES derivations (id),
+ PRIMARY KEY (guix_revision_id, system),
+ UNIQUE (derivation_id)
+);
+
+COMMIT;
diff --git a/sqitch/revert/channel_instance_derivations.sql b/sqitch/revert/channel_instance_derivations.sql
new file mode 100644
index 0000000..42cc943
--- /dev/null
+++ b/sqitch/revert/channel_instance_derivations.sql
@@ -0,0 +1,7 @@
+-- Revert guix-data-service:channel_instance_derivations from pg
+
+BEGIN;
+
+DROP TABLE channel_instances;
+
+COMMIT;
diff --git a/sqitch/sqitch.plan b/sqitch/sqitch.plan
index 6eabcc1..e21306b 100644
--- a/sqitch/sqitch.plan
+++ b/sqitch/sqitch.plan
@@ -49,3 +49,4 @@ remove_old_cross_derivations 2020-02-07T19:42:54Z Christopher Baines <mail@cbain
increase_fillfactor_for_some_indexes 2020-02-07T20:49:17Z Christopher Baines <mail@cbaines.net> # Increase the fillfactor for some btree indexes
change_package_derivations_by_guix_revision_range_target 2020-02-08T10:13:07Z Christopher Baines <mail@cbaines.net> # Change the values for package_derivations_by_guix_revision_range target
allow_including_and_excluding_branches_for_repositories 2020-02-08T11:30:02Z Christopher Baines <mail@cbaines.net> # Allow including and excluding branches for repositories
+channel_instance_derivations 2020-02-10T07:59:03Z Christopher Baines <mail@cbaines.net> # Add tables to store derivations for channel instances
diff --git a/sqitch/verify/channel_instance_derivations.sql b/sqitch/verify/channel_instance_derivations.sql
new file mode 100644
index 0000000..50511cb
--- /dev/null
+++ b/sqitch/verify/channel_instance_derivations.sql
@@ -0,0 +1,7 @@
+-- Verify guix-data-service:channel_instance_derivations on pg
+
+BEGIN;
+
+-- XXX Add verifications here.
+
+ROLLBACK;
diff --git a/tests/jobs-load-new-guix-revision.scm b/tests/jobs-load-new-guix-revision.scm
index b5ddc78..b362d55 100644
--- a/tests/jobs-load-new-guix-revision.scm
+++ b/tests/jobs-load-new-guix-revision.scm
@@ -44,18 +44,24 @@
#t))
(mock
- ((guix channels)
- channel-news-for-commit
- (lambda (channel commit)
- '()))
-
- (match (enqueue-load-new-guix-revision-job
- conn
- (git-repository-url->git-repository-id conn "test-url")
- "test-commit"
- "test-source")
- ((id)
- (process-load-new-guix-revision-job id))))))))
+ ((guix-data-service model channel-instance)
+ insert-channel-instances
+ (lambda (conn guix-revision-id derivations-by-system)
+ #t))
+
+ (mock
+ ((guix channels)
+ channel-news-for-commit
+ (lambda (channel commit)
+ '()))
+
+ (match (enqueue-load-new-guix-revision-job
+ conn
+ (git-repository-url->git-repository-id conn "test-url")
+ "test-commit"
+ "test-source")
+ ((id)
+ (process-load-new-guix-revision-job id)))))))))
(exec-query conn "TRUNCATE guix_revisions CASCADE")
(exec-query conn "TRUNCATE load_new_guix_revision_jobs CASCADE")