Remove (guix http) and (guix ftp).

* guix/ftp.scm, guix/http.scm, guix/build/ftp.scm, guix/build/http.scm:
  Remove.
* Makefile.am (MODULES): Likewise.
* tests/builders.scm, distro/packages/base.scm,
  distro/packages/bash.scm, distro/packages/bdw-gc.scm,
  distro/packages/compression.scm, distro/packages/gawk.scm,
  distro/packages/gnupg.scm, distro/packages/gperf.scm,
  distro/packages/guile.scm, distro/packages/libffi.scm,
  distro/packages/libsigsegv.scm, distro/packages/libtool.scm,
  distro/packages/libunistring.scm, distro/packages/lout.scm,
  distro/packages/m4.scm, distro/packages/multiprecision.scm,
  distro/packages/ncurses.scm, distro/packages/perl.scm,
  distro/packages/pkg-config.scm, distro/packages/pth.scm,
  distro/packages/readline.scm, distro/packages/recutils.scm: Use
  `url-fetch' instead of `http-fetch' and `ftp-fetch'.
* distro/packages/bootstrap.scm: Likewise
  (bootstrap-origin): Remove references to `http-fetch' and
  `ftp-fetch'.
* guix.scm (%public-modules): Remove `http' and `ftp'; add `download'.
This commit is contained in:
Ludovic Courtès 2012-11-13 00:22:44 +01:00
parent 62cab99c32
commit 87f5d36630
29 changed files with 72 additions and 371 deletions

View File

@ -30,15 +30,11 @@ MODULES = \
guix/build-system.scm \
guix/build-system/gnu.scm \
guix/build-system/trivial.scm \
guix/ftp.scm \
guix/ftp-client.scm \
guix/http.scm \
guix/store.scm \
guix/ui.scm \
guix/build/download.scm \
guix/build/gnu-build-system.scm \
guix/build/ftp.scm \
guix/build/http.scm \
guix/build/utils.scm \
guix/build/union.scm \
guix/packages.scm \

View File

@ -27,8 +27,7 @@
#:use-module (distro packages multiprecision)
#:use-module (distro packages perl)
#:use-module (guix packages)
#:use-module (guix ftp)
#:use-module (guix http)
#:use-module (guix download)
#:use-module (guix build-system gnu)
#:use-module (guix build-system trivial)
#:use-module (guix utils)
@ -47,7 +46,7 @@
(name "hello")
(version "2.8")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/hello/hello-" version
".tar.gz"))
(sha256
@ -68,7 +67,7 @@
(name "grep")
(version "2.14")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/grep/grep-"
version ".tar.xz"))
(sha256
@ -88,7 +87,7 @@ lines.")
(name "sed")
(version "4.2.1")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/sed/sed-" version
".tar.bz2"))
(sha256
@ -110,7 +109,7 @@ substituting multiple occurrences of a string within a file.")
(name "tar")
(version "1.26")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/tar/tar-"
version ".tar.bz2"))
(sha256
@ -140,7 +139,7 @@ files (as archives).")
(name "patch")
(version "2.6.1")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/patch/patch-"
version ".tar.xz"))
(sha256
@ -166,7 +165,7 @@ producing patched versions.")
(name "diffutils")
(version "3.2")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/diffutils/diffutils-"
version ".tar.xz"))
(sha256
@ -211,7 +210,7 @@ You can use the sdiff command to merge two files interactively.")
(name "findutils")
(version "4.4.2")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/findutils/findutils-"
version ".tar.gz"))
(sha256
@ -253,7 +252,7 @@ The tools supplied with this package are:
(name "coreutils")
(version "8.19")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/coreutils/coreutils-"
version ".tar.xz"))
(sha256
@ -279,7 +278,7 @@ are expected to exist on every operating system.")
(name "make")
(version "3.82")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/make/make-" version
".tar.bz2"))
(sha256
@ -308,7 +307,7 @@ that it is possible to use Make to build and install the program.")
(name "binutils")
(version "2.22")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/binutils/binutils-"
version ".tar.bz2"))
(sha256
@ -341,7 +340,7 @@ BFD (Binary File Descriptor) library, `gprof', `nm', `strip', etc.")
(name "gcc")
(version "4.7.2")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/gcc/gcc-"
version "/gcc-" version ".tar.bz2"))
(sha256
@ -469,7 +468,7 @@ used in the GNU system including the GNU/Linux variant.")
(name "linux-libre-headers")
(version version*)
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append
"http://linux-libre.fsfla.org/pub/linux-libre/releases/3.3.8-gnu/linux-libre-"
version "-gnu.tar.xz"))
@ -498,7 +497,7 @@ used in the GNU system including the GNU/Linux variant.")
(name "glibc")
(version "2.16.0")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/glibc/glibc-"
version ".tar.xz"))
(sha256

View File

@ -20,7 +20,7 @@
#:use-module (distro packages ncurses)
#:use-module (distro packages readline)
#:use-module (guix packages)
#:use-module (guix http)
#:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu))
@ -36,7 +36,7 @@
(name "bash")
(version "4.2")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append
"http://ftp.gnu.org/gnu/bash/bash-" version ".tar.gz"))
(sha256

View File

@ -18,7 +18,7 @@
(define-module (distro packages bdw-gc)
#:use-module (guix packages)
#:use-module (guix http)
#:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu))
@ -27,7 +27,7 @@
(name "libgc")
(version "7.2alpha6")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append
"http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gc-"
version ".tar.gz"))

View File

@ -19,8 +19,6 @@
(define-module (distro packages bootstrap)
#:use-module (distro)
#:use-module (guix packages)
#:use-module (guix ftp)
#:use-module (guix http)
#:use-module (guix download)
#:use-module (guix build-system)
#:use-module (guix build-system gnu)
@ -67,11 +65,7 @@
(let ((orig-method (origin-method source)))
(origin (inherit source)
(method (cond ((eq? orig-method http-fetch)
(boot http-fetch))
((eq? orig-method ftp-fetch)
(boot ftp-fetch))
((eq? orig-method url-fetch)
(method (cond ((eq? orig-method url-fetch)
(boot url-fetch))
(else orig-method))))))
@ -207,7 +201,7 @@ $out/bin/guile --version~%"
(package-from-tarball "bootstrap-binaries"
(lambda (system)
(origin
(method http-fetch)
(method url-fetch)
(uri (string-append
%bootstrap-base-url "/"
system "/static-binaries.tar.xz"))
@ -226,7 +220,7 @@ $out/bin/guile --version~%"
(package-from-tarball "binutils-bootstrap"
(lambda (system)
(origin
(method http-fetch)
(method url-fetch)
(uri (string-append
%bootstrap-base-url "/"
system "/binutils-2.22.tar.xz"))
@ -280,7 +274,7 @@ $out/bin/guile --version~%"
("tarball" ,(lambda (system)
(bootstrap-origin
(origin
(method http-fetch)
(method url-fetch)
(uri (string-append %bootstrap-base-url "/"
system "/glibc-2.16.0.tar.xz"))
(sha256
@ -351,7 +345,7 @@ exec ~a/bin/.gcc-wrapped -B~a/lib \
("tarball" ,(lambda (system)
(bootstrap-origin
(origin
(method http-fetch)
(method url-fetch)
(uri (string-append %bootstrap-base-url "/"
system "/gcc-4.7.2.tar.xz"))
(sha256

View File

@ -18,7 +18,7 @@
(define-module (distro packages compression)
#:use-module (guix packages)
#:use-module (guix http)
#:use-module (guix download)
#:use-module (guix build-system gnu))
(define-public zlib
@ -27,7 +27,7 @@
(version "1.2.7")
(source
(origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://zlib.net/zlib-"
version ".tar.gz"))
(sha256
@ -66,7 +66,7 @@ in compression.")
(name "gzip")
(version "1.5")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/gzip/gzip-"
version ".tar.gz"))
(sha256
@ -114,7 +114,7 @@ superior compression ratio of gzip is just a bonus.")
(name "bzip2")
(version "1.0.6")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://www.bzip.org/" version "/bzip2-"
version ".tar.gz"))
(sha256
@ -150,7 +150,7 @@ decompression.")
(name "xz")
(version "5.0.4")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://tukaani.org/xz/xz-" version
".tar.gz"))
(sha256

View File

@ -19,7 +19,7 @@
(define-module (distro packages gawk)
#:use-module (distro packages libsigsegv)
#:use-module (guix packages)
#:use-module (guix http)
#:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu))
@ -28,7 +28,7 @@
(name "gawk")
(version "4.0.0")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/gawk/gawk-" version
".tar.bz2"))
(sha256

View File

@ -21,7 +21,7 @@
#:use-module (distro packages readline)
#:use-module (distro packages compression)
#:use-module (guix packages)
#:use-module (guix ftp)
#:use-module (guix download)
#:use-module (guix build-system gnu))
(define-public libgpg-error
@ -30,7 +30,7 @@
(version "1.10")
(source
(origin
(method ftp-fetch)
(method url-fetch)
(uri (string-append "ftp://ftp.gnupg.org/gcrypt/libgpg-error/libgpg-error-"
version ".tar.bz2"))
(sha256
@ -53,7 +53,7 @@ Daemon and possibly more in the future.")
(version "1.5.0")
(source
(origin
(method ftp-fetch)
(method url-fetch)
(uri (string-append "ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-"
version ".tar.bz2"))
(sha256
@ -79,7 +79,7 @@ functions, random numbers and a lot of supporting functions.")
(version "2.0.3")
(source
(origin
(method ftp-fetch)
(method url-fetch)
(uri (string-append "ftp://ftp.gnupg.org/gcrypt/libassuan/libassuan-"
version ".tar.bz2"))
(sha256
@ -104,7 +104,7 @@ provided.")
(version "1.2.0")
(source
(origin
(method ftp-fetch)
(method url-fetch)
(uri (string-append
"ftp://ftp.gnupg.org/gcrypt/libksba/libksba-"
version ".tar.bz2"))
@ -129,7 +129,7 @@ specifications are building blocks of S/MIME and TLS.")
(version "2.0.19")
(source
(origin
(method ftp-fetch)
(method url-fetch)
(uri (string-append
"ftp://ftp.gnupg.org/gcrypt/gnupg/gnupg-" version
".tar.bz2"))

View File

@ -18,7 +18,7 @@
(define-module (distro packages gperf)
#:use-module (guix packages)
#:use-module (guix ftp)
#:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu))
@ -28,7 +28,7 @@
(version "3.0.4")
(source
(origin
(method ftp-fetch)
(method url-fetch)
(uri (string-append "ftp://ftp.gnu.org/gnu/gperf/gperf-"
version ".tar.gz"))
(sha256

View File

@ -29,7 +29,7 @@
#:use-module (distro packages pkg-config)
#:use-module (distro packages readline)
#:use-module (guix packages)
#:use-module (guix http)
#:use-module (guix download)
#:use-module (guix build-system gnu))
;;; Commentary:
@ -43,7 +43,7 @@
(name "guile")
(version "1.8.8")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/guile/guile-" version
".tar.gz"))
(sha256
@ -93,7 +93,7 @@ extensible. It supports many SRFIs.")
(name "guile")
(version "2.0.6")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/guile/guile-" version
".tar.xz"))
(sha256
@ -142,7 +142,7 @@ or 2.0."
(name (string-append "guile-reader-for-guile-" (package-version guile)))
(version "0.6")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append
"http://download-mirror.savannah.gnu.org/releases/guile-reader/guile-reader-"
version ".tar.gz"))

View File

@ -18,7 +18,7 @@
(define-module (distro packages libffi)
#:use-module (guix packages)
#:use-module (guix ftp)
#:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu))
@ -40,7 +40,7 @@
(name "libffi")
(version "3.0.9")
(source (origin
(method ftp-fetch)
(method url-fetch)
(uri
(string-append "ftp://sourceware.org/pub/libffi/"
name "-" version ".tar.gz"))

View File

@ -18,7 +18,7 @@
(define-module (distro packages libsigsegv)
#:use-module (guix packages)
#:use-module (guix http)
#:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu))
@ -27,7 +27,7 @@
(name "libsigsegv")
(version "2.10")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append
"http://ftp.gnu.org/gnu/libsigsegv/libsigsegv-"
version ".tar.gz"))

View File

@ -21,7 +21,7 @@
#:use-module (distro packages m4)
#:use-module (distro packages perl)
#:use-module (guix packages)
#:use-module (guix http)
#:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu))
@ -30,7 +30,7 @@
(name "libtool")
(version "2.4.2")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/libtool/libtool-"
version ".tar.gz"))
(sha256

View File

@ -18,7 +18,7 @@
(define-module (distro packages libunistring)
#:use-module (guix packages)
#:use-module (guix http)
#:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu))
@ -27,7 +27,7 @@
(name "libunistring")
(version "0.9.3")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append
"http://ftp.gnu.org/gnu/libunistring/libunistring-"
version ".tar.gz"))

View File

@ -18,7 +18,7 @@
(define-module (distro packages lout)
#:use-module (guix packages)
#:use-module (guix http)
#:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu))
@ -78,7 +78,7 @@
(name "lout")
(version "3.39")
(source (origin
(method http-fetch)
(method url-fetch)
;; FIXME: `http-get' doesn't follow redirects, hence the URL.
(uri (string-append
"http://download-mirror.savannah.gnu.org/releases/lout/lout-"

View File

@ -19,7 +19,7 @@
(define-module (distro packages m4)
#:use-module (distro)
#:use-module (guix packages)
#:use-module (guix http)
#:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu))
@ -28,7 +28,7 @@
(name "m4")
(version "1.4.16")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/m4/m4-"
version ".tar.bz2"))
(sha256

View File

@ -20,7 +20,7 @@
#:use-module (distro)
#:use-module (distro packages m4)
#:use-module (guix packages)
#:use-module (guix http)
#:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu))
@ -29,7 +29,7 @@
(name "gmp")
(version "5.0.5")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/gmp/gmp-" version
".tar.bz2"))
(sha256
@ -71,7 +71,7 @@ faster algorithms.")
(name "mpfr")
(version "3.1.1")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/mpfr/mpfr-" version
".tar.xz"))
(sha256 (base32
@ -97,7 +97,7 @@ double-precision floating-point arithmetic (53-bit mantissa).")
(name "mpc")
(version "1.0")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append
"http://www.multiprecision.org/mpc/download/mpc-"
version ".tar.gz"))

View File

@ -18,7 +18,7 @@
(define-module (distro packages ncurses)
#:use-module (guix packages)
#:use-module (guix http)
#:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu))
@ -55,7 +55,7 @@
(name "ncurses")
(version "5.9")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/ncurses/ncurses-"
version ".tar.gz"))
(sha256

View File

@ -19,7 +19,7 @@
(define-module (distro packages perl)
#:use-module (distro)
#:use-module (guix packages)
#:use-module (guix http)
#:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu))
@ -29,7 +29,7 @@
(name "perl")
(version "5.16.1")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://www.cpan.org/src/5.0/perl-"
version ".tar.gz"))
(sha256

View File

@ -18,7 +18,7 @@
(define-module (distro packages pkg-config)
#:use-module (guix packages)
#:use-module (guix http)
#:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu))
@ -27,7 +27,7 @@
(name "pkg-config")
(version "0.27.1")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append
"http://pkgconfig.freedesktop.org/releases/pkg-config-"
version ".tar.gz"))

View File

@ -18,7 +18,7 @@
(define-module (distro packages pth)
#:use-module (guix packages)
#:use-module (guix ftp)
#:use-module (guix download)
#:use-module (guix build-system gnu))
(define-public pth
@ -27,7 +27,7 @@
(version "2.0.7")
(source
(origin
(method ftp-fetch)
(method url-fetch)
(uri (string-append "ftp://ftp.gnu.org/gnu/pth/pth-" version
".tar.gz"))
(sha256

View File

@ -20,7 +20,7 @@
#:use-module (distro)
#:use-module (distro packages ncurses)
#:use-module (guix packages)
#:use-module (guix http)
#:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu))
@ -29,7 +29,7 @@
(name "readline")
(version "6.2")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/readline/readline-"
version ".tar.gz"))
(sha256

View File

@ -19,7 +19,7 @@
(define-module (distro packages recutils)
#:use-module (distro)
#:use-module (guix packages)
#:use-module (guix http)
#:use-module (guix download)
#:use-module (guix utils)
#:use-module (guix build-system gnu))
@ -28,7 +28,7 @@
(name "recutils")
(version "1.5")
(source (origin
(method http-fetch)
(method url-fetch)
(uri (string-append "http://ftp.gnu.org/gnu/recutils/recutils-"
version ".tar.gz"))
(sha256

View File

@ -27,8 +27,7 @@
build-system
derivations
ftp-client
ftp
http
download
packages
store
utils))

View File

@ -1,48 +0,0 @@
;;; Guix --- Nix package management from Guile. -*- coding: utf-8 -*-
;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of Guix.
;;;
;;; Guix is free software; you can redistribute it and/or modify it
;;; 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.
;;;
;;; Guix is distributed in the hope that it will be useful, but
;;; 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
;;; along with Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (guix build ftp)
#:use-module (guix ftp-client)
#:use-module (guix build utils)
#:use-module (web uri)
#:export (ftp-fetch))
;;; Commentary:
;;;
;;; Fetch data such as tarballs over FTP (builder-side code).
;;;
;;; Code:
(define (ftp-fetch url file)
"Fetch data from URL and write it to FILE. Return FILE on success."
(setvbuf (current-output-port) _IOLBF)
(format #t "starting FTP download of `~a' from `~a'...~%" file url)
(let* ((uri (string->uri url))
(conn (ftp-open (uri-host uri)))
(in (ftp-retr conn (basename (uri-path uri))
(dirname (uri-path uri)))))
(call-with-output-file file
(lambda (out)
;; TODO: Show a progress bar.
(dump-port in out)))
(ftp-close conn))
file)
;;; ftp.scm ends here

View File

@ -1,100 +0,0 @@
;;; Guix --- Nix package management from Guile. -*- coding: utf-8 -*-
;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of Guix.
;;;
;;; Guix is free software; you can redistribute it and/or modify it
;;; 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.
;;;
;;; Guix is distributed in the hope that it will be useful, but
;;; 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
;;; along with Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (guix build http)
#:use-module (web uri)
#:use-module (web client)
#:use-module (web response)
#:use-module (rnrs io ports)
#:use-module (srfi srfi-11)
#:export (http-fetch))
;;; Commentary:
;;;
;;; Fetch data such as tarballs over HTTP (builder-side code).
;;;
;;; Code:
(define (open-connection-for-uri uri)
"Return an open input/output port for a connection to URI.
This is the same as Guile's `open-socket-for-uri', except that we always
use a numeric port argument, to avoid the need to go through libc's NSS,
which is not available during bootstrap."
(define addresses
(let ((port (or (uri-port uri)
(case (uri-scheme uri)
((http) 80) ; /etc/services, not for me!
(else
(error "unsupported URI scheme" uri))))))
(getaddrinfo (uri-host uri)
(number->string port)
AI_NUMERICSERV)))
(let loop ((addresses addresses))
(let* ((ai (car addresses))
(s (with-fluids ((%default-port-encoding #f))
(socket (addrinfo:fam ai) (addrinfo:socktype ai)
(addrinfo:protocol ai)))))
(catch 'system-error
(lambda ()
(connect s (addrinfo:addr ai))
;; Buffer input and output on this port.
(setvbuf s _IOFBF)
;; Enlarge the receive buffer.
(setsockopt s SOL_SOCKET SO_RCVBUF (* 12 1024))
s)
(lambda args
;; Connection failed, so try one of the other addresses.
(close s)
(if (null? addresses)
(apply throw args)
(loop (cdr addresses))))))))
;; XXX: This is an awful hack to make sure the (set-port-encoding! p
;; "ISO-8859-1") call in `read-response' passes, even during bootstrap
;; where iconv is not available.
(module-define! (resolve-module '(web response))
'set-port-encoding!
(lambda (p e) #f))
(define (http-fetch url file)
"Fetch data from URL and write it to FILE. Return FILE on success."
(setvbuf (current-output-port) _IOLBF)
(format #t "starting HTTP download of `~a' from `~a'...~%" file url)
;; FIXME: Use a variant of `http-get' that returns a port instead of
;; loading everything in memory.
(let*-values (((uri)
(string->uri url))
((connection)
(open-connection-for-uri uri))
((resp bv)
(http-get uri #:port connection #:decode-body? #f))
((code)
(response-code resp)))
(if (= 200 code)
(begin
(call-with-output-file file
(lambda (p)
(put-bytevector p bv)))
file)
(error "download failed" url
code (response-reason-phrase resp)))))

View File

@ -1,65 +0,0 @@
;;; Guix --- Nix package management from Guile. -*- coding: utf-8 -*-
;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of Guix.
;;;
;;; Guix is free software; you can redistribute it and/or modify it
;;; 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.
;;;
;;; Guix is distributed in the hope that it will be useful, but
;;; 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
;;; along with Guix. If not, see <ftp://www.gnu.org/licenses/>.
(define-module (guix ftp)
#:use-module (ice-9 match)
#:use-module (guix derivations)
#:use-module (guix packages)
#:use-module ((guix store) #:select (derivation-path?))
#:use-module (guix utils)
#:export (ftp-fetch))
;;; Commentary:
;;;
;;; Produce fixed-output derivations with data fetched over FTP.
;;;
;;; Code:
(define* (ftp-fetch store url hash-algo hash
#:optional name
#:key (system (%current-system)) guile)
"Return the path of a fixed-output derivation in STORE that fetches URL,
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 different file name."
(define builder
`(begin
(use-modules (guix build ftp))
(ftp-fetch ,url %output)))
(define guile-for-build
(match guile
((? package?)
(package-derivation store guile system))
((and (? string?) (? derivation-path?))
guile)
(#f ; the default
(let* ((distro (resolve-interface '(distro packages base)))
(guile (module-ref distro 'guile-final)))
(package-derivation store guile system)))))
(build-expression->derivation store (or name (basename url)) system
builder '()
#:hash-algo hash-algo
#:hash hash
#:modules '((guix ftp-client)
(guix build ftp)
(guix build utils))
#:guile-for-build guile-for-build))
;;; ftp.scm ends here

View File

@ -1,63 +0,0 @@
;;; Guix --- Nix package management from Guile. -*- coding: utf-8 -*-
;;; Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of Guix.
;;;
;;; Guix is free software; you can redistribute it and/or modify it
;;; 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.
;;;
;;; Guix is distributed in the hope that it will be useful, but
;;; 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
;;; along with Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (guix http)
#:use-module (ice-9 match)
#:use-module (guix derivations)
#:use-module (guix packages)
#:use-module ((guix store) #:select (derivation-path?))
#:use-module (guix utils)
#:export (http-fetch))
;;; Commentary:
;;;
;;; Produce fixed-output derivations with data fetched over HTTP.
;;;
;;; Code:
(define* (http-fetch store url hash-algo hash
#:optional name
#:key (system (%current-system)) guile)
"Return the path of a fixed-output derivation in STORE that fetches URL,
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 different file name."
(define builder
`(begin
(use-modules (guix build http))
(http-fetch ,url %output)))
(define guile-for-build
(match guile
((? package?)
(package-derivation store guile system))
((and (? string?) (? derivation-path?))
guile)
(#f ; the default
(let* ((distro (resolve-interface '(distro packages base)))
(guile (module-ref distro 'guile-final)))
(package-derivation store guile system)))))
(build-expression->derivation store (or name (basename url)) system
builder '()
#:hash-algo hash-algo
#:hash hash
#:modules '((guix build http))
#:guile-for-build guile-for-build))
;;; http.scm ends here

View File

@ -18,7 +18,6 @@
(define-module (test-builders)
#:use-module (guix http)
#:use-module (guix download)
#:use-module (guix build-system)
#:use-module (guix build-system gnu)
@ -54,16 +53,6 @@
(test-begin "builders")
(test-assert "http-fetch"
(let* ((url "http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz")
(hash (nix-base32-string->bytevector
"0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))
(drv-path (http-fetch %store url 'sha256 hash))
(out-path (derivation-path->output-path drv-path)))
(and (build-derivations %store (list drv-path))
(file-exists? out-path)
(valid-path? %store out-path))))
(test-assert "url-fetch"
(let* ((url '("http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz"
"ftp://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz"))
@ -83,7 +72,7 @@
(let* ((url "http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz")
(hash (nix-base32-string->bytevector
"0wqd8sjmxfskrflaxywc7gqw7sfawrfvdxd9skxawzfgyy0pzdz6"))
(tarball (http-fetch %store url 'sha256 hash))
(tarball (url-fetch %store url 'sha256 hash))
(build (gnu-build %store "hello-2.8" tarball
%bootstrap-inputs
#:implicit-inputs? #f