3 -c '(apply (@ (list-packages) list-packages)
6 ;;; GNU Guix
--- Functional package management
for GNU
7 ;;; Copyright ©
2013 Ludovic Courtès
<ludo@gnu.org
>
9 ;;; This
file is part of GNU Guix.
11 ;;; GNU Guix is free software
; you can redistribute it and
/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation
; either version
3 of the License
, or
(at
14 ;;; your option
) any later version.
16 ;;; GNU Guix is distributed
in the hope that it will be useful
, but
17 ;;; WITHOUT ANY WARRANTY
; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License
for more details.
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not
, see
<http
://www.gnu.org
/licenses
/>.
24 (define-module
(list-packages
)
25 #:use-module (guix utils)
26 #:use-module (guix packages)
27 #:use-module (guix licenses)
28 #:use-module (guix gnu-maintenance)
29 #:use-module (gnu packages)
30 #:use-module (sxml simple)
31 #:use-module (web uri)
32 #:use-module (ice-9 match)
33 #:use-module (srfi srfi-1)
34 #:export (list-packages))
38 ;;; Emit an HTML representation of the packages available
in GNU Guix.
42 (define lookup-gnu-package
43 (let ((gnu
(official-gnu-packages
)))
45 "Return the package description for GNU package NAME, or #f."
46 (find (lambda
(package
)
47 (equal?
(gnu-package-name package
) name
))
50 (define
(package-
>sxml package
)
51 "Return HTML-as-SXML representing PACKAGE."
52 (define
(source-url package
)
53 (let ((loc
(package-location package
)))
55 (string-append
"http://git.savannah.gnu.org/cgit/guix.git/tree/"
56 (location-file loc
) "#n"
57 (number-
>string
(location-line loc
))))))
59 (define
(license package
)
63 `(div ,(map ->sxml lst)))
65 (let ((uri (license-uri license)))
66 (case (and=> (and uri (string->uri uri)) uri-scheme)
68 `(div
(a
(@
(href
,uri
))
69 ,(license-name license
))))
71 `(div ,(license-name license) " ("
72 ,(license-comment license) ")")))))
75 (->sxml (package-license package)))
77 (define (status package)
79 `(a
(@
(href
,(string-append
"http://hydra.gnu.org/job/gnu/master/"
80 (package-full-name package
) "."
85 ,(url "x86_64-linux") " "
88 (define (package-logo name)
89 (and=> (lookup-gnu-package name)
92 (let ((description-id (symbol->string
93 (gensym (package-name package)))))
94 `(tr (td
,(if (gnu-package? package
)
95 `(img (@ (src "/graphics/gnu-head-mini.png")))
97 (td (a (@ (href ,(source-url package)))
98 ,(package-name package) " "
99 ,(package-version package)))
100 (td (@ (colspan "2") (height "0"))
101 (a (@ (href "javascript:void(0)")
102 (title "show/hide package description")
103 (onClick ,(format #f "javascript:show_hide('~a')"
105 ,(package-synopsis package))
106 (div (@ (id ,description-id)
107 (style "position: relative; display: none;"))
108 ,(match (package-logo (package-name package))
112 (style
"float: left; padding-right: 1em;"))))
114 (p
,(package-description package
))
116 (a
(@
(href
,(package-home-page package
)))
117 ,(package-home-page package
))
118 ,(status package
))))))
120 (define
(packages-
>sxml packages
)
121 "Return an HTML page as SXML describing PACKAGES."
123 (h2 "GNU Guix Package List")
124 (div (@ (style "margin-bottom: 5em;"))
126 (img (@ (src "graphics/guix-logo.small.png")
127 (alt "GNU Guix and the GNU System")
129 "This web page lists the packages currently provided by the "
130 (a (@ (href "manual/guix.html#GNU-Distribution"))
131 "GNU system distribution")
133 (a (@ (href "/software/guix/guix.html")) "GNU Guix") ". "
134 "Our " (a (@ (href "http://hydra.gnu.org/jobset/gnu/master"))
135 "continuous integration system")
136 " shows their current build status.")
137 (table (@ (style "border: none;"))
138 ,@(map package->sxml packages))))
141 (define (list-packages . args)
142 "Return an HTML page listing all the packages found in the GNU distribution,
143 with gnu.org server-side include and all that."
144 ;; Don't attempt to translate descriptions.
145 (setlocale LC_ALL "C")
147 ;; Output the page as UTF-8 since that's what the gnu.org server-side
149 (set-port-encoding! (current-output-port) "UTF-8")
151 (let ((packages (sort (fold-packages cons '())
153 (string<? (package-name p1) (package-name p2))))))
154 (format #t "<!--#include virtual=\"/server/html5-header.html\" -->
155 <!-- Parent-Version: 1.70 $ -->
157 <title>GNU Guix - GNU Distribution - GNU Project</title>
158 <!--#include virtual=\"/server/banner.html\" -->
160 <script language=\"javascript\" type=\"text/javascript\">
162 function show_hide(idThing)
164 var thing = document.getElementById(idThing);
166 if (thing.style.display == \"none\") {
167 thing.style.display = \"\";
169 thing.style.display = \"none\";
174 (display (sxml->xml (packages->sxml packages)))
175 (format #t "<!--#include virtual=\"/server/footer.html\" -->
178 <p>Please send general FSF & GNU inquiries to
179 <a href=\"mailto:gnu@gnu.org\"><gnu@gnu.org></a>.
180 There are also <a href=\"/contact/\">other ways to contact</a>
181 the FSF. Broken links and other corrections or suggestions can be sent
182 to <a href=\"mailto:bug-guix@gnu.org\"><bug-guix@gnu.org></a>.</p>
184 <p>Copyright © 2013 Free Software Foundation, Inc.</p>
186 <p>This page is licensed under a <a rel=\"license\"
187 href=\"http://creativecommons.org/licenses/by-nd/3.0/us/\">Creative
188 Commons Attribution-NoDerivs 3.0 United States License</a>.</p>
191 <!-- timestamp start -->
193 <!-- timestamp end -->
202 ;;; list-packages.scm ends here