From: Nikita Karetnikov <nikita@karetnikov.org>
To: bug-guix@gnu.org
Subject: [PATCH] gnu-maintenance: Add 'find-package-with-attrs' and '%package-list'.
Date: Fri, 22 Feb 2013 00:29:47 -0500 [thread overview]
Message-ID: <87obfchq38.fsf@karetnikov.org> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 799 bytes --]
This patch adds a procedure to fetch information from Womb.
scheme@(guile-user)> ,use (guix gnu-maintenance)
scheme@(guile-user)> (find-package-with-attrs "guix")
$1 = ("package: guix" "logo: /software/guix/graphics/guix-logo.small.png" "doc-category: Sysadmin" "doc-summary: Managing installed software packages and versions" "doc-url: none" "gplv3-status: should-be-ok" "activity-status: newpkg/20121117")
(By the way, we should add 'doc-url'.)
I'd like to simplify it. For instance, it would be great to find the
needed package using a single 'filter'. I guess that 'fold' can be
removed too.
Also, it should be possible to get a single attribute (e.g.,
'doc-summary'), not all of them. I'll implement that later.
The goal is to use this procedure from 'guix import'.
[-- Attachment #1.2: 0001-gnu-maintenance-Add-find-package-with-attrs-and-pack.patch --]
[-- Type: text/x-diff, Size: 2657 bytes --]
From ce7af670e767f425ccbb732cbe0e74423a194dbf Mon Sep 17 00:00:00 2001
From: Nikita Karetnikov <nikita@karetnikov.org>
Date: Fri, 22 Feb 2013 05:02:33 +0000
Subject: [PATCH] gnu-maintenance: Add 'find-package-with-attrs' and
'%package-list'.
* guix/gnu-maintenance.scm (%package-list): New variable.
(find-package-with-attrs): New procedure.
---
guix/gnu-maintenance.scm | 33 ++++++++++++++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/guix/gnu-maintenance.scm b/guix/gnu-maintenance.scm
index 6475c38..42f4383 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.
;;;
@@ -30,6 +30,7 @@
#:use-module (guix ftp-client)
#:use-module (guix utils)
#:export (official-gnu-packages
+ find-package-with-attrs
releases
latest-release
gnu-package-name->name+version))
@@ -74,6 +75,36 @@
(and=> (regexp-exec %package-line-rx line)
(cut match:substring <> 1)))
lst)))
+
+(define %package-list
+ (string-split (http-fetch %package-list-url) #\nl))
+
+(define (find-package-with-attrs package)
+ "Return a list that contains PACKAGE and its attributes."
+ (define (split-womb-packages xs ys)
+ ;; Return a list of lists; each inner list represents a package.
+ (define (tail lst)
+ (if (null-list? lst)
+ lst
+ (cdr lst)))
+
+ (cond ((null-list? ys) (filter (lambda (lst)
+ (not (null-list? lst)))
+ xs))
+ (else (let-values (((xs' ys') (span (lambda (str)
+ (not (string-null? str)))
+ ys)))
+ (split-womb-packages (append xs (list xs'))
+ (tail ys'))))))
+
+ (let ((package-rx (make-regexp (format #f "^package: ~a$" package)
+ regexp/icase))
+ (split-lst (split-womb-packages (list '()) %package-list)))
+ (fold append '()
+ (filter (lambda (x)
+ (regexp-exec package-rx (car x)))
+ split-lst))))
+
\f
;;;
;;; Latest release.
--
1.7.5.4
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
next reply other threads:[~2013-02-22 5:29 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-22 5:29 Nikita Karetnikov [this message]
2013-02-22 10:00 ` [PATCH] gnu-maintenance: Add 'find-package-with-attrs' and '%package-list' 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
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87obfchq38.fsf@karetnikov.org \
--to=nikita@karetnikov.org \
--cc=bug-guix@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 public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).