From 579f674656f21e9e8da5ced83adfe809ca0c1afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 9 May 2023 15:13:39 +0200 Subject: [PATCH] maint: Update Guix package definition. * build-aux/guix.scm: Rename to... * build-aux/guix/cuirass-package.scm: ... this. Turn into a module and update package definition. * guix.scm: Add symlink. * Makefile.am (EXTRA_DIST): Update accordingly. --- Makefile.am | 17 +-- README | 2 +- build-aux/guix.scm | 95 ----------------- build-aux/guix/cuirass-package.scm | 163 +++++++++++++++++++++++++++++ guix.scm | 1 + 5 files changed, 174 insertions(+), 104 deletions(-) delete mode 100644 build-aux/guix.scm create mode 100644 build-aux/guix/cuirass-package.scm create mode 120000 guix.scm diff --git a/Makefile.am b/Makefile.am index a40a76d..28796b5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ # Copyright © 1995-2016 Free Software Foundation, Inc. # Copyright © 2016, 2017 Mathieu Lirzin -# Copyright © 2018 Ludovic Courtès +# Copyright © 2018, 2023 Ludovic Courtès # Copyright © 2018 Clément Lassieur # Copyright © 2018 Tatiana Sholokhova # Copyright © 2020 Mathieu Othacehe @@ -193,13 +193,14 @@ CLEANFILES = \ ## Distribution. ## ## -------------- ## -EXTRA_DIST = \ - .dir-locals.el \ - bin/cuirass.in \ - bootstrap \ - build-aux/guix.scm \ - src/cuirass/config.scm.in \ - etc/cuirass-remote-worker.service.in \ +EXTRA_DIST = \ + .dir-locals.el \ + bin/cuirass.in \ + bootstrap \ + guix.scm \ + build-aux/guix/cuirass-package.scm \ + src/cuirass/config.scm.in \ + etc/cuirass-remote-worker.service.in \ $(TESTS) dist-hook: gen-ChangeLog diff --git a/README b/README index 0172dc4..abc213e 100644 --- a/README +++ b/README @@ -24,7 +24,7 @@ A convenient way to install those dependencies is to install Guix and execute the following command: #+BEGIN_EXAMPLE - guix environment cuirass + guix shell -CPNW --expose=/var/run/dbus --expose=/var/log/guix/drvs #+END_EXAMPLE This will build and enter an environment which provides all the necessary diff --git a/build-aux/guix.scm b/build-aux/guix.scm deleted file mode 100644 index b03f173..0000000 --- a/build-aux/guix.scm +++ /dev/null @@ -1,95 +0,0 @@ -;;;; guix.scm -- Guix package definition -;;; Copyright © 2016 Jan Nieuwenhuizen -;;; Copyright © 2016, 2017 Mathieu Lirzin -;;; -;;; This file is part of Cuirass. -;;; -;;; Cuirass 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. -;;; -;;; Cuirass 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 Cuirass. If not, see . - -(use-modules (ice-9 popen) - (ice-9 rdelim) - (gnu) - (guix) - (srfi srfi-1)) - -(define (keep-cuirass-file? file stat) - ;; Return #t if FILE in Cuirass repository must be kept, #f otherwise. FILE - ;; is an absolute file name and STAT is the result of 'lstat' applied to - ;; FILE. - (not (or (any (lambda (str) (string-contains file str)) - '(".git" "autom4te" "Makefile.in" ".go" ".log" - "stamp-vti" ".dirstamp")) - (any (lambda (str) (string-suffix? str file)) - '("trs""configure" "Makefile" "config.status" "pre-inst-env" - "aclocal.m4" "bin/cuirass" "bin/evaluate" "config.cache" - "guix.scm"))))) - -(define %aux-dir - (current-source-directory)) - -(define %srcdir - (dirname %aux-dir)) - -(define (git-version-gen) - ;; Return a string containing Cuirass version number. - (let* ((cmd "git-version-gen .tarball-version") - (port (open-input-pipe (string-append %aux-dir "/" cmd))) - (str (read-line port))) - (close-pipe port) - str)) - -(define (spec+package-list spec) - (list spec (specification->package spec))) - -(package - (inherit (specification->package "cuirass")) - (version (git-version-gen)) - (source (local-file %srcdir #:recursive? #t - #:select? keep-cuirass-file?)) - (arguments - '(#:phases - (modify-phases %standard-phases - (add-before 'configure 'bootstrap - (lambda _ (zero? (system* "sh" "bootstrap")))) - (add-after 'install 'wrap-program - (lambda* (#:key inputs outputs #:allow-other-keys) - ;; Wrap the 'cuirass' command to refer to the right modules. - (let* ((out (assoc-ref outputs "out")) - (json (assoc-ref inputs "guile-json")) - (squee (assoc-ref inputs "guile-squee")) - (zlib (assoc-ref inputs "guile-zlib")) - (guix (assoc-ref inputs "guix")) - (mods (string-append json "/share/guile/site/3.0:" - squee "/share/guile/site/3.0:" - zlib "/share/guile/site/3.0:" - guix "/share/guile/site/3.0"))) - (wrap-program (string-append out "/bin/cuirass") - `("GUILE_LOAD_PATH" ":" prefix (,mods)) - `("GUILE_LOAD_COMPILED_PATH" ":" prefix (,mods))))))))) - (inputs - (map spec+package-list - '("guile" - "guile-fibers" - "guile-json" - "guile-squee" - "guile-git" - "guile-zlib" - "guix"))) - (native-inputs - (map spec+package-list - '("autoconf" - "automake" - "bash" - "pkg-config" - "texinfo")))) diff --git a/build-aux/guix/cuirass-package.scm b/build-aux/guix/cuirass-package.scm new file mode 100644 index 0000000..dad0da0 --- /dev/null +++ b/build-aux/guix/cuirass-package.scm @@ -0,0 +1,163 @@ +;;;; guix.scm -- Guix package definition +;;; Copyright © 2016 Jan Nieuwenhuizen +;;; Copyright © 2016, 2017 Mathieu Lirzin +;;; Copyright © 2023 Ludovic Courtès +;;; +;;; This file is part of Cuirass. +;;; +;;; Cuirass 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. +;;; +;;; Cuirass 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 Cuirass. If not, see . + +(define-module (cuirass-package) + #:use-module (guix) + #:use-module (guix build-system gnu) + #:use-module (guix git-download) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix search-paths) + #:use-module (gnu packages autotools) + #:use-module (gnu packages databases) + #:use-module (gnu packages gnupg) + #:use-module (gnu packages guile) + #:use-module (gnu packages guile-xyz) + #:use-module (gnu packages mail) + #:use-module (gnu packages package-management) + #:use-module (gnu packages pkg-config) + #:use-module (gnu packages texinfo) + #:use-module (gnu packages tls)) + +(define source-checkout + (let ((vcs-file? (or (git-predicate + (string-append (current-source-directory) + "/../..")) + (const #t)))) + (local-file "../.." "cuirass-checkout" + #:recursive? #t + #:select? vcs-file?))) + +(define %cuirass-version "1.99.99-git") + +(define-public cuirass + (package + (name "cuirass") + (version %cuirass-version) + (source source-checkout) + (build-system gnu-build-system) + (arguments + (list #:modules '((guix build utils) + (guix build gnu-build-system) + (ice-9 rdelim) + (ice-9 popen)) + #:configure-flags #~'("--localstatedir=/var") ;for /var/log/cuirass + #:parallel-tests? #f + #:phases + #~(modify-phases %standard-phases + (add-before 'bootstrap 'fix-version-gen + (lambda _ + (patch-shebang "build-aux/git-version-gen") + + (call-with-output-file ".tarball-version" + (lambda (port) + (display #$(package-version this-package) port))))) + (add-before 'check 'set-PATH-for-tests + (lambda* (#:key inputs #:allow-other-keys) + (let ((pg (assoc-ref inputs "ephemeralpg")) + (path (getenv "PATH"))) + (setenv "PATH" (string-append pg "/bin:" path))))) + ;; Disable the remote tests that require a Guix daemon connection. + (add-before 'check 'disable-remote-tests + (lambda _ + (substitute* "Makefile.am" + (("tests/remote.scm") "")))) + (add-after 'install 'wrap-program + (lambda* (#:key inputs outputs #:allow-other-keys) + ;; Wrap the 'cuirass' command to refer to the right modules. + (let* ((out (assoc-ref outputs "out")) + (avahi (assoc-ref inputs "guile-avahi")) + (gcrypt (assoc-ref inputs "guile-gcrypt")) + (json (assoc-ref inputs "guile-json")) + (zmq (assoc-ref inputs "guile-simple-zmq")) + (squee (assoc-ref inputs "guile-squee")) + (git (assoc-ref inputs "guile-git")) + (bytes (assoc-ref inputs "guile-bytestructures")) + (fibers (assoc-ref inputs "guile-fibers")) + (zlib (assoc-ref inputs "guile-zlib")) + (matd (assoc-ref inputs "guile-mastodon")) + (tls (assoc-ref inputs "guile-gnutls")) + (mail (assoc-ref inputs "mailutils")) + (guix (assoc-ref inputs "guix")) + (deps (list avahi gcrypt json zmq squee git bytes + fibers zlib matd tls mail guix)) + (guile (assoc-ref inputs "guile")) + (effective + (read-line + (open-pipe* OPEN_READ + (string-append guile "/bin/guile") + "-c" "(display (effective-version))"))) + (mods + (string-drop-right ;drop trailing colon + (string-join deps + (string-append "/share/guile/site/" + effective ":") + 'suffix) + 1)) + (objs + (string-drop-right + (string-join deps + (string-append "/lib/guile/" effective + "/site-ccache:") + 'suffix) + 1))) + ;; Make sure 'cuirass' can find the relevant Guile modules. + (wrap-program (string-append out "/bin/cuirass") + `("PATH" ":" prefix (,(string-append out "/bin"))) + `("GUILE_LOAD_PATH" ":" prefix (,mods)) + `("GUILE_LOAD_COMPILED_PATH" ":" prefix (,objs))))))))) + (inputs + (list guile-3.0-latest + guile-avahi + guile-fibers-1.1 + guile-gcrypt + guile-json-4 + guile-simple-zmq + guile-squee + guile-git + guile-zlib + guile-mastodon + guile-gnutls + mailutils + ;; FIXME: this is propagated by "guile-git", but it needs to be among + ;; the inputs to add it to GUILE_LOAD_PATH. + guile-bytestructures + + guix)) + (native-inputs + (list autoconf automake pkg-config texinfo ephemeralpg)) + (native-search-paths + ;; For HTTPS access, Cuirass itself honors these variables, with the + ;; same semantics as Git and OpenSSL (respectively). + (list (search-path-specification + (variable "GIT_SSL_CAINFO") + (file-type 'regular) + (separator #f) ;single entry + (files '("etc/ssl/certs/ca-certificates.crt"))) + $SSL_CERT_DIR)) + (synopsis "Continuous integration system") + (description + "Cuirass is a continuous integration tool using GNU Guix. It is +intended as a replacement for Hydra.") + (home-page "https://guix.gnu.org/cuirass/") + (license license:gpl3+))) + +;; Return the Cuirass package that lets you build from Git, for the benefit +;; of 'guix shell'. +cuirass diff --git a/guix.scm b/guix.scm new file mode 120000 index 0000000..4b9e4c8 --- /dev/null +++ b/guix.scm @@ -0,0 +1 @@ +build-aux/guix/cuirass-package.scm \ No newline at end of file