Commit | Line | Data |
---|---|---|
233e7676 | 1 | ;;; GNU Guix --- Functional package management for GNU |
483f1158 | 2 | ;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org> |
149acc29 | 3 | ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr> |
62cab99c | 4 | ;;; |
233e7676 | 5 | ;;; This file is part of GNU Guix. |
62cab99c | 6 | ;;; |
233e7676 | 7 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
62cab99c LC |
8 | ;;; under the terms of the GNU General Public License as published by |
9 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
10 | ;;; your option) any later version. | |
11 | ;;; | |
233e7676 | 12 | ;;; GNU Guix is distributed in the hope that it will be useful, but |
62cab99c LC |
13 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | ;;; GNU General Public License for more details. | |
16 | ;;; | |
17 | ;;; You should have received a copy of the GNU General Public License | |
233e7676 | 18 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
62cab99c LC |
19 | |
20 | (define-module (guix download) | |
21 | #:use-module (ice-9 match) | |
22 | #:use-module (guix derivations) | |
23 | #:use-module (guix packages) | |
24 | #:use-module ((guix store) #:select (derivation-path?)) | |
25 | #:use-module (guix utils) | |
483f1158 LC |
26 | #:use-module (srfi srfi-1) |
27 | #:use-module (srfi srfi-11) | |
94d222ad | 28 | #:use-module (srfi srfi-26) |
ec4d308a LC |
29 | #:export (%mirrors |
30 | url-fetch)) | |
62cab99c LC |
31 | |
32 | ;;; Commentary: | |
33 | ;;; | |
34 | ;;; Produce fixed-output derivations with data fetched over HTTP or FTP. | |
35 | ;;; | |
36 | ;;; Code: | |
37 | ||
94d222ad LC |
38 | (define %mirrors |
39 | ;; Mirror lists used when `mirror://' URLs are passed. | |
40 | (let* ((gnu-mirrors | |
41 | '(;; This one redirects to a (supposedly) nearby and (supposedly) | |
42 | ;; up-to-date mirror. | |
43 | "http://ftpmirror.gnu.org/" | |
44 | ||
45 | "ftp://ftp.cs.tu-berlin.de/pub/gnu/" | |
46 | "ftp://ftp.chg.ru/pub/gnu/" | |
47 | "ftp://ftp.funet.fi/pub/mirrors/ftp.gnu.org/gnu/" | |
48 | ||
49 | ;; This one is the master repository, and thus it's always | |
50 | ;; up-to-date. | |
51 | "http://ftp.gnu.org/pub/gnu/"))) | |
52 | `((gnu ,@gnu-mirrors) | |
53 | (gcc | |
54 | "ftp://ftp.nluug.nl/mirror/languages/gcc/" | |
55 | "ftp://ftp.fu-berlin.de/unix/languages/gcc/" | |
56 | "ftp://ftp.irisa.fr/pub/mirrors/gcc.gnu.org/gcc/" | |
57 | "ftp://gcc.gnu.org/pub/gcc/" | |
58 | ,@(map (cut string-append <> "/gcc") gnu-mirrors)) | |
59 | (gnupg | |
60 | "ftp://gd.tuwien.ac.at/privacy/gnupg/" | |
61 | "ftp://gnupg.x-zone.org/pub/gnupg/" | |
62 | "ftp://ftp.gnupg.cz/pub/gcrypt/" | |
63 | "ftp://sunsite.dk/pub/security/gcrypt/" | |
64 | "http://gnupg.wildyou.net/" | |
65 | "http://ftp.gnupg.zone-h.org/" | |
66 | "ftp://ftp.jyu.fi/pub/crypt/gcrypt/" | |
67 | "ftp://trumpetti.atm.tut.fi/gcrypt/" | |
68 | "ftp://mirror.cict.fr/gnupg/" | |
69 | "ftp://ftp.strasbourg.linuxfr.org/pub/gnupg/") | |
70 | (savannah | |
a4eabecd | 71 | "http://download.savannah.gnu.org/releases/" |
94d222ad LC |
72 | "ftp://ftp.twaren.net/Unix/NonGNU/" |
73 | "ftp://mirror.csclub.uwaterloo.ca/nongnu/" | |
74 | "ftp://mirror.publicns.net/pub/nongnu/" | |
75 | "ftp://savannah.c3sl.ufpr.br/" | |
76 | "http://ftp.cc.uoc.gr/mirrors/nongnu.org/" | |
77 | "http://ftp.twaren.net/Unix/NonGNU/" | |
78 | "http://mirror.csclub.uwaterloo.ca/nongnu/" | |
79 | "http://nongnu.askapache.com/" | |
80 | "http://savannah.c3sl.ufpr.br/" | |
81 | "http://www.centervenus.com/mirrors/nongnu/") | |
82 | (sourceforge | |
83 | "http://prdownloads.sourceforge.net/" | |
84 | "http://heanet.dl.sourceforge.net/sourceforge/" | |
85 | "http://surfnet.dl.sourceforge.net/sourceforge/" | |
86 | "http://dfn.dl.sourceforge.net/sourceforge/" | |
87 | "http://mesh.dl.sourceforge.net/sourceforge/" | |
88 | "http://ovh.dl.sourceforge.net/sourceforge/" | |
c43e0061 | 89 | "http://osdn.dl.sourceforge.net/sourceforge/") |
b40b259f LC |
90 | (kernel.org |
91 | "http://www.all.kernel.org/pub/" | |
92 | "http://ramses.wh2.tu-dresden.de/pub/mirrors/kernel.org/" | |
93 | "http://linux-kernel.uio.no/pub/" | |
94 | "http://kernel.osuosl.org/pub/" | |
47f9db41 LC |
95 | "ftp://ftp.funet.fi/pub/mirrors/ftp.kernel.org/pub/") |
96 | (apache ; from http://www.apache.org/mirrors/dist.html | |
97 | "http://www.eu.apache.org/dist/" | |
98 | "http://www.us.apache.org/dist/" | |
99 | "ftp://gd.tuwien.ac.at/pub/infosys/servers/http/apache/dist/" | |
100 | "http://apache.belnet.be/" | |
101 | "http://mirrors.ircam.fr/pub/apache/" | |
149acc29 AE |
102 | "http://apache-mirror.rbc.ru/pub/apache/") |
103 | (xorg ; from http://www.x.org/wiki/Releases/Download | |
104 | "http://xorg.freedesktop.org/releases/" ; main mirrors | |
105 | "http://www.x.org/pub/" | |
106 | "ftp://mirror.csclub.uwaterloo.ca/x.org/" ; North America | |
107 | "ftp://xorg.mirrors.pair.com/" | |
108 | "http://mirror.csclub.uwaterloo.ca/x.org/" | |
109 | "http://xorg.mirrors.pair.com/" | |
110 | "http://mirror.us.leaseweb.net/xorg/" | |
111 | "ftp://artfiles.org/x.org/" ; Europe | |
112 | "ftp://ftp.chg.ru/pub/X11/x.org/" | |
113 | "ftp://ftp.fu-berlin.de/unix/X11/FTP.X.ORG/" | |
114 | "ftp://ftp.gwdg.de/pub/x11/x.org/" | |
115 | "ftp://ftp.mirrorservice.org/sites/ftp.x.org/" | |
116 | "ftp://ftp.ntua.gr/pub/X11/" | |
117 | "ftp://ftp.piotrkosoft.net/pub/mirrors/ftp.x.org/" | |
118 | "ftp://ftp.portal-to-web.de/pub/mirrors/x.org/" | |
119 | "ftp://ftp.solnet.ch/mirror/x.org/" | |
120 | "ftp://ftp.sunet.se/pub/X11/" | |
121 | "ftp://gd.tuwien.ac.at/X11/" | |
122 | "ftp://mi.mirror.garr.it/mirrors/x.org/" | |
123 | "ftp://mirror.cict.fr/x.org/" | |
124 | "ftp://mirror.switch.ch/mirror/X11/" | |
125 | "ftp://mirrors.ircam.fr/pub/x.org/" | |
126 | "ftp://x.mirrors.skynet.be/pub/ftp.x.org/" | |
127 | "ftp://ftp.cs.cuhk.edu.hk/pub/X11" ; East Asia | |
128 | "ftp://ftp.u-aizu.ac.jp/pub/x11/x.org/" | |
129 | "ftp://ftp.yz.yamagata-u.ac.jp/pub/X11/x.org/" | |
130 | "ftp://ftp.kaist.ac.kr/x.org/" | |
131 | "ftp://mirrors.go-part.com/xorg/" | |
132 | "http://x.cs.pu.edu.tw/" | |
133 | "ftp://ftp.is.co.za/pub/x.org")))) ; South Africa | |
94d222ad | 134 | |
483f1158 LC |
135 | (define (gnutls-derivation store system) |
136 | "Return the GnuTLS derivation for SYSTEM." | |
137 | (let* ((module (resolve-interface '(gnu packages gnutls))) | |
138 | (gnutls (module-ref module 'gnutls))) | |
139 | (package-derivation store gnutls system))) | |
94d222ad | 140 | |
62cab99c LC |
141 | (define* (url-fetch store url hash-algo hash |
142 | #:optional name | |
94d222ad LC |
143 | #:key (system (%current-system)) guile |
144 | (mirrors %mirrors)) | |
62cab99c LC |
145 | "Return the path of a fixed-output derivation in STORE that fetches |
146 | URL (a string, or a list of strings denoting alternate URLs), which is | |
147 | expected to have hash HASH of type HASH-ALGO (a symbol). By default, | |
148 | the file name is the base name of URL; optionally, NAME can specify a | |
94d222ad LC |
149 | different file name. |
150 | ||
151 | When one of the URL starts with mirror://, then its host part is | |
152 | interpreted as the name of a mirror scheme, taken from MIRRORS; MIRRORS | |
153 | must be a list of symbol/URL-list pairs." | |
62cab99c LC |
154 | (define builder |
155 | `(begin | |
156 | (use-modules (guix build download)) | |
94d222ad LC |
157 | (url-fetch ',url %output |
158 | #:mirrors ',mirrors))) | |
62cab99c LC |
159 | |
160 | (define guile-for-build | |
161 | (match guile | |
162 | ((? package?) | |
163 | (package-derivation store guile system)) | |
164 | ((and (? string?) (? derivation-path?)) | |
165 | guile) | |
166 | (#f ; the default | |
1ffa7090 | 167 | (let* ((distro (resolve-interface '(gnu packages base))) |
62cab99c LC |
168 | (guile (module-ref distro 'guile-final))) |
169 | (package-derivation store guile system))))) | |
170 | ||
171 | (define file-name | |
172 | (match url | |
173 | ((head _ ...) | |
174 | (basename head)) | |
175 | (_ | |
176 | (basename url)))) | |
177 | ||
483f1158 LC |
178 | (define need-gnutls? |
179 | ;; True if any of the URLs need TLS support. | |
180 | (let ((https? (cut string-prefix? "https://" <>))) | |
181 | (match url | |
182 | ((? string?) | |
183 | (https? url)) | |
184 | ((url ...) | |
185 | (any https? url))))) | |
186 | ||
187 | (let*-values (((gnutls-drv-path gnutls-drv) | |
188 | (if need-gnutls? | |
189 | (gnutls-derivation store system) | |
190 | (values #f #f))) | |
191 | ((gnutls) | |
192 | (and gnutls-drv | |
193 | (derivation-output-path | |
194 | (assoc-ref (derivation-outputs gnutls-drv) | |
195 | "out")))) | |
196 | ((env-vars) | |
197 | (if gnutls | |
198 | (let ((dir (string-append gnutls "/share/guile/site"))) | |
199 | ;; XXX: `GUILE_LOAD_COMPILED_PATH' is overridden | |
200 | ;; by `build-expression->derivation', so we can't | |
201 | ;; set it here. | |
202 | `(("GUILE_LOAD_PATH" . ,dir))) | |
203 | '()))) | |
204 | (build-expression->derivation store (or name file-name) system | |
205 | builder | |
206 | (if gnutls-drv | |
207 | `(("gnutls" ,gnutls-drv-path)) | |
208 | '()) | |
209 | #:hash-algo hash-algo | |
210 | #:hash hash | |
211 | #:modules '((guix build download) | |
212 | (guix build utils) | |
213 | (guix ftp-client)) | |
214 | #:guile-for-build guile-for-build | |
215 | #:env-vars env-vars))) | |
62cab99c LC |
216 | |
217 | ;;; download.scm ends here |