From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nikita Karetnikov Subject: Re: [PATCH] gnu-maintenance: Improve 'official-gnu-packages'; add the related procedures. Date: Wed, 27 Mar 2013 10:05:09 +0400 Message-ID: <87r4j18jje.fsf@karetnikov.org> References: <87obfchq38.fsf@karetnikov.org> <87sj4ok6sc.fsf@gnu.org> <87sj48gxzp.fsf_-_@karetnikov.org> <87lia09khe.fsf@gnu.org> <874ngbcfbl.fsf_-_@karetnikov.org> <87vc8rq6ol.fsf@gnu.org> <877gl0kye8.fsf@karetnikov.org> <87620jk4oi.fsf@gnu.org> <8738vhud12.fsf@karetnikov.org> <87620dx4um.fsf@gnu.org> <878v59swr0.fsf@karetnikov.org> <87ip4dvour.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:41277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UKjSL-00019e-JX for bug-guix@gnu.org; Wed, 27 Mar 2013 02:03:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UKjSI-0005Pr-5G for bug-guix@gnu.org; Wed, 27 Mar 2013 02:03:29 -0400 In-Reply-To: <87ip4dvour.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Tue, 26 Mar 2013 22:21:48 +0100") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: bug-guix@gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > You can if you end up not using the =E2=80=9Csyntactic constructor=E2=80= =9D with named > fields (as was the case in my example). Heh, I used it; it's very handy. I didn't even try to use 'gnu-package-descriptor'. Thanks for your suggestions. Any other comments? If not, I'll create a proper patch (the attached version doesn't honor multiple fields). --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=gnu-maintenance.diff Content-Transfer-Encoding: quoted-printable diff --git a/guix/gnu-maintenance.scm b/guix/gnu-maintenance.scm index 89a0174..a0e9da5 100644 =2D-- a/guix/gnu-maintenance.scm +++ b/guix/gnu-maintenance.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU =2D;;; Copyright =C2=A9 2012 Nikita Karetnikov ;;; Copyright =C2=A9 2010, 2011, 2012, 2013 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2012, 2013 Nikita Karetnikov ;;; ;;; This file is part of GNU Guix. ;;; @@ -23,6 +23,7 @@ #:use-module (web response) #:use-module (ice-9 regex) #:use-module (ice-9 match) + #:use-module (ice-9 rdelim) ; http-fetch* #:use-module (srfi srfi-1) #:use-module (srfi srfi-11) #:use-module (srfi srfi-26) @@ -74,22 +75,100 @@ (error "download failed:" uri code (response-reason-phrase resp)))))) =20 +(define (http-fetch* uri) + "Return an input port with the textual data at URI, a string." + (let*-values (((resp port) + (http-get* (string->uri uri))) + ((code) + (response-code resp))) + (case code + ((200) + port) + (else + (error "download failed" uri code + (response-reason-phrase resp)))))) + (define %package-list-url (string-append "http://cvs.savannah.gnu.org/" "viewvc/*checkout*/gnumaint/" "gnupackages.txt?root=3Dwomb")) =20 +(define-record-type* + gnu-package-descriptor + make-gnu-package-descriptor + + gnu-package-descriptor? + + (name gnu-package-name) + (mundane-name gnu-package-mundane-name) + (copyright-holder gnu-package-copyright-holder) + (savannah gnu-package-savannah) + (fsd gnu-package-fsd) + (language gnu-package-language) + (logo gnu-package-logo) + (doc-category gnu-package-doc-category) + (doc-summary gnu-package-doc-summary) + (doc-url gnu-package-doc-url) + (download-url gnu-package-download-url) + (gplv3-status gnu-package-gplv3-status) + (activity-status gnu-package-activity-status) + (last-contact gnu-package-last-contact) + (next-contact gnu-package-next-contact) + (note gnu-package-note)) + (define (official-gnu-packages) =2D "Return a list of GNU packages." =2D (define %package-line-rx =2D (make-regexp "^package: (.+)$")) + "Return a list of records, which are GNU packages." + (define (group-package-fields port state) + ;; Return a list of alists. Each alist contains fields of a GNU + ;; package. + (let ((line (read-line port)) + (field-rx (make-regexp "^([[:graph:]]+): (.*)$")) + (end-rx (make-regexp "^# End. .+Do not remove this line.+"))) + + (define (match-field str) + ;; Packages are separated by empty strings. If STR is an + ;; empty string, create a new list to store fields of a + ;; different package. Otherwise, match and create a key-value + ;; pair. + (match str + ("" + (group-package-fields port (cons '() state))) + (str + (cond ((regexp-exec field-rx str) + =3D> + (lambda (match) + (group-package-fields + port (cons (cons (cons (match:substring match 1) + (match:substring match 2)) + (first state)) + (drop state 1))))) + (else (group-package-fields port state)))))) + + (if (or (eof-object? line) + (regexp-exec end-rx line)) ; don't include dummy fields + (remove null-list? state) + (match-field line)))) + + (define (alist->record alist make keys) + ;; Apply MAKE, which should be a syntactic constructor, to the + ;; values associated with KEYS in ALIST. + (let ((args (map (cut assoc-ref alist <>) keys))) + (apply make args))) =20 =2D (let ((lst (string-split (http-fetch %package-list-url) #\nl))) =2D (filter-map (lambda (line) =2D (and=3D> (regexp-exec %package-line-rx line) =2D (cut match:substring <> 1))) =2D lst))) + (reverse + (map (lambda (alist) + (alist->record alist + make-gnu-package-descriptor + (list "package" "mundane-name" "copyright-holder" + "savannah" "fsd" "language" "logo" + "doc-category" "doc-summary" "doc-url" + "download-url" "gplv3-status" + "activity-status" "last-contact" "next-cont= act" + "note"))) + (group-package-fields (http-fetch* %package-list-url) + '(()))))) =20 +;;; XXX: FIXME! (define gnu-package? (memoize (lambda (package) --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBAgAGBQJRUowZAAoJEM+IQzI9IQ384a0QAIgzNoTWoFzTMc1scfcjLfzD fXq80a2oI/p8jkW44cwvVndandut1DV2EESe4e639vzavvVFwqEg8DUcuHP98cJc Kvesn1t6Jsq31wmz1lXVGLq6rPIAcOSi6je5L9SOlaQDtxF0dEYsbzWWEUNPrvdi kRiWyUzOiWl43dy0tfFcrMMdWD60bQ57y4usBKo3Ec11nD+ub/uRUHHYC3zbi8Q5 0U32q0SDwQq2caChz8dDuivOFls3i6ZiVhshiOF2Rl5NPnhU78aI4urxlOHOJzZW Tt3VcOHtKSTOSQqFCJknU88ckVwvgkBtcEJm2ElGL1jfUht/tgiVLDmAmEx0Q9OH /xy0e4wNrqRJj5xI0PoO1NuMSd+PIqdqu4PE4wCk/y3Xn/odWJDuqfxbkagoRiSg +iQMyMbp9URFpDq/tfZbk5r7bQdBaW6yjcNhdiee03+RAU45QDQl+0SKRLP84ueb 2LvAXZuCa1HHUFeCqn4PLecPZPEGTgXEufySexxbMWiwILVd/WRiQcnru1fEt0G/ DUQ5b99mqwz0V9Ja/qA0cJAxAvgNDxTuZmMmDcw18vJdi1BDIQKXvU2uY2HK44Eb UWPIlLCrl7SLmnK2y1s3cIzym6wJo3Fno/Bv9jpErIf/H6NzP/oXBqM91ipADewL 3tBOGlK34S0HFwrQg789 =L1DB -----END PGP SIGNATURE----- --==-=-=--