From 89328d240f4d6345d55c1fec3c11478892093958 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Sat, 17 Jan 2015 22:11:45 -0500 Subject: [PATCH] Add support for 'cvs-fetch' method in origins. * guix/cvs-download.scm, guix/build/cvs.scm: New files. * Makefile.am (MODULES): Add them. --- Makefile.am | 2 ++ guix/build/cvs.scm | 66 ++++++++++++++++++++++++++++++++++ guix/cvs-download.scm | 82 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 150 insertions(+) create mode 100644 guix/build/cvs.scm create mode 100644 guix/cvs-download.scm 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 +;;; +;;; 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 . + +(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 +;;; Copyright © 2014 Sree Harsha Totakura +;;; Copyright © 2015 Mark H Weaver +;;; +;;; 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 . + +(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 method that fetches a specific revision or date from a CVS +;;; repository. The CVS-ROOT-DIRECTORY, MODULE and REVISION are specified +;;; with a 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 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 +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