From: Nikita Karetnikov <nikita@karetnikov.org>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: bug-guix@gnu.org
Subject: Re: [PATCH] gnu-maintenance: Improve 'official-gnu-packages'; add the related procedures.
Date: Fri, 22 Mar 2013 05:37:35 +0400 [thread overview]
Message-ID: <877gl0kye8.fsf@karetnikov.org> (raw)
In-Reply-To: <87vc8rq6ol.fsf@gnu.org> ("Ludovic Courtès"'s message of "Sun, 17 Mar 2013 00:13:46 +0100")
[-- Attachment #1.1: Type: text/plain, Size: 993 bytes --]
> Yes, use the wonderful ‘define-record-type*’ from (guix utils). This is
> what we use for ‘package’, etc. See
> <http://lists.gnu.org/archive/html/guile-user/2012-11/msg00016.html>,
> for details.
I attached the draft. (I remember about other issues.)
But it doesn't work. These lines rise an error:
+ (cons (gnu-package-descriptor
+ (inherit (first state))
+ ((eval (match-field str)
+ (interaction-environment)) str))
(There may be other problems. For instance, it should remove fields'
names from 'str' before creating a record.)
What do you think about the 'eval' idea? It's used to avoid unnecessary
repetition.
I'll try to pinpoint the cause later. Though, it will save a lot of
time if you tell that the whole idea is bad. Or if you already know the
cause of the problem.
Also, is it possible to create a default value for a field (like #f)?
[-- Attachment #1.2: gnu-maintenance.diff --]
[-- Type: text/x-diff, Size: 5979 bytes --]
diff --git a/guix/gnu-maintenance.scm b/guix/gnu-maintenance.scm
index 89a0174..3baa460 100644
--- a/guix/gnu-maintenance.scm
+++ b/guix/gnu-maintenance.scm
@@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
;;; Copyright © 2010, 2011, 2012, 2013 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012, 2013 Nikita Karetnikov <nikita@karetnikov.org>
;;;
;;; 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,119 @@
(error "download failed:" uri code
(response-reason-phrase resp))))))
+(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=womb"))
+(define-record-type* <gnu-package-descriptor>
+ 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)
- "Return a list of GNU packages."
- (define %package-line-rx
- (make-regexp "^package: (.+)$"))
+ "Return the list of records, which are GNU packages."
+ (define (group-package-fields port state)
+ (let ((line (read-line port)))
+ (define (match-field str)
+ (define empty-descriptor
+ (gnu-package-descriptor (name #f)
+ (mundane-name #f)
+ (copyright-holder #f)
+ (savannah #f)
+ (fsd #f)
+ (language #f)
+ (logo #f)
+ (doc-category #f)
+ (doc-summary #f)
+ (doc-url #f)
+ (download-url #f)
+ (gplv3-status #f)
+ (activity-status #f)
+ (last-contact #f)
+ (next-contact #f)
+ (note #f)))
+
+ (define field-setter-alist
+ (list (list "package" 'name)
+ (list "mundane-name" 'mundane-name)
+ (list "copyright-holder" 'copyright-holder)
+ (list "savannah" 'savannah)
+ (list "fsd" 'fsd)
+ (list "language" 'language)
+ (list "logo" 'logo)
+ (list "doc-category" 'doc-category)
+ (list "doc-summary" 'doc-summary)
+ (list "doc-url" 'doc-url)
+ (list "doc-category" 'doc-category)
+ (list "download-url" 'download-url)
+ (list "gplv3-status" 'gplv3-status)
+ (list "activity-status" 'activity-status)
+ (list "last-contact" 'last-contact)
+ (list "next-contact" 'next-contact)
+ (list "note" 'note)))
+
+ (define (find-setter str)
+ "Find the right setter for STR."
+ (define (field-prefix? lst str)
+ ;; Find the field which is a prefix of STR.
+ (false-if-exception (string-prefix? (first lst) str)))
+
+ (and=> (find (cut field-prefix? <> str) field-setter-alist)
+ last))
+
+ (match str
+ (""
+ (group-package-fields port (cons empty-descriptor state)))
+ (str
+ (group-package-fields
+ port
+ (cons (gnu-package-descriptor
+ (inherit (first state))
+ ((eval (match-field str)
+ (interaction-environment)) str))
+ (drop state 1))))))
+
+ (if (eof-object? line)
+ (remove null-list? state)
+ (match-field line))))
- (let ((lst (string-split (http-fetch %package-list-url) #\nl)))
- (filter-map (lambda (line)
- (and=> (regexp-exec %package-line-rx line)
- (cut match:substring <> 1)))
- lst)))
+ ;; XXX: 'reverse'?
+ (group-package-fields (http-fetch* %package-list-url)
+ '(())))
+;;; XXX: FIXME!
(define gnu-package?
(memoize
(lambda (package)
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
next prev parent reply other threads:[~2013-03-22 1:35 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-22 5:29 [PATCH] gnu-maintenance: Add 'find-package-with-attrs' and '%package-list' Nikita Karetnikov
2013-02-22 10:00 ` Ludovic Courtès
2013-03-06 18:54 ` [PATCH] gnu-maintenance: Replace 'official-gnu-packages' with 'find-packages' Nikita Karetnikov
2013-03-06 23:28 ` Ludovic Courtès
2013-03-16 19:30 ` [PATCH] gnu-maintenance: Improve 'official-gnu-packages'; add the related procedures Nikita Karetnikov
2013-03-16 23:13 ` Ludovic Courtès
2013-03-22 1:37 ` Nikita Karetnikov [this message]
2013-03-22 10:08 ` Brandon Invergo
2013-03-22 12:30 ` Ludovic Courtès
2013-03-22 12:19 ` Ludovic Courtès
2013-03-26 20:22 ` Nikita Karetnikov
2013-03-26 20:50 ` Ludovic Courtès
2013-03-26 20:59 ` Nikita Karetnikov
2013-03-26 21:21 ` Ludovic Courtès
2013-03-27 6:05 ` Nikita Karetnikov
2013-03-27 10:08 ` Ludovic Courtès
2013-03-31 22:50 ` Ludovic Courtès
2013-03-26 20:49 ` Nikita Karetnikov
2013-03-26 21:02 ` Ludovic Courtès
2013-03-28 2:08 ` [PATCH] gnu-maintenance: Improve 'official-gnu-packages'; add " Nikita Karetnikov
2013-03-28 16:48 ` Ludovic Courtès
2013-03-28 22:40 ` Nikita Karetnikov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877gl0kye8.fsf@karetnikov.org \
--to=nikita@karetnikov.org \
--cc=bug-guix@gnu.org \
--cc=ludo@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.