From patchwork Thu Oct 5 17:24:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivien Kraus X-Patchwork-Id: 54726 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 3F40127BBEA; Tue, 10 Oct 2023 20:34:32 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id EFC7127BBE2 for ; Tue, 10 Oct 2023 20:34:30 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qqIUK-0000Gl-6d; Tue, 10 Oct 2023 15:33:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qqIUC-0000Dl-66 for guix-patches@gnu.org; Tue, 10 Oct 2023 15:33:44 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qqIU9-0008K7-P4 for guix-patches@gnu.org; Tue, 10 Oct 2023 15:33:42 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qqIUV-0008NN-2c for guix-patches@gnu.org; Tue, 10 Oct 2023 15:34:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#66099] [PATCH gnome-team v10 3/6] services: udev: Make udev-rule helper functions generic. Resent-From: Vivien Kraus Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 10 Oct 2023 19:34:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66099 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Maxim Cournoyer , Liliana Marie Prikler , 66099@debbugs.gnu.org Cc: rg@raghavgururajan.name Received: via spool by 66099-submit@debbugs.gnu.org id=B66099.169696641632118 (code B ref 66099); Tue, 10 Oct 2023 19:34:03 +0000 Received: (at 66099) by debbugs.gnu.org; 10 Oct 2023 19:33:36 +0000 Received: from localhost ([127.0.0.1]:36928 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qqIU3-0008Lw-Bd for submit@debbugs.gnu.org; Tue, 10 Oct 2023 15:33:35 -0400 Received: from planete-kraus.eu ([89.234.140.182]:33880) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qqITx-0008KX-HX for 66099@debbugs.gnu.org; Tue, 10 Oct 2023 15:33:30 -0400 Received: from planete-kraus.eu (localhost.lan [127.0.0.1]) by planete-kraus.eu (OpenSMTPD) with ESMTP id 64571b6c; Tue, 10 Oct 2023 19:33:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=planete-kraus.eu; h= message-id:in-reply-to:references:from:date:subject:to:cc :mime-version; s=albinoniB; bh=PVY0dkxKH7fADxZD/9kSDthztj4=; b=Z iZn0fI4ywJ/QLCvb6ltP1RZo7k9mpjeA/dFZhUdQloRJHsejitYVu5ckNAFqRRep ZDXs3ilEubFxUuMIOebNYfHrRkBgL3SPPjFSWwke63ruukkCH9bvmtFcGEGae0ms GkbQAGJyddE2H4zJv1CmdskAeSfjn3lCv/QrdMkzwudpoiYaEgGTs2MR8ihCBf2K qTAGe0zqbcJ0CVAYnsN7WH8Gu13yJ4GmReklKIULkkS/YDfeo6kvzNJyHeLUQf5v DDLYGwnrQ1bM9fkFUpkjNmCIPiGPsL20jfoWk/UzEgellCUmRNx0BEW9U6LSb3qj Sox704PvclRaEdBQfiQqg== Received: by planete-kraus.eu (OpenSMTPD) with ESMTPSA id 8ce46c0e (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO); Tue, 10 Oct 2023 19:33:06 +0000 (UTC) Message-ID: In-Reply-To: <70ae450282e2411c5506447c79adf6a62345344c.1696966139.git.vivien@planete-kraus.eu> References: <87mswte1rx.fsf@gmail.com> <4744acd296e1c2f5d3f9f14c7cfba3e3696dcac7.1696966139.git.vivien@planete-kraus.eu> <70ae450282e2411c5506447c79adf6a62345344c.1696966139.git.vivien@planete-kraus.eu> Date: Thu, 5 Oct 2023 19:24:56 +0200 MIME-Version: 1.0 User-Agent: Evolution 3.46.4 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Vivien Kraus X-ACL-Warn: , Vivien Kraus via Guix-patches X-Patchwork-Original-From: Vivien Kraus via Guix-patches via From: Vivien Kraus Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/services/base.scm (udev-configurations-union): New function. (udev-configuration-file): New function, use file->udev-configuration-file. (file->udev-configuration-file): New function. (udev-rules-union): Use udev-configurations-union. (udev-rule): Use udev-configuration-file. (file->udev-rule): Use file->udev-configuration-file. --- gnu/services/base.scm | 50 +++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 8b54f30ef6..10e7383475 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -2234,9 +2234,9 @@ (define-record-type* (rules udev-configuration-rules ;list of file-like (default '()))) -(define (udev-rules-union packages) - "Return the union of the @code{lib/udev/rules.d} directories found in each -item of @var{packages}." +(define (udev-configurations-union subdirectory packages) + "Return the union of the lib/udev/SUBDIRECTORY.d directories found in each +item of PACKAGES." (define build (with-imported-modules '((guix build union) (guix build utils)) @@ -2247,39 +2247,57 @@ (define (udev-rules-union packages) (srfi srfi-26)) (define %standard-locations - '("/lib/udev/rules.d" "/libexec/udev/rules.d")) + '(#$(string-append "/lib/udev/" subdirectory ".d") + #$(string-append "/libexec/udev/" subdirectory ".d"))) - (define (rules-sub-directory directory) - ;; Return the sub-directory of DIRECTORY containing udev rules, or - ;; #f if none was found. + (define (configuration-sub-directory directory) + ;; Return the sub-directory of DIRECTORY containing udev + ;; configurations, or #f if none was found. (find directory-exists? (map (cut string-append directory <>) %standard-locations))) (union-build #$output - (filter-map rules-sub-directory '#$packages))))) + (filter-map configuration-sub-directory '#$packages))))) + + (computed-file (string-append "udev-" subdirectory) build)) - (computed-file "udev-rules" build)) +(define (udev-rules-union packages) + "Return the union of the lib/udev/rules.d directories found in each +item of PACKAGES." + (udev-configurations-union "rules" packages)) + +(define (udev-configuration-file subdirectory file-name contents) + "Return a directory with a udev configuration file FILE-NAME containing CONTENTS." + (file->udev-configuration-file subdirectory file-name (plain-file file-name contents))) (define (udev-rule file-name contents) "Return a directory with a udev rule file FILE-NAME containing CONTENTS." - (file->udev-rule file-name (plain-file file-name contents))) + (udev-configuration-file "rules" file-name contents)) -(define (file->udev-rule file-name file) - "Return a directory with a udev rule file FILE-NAME which is a copy of FILE." +(define (file->udev-configuration-file subdirectory file-name file) + "Return a directory with a udev configuration file FILE-NAME which is a copy + of FILE." (computed-file file-name (with-imported-modules '((guix build utils)) #~(begin (use-modules (guix build utils)) - (define rules.d - (string-append #$output "/lib/udev/rules.d")) + (define configuration-directory + (string-append #$output + "/lib/udev/" + #$subdirectory + ".d")) (define file-copy-dest - (string-append rules.d "/" #$file-name)) + (string-append configuration-directory "/" #$file-name)) - (mkdir-p rules.d) + (mkdir-p configuration-directory) (copy-file #$file file-copy-dest))))) +(define (file->udev-rule file-name file) + "Return a directory with a udev rule file FILE-NAME which is a copy of FILE." + (file->udev-configuration-file "rules" file-name file)) + (define kvm-udev-rule ;; Return a directory with a udev rule that changes the group of /dev/kvm to ;; "kvm" and makes it #o660. Apparently QEMU-KVM used to ship this rule,