[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#43029] [PATCH] offload: Modify the build-machine record to accept m
From: |
Maxim Cournoyer |
Subject: |
[bug#43029] [PATCH] offload: Modify the build-machine record to accept multiple systems. |
Date: |
Mon, 24 Aug 2020 17:08:02 -0400 |
* guix/scripts/offload.scm (<build-machine>)[systems]: New field.
[system]: Accessor changed to %build-machine-system. Default to #f.
* guix/scripts/offload.scm (build-machine-system): Wrap %build-machine-system
with a deprecation warning.
(build-machine-systems): Access the new systems field or fallback to use
build-machine-system, for backward compatibility.
(machine-matches?): Adjust.
* tests/offload.scm: Add tests...
* Makefile.am (SCM_TESTS): ...and register them.
---
Makefile.am | 1 +
guix/scripts/offload.scm | 24 +++++++++++---
tests/offload.scm | 71 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 92 insertions(+), 4 deletions(-)
create mode 100644 tests/offload.scm
diff --git a/Makefile.am b/Makefile.am
index 4e50a33f82..9c38c2f83c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -433,6 +433,7 @@ SCM_TESTS = \
tests/monads.scm \
tests/nar.scm \
tests/networking.scm \
+ tests/offload.scm \
tests/opam.scm \
tests/openpgp.scm \
tests/packages.scm \
diff --git a/guix/scripts/offload.scm b/guix/scripts/offload.scm
index 20ae7a9469..a56701f07a 100644
--- a/guix/scripts/offload.scm
+++ b/guix/scripts/offload.scm
@@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright ?? 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Court??s
<ludo@gnu.org>
;;; Copyright ?? 2017 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright ?? 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -66,14 +67,16 @@
;;;
;;; Code:
-
(define-record-type* <build-machine>
build-machine make-build-machine
build-machine?
(name build-machine-name) ; string
(port build-machine-port ; number
(default 22))
- (system build-machine-system) ; string
+ (systems %build-machine-systems ; list of strings
+ (default #f)) ; drop default after system
is removed
+ (system %build-machine-system ; deprecated
+ (default #f))
(user build-machine-user) ; string
(private-key build-machine-private-key ; file name
(default (user-openssh-private-key)))
@@ -91,6 +94,19 @@
(features build-machine-features ; list of strings
(default '())))
+;;; Deprecated.
+(define (build-machine-system machine)
+ (warning (G_ "The 'system' field is deprecated, \
+please use 'systems' instead.~%"))
+ (%build-machine-system machine))
+
+;;; TODO: Remove after the deprecated 'system' field is removed.
+(define (build-machine-systems machine)
+ (or (%build-machine-systems machine)
+ (list (build-machine-system machine))
+ (leave (G_ "The build-machine object lacks a value for its 'systems'
+field."))))
+
(define-record-type* <build-requirements>
build-requirements make-build-requirements
build-requirements?
@@ -359,8 +375,8 @@ of free disk space on '~a'~%")
(define (machine-matches? machine requirements)
"Return #t if MACHINE matches REQUIREMENTS."
- (and (string=? (build-requirements-system requirements)
- (build-machine-system machine))
+ (and (member (build-requirements-system requirements)
+ (build-machine-systems machine))
(lset<= string=?
(build-requirements-features requirements)
(build-machine-features machine))))
diff --git a/tests/offload.scm b/tests/offload.scm
new file mode 100644
index 0000000000..5a5de4e8b9
--- /dev/null
+++ b/tests/offload.scm
@@ -0,0 +1,71 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright ?? 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix 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 General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (tests offload)
+ #:use-module (guix scripts offload)
+ #:use-module (srfi srfi-64))
+
+
+(test-begin "offload")
+
+(define-syntax-rule (expose-internal-definitions s1 s2 ...)
+ (begin
+ (define s1 (@@ (guix scripts offload) s1))
+ (define s2 (@@ (guix scripts offload) s2)) ...))
+
+(expose-internal-definitions machine-matches?
+ build-requirements-system
+ build-requirements-features
+ build-machine-system
+ build-machine-systems
+ %build-machine-system
+ %build-machine-systems
+ build-machine-features)
+
+(define (deprecated-build-machine system)
+ (build-machine
+ (name "m1")
+ (user "dummy")
+ (host-key "some-key")
+ (system system)))
+
+(define (new-build-machine systems)
+ (build-machine
+ (name "m1")
+ (user "dummy")
+ (host-key "some-key")
+ (systems systems)))
+
+;;; Test that deprecated build-machine definitions still work.
+(test-assert (machine-matches? (deprecated-build-machine "i686-linux")
+ (build-requirements
+ (system "i686-linux"))))
+
+
+(test-assert (machine-matches? (new-build-machine '("i686-linux"))
+ (build-requirements
+ (system "i686-linux"))))
+
+;;; A build machine can act as more than one system type, thanks to QEMU
+;;; emulation.
+(test-assert (machine-matches? (new-build-machine '("armhf-linux"
+ "aarch64-linux"
+ "i686-linux"
+ "x86_64-linux"))
+ (build-requirements
+ (system "armhf-linux"))))
--
2.27.0
- [bug#43029] [PATCH] offload: Modify the build-machine record to accept multiple systems.,
Maxim Cournoyer <=