From 3fe742290f24fa5e514a06c73247537aed3e58a4 Mon Sep 17 00:00:00 2001 From: Efraim Flashner Date: Thu, 19 Nov 2020 14:51:28 +0200 Subject: [PATCH] build: Add guix.scm helper file. * build-aux/guix.scm: New file. * Makefile.am (EXTRA_DIST): Register it. --- Makefile.am | 2 +- build-aux/guix.scm | 79 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 build-aux/guix.scm diff --git a/Makefile.am b/Makefile.am index 774ebba..1c4acda 100644 --- a/Makefile.am +++ b/Makefile.am @@ -71,7 +71,7 @@ CLEANFILES = \ # Crash handler. -EXTRA_DIST = etc/crash-handler.c +EXTRA_DIST = etc/crash-handler.c build-aux/guix.scm if BUILD_CRASH_HANDLER diff --git a/build-aux/guix.scm b/build-aux/guix.scm new file mode 100644 index 0000000..d895db4 --- /dev/null +++ b/build-aux/guix.scm @@ -0,0 +1,79 @@ +;;; guix.scm -- Guix package definition +;; Copyright (C) 2020 Efraim Flashner +;; +;; This file is part of the GNU Shepherd. +;; +;; The GNU Shepherd 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. +;; +;; The GNU Shepherd 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 the GNU Shepherd. If not, see . + +(use-modules + (guix packages) + ((guix git-download) #:select (git-version)) + ((guix build utils) #:select (find-files)) + ((guix gexp) #:select (local-file)) + ((guix utils) #:select (substitute-keyword-arguments)) + ((gnu packages) #:select (specification->package)) + ((ice-9 popen) #:select (open-pipe)) + ((ice-9 rdelim) #:select (read-string)) + ((srfi srfi-1) #:select (any))) + +(define %source-dir (dirname (dirname (current-filename)))) + +(define %git-commit + (read-string (open-pipe "git show HEAD | head -1 | cut -d ' ' -f 2" OPEN_READ))) + +(define (keep-file? file stat) + (not (any (lambda (my-string) + (string-contains file my-string)) + (list ".git" ".dir-locals.el" "build-aux")))) + +(define (build-from-git base) + (package + (inherit base) + (version (git-version (package-version base) "HEAD" %git-commit)) + (source (local-file %source-dir + #:recursive? #t + #:select? keep-file?)) + (native-inputs + `(("autoconf" ,(specification->package "autoconf")) + ("automake" ,(specification->package "automake")) + ("gettext" ,(specification->package "gettext")) + ("help2man" ,(specification->package "help2man")) + ("texinfo" ,(specification->package "texinfo")) + ,@(package-native-inputs base))) + (arguments + `(#:configure-flags '("--localstatedir=/var") + #:make-flags (list "GUILE_AUTO_COMPILE=0") + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'make-po-directory-writable + (lambda _ + (for-each make-file-writable + (find-files "po")) + #t))))))) + +(list (build-from-git (specification->package "shepherd")) + (build-from-git (specification->package "guile2.2-shepherd")) + (let ((base (build-from-git (specification->package "guile2.0-shepherd")))) + (package + (inherit base) + (arguments + (substitute-keyword-arguments (package-arguments base) + ((#:phases phases) + `(modify-phases ,phases + (add-after 'unpack 'patch-source + (lambda _ + ;; (ice-9 threads) isn't available in guile-2.0 + (substitute* "modules/shepherd.scm" + ((".*\\(ice-9 threads\\).*") "")) + #t))))))))) -- 2.30.0