From patchwork Sat Mar 22 17:09:10 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: 40644 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 CB0C727BBEC; Sat, 22 Mar 2025 17:12:09 +0000 (GMT) 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=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 3546727BBE2 for ; Sat, 22 Mar 2025 17:12:09 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tw2NP-0000cH-RQ; Sat, 22 Mar 2025 13:11:15 -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 1tw2NG-0000YA-H8 for guix-patches@gnu.org; Sat, 22 Mar 2025 13:11:06 -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 1tw2NG-0007kj-7G for guix-patches@gnu.org; Sat, 22 Mar 2025 13:11:06 -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=2cAW6lmMr2U7hBhfTPOQc8OBpf2Fx4cc1lWoJLd63Sc=; b=Kmwqspl1BMgRH24N6b058Qt1/iTjJ8jx4JUiTCAYsv6iO/mdMsegNs8coJbwfv2EF+/V9IZorGufGXkEA4RnIHGkh7Ip33tLKX4CrcXA9zdsTJRJmXOtoCE6QJnuU/Apsn51YcNzfV6XwTCFkpUI54p5jqsHYtWfu9vBl/e2IOAtucFBREYEjMijDOmWtN9nbMVzmbXvnR6mZFjPwnsmYomTis+9OjtVAT6V7gsjY6aB7F2xIIWQfnBwMr1tXuv2D1sQ2mNEuC7JeeLLXfR6tSvY1E1HKCpOFsFmNSmIx0nALGIM1AP71ziPKYeCqoUAraChpGjYLPpYiR9uYnGr2A==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tw2NG-0007Ir-0b for guix-patches@gnu.org; Sat, 22 Mar 2025 13:11:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#77186] [PATCH v2 09/13] 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: Sat, 22 Mar 2025 17:11:05 +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.174266343027775 (code B ref 77186); Sat, 22 Mar 2025 17:11:05 +0000 Received: (at 77186) by debbugs.gnu.org; 22 Mar 2025 17:10:30 +0000 Received: from localhost ([127.0.0.1]:45251 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tw2Mg-0007Dq-2c for submit@debbugs.gnu.org; Sat, 22 Mar 2025 13:10:30 -0400 Received: from wolfsden.cz ([37.205.8.62]:57590) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from <~@wolfsden.cz>) id 1tw2MF-00075F-Hc for 77186@debbugs.gnu.org; Sat, 22 Mar 2025 13:10:05 -0400 Received: by wolfsden.cz (Postfix, from userid 104) id 67BC037EB7C; Sat, 22 Mar 2025 17:10:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1742663402; bh=v8Pnm4vHhClSIvEbarfZCgL9aVhiD0u05YjXi6ctQZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oYYv0GSSxzBJYBgUP/63p1qyo9n4TIxkMTUGgFpLcj+6M7ruQYvacWXc9HjqVBfJj CDmoER9rzTdc2/y/XM7dSUn5kKeymS9xVdMsD29Fe35PVRj5UXHHE1/TVLLR/jmcAa wMCWeKvwTOLR14aj/aEkMJtLe0gxnkqNhUJF87kDlEL+qKb7/jk78MTErbGZOFOc3N qbDpMUVqWEzCD6ryX7aR9WZl+l1N/z0zMZFutxL+0WPa6GkTFexBkpz02uF9a3Uyh8 dz4+rYIp/NEmTIOllMPQMbgOG6VCDscvu8dw3/knGFM0t5gg0x316T6Cfvsa2WZDeY ectdqegTdZ9TQSQoofUztdde/w8zvTiOOblyZZfa/yFGgLnLnP6FxEFtZpgBi3P7Nc Wn/TuzTTWtpQMkCCODPx8hPxMqRApP2qvYC7UUzwleOzMOMPqa8Voeh0efpOMsihrz xSkX2q7S/L5sOOKioM2wlJg8aZNAzI0hCZtRTxY0pmv7AMGMftFfk6kxnGid0o+6/D SmAnIqM4v+Dfp7Z6gMhiWApnPMXIDHcntTj1Ker9cmT6cOqHuTfQ6bt6bhvuaRXusk q2moS6kocaU9vCAb0InwGPmWzBbxr4xmcDbzJkHnJhwtuTkdffDLBX8xy2GVV/3WUU 0tpfKHgxAMbfOMDD+M2xPT3s= Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id 989C03803D5; Sat, 22 Mar 2025 17:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1742663401; bh=v8Pnm4vHhClSIvEbarfZCgL9aVhiD0u05YjXi6ctQZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yf4/0UyozEI4+N0MDN2Wknq/MxEI1wY4uAhWnKs4QUxQjh9w59fN/zkN+VCZaGtka Y2IZYZrSJvRrm221zzf4u4Z05nGNZ7pHrwV0U8NuGwJn/yYgdXLib+LDJnpMxCgr8z D/gba9ME4VOb1jEwBQWu3J0smmmuw2arTZTJt1e0fZaVWMwwhrhxSQ7XhrtOGBf5A0 G98FAzKlVr8+AwlkCntFLBUvHe3ELFRGRbM0C9/CYjZEREXg9/rPYor6i7ANP9ps0h +0UuXaTS2D8WySeIgZyizgtQH78py6kMD3BbU/a15EOqJGqNcq3I/Y/lO11bhcaj95 7gtMFzCve3hHhcAdpebVgMF6ZqIAsi47XpEDYQ2ll6XwfVr6VP4iH5MTHnWlo5VV8i q8tDCuRlSf0IRp1sbrZdrLTjGo78wDISiCuXOenIwvO38ld7oGyBk7zi2fMxDbTLmB Qyb/Zo8A6SkmUp9i4KFZMFyQs/Qjhc08XSKgW0ZQOO8znkDRbVHmpKSE0IkifKq1gB 5trxguyFWtwTpGnYp6txVul5tUzmvffiV1FmhRoHro/gAe9UpuMgq3+0k19UgibqWU LzlsBUNLfl7s6w+OBQMJ36L3CDiD6to1H+xo60PAwkmYxj0Ml/c0K0RsrLNHtZAGW2 w53POeZRepXjdxB3HekpNsOs= From: Tomas Volf <~@wolfsden.cz> Date: Sat, 22 Mar 2025 18:09:10 +0100 Message-ID: <708f8aad56c7277beb422cfd1d4cc45a0de233ce.1742663354.git.~@wolfsden.cz> X-Mailer: git-send-email 2.48.1 In-Reply-To: <39fb02cc97f30aa37523d9f5f9390264d53fcf8b.1742663354.git.~@wolfsden.cz> References: <39fb02cc97f30aa37523d9f5f9390264d53fcf8b.1742663354.git.~@wolfsden.cz> 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