cvs-download.scm 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2014, 2015, 2016, 2017, 2019 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2014 Sree Harsha Totakura <sreeharsha@totakura.in>
  4. ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
  5. ;;;
  6. ;;; This file is part of GNU Guix.
  7. ;;;
  8. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  9. ;;; under the terms of the GNU General Public License as published by
  10. ;;; the Free Software Foundation; either version 3 of the License, or (at
  11. ;;; your option) any later version.
  12. ;;;
  13. ;;; GNU Guix is distributed in the hope that it will be useful, but
  14. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;;; GNU General Public License for more details.
  17. ;;;
  18. ;;; You should have received a copy of the GNU General Public License
  19. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  20. (define-module (guix cvs-download)
  21. #:use-module (guix records)
  22. #:use-module (guix gexp)
  23. #:use-module (guix store)
  24. #:use-module (guix monads)
  25. #:use-module (guix modules)
  26. #:use-module (guix packages)
  27. #:use-module (ice-9 match)
  28. #:export (cvs-reference
  29. cvs-reference?
  30. cvs-reference-url
  31. cvs-reference-revision
  32. cvs-fetch))
  33. ;;; Commentary:
  34. ;;;
  35. ;;; An <origin> method that fetches a specific revision or date from a CVS
  36. ;;; repository. The CVS-ROOT-DIRECTORY, MODULE and REVISION are specified
  37. ;;; with a <cvs-reference> object. REVISION should be specified as either a
  38. ;;; date string in ISO-8601 format (e.g. "2012-12-21") or a CVS tag.
  39. ;;;
  40. ;;; Code:
  41. (define-record-type* <cvs-reference>
  42. cvs-reference make-cvs-reference
  43. cvs-reference?
  44. (root-directory cvs-reference-root-directory) ; string
  45. (module cvs-reference-module) ; string
  46. (revision cvs-reference-revision)) ; string
  47. (define (cvs-package)
  48. "Return the default CVS package."
  49. (let ((distro (resolve-interface '(gnu packages version-control))))
  50. (module-ref distro 'cvs)))
  51. (define* (cvs-fetch ref hash-algo hash
  52. #:optional name
  53. #:key (system (%current-system)) (guile (default-guile))
  54. (cvs (cvs-package)))
  55. "Return a fixed-output derivation that fetches REF, a <cvs-reference>
  56. object. The output is expected to have recursive hash HASH of type
  57. HASH-ALGO (a symbol). Use NAME as the file name, or a generic name if #f."
  58. (define guile-zlib
  59. (module-ref (resolve-interface '(gnu packages guile)) 'guile-zlib))
  60. (define modules
  61. (delete '(guix config)
  62. (source-module-closure '((guix build cvs)
  63. (guix build download-nar)))))
  64. (define build
  65. (with-imported-modules modules
  66. (with-extensions (list guile-zlib)
  67. #~(begin
  68. (use-modules (guix build cvs)
  69. (guix build download-nar))
  70. (or (cvs-fetch '#$(cvs-reference-root-directory ref)
  71. '#$(cvs-reference-module ref)
  72. '#$(cvs-reference-revision ref)
  73. #$output
  74. #:cvs-command (string-append #+cvs "/bin/cvs"))
  75. (download-nar #$output))))))
  76. (mlet %store-monad ((guile (package->derivation guile system)))
  77. (gexp->derivation (or name "cvs-checkout") build
  78. #:leaked-env-vars '("http_proxy" "https_proxy"
  79. "LC_ALL" "LC_MESSAGES" "LANG"
  80. "COLUMNS")
  81. #:system system
  82. #:hash-algo hash-algo
  83. #:hash hash
  84. #:recursive? #t
  85. #:guile-for-build guile
  86. #:local-build? #t)))
  87. ;;; cvs-download.scm ends here