2013-01-05 18:47:50 -05:00
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
2013-01-20 16:28:38 -05:00
|
|
|
;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
|
2012-11-12 17:10:26 -05:00
|
|
|
;;;
|
2013-01-05 18:47:50 -05:00
|
|
|
;;; This file is part of GNU Guix.
|
2012-11-12 17:10:26 -05:00
|
|
|
;;;
|
2013-01-05 18:47:50 -05:00
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
2012-11-12 17:10:26 -05:00
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
;;; your option) any later version.
|
|
|
|
;;;
|
2013-01-05 18:47:50 -05:00
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
2012-11-12 17:10:26 -05:00
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
;;;
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
2013-01-05 18:47:50 -05:00
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
2012-11-12 17:10:26 -05:00
|
|
|
|
|
|
|
(define-module (guix download)
|
|
|
|
#:use-module (ice-9 match)
|
|
|
|
#:use-module (guix derivations)
|
|
|
|
#:use-module (guix packages)
|
|
|
|
#:use-module ((guix store) #:select (derivation-path?))
|
|
|
|
#:use-module (guix utils)
|
2013-01-20 16:28:38 -05:00
|
|
|
#:use-module (srfi srfi-1)
|
|
|
|
#:use-module (srfi srfi-11)
|
2012-11-12 17:20:06 -05:00
|
|
|
#:use-module (srfi srfi-26)
|
2012-11-13 16:57:36 -05:00
|
|
|
#:export (%mirrors
|
|
|
|
url-fetch))
|
2012-11-12 17:10:26 -05:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;;;
|
|
|
|
;;; Produce fixed-output derivations with data fetched over HTTP or FTP.
|
|
|
|
;;;
|
|
|
|
;;; Code:
|
|
|
|
|
2012-11-12 17:20:06 -05:00
|
|
|
(define %mirrors
|
|
|
|
;; Mirror lists used when `mirror://' URLs are passed.
|
|
|
|
(let* ((gnu-mirrors
|
|
|
|
'(;; This one redirects to a (supposedly) nearby and (supposedly)
|
|
|
|
;; up-to-date mirror.
|
|
|
|
"http://ftpmirror.gnu.org/"
|
|
|
|
|
|
|
|
"ftp://ftp.cs.tu-berlin.de/pub/gnu/"
|
|
|
|
"ftp://ftp.chg.ru/pub/gnu/"
|
|
|
|
"ftp://ftp.funet.fi/pub/mirrors/ftp.gnu.org/gnu/"
|
|
|
|
|
|
|
|
;; This one is the master repository, and thus it's always
|
|
|
|
;; up-to-date.
|
|
|
|
"http://ftp.gnu.org/pub/gnu/")))
|
|
|
|
`((gnu ,@gnu-mirrors)
|
|
|
|
(gcc
|
|
|
|
"ftp://ftp.nluug.nl/mirror/languages/gcc/"
|
|
|
|
"ftp://ftp.fu-berlin.de/unix/languages/gcc/"
|
|
|
|
"ftp://ftp.irisa.fr/pub/mirrors/gcc.gnu.org/gcc/"
|
|
|
|
"ftp://gcc.gnu.org/pub/gcc/"
|
|
|
|
,@(map (cut string-append <> "/gcc") gnu-mirrors))
|
|
|
|
(gnupg
|
|
|
|
"ftp://gd.tuwien.ac.at/privacy/gnupg/"
|
|
|
|
"ftp://gnupg.x-zone.org/pub/gnupg/"
|
|
|
|
"ftp://ftp.gnupg.cz/pub/gcrypt/"
|
|
|
|
"ftp://sunsite.dk/pub/security/gcrypt/"
|
|
|
|
"http://gnupg.wildyou.net/"
|
|
|
|
"http://ftp.gnupg.zone-h.org/"
|
|
|
|
"ftp://ftp.jyu.fi/pub/crypt/gcrypt/"
|
|
|
|
"ftp://trumpetti.atm.tut.fi/gcrypt/"
|
|
|
|
"ftp://mirror.cict.fr/gnupg/"
|
|
|
|
"ftp://ftp.strasbourg.linuxfr.org/pub/gnupg/")
|
|
|
|
(savannah
|
2012-12-07 15:06:03 -05:00
|
|
|
"http://download.savannah.gnu.org/releases/"
|
2012-11-12 17:20:06 -05:00
|
|
|
"ftp://ftp.twaren.net/Unix/NonGNU/"
|
|
|
|
"ftp://mirror.csclub.uwaterloo.ca/nongnu/"
|
|
|
|
"ftp://mirror.publicns.net/pub/nongnu/"
|
|
|
|
"ftp://savannah.c3sl.ufpr.br/"
|
|
|
|
"http://ftp.cc.uoc.gr/mirrors/nongnu.org/"
|
|
|
|
"http://ftp.twaren.net/Unix/NonGNU/"
|
|
|
|
"http://mirror.csclub.uwaterloo.ca/nongnu/"
|
|
|
|
"http://nongnu.askapache.com/"
|
|
|
|
"http://savannah.c3sl.ufpr.br/"
|
|
|
|
"http://www.centervenus.com/mirrors/nongnu/")
|
|
|
|
(sourceforge
|
|
|
|
"http://prdownloads.sourceforge.net/"
|
|
|
|
"http://heanet.dl.sourceforge.net/sourceforge/"
|
|
|
|
"http://surfnet.dl.sourceforge.net/sourceforge/"
|
|
|
|
"http://dfn.dl.sourceforge.net/sourceforge/"
|
|
|
|
"http://mesh.dl.sourceforge.net/sourceforge/"
|
|
|
|
"http://ovh.dl.sourceforge.net/sourceforge/"
|
2012-12-16 18:18:15 -05:00
|
|
|
"http://osdn.dl.sourceforge.net/sourceforge/")
|
2012-11-27 15:55:53 -05:00
|
|
|
(kernel.org
|
|
|
|
"http://www.all.kernel.org/pub/"
|
|
|
|
"http://ramses.wh2.tu-dresden.de/pub/mirrors/kernel.org/"
|
|
|
|
"http://linux-kernel.uio.no/pub/"
|
|
|
|
"http://kernel.osuosl.org/pub/"
|
2013-01-25 15:49:49 -05:00
|
|
|
"ftp://ftp.funet.fi/pub/mirrors/ftp.kernel.org/pub/")
|
|
|
|
(apache ; from http://www.apache.org/mirrors/dist.html
|
|
|
|
"http://www.eu.apache.org/dist/"
|
|
|
|
"http://www.us.apache.org/dist/"
|
|
|
|
"ftp://gd.tuwien.ac.at/pub/infosys/servers/http/apache/dist/"
|
|
|
|
"http://apache.belnet.be/"
|
|
|
|
"http://mirrors.ircam.fr/pub/apache/"
|
|
|
|
"http://apache-mirror.rbc.ru/pub/apache/"))))
|
2012-11-12 17:20:06 -05:00
|
|
|
|
2013-01-20 16:28:38 -05:00
|
|
|
(define (gnutls-derivation store system)
|
|
|
|
"Return the GnuTLS derivation for SYSTEM."
|
|
|
|
(let* ((module (resolve-interface '(gnu packages gnutls)))
|
|
|
|
(gnutls (module-ref module 'gnutls)))
|
|
|
|
(package-derivation store gnutls system)))
|
2012-11-12 17:20:06 -05:00
|
|
|
|
2012-11-12 17:10:26 -05:00
|
|
|
(define* (url-fetch store url hash-algo hash
|
|
|
|
#:optional name
|
2012-11-12 17:20:06 -05:00
|
|
|
#:key (system (%current-system)) guile
|
|
|
|
(mirrors %mirrors))
|
2012-11-12 17:10:26 -05:00
|
|
|
"Return the path of a fixed-output derivation in STORE that fetches
|
|
|
|
URL (a string, or a list of strings denoting alternate URLs), which is
|
|
|
|
expected to have hash HASH of type HASH-ALGO (a symbol). By default,
|
|
|
|
the file name is the base name of URL; optionally, NAME can specify a
|
2012-11-12 17:20:06 -05:00
|
|
|
different file name.
|
|
|
|
|
|
|
|
When one of the URL starts with mirror://, then its host part is
|
|
|
|
interpreted as the name of a mirror scheme, taken from MIRRORS; MIRRORS
|
|
|
|
must be a list of symbol/URL-list pairs."
|
2012-11-12 17:10:26 -05:00
|
|
|
(define builder
|
|
|
|
`(begin
|
|
|
|
(use-modules (guix build download))
|
2012-11-12 17:20:06 -05:00
|
|
|
(url-fetch ',url %output
|
|
|
|
#:mirrors ',mirrors)))
|
2012-11-12 17:10:26 -05:00
|
|
|
|
|
|
|
(define guile-for-build
|
|
|
|
(match guile
|
|
|
|
((? package?)
|
|
|
|
(package-derivation store guile system))
|
|
|
|
((and (? string?) (? derivation-path?))
|
|
|
|
guile)
|
|
|
|
(#f ; the default
|
2013-01-17 19:06:24 -05:00
|
|
|
(let* ((distro (resolve-interface '(gnu packages base)))
|
2012-11-12 17:10:26 -05:00
|
|
|
(guile (module-ref distro 'guile-final)))
|
|
|
|
(package-derivation store guile system)))))
|
|
|
|
|
|
|
|
(define file-name
|
|
|
|
(match url
|
|
|
|
((head _ ...)
|
|
|
|
(basename head))
|
|
|
|
(_
|
|
|
|
(basename url))))
|
|
|
|
|
2013-01-20 16:28:38 -05:00
|
|
|
(define need-gnutls?
|
|
|
|
;; True if any of the URLs need TLS support.
|
|
|
|
(let ((https? (cut string-prefix? "https://" <>)))
|
|
|
|
(match url
|
|
|
|
((? string?)
|
|
|
|
(https? url))
|
|
|
|
((url ...)
|
|
|
|
(any https? url)))))
|
|
|
|
|
|
|
|
(let*-values (((gnutls-drv-path gnutls-drv)
|
|
|
|
(if need-gnutls?
|
|
|
|
(gnutls-derivation store system)
|
|
|
|
(values #f #f)))
|
|
|
|
((gnutls)
|
|
|
|
(and gnutls-drv
|
|
|
|
(derivation-output-path
|
|
|
|
(assoc-ref (derivation-outputs gnutls-drv)
|
|
|
|
"out"))))
|
|
|
|
((env-vars)
|
|
|
|
(if gnutls
|
|
|
|
(let ((dir (string-append gnutls "/share/guile/site")))
|
|
|
|
;; XXX: `GUILE_LOAD_COMPILED_PATH' is overridden
|
|
|
|
;; by `build-expression->derivation', so we can't
|
|
|
|
;; set it here.
|
|
|
|
`(("GUILE_LOAD_PATH" . ,dir)))
|
|
|
|
'())))
|
|
|
|
(build-expression->derivation store (or name file-name) system
|
|
|
|
builder
|
|
|
|
(if gnutls-drv
|
|
|
|
`(("gnutls" ,gnutls-drv-path))
|
|
|
|
'())
|
|
|
|
#:hash-algo hash-algo
|
|
|
|
#:hash hash
|
|
|
|
#:modules '((guix build download)
|
|
|
|
(guix build utils)
|
|
|
|
(guix ftp-client))
|
|
|
|
#:guile-for-build guile-for-build
|
|
|
|
#:env-vars env-vars)))
|
2012-11-12 17:10:26 -05:00
|
|
|
|
|
|
|
;;; download.scm ends here
|