aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--guix/build/cvs.scm66
-rw-r--r--guix/cvs-download.scm82
3 files changed, 150 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 67367d6e01..2e0da77279 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -60,6 +60,7 @@ MODULES = \
guix/gnupg.scm \
guix/elf.scm \
guix/store.scm \
+ guix/cvs-download.scm \
guix/svn-download.scm \
guix/ui.scm \
guix/build/download.scm \
@@ -76,6 +77,7 @@ MODULES = \
guix/build/union.scm \
guix/build/pull.scm \
guix/build/rpath.scm \
+ guix/build/cvs.scm \
guix/build/svn.scm \
guix/build/syscalls.scm \
guix/build/emacs-utils.scm \
diff --git a/guix/build/cvs.scm b/guix/build/cvs.scm
new file mode 100644
index 0000000000..bd5c50a51a
--- /dev/null
+++ b/guix/build/cvs.scm
@@ -0,0 +1,66 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU 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.
+;;;
+;;; GNU 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build cvs)
+ #:use-module (guix build utils)
+ #:use-module (ice-9 regex)
+ #:use-module (ice-9 ftw)
+ #:export (cvs-fetch))
+
+;;; Commentary:
+;;;
+;;; This is the build-side support code of (guix cvs-download). It allows a
+;;; CVS repository to be checked out at a specific revision or date.
+;;;
+;;; Code:
+
+(define (find-cvs-directories)
+ (define (enter? path st result)
+ (not (string-suffix? "/CVS" path)))
+ (define (leaf path st result) result)
+ (define (down path st result) result)
+ (define (up path st result) result)
+ (define (skip path st result)
+ (if (and (string-suffix? "/CVS" path)
+ (eqv? 'directory (stat:type st)))
+ (cons path result)
+ result))
+ (define (error path st errno result)
+ (format (current-error-port) "cvs-fetch: ~a: ~a~%"
+ path (strerror errno)))
+ (sort (file-system-fold enter? leaf down up skip error '() "." lstat)
+ string<?))
+
+(define* (cvs-fetch cvs-root-directory module revision directory
+ #:key (cvs-command "cvs"))
+ "Fetch REVISION from MODULE of CVS-ROOT-DIRECTORY into DIRECTORY. REVISION
+must either be a date in ISO-8601 format (e.g. \"2012-12-21\") or a CVS tag.
+Return #t on success, #f otherwise."
+ (and (zero? (system* cvs-command "-z3"
+ "-d" cvs-root-directory
+ "checkout"
+ (if (string-match "^[0-9]{4}-[0-9]{2}-[0-9]{2}$" revision)
+ "-D" "-r")
+ revision
+ module))
+ (rename-file module directory)
+ (with-directory-excursion directory
+ (for-each delete-file-recursively (find-cvs-directories)))
+ #t))
+
+;;; cvs.scm ends here
diff --git a/guix/cvs-download.scm b/guix/cvs-download.scm
new file mode 100644
index 0000000000..8a0d479fa4
--- /dev/null
+++ b/guix/cvs-download.scm
@@ -0,0 +1,82 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014 Sree Harsha Totakura <sreeharsha@totakura.in>
+;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU 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.
+;;;
+;;; GNU 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 GNU Guix. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix cvs-download)
+ #:use-module (guix records)
+ #:use-module (guix gexp)
+ #:use-module (guix store)
+ #:use-module (guix monads)
+ #:use-module (guix packages)
+ #:use-module (ice-9 match)
+ #:export (cvs-reference
+ cvs-reference?
+ cvs-reference-url
+ cvs-reference-revision
+ cvs-fetch))
+
+;;; Commentary:
+;;;
+;;; An <origin> method that fetches a specific revision or date from a CVS
+;;; repository. The CVS-ROOT-DIRECTORY, MODULE and REVISION are specified
+;;; with a <cvs-reference> object. REVISION should be specified as either a
+;;; date string in ISO-8601 format (e.g. "2012-12-21") or a CVS tag.
+;;;
+;;; Code:
+
+(define-record-type* <cvs-reference>
+ cvs-reference make-cvs-reference
+ cvs-reference?
+ (root-directory cvs-reference-root-directory) ; string
+ (module cvs-reference-module) ; string
+ (revision cvs-reference-revision)) ; string
+
+(define (cvs-package)
+ "Return the default CVS package."
+ (let ((distro (resolve-interface '(gnu packages version-control))))
+ (module-ref distro 'cvs)))
+
+(define* (cvs-fetch ref hash-algo hash
+ #:optional name
+ #:key (system (%current-system)) (guile (default-guile))
+ (cvs (cvs-package)))
+ "Return a fixed-output derivation that fetches REF, a <cvs-reference>
+object. The output is expected to have recursive hash HASH of type
+HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if #f."
+ (define build
+ #~(begin
+ (use-modules (guix build cvs))
+ (cvs-fetch '#$(cvs-reference-root-directory ref)
+ '#$(cvs-reference-module ref)
+ '#$(cvs-reference-revision ref)
+ #$output
+ #:cvs-command (string-append #$cvs "/bin/cvs"))))
+
+ (mlet %store-monad ((guile (package->derivation guile system)))
+ (gexp->derivation (or name "cvs-checkout") build
+ #:system system
+ #:hash-algo hash-algo
+ #:hash hash
+ #:recursive? #t
+ #:modules '((guix build cvs)
+ (guix build utils))
+ #:guile-for-build guile
+ #:local-build? #t)))
+
+;;; cvs-download.scm ends here