From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkHln-0001Ee-6v for guix-patches@gnu.org; Mon, 30 Jul 2018 19:40:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fkHli-00006p-Av for guix-patches@gnu.org; Mon, 30 Jul 2018 19:40:07 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:58773) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fkHli-00006f-5n for guix-patches@gnu.org; Mon, 30 Jul 2018 19:40:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fkHlh-00035h-Om for guix-patches@gnu.org; Mon, 30 Jul 2018 19:40:01 -0400 Subject: [bug#30809] [PATCH 2/2] services: Add Gitolite. Resent-Message-ID: References: <20180729201822.12372-1-mail@cbaines.net> <20180729201822.12372-2-mail@cbaines.net> From: =?UTF-8?Q?Cl=C3=A9ment?= Lassieur In-reply-to: <20180729201822.12372-2-mail@cbaines.net> Date: Tue, 31 Jul 2018 01:39:00 +0200 Message-ID: <87r2jk8faj.fsf@lassieur.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Christopher Baines Cc: 30809@debbugs.gnu.org Hey Christopher! Thank you for the update. Christopher Baines writes: [...] > +@example > +git clone git@@example.com:gitolite-admin > +@end example > + > +When the Gitolite service is activated, the provided @code{admin-pubkey}= will > +be inserted in to the @file{keydir} directory in the gitolite-admin > +repository. If this results in a change in the repository, it will be > +committed using the message ``gitolite setup by GNU Guix''. > + > +@deftp {Data Type} gitolite-configuration > +Data type representing the configuration for @code{gitolite-service-type= }. > + > +@table @asis > +@item @code{package} (default: @var{gitolite}) > +Gitolite package to use. > + > +@item @code{user} (default: @var{git}) ^ It should be a string --------------- I don't think you should use @var for default values. @code would be bette= r. > +User to use for Gitolite. This will be user that you use when accessing > +Gitolite over SSH. > + > +@item @code{group} (default: @var{git}) ^ It should be a string --------------- > +Group to use for Gitolite. > + > +@item @code{home-directory} (default: @var{"/var/lib/gitolite"}) > +Directory in which to store the Gitolite configuration and repositories. > + > +@item @code{rc-file} (default: @var{(gitolite-rc-file)}) > +A ``file-like'' object (@pxref{G-Expressions, file-like objects}), > +representing the configuration for Gitolite. > + > +@item @code{admin-pubkey} (default: @var{#f}) Actually, there is no default :-) [...] > + (match-lambda > + (($ package user group home > + rc-file admin-pubkey) > + #~(let* ((user-info (getpwnam #$user)) > + (admin-pubkey #$admin-pubkey) > + (pubkey-file (string-append > + #$home "/" > + (basename > + (strip-store-file-name admin-pubkey))))) > + (use-modules (guix build utils)) > + > + (simple-format #t "guix: gitolite: installing ~A\n" #$rc-file) > + (copy-file #$rc-file #$(string-append home "/.gitolite.rc")) ^ Maybe a symlink here? > + ;; The key must be writable, so copy it from the store > + (copy-file admin-pubkey pubkey-file) > + > + (chmod pubkey-file #o500) I don't think it must be writable, because #o500 isn't writable. > + (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] > + name =3D GNU Guix > + email =3D 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 > + (let ((pid (primitive-fork))) > + (if (eq? pid 0) > + ;; Exit with a non-zero status code if an exception is th= rown. > + (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))) > + (waitpid pid))) This works (with the (ice-9 match) module added): (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))) Other than that, it looks good to me! Thanks again, Cl=C3=A9ment