[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Add support for 'cvs-fetch' method in origins
From: |
Mark H Weaver |
Subject: |
[PATCH] Add support for 'cvs-fetch' method in origins |
Date: |
Tue, 03 Feb 2015 03:45:18 -0500 |
The motivation for this is libffcall, which hasn't been released in such
a long time that http://gnu.org/s/libffcall doesn't even link to the
last release, but just says to download it from CVS.
guix/cvs-download.scm is based so heavily on guix/svn-download.scm that
I copied the copyright notices from svn-download.scm.
Mark
>From 118c8b739f368e4e5f691e119618568dcda0e12b Mon Sep 17 00:00:00 2001
From: Mark H Weaver <address@hidden>
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 | 65 +++++++++++++++++++++++++++++++++++++++
guix/cvs-download.scm | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 151 insertions(+)
create mode 100644 guix/build/cvs.scm
create mode 100644 guix/cvs-download.scm
diff --git a/Makefile.am b/Makefile.am
index 67367d6..2e0da77 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 0000000..18b138c
--- /dev/null
+++ b/guix/build/cvs.scm
@@ -0,0 +1,65 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2015 Mark H Weaver <address@hidden>
+;;;
+;;; 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)))
+ (file-system-fold enter? leaf down up skip error '() "." lstat))
+
+(define* (cvs-fetch cvs-root-dir module revision directory
+ #:key (cvs-command "cvs"))
+ "Fetch REVISION from MODULE of CVS-ROOT-DIR 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-dir
+ "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 0000000..e3d8ad1
--- /dev/null
+++ b/guix/cvs-download.scm
@@ -0,0 +1,84 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2014, 2015 Ludovic Courtès <address@hidden>
+;;; Copyright © 2014 Sree Harsha Totakura <address@hidden>
+;;; Copyright © 2015 Mark H Weaver <address@hidden>
+;;;
+;;; 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-DIR, 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-dir cvs-reference-root-dir) ; 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-dir 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
+ ;; FIXME: See <https://bugs.gnu.org/18747>.
+ ;;#:local-build? #t
+ #: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
--
2.2.1
- [PATCH] Add support for 'cvs-fetch' method in origins,
Mark H Weaver <=