Commit | Line | Data |
---|---|---|
b3acf365 SHT |
1 | ;;; GNU Guix --- Functional package management for GNU |
2 | ;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org> | |
3 | ;;; Copyright © 2014 Sree Harsha Totakura <sreeharsha@totakura.in> | |
4 | ;;; | |
5 | ;;; This file is part of GNU Guix. | |
6 | ;;; | |
7 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
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 | ;;; | |
12 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
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 | |
18 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
19 | ||
20 | (define-module (guix svn-download) | |
21 | #:use-module (guix records) | |
bc672694 LC |
22 | #:use-module (guix gexp) |
23 | #:use-module (guix monads) | |
b3acf365 SHT |
24 | #:use-module (guix packages) |
25 | #:use-module (ice-9 match) | |
26 | #:export (svn-reference | |
27 | svn-reference? | |
28 | svn-reference-url | |
29 | svn-reference-revision | |
30 | svn-fetch)) | |
31 | ||
32 | ;;; Commentary: | |
33 | ;;; | |
34 | ;;; An <origin> method that fetches a specific revision from a Subversion | |
35 | ;;; repository. The repository URL and REVISION are specified with a | |
36 | ;;; <svn-reference> object. REVISION should be specified as a number. | |
37 | ;;; | |
38 | ;;; Code: | |
39 | ||
40 | (define-record-type* <svn-reference> | |
41 | svn-reference make-svn-reference | |
42 | svn-reference? | |
43 | (url svn-reference-url) ; string | |
44 | (revision svn-reference-revision)) ; number | |
45 | ||
bc672694 LC |
46 | (define (subversion-package) |
47 | "Return the default Subversion package." | |
48 | (let ((distro (resolve-interface '(gnu packages version-control)))) | |
49 | (module-ref distro 'subversion))) | |
50 | ||
b3acf365 SHT |
51 | (define* (svn-fetch store ref hash-algo hash |
52 | #:optional name | |
bc672694 LC |
53 | #:key (system (%current-system)) guile |
54 | (svn (subversion-package))) | |
b3acf365 SHT |
55 | "Return a fixed-output derivation in STORE that fetches REF, a |
56 | <svn-reference> object. The output is expected to have recursive hash HASH of | |
57 | type HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if | |
58 | #f." | |
59 | (define guile-for-build | |
60 | (match guile | |
61 | ((? package?) | |
62 | (package-derivation store guile system)) | |
63 | (#f ; the default | |
bdb36958 | 64 | (let* ((distro (resolve-interface '(gnu packages commencement))) |
b3acf365 SHT |
65 | (guile (module-ref distro 'guile-final))) |
66 | (package-derivation store guile system))))) | |
67 | ||
bc672694 LC |
68 | (define build |
69 | #~(begin | |
70 | (use-modules (guix build svn)) | |
71 | (svn-fetch '#$(svn-reference-url ref) | |
72 | '#$(svn-reference-revision ref) | |
73 | #$output | |
74 | #:svn-command (string-append #$svn "/bin/svn")))) | |
b3acf365 | 75 | |
bc672694 LC |
76 | (run-with-store store |
77 | (gexp->derivation (or name "svn-checkout") build | |
78 | #:system system | |
347e17b4 LC |
79 | ;; FIXME: See <https://bugs.gnu.org/18747>. |
80 | ;;#:local-build? #t | |
bc672694 LC |
81 | #:hash-algo hash-algo |
82 | #:hash hash | |
83 | #:recursive? #t | |
84 | #:modules '((guix build svn) | |
85 | (guix build utils)) | |
86 | #:guile-for-build guile-for-build | |
87 | #:local-build? #t) | |
88 | #:guile-for-build guile-for-build | |
89 | #:system system)) | |
b3acf365 SHT |
90 | |
91 | ;;; svn-download.scm ends here |