Commit | Line | Data |
---|---|---|
89328d24 | 1 | ;;; GNU Guix --- Functional package management for GNU |
67c2db17 | 2 | ;;; Copyright © 2014, 2015, 2016, 2017, 2019 Ludovic Courtès <ludo@gnu.org> |
89328d24 MW |
3 | ;;; Copyright © 2014 Sree Harsha Totakura <sreeharsha@totakura.in> |
4 | ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org> | |
5 | ;;; | |
6 | ;;; This file is part of GNU Guix. | |
7 | ;;; | |
8 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
9 | ;;; under the terms of the GNU General Public License as published by | |
10 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
11 | ;;; your option) any later version. | |
12 | ;;; | |
13 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
14 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | ;;; GNU General Public License for more details. | |
17 | ;;; | |
18 | ;;; You should have received a copy of the GNU General Public License | |
19 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
20 | ||
21 | (define-module (guix cvs-download) | |
22 | #:use-module (guix records) | |
23 | #:use-module (guix gexp) | |
24 | #:use-module (guix store) | |
25 | #:use-module (guix monads) | |
37ce440d | 26 | #:use-module (guix modules) |
89328d24 MW |
27 | #:use-module (guix packages) |
28 | #:use-module (ice-9 match) | |
29 | #:export (cvs-reference | |
30 | cvs-reference? | |
31 | cvs-reference-url | |
32 | cvs-reference-revision | |
33 | cvs-fetch)) | |
34 | ||
35 | ;;; Commentary: | |
36 | ;;; | |
37 | ;;; An <origin> method that fetches a specific revision or date from a CVS | |
38 | ;;; repository. The CVS-ROOT-DIRECTORY, MODULE and REVISION are specified | |
39 | ;;; with a <cvs-reference> object. REVISION should be specified as either a | |
40 | ;;; date string in ISO-8601 format (e.g. "2012-12-21") or a CVS tag. | |
41 | ;;; | |
42 | ;;; Code: | |
43 | ||
44 | (define-record-type* <cvs-reference> | |
45 | cvs-reference make-cvs-reference | |
46 | cvs-reference? | |
47 | (root-directory cvs-reference-root-directory) ; string | |
48 | (module cvs-reference-module) ; string | |
49 | (revision cvs-reference-revision)) ; string | |
50 | ||
51 | (define (cvs-package) | |
52 | "Return the default CVS package." | |
53 | (let ((distro (resolve-interface '(gnu packages version-control)))) | |
54 | (module-ref distro 'cvs))) | |
55 | ||
56 | (define* (cvs-fetch ref hash-algo hash | |
57 | #:optional name | |
58 | #:key (system (%current-system)) (guile (default-guile)) | |
59 | (cvs (cvs-package))) | |
60 | "Return a fixed-output derivation that fetches REF, a <cvs-reference> | |
61 | object. The output is expected to have recursive hash HASH of type | |
62 | HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if #f." | |
e9f8a7e2 MO |
63 | (define guile-zlib |
64 | (module-ref (resolve-interface '(gnu packages guile)) 'guile-zlib)) | |
37ce440d LC |
65 | |
66 | (define modules | |
e9f8a7e2 MO |
67 | (delete '(guix config) |
68 | (source-module-closure '((guix build cvs) | |
69 | (guix build download-nar))))) | |
89328d24 | 70 | (define build |
37ce440d | 71 | (with-imported-modules modules |
e9f8a7e2 MO |
72 | (with-extensions (list guile-zlib) |
73 | #~(begin | |
74 | (use-modules (guix build cvs) | |
75 | (guix build download-nar)) | |
37ce440d | 76 | |
e9f8a7e2 MO |
77 | (or (cvs-fetch '#$(cvs-reference-root-directory ref) |
78 | '#$(cvs-reference-module ref) | |
79 | '#$(cvs-reference-revision ref) | |
80 | #$output | |
81 | #:cvs-command (string-append #+cvs "/bin/cvs")) | |
82 | (download-nar #$output)))))) | |
89328d24 MW |
83 | |
84 | (mlet %store-monad ((guile (package->derivation guile system))) | |
85 | (gexp->derivation (or name "cvs-checkout") build | |
67c2db17 LC |
86 | #:leaked-env-vars '("http_proxy" "https_proxy" |
87 | "LC_ALL" "LC_MESSAGES" "LANG" | |
88 | "COLUMNS") | |
89328d24 MW |
89 | #:system system |
90 | #:hash-algo hash-algo | |
91 | #:hash hash | |
92 | #:recursive? #t | |
89328d24 MW |
93 | #:guile-for-build guile |
94 | #:local-build? #t))) | |
95 | ||
96 | ;;; cvs-download.scm ends here |