From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nikita Karetnikov Subject: [PATCH] gnu-maintenance: Add 'find-package-with-attrs' and '%package-list'. Date: Fri, 22 Feb 2013 00:29:47 -0500 Message-ID: <87obfchq38.fsf@karetnikov.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]:42562) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8lCd-0002Mc-PU for bug-guix@gnu.org; Fri, 22 Feb 2013 00:29:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U8lCa-00067t-Ly for bug-guix@gnu.org; Fri, 22 Feb 2013 00:29:47 -0500 Received: from [2a01:7e00::f03c:91ff:fedf:181] (port=36280 helo=cooksoni.karetnikov.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8lCa-000669-Dz for bug-guix@gnu.org; Fri, 22 Feb 2013 00:29:44 -0500 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: bug-guix@gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Transfer-Encoding: quoted-printable 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 =3D ("package: guix" "logo: /software/guix/graphics/guix-logo.small.png"= "doc-category: Sysadmin" "doc-summary: Managing installed software package= s and versions" "doc-url: none" "gplv3-status: should-be-ok" "activity-stat= us: 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.=20=20 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'. --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-gnu-maintenance-Add-find-package-with-attrs-and-pack.patch Content-Transfer-Encoding: quoted-printable From=20ce7af670e767f425ccbb732cbe0e74423a194dbf Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov 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. =2D-- 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 =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. ;;; @@ -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=3D> (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)))) + ;;; ;;; Latest release. =2D-=20 1.7.5.4 --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBAgAGBQJRJwKvAAoJEM+IQzI9IQ38+goQAJMzujOSVi+3qbGd+91qhRaZ i0Ht6fND1C88QWV39A27E97FaVHRaHQ8LsgmhGzWksC+72O0C3SMahL7mqLgK6pr z7Up8AiUodhz99Ci9LQG4U/PKJc5V/oxSKgNy8zLEJqO56Ie7HLZunQYnrKxYeYD MubWafa5lne16iztRx2ssDeQKHBKx/XNtmuQ1CWbiqmY59rG5+IkX5MduAJ05cMC dej3QsEa90Cu4lPaLEPA+F7WLJQEXeP1chE9UquINV12fwJsAMmhs7xkBVGDZZJM VmMbLJgAhMCFh1MfCX9MxMkFcuQ8Q6NiExs4uQNphIMEe34/gU6KH1+dBqHBYsAq c/2hgu4pYhriZ+YQqL6ljhnAiNqvLPA3D36+uXyttYn24zSoBaz8H12I/5FNO2wZ sKa29jq/EATcdN06/mOucNNDw0aQ+RxLOdLAk5SBWctyQHUK3bcnnRXTdhkQ3IRb Wwkwbpe4Vu3+SE3bp4UmbKiDvyzZhzmNMR13EwOEoqwcE6jiVSbG2mEoE6/9bkB4 JFHubEeE1ilT97isCfJ2UWWc4g3Bdh7lEwfW6JL10kE7EXgcrqol+g1tdATAkZLM QR02WLHUPNzLsVGaJEmajKzKchUUyHef/g2ypiLoMMrPZ6LDkUfQd34oMQBtqmuG DNlB3PvPWIPJWE1M9RPU =wef+ -----END PGP SIGNATURE----- --==-=-=--