;;; Copyright © 2020 Ludovic Courtès ;;; ;;; This program 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. ;;; ;;; This program 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 this program. If not, see . (define-module (maintainers) #:use-module (guix records) #:use-module (ssh popen) #:use-module ((ssh session) #:select (disconnect!)) #:use-module (guix ssh) #:use-module (srfi srfi-9) #:export (maintainer? maintainer-name maintainer-address maintainer-packages maintainer-collective? read-maintainers read-maintainers-from-fencepost)) (define-record-type (maintainer name address packages) maintainer? (name maintainer-name) (address maintainer-address) (packages maintainer-packages)) (define (maintainer-collective? maintainer) (or (string-suffix? "maintainers@gnu.org" (maintainer-address maintainer)) (string-suffix? " maintainers" (maintainer-name maintainer)) (string-suffix? " committee" (maintainer-name maintainer)))) (define (read-maintainers port) "Read from PORT recutils-formatted info about GNU maintainers, and return a list of records." (define (read-one port) (alist->record (recutils->alist port) maintainer '("name" "email" "package") '("package"))) (let loop ((result '())) (if (eof-object? (peek-char port)) (reverse result) (let ((maintainer (read-one port))) (loop (if (and (maintainer-name maintainer) (maintainer-address maintainer)) (cons maintainer result) result)))))) (define (read-maintainers-from-fencepost) (let* ((session (open-ssh-session "fencepost.gnu.org")) (pipe (open-remote-pipe* session OPEN_READ "cat" "/gd/gnuorg/maintainers")) (maintainers (read-maintainers pipe))) (close-port pipe) (disconnect! session) maintainers))