* [PATCH] Add support for 'cvs-fetch' method in origins
@ 2015-02-03 8:45 Mark H Weaver
2015-02-03 21:11 ` Ludovic Courtès
0 siblings, 1 reply; 3+ messages in thread
From: Mark H Weaver @ 2015-02-03 8:45 UTC (permalink / raw)
To: guix-devel
[-- Attachment #1: Type: text/plain, Size: 335 bytes --]
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
[-- Attachment #2: [PATCH] Add support for 'cvs-fetch' method in origins --]
[-- Type: text/x-patch, Size: 7688 bytes --]
From 118c8b739f368e4e5f691e119618568dcda0e12b Mon Sep 17 00:00:00 2001
From: Mark H Weaver <mhw@netris.org>
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 <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)))
+ (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 <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-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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Add support for 'cvs-fetch' method in origins
2015-02-03 8:45 [PATCH] Add support for 'cvs-fetch' method in origins Mark H Weaver
@ 2015-02-03 21:11 ` Ludovic Courtès
2015-02-04 15:41 ` Mark H Weaver
0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2015-02-03 21:11 UTC (permalink / raw)
To: Mark H Weaver; +Cc: guix-devel
Mark H Weaver <mhw@netris.org> skribis:
> 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.
OK.
> From 118c8b739f368e4e5f691e119618568dcda0e12b Mon Sep 17 00:00:00 2001
> From: Mark H Weaver <mhw@netris.org>
> 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.
[...]
> +(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))
Might be best to sort the result to make it deterministic.
[...]
> +(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
s/root-dir/root-directory/ maybe?
> + (gexp->derivation (or name "cvs-checkout") build
> + #:system system
> + ;; FIXME: See <https://bugs.gnu.org/18747>.
> + ;;#:local-build? #t
[...]
> + #:local-build? #t)))
To #:local-build? or not to #:local-build?, that is the question. :-)
LGTM modulo these little things.
Thank you,
Ludo’.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Add support for 'cvs-fetch' method in origins
2015-02-03 21:11 ` Ludovic Courtès
@ 2015-02-04 15:41 ` Mark H Weaver
0 siblings, 0 replies; 3+ messages in thread
From: Mark H Weaver @ 2015-02-04 15:41 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: guix-devel
ludo@gnu.org (Ludovic Courtès) writes:
>> + (gexp->derivation (or name "cvs-checkout") build
>> + #:system system
>> + ;; FIXME: See <https://bugs.gnu.org/18747>.
>> + ;;#:local-build? #t
>
> [...]
>
>> + #:local-build? #t)))
>
> To #:local-build? or not to #:local-build?, that is the question. :-)
Oops :) This was inherited from 'svn-fetch'. I've fixed them both now.
> LGTM modulo these little things.
I incorporated your suggestions and pushed.
Thanks!
Mark
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-02-04 15:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-03 8:45 [PATCH] Add support for 'cvs-fetch' method in origins Mark H Weaver
2015-02-03 21:11 ` Ludovic Courtès
2015-02-04 15:41 ` Mark H Weaver
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.