svn.scm 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2014, 2020 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2014 Sree Harsha Totakura <sreeharsha@totakura.in>
  4. ;;; Copyright © 2018 Mark H Weaver <mhw@netris.org>
  5. ;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
  6. ;;;
  7. ;;; This file is part of GNU Guix.
  8. ;;;
  9. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  10. ;;; under the terms of the GNU General Public License as published by
  11. ;;; the Free Software Foundation; either version 3 of the License, or (at
  12. ;;; your option) any later version.
  13. ;;;
  14. ;;; GNU Guix is distributed in the hope that it will be useful, but
  15. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ;;; GNU General Public License for more details.
  18. ;;;
  19. ;;; You should have received a copy of the GNU General Public License
  20. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  21. (define-module (guix build svn)
  22. #:use-module (guix build utils)
  23. #:use-module (srfi srfi-34)
  24. #:use-module (ice-9 format)
  25. #:export (svn-fetch))
  26. ;;; Commentary:
  27. ;;;
  28. ;;; This is the build-side support code of (guix svn-download). It allows a
  29. ;;; Subversion repository to be cloned and checked out at a specific revision.
  30. ;;;
  31. ;;; Code:
  32. (define* (svn-fetch url revision directory
  33. #:key (svn-command "svn")
  34. (recursive? #t)
  35. (user-name #f)
  36. (password #f))
  37. "Fetch REVISION from URL into DIRECTORY. REVISION must be an integer, and a
  38. valid Subversion revision. Return #t on success, #f otherwise."
  39. (guard (c ((invoke-error? c)
  40. (report-invoke-error c)
  41. #f))
  42. (apply invoke svn-command
  43. "export" "--non-interactive"
  44. ;; Trust the server certificate. This is OK as we
  45. ;; verify the checksum later. This can be removed when
  46. ;; ca-certificates package is added.
  47. "--trust-server-cert" "-r" (number->string revision)
  48. `(,@(if (and user-name password)
  49. (list (string-append "--username=" user-name)
  50. (string-append "--password=" password))
  51. '())
  52. ,@(if recursive?
  53. '()
  54. (list "--ignore-externals"))
  55. ,url ,directory))
  56. #t))
  57. ;;; svn.scm ends here