From patchwork Mon Mar 31 22:10:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomas Volf <~@wolfsden.cz> X-Patchwork-Id: 41106 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 ECB4827BBE9; Mon, 31 Mar 2025 23:13:38 +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=-6.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_ALL,DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable 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 E6AF527BBE2 for ; Mon, 31 Mar 2025 23:13:36 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tzNMz-0000MU-QJ; Mon, 31 Mar 2025 18:12:37 -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 1tzNMV-0000DB-Tz for guix-patches@gnu.org; Mon, 31 Mar 2025 18:12:09 -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 1tzNMV-0006zJ-Kz for guix-patches@gnu.org; Mon, 31 Mar 2025 18:12:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=7GXBSJK+0XZYZvsRClPAXFPA5+XIxfd7SyHkK3NqvuQ=; b=n+gcEvSLlVuskYUVjpWa7vczcKG/3/kt624ymT1Fs6TAG+vCYV0LWsbvPIfrN2qmEYL8II2Cp5EbUqexlMa/cam1gdVRg2RDOi2upw8JO9iNeLD+E0Dlpsc9/UQDbe1b8BtI1vkTS44usdAHmPjd06zPvc4wu4AgJJ8oim2fDNSKArDsPGFAS/v3FV3LYTze3LTxsSAwtZnn2ktBTFNOAnxXU/hYt3Ha1PfinO3NYX0qdh4afJJk8aiXnFezOJdJIPtNYThduUR6JgLBRFAoGa1ctXScmhxZxAoNYgffoO8hCzblZJ35lQuJUkFWYhYZ1taAA/1m6QfMdPVjaElijg==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tzNMV-0000bq-GL for guix-patches@gnu.org; Mon, 31 Mar 2025 18:12:07 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77186] [PATCH v2 09/14] services: gitolite-activation: Convert to match-record. Resent-From: Tomas Volf <~@wolfsden.cz> Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 31 Mar 2025 22:12:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 77186 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 77186@debbugs.gnu.org Cc: Tomas Volf <~@wolfsden.cz> Received: via spool by 77186-submit@debbugs.gnu.org id=B77186.17434590732003 (code B ref 77186); Mon, 31 Mar 2025 22:12:07 +0000 Received: (at 77186) by debbugs.gnu.org; 31 Mar 2025 22:11:13 +0000 Received: from localhost ([127.0.0.1]:43364 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tzNLc-0000W4-DO for submit@debbugs.gnu.org; Mon, 31 Mar 2025 18:11:13 -0400 Received: from wolfsden.cz ([37.205.8.62]:41012) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <~@wolfsden.cz>) id 1tzNL4-0000QG-MY for 77186@debbugs.gnu.org; Mon, 31 Mar 2025 18:10:43 -0400 Received: by wolfsden.cz (Postfix, from userid 104) id 9DD173790C5; Mon, 31 Mar 2025 22:10:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1743459037; bh=x0X4pCp/3Eg6dRiy6Qj1MFkTqm9nVFRUjKlK1sO8Rj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=wkD51yuURdoVjAoNT4DFHgVMoOM5GpK5yJNXG2ZWc+eQ6QhtEBouTxHF8VeEnrOk8 qhc3183mUni1Q0Q7wop5qQ+uqAsauCZXjW4LX+72f6aINlGddreSkSRlZj5+jODJG+ EviNXyKb0BzAhaiH8W89Ga1o7wnZs5mSPpxGmQPk33/R1DcwII6XNgvqMvDGmdRVFj hOkpkEDGcRWYy4RsHiatnYQQLYGW5dlnp5tXD4C2TV4pjvrPUCdsyEiGrRzu9jvFup tBP0adRakHsXMM6pqqDrmuFPLXAbUIKFD4y+SO9H5PVTnMXM4qvUU5k8FoY5VAsjNl IfGs4fRX8TIkCPUeayUtMFaq0Ya9ouCrpdpJNVGVtCPS6u2FmbUoK+aUylMbfL/wO3 pWY/RXSytBvFZhW8bclLiiITJswXbm0uIBL95swRjflUtm0zJXKoeG0D347Hti6efE lEWSpjxJBI97VCSihUcnVWEiJ7F9ZJ6YR7fuGTL9MgsQwyNfhS4p1LDmaaTiSNtNo9 5BPZEQzwp7JRzsjHWPDUMDHIhr7wR3TKrqn/pp3UznKxLcvC3W/jp9dmjI+62oF4Wt fa2bWWBYq9noF89uH1JTcI4zVHPtD6xWlj5xmDWonXrMeLR2k3RKiMkpUdjNr5/c2x Boh2PyouUZ/q2LGmZgv97Nrc= Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id 0E7143788CD; Mon, 31 Mar 2025 22:10:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1743459037; bh=x0X4pCp/3Eg6dRiy6Qj1MFkTqm9nVFRUjKlK1sO8Rj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=wkD51yuURdoVjAoNT4DFHgVMoOM5GpK5yJNXG2ZWc+eQ6QhtEBouTxHF8VeEnrOk8 qhc3183mUni1Q0Q7wop5qQ+uqAsauCZXjW4LX+72f6aINlGddreSkSRlZj5+jODJG+ EviNXyKb0BzAhaiH8W89Ga1o7wnZs5mSPpxGmQPk33/R1DcwII6XNgvqMvDGmdRVFj hOkpkEDGcRWYy4RsHiatnYQQLYGW5dlnp5tXD4C2TV4pjvrPUCdsyEiGrRzu9jvFup tBP0adRakHsXMM6pqqDrmuFPLXAbUIKFD4y+SO9H5PVTnMXM4qvUU5k8FoY5VAsjNl IfGs4fRX8TIkCPUeayUtMFaq0Ya9ouCrpdpJNVGVtCPS6u2FmbUoK+aUylMbfL/wO3 pWY/RXSytBvFZhW8bclLiiITJswXbm0uIBL95swRjflUtm0zJXKoeG0D347Hti6efE lEWSpjxJBI97VCSihUcnVWEiJ7F9ZJ6YR7fuGTL9MgsQwyNfhS4p1LDmaaTiSNtNo9 5BPZEQzwp7JRzsjHWPDUMDHIhr7wR3TKrqn/pp3UznKxLcvC3W/jp9dmjI+62oF4Wt fa2bWWBYq9noF89uH1JTcI4zVHPtD6xWlj5xmDWonXrMeLR2k3RKiMkpUdjNr5/c2x Boh2PyouUZ/q2LGmZgv97Nrc= From: Tomas Volf <~@wolfsden.cz> Date: Tue, 1 Apr 2025 00:10:15 +0200 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: MIME-Version: 1.0 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: , 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/version-control.scm (gitolite-activation): Use match-record instead of match-lambda with $. Change-Id: I37e3018513a8f20eeed8614dff46a63b8d7c2883 --- gnu/services/version-control.scm | 123 +++++++++++++++---------------- 1 file changed, 61 insertions(+), 62 deletions(-) diff --git a/gnu/services/version-control.scm b/gnu/services/version-control.scm index 07984d309e..268b0a47ee 100644 --- a/gnu/services/version-control.scm +++ b/gnu/services/version-control.scm @@ -350,78 +350,77 @@ (define (gitolite-accounts config) (comment "Gitolite user") (home-directory home-directory))))) -(define gitolite-activation - (match-lambda - (($ package user group home - rc-file admin-pubkey) - #~(begin - (use-modules (ice-9 match) - (guix build utils)) +(define (gitolite-activation config) + (match-record config + (package user group home-directory rc-file admin-pubkey) + #~(begin + (use-modules (ice-9 match) + (guix build utils)) - (let* ((user-info (getpwnam #$user)) - (admin-pubkey #$admin-pubkey) - (pubkey-file (string-append - #$home "/" - (basename - (strip-store-file-name admin-pubkey)))) - (rc-file #$(string-append home "/.gitolite.rc"))) + (let* ((user-info (getpwnam #$user)) + (admin-pubkey #$admin-pubkey) + (pubkey-file (string-append + #$home-directory "/" + (basename + (strip-store-file-name admin-pubkey)))) + (rc-file #$(string-append home-directory "/.gitolite.rc"))) - ;; activate-users+groups in (gnu build activation) sets the - ;; permission flags of home directories to #o700 and mentions that - ;; services needing looser permissions should chmod it during - ;; service activation. We also want the git group to be able to - ;; read from the gitolite home directory, so a chmod'ing we will - ;; go! - (chmod #$home #o750) + ;; activate-users+groups in (gnu build activation) sets the + ;; permission flags of home directories to #o700 and mentions that + ;; services needing looser permissions should chmod it during + ;; service activation. We also want the git group to be able to + ;; read from the gitolite home directory, so a chmod'ing we will + ;; go! + (chmod #$home-directory #o750) - (simple-format #t "guix: gitolite: installing ~A\n" #$rc-file) - (copy-file #$rc-file rc-file) - ;; ensure gitolite's user can read the configuration - (chown rc-file - (passwd:uid user-info) - (passwd:gid user-info)) + (simple-format #t "guix: gitolite: installing ~A\n" #$rc-file) + (copy-file #$rc-file rc-file) + ;; ensure gitolite's user can read the configuration + (chown rc-file + (passwd:uid user-info) + (passwd:gid user-info)) - ;; The key must be writable, so copy it from the store - (copy-file admin-pubkey pubkey-file) + ;; The key must be writable, so copy it from the store + (copy-file admin-pubkey pubkey-file) - (chmod pubkey-file #o500) - (chown pubkey-file - (passwd:uid user-info) - (passwd:gid user-info)) + (chmod pubkey-file #o500) + (chown pubkey-file + (passwd:uid user-info) + (passwd:gid user-info)) - ;; Set the git configuration, to avoid gitolite trying to use - ;; the hostname command, as the network might not be up yet - (with-output-to-file #$(string-append home "/.gitconfig") - (lambda () - (display "[user] + ;; Set the git configuration, to avoid gitolite trying to use + ;; the hostname command, as the network might not be up yet + (with-output-to-file #$(string-append home-directory "/.gitconfig") + (lambda () + (display "[user] name = GNU Guix email = guix@localhost "))) - ;; Run Gitolite setup, as this updates the hooks and include the - ;; admin pubkey if specified. The admin pubkey is required for - ;; initial setup, and will replace the previous key if run after - ;; initial setup - (match (primitive-fork) - (0 - ;; Exit with a non-zero status code if an exception is thrown. - (dynamic-wind - (const #t) - (lambda () - (setenv "HOME" (passwd:dir user-info)) - (setenv "USER" #$user) - (setgid (passwd:gid user-info)) - (setuid (passwd:uid user-info)) - (primitive-exit - (system* #$(file-append package "/bin/gitolite") - "setup" - "-m" "gitolite setup by GNU Guix" - "-pk" pubkey-file))) - (lambda () - (primitive-exit 1)))) - (pid (waitpid pid))) + ;; Run Gitolite setup, as this updates the hooks and include the + ;; admin pubkey if specified. The admin pubkey is required for + ;; initial setup, and will replace the previous key if run after + ;; initial setup + (match (primitive-fork) + (0 + ;; Exit with a non-zero status code if an exception is thrown. + (dynamic-wind + (const #t) + (lambda () + (setenv "HOME" (passwd:dir user-info)) + (setenv "USER" #$user) + (setgid (passwd:gid user-info)) + (setuid (passwd:uid user-info)) + (primitive-exit + (system* #$(file-append package "/bin/gitolite") + "setup" + "-m" "gitolite setup by GNU Guix" + "-pk" pubkey-file))) + (lambda () + (primitive-exit 1)))) + (pid (waitpid pid))) - (when (file-exists? pubkey-file) - (delete-file pubkey-file))))))) + (when (file-exists? pubkey-file) + (delete-file pubkey-file)))))) (define gitolite-service-type (service-type